:root {
    --bg-base: #0B0F19;
    --bg-surface: rgba(30, 41, 59, 0.5);
    --bg-surface-solid: #1E293B;
    --border-color: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(79, 70, 229, 0.5);
    
    --text-primary: #F8FAFC;
    --text-secondary: #E2E8F0;
    --text-muted: #94A3B8;
    
    --color-primary: #4F46E5;
    --color-primary-hover: #6366F1;
    --color-primary-glow: rgba(79, 70, 229, 0.35);
    --color-secondary: #06B6D4;
    
    --color-success: #10B981;
    --color-success-bg: rgba(16, 185, 129, 0.1);
    --color-error: #EF4444;
    --color-error-bg: rgba(239, 68, 68, 0.1);
    --color-warn: #F59E0B;
    --color-warn-bg: rgba(245, 158, 11, 0.1);
    --color-info: #3B82F6;
    --color-info-bg: rgba(59, 130, 246, 0.1);
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.light-theme {
    --bg-base: #F8FAFC;
    --bg-surface: rgba(255, 255, 255, 0.85);
    --bg-surface-solid: #FFFFFF;
    --border-color: rgba(0, 0, 0, 0.06);
    --border-focus: rgba(79, 70, 229, 0.6);
    
    --text-primary: #0F172A;
    --text-secondary: #334155;
    --text-muted: #64748B;
    
    --color-success-bg: rgba(16, 185, 129, 0.15);
    --color-error-bg: rgba(239, 68, 68, 0.15);
    --color-warn-bg: rgba(245, 158, 11, 0.15);
    --color-info-bg: rgba(59, 130, 246, 0.15);
}

/* Ajustes de componentes para el Modo Claro */
body.light-theme .sidebar {
    background: rgba(255, 255, 255, 0.95);
    border-right-color: rgba(0, 0, 0, 0.08);
}
body.light-theme .sidebar-brand .logo-icon {
    background: rgba(0, 0, 0, 0.02);
}
body.light-theme .menu-item:hover {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.02);
}
body.light-theme .menu-item.active {
    color: #ffffff;
    background: var(--color-primary);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25);
}
body.light-theme .kpi-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}
body.light-theme .kpi-value {
    color: #111827;
}
body.light-theme .kpi-card:hover {
    border-color: var(--color-primary);
}
body.light-theme .content-header h1 {
    color: var(--color-primary);
}
body.light-theme .table-filters input {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    border-color: rgba(0, 0, 0, 0.15);
}
body.light-theme .table-filters select {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    border-color: rgba(0, 0, 0, 0.15);
}
body.light-theme input[type="text"], 
body.light-theme input[type="password"], 
body.light-theme input[type="date"], 
body.light-theme input[type="number"], 
body.light-theme textarea, 
body.light-theme select {
    background: rgba(255, 255, 255, 0.9);
    color: #111827;
    border-color: rgba(0, 0, 0, 0.12);
}
body.light-theme select option {
    background-color: #ffffff;
    color: #111827;
}
body.light-theme .db-table th {
    background: var(--bg-base);
    color: var(--text-secondary);
}
body.light-theme .db-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.01);
}
body.light-theme .terminal-container {
    background: #f9fafb;
    border: 1px solid rgba(0, 0, 0, 0.08);
}
body.light-theme .terminal-header {
    background: rgba(0, 0, 0, 0.02);
}
body.light-theme .terminal-title {
    color: var(--text-secondary);
}
body.light-theme .terminal-body {
    color: #111827;
}
body.light-theme .log-line.info {
    color: #1f2937;
}
body.light-theme .log-line.success {
    color: #047857;
    background: rgba(16, 185, 129, 0.15);
}
body.light-theme .log-line.error {
    color: #b91c1c;
    background: rgba(239, 68, 68, 0.15);
}
body.light-theme .countdown-display-wrapper {
    background: rgba(255, 255, 255, 0.9);
}
body.light-theme .slider {
    background-color: rgba(0, 0, 0, 0.05);
}
body.light-theme .glow-bg {
    background: var(--color-primary-glow);
}
body.light-theme .main-header h1 {
    color: var(--color-primary);
}
body.light-theme .server-status {
    background: rgba(0, 0, 0, 0.02);
}
body.light-theme .chart-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}
body.light-theme .data-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(0, 0, 0, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* Decoración de fondo */
.glow-bg {
    display: none;
}

@keyframes glow-pulse {
    0% {
        transform: translate(0, 0) scale(1);
    }
    100% {
        transform: translate(-50px, 50px) scale(1.1);
    }
}

.app-container {
    width: 100%;
    max-width: 1280px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    z-index: 1;
}

/* HEADER */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
}

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--color-primary);
}

.main-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.server-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 0.5rem 0.875rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.online {
    background-color: var(--color-success);
    box-shadow: 0 0 8px var(--color-success);
    animation: status-pulse 2s infinite;
}

.status-indicator.running {
    background-color: var(--color-warn);
    box-shadow: 0 0 8px var(--color-warn);
    animation: status-pulse 1s infinite;
}

@keyframes status-pulse {
    0% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0.6;
    }
}

/* LAYOUT GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 960px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* CARD SYSTEM */
.card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header svg {
    color: var(--color-primary);
}

/* CONFIG FORM */
.panel-config form {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrapper input {
    width: 100%;
}

.icon-link {
    position: absolute;
    right: 0.75rem;
    color: var(--text-muted);
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
}

.icon-link:hover {
    color: var(--color-success);
}

.icon-link.hidden {
    display: none;
}

input[type="text"], input[type="password"], input[type="date"], input[type="number"], textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    transition: var(--transition-fast);
}

.input-wrapper input {
    padding-right: 2.5rem;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="number"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
    background: rgba(0, 0, 0, 0.3);
}

/* Make calendar icon visible in dark mode */
input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.7;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

body.light-theme input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

select option {
    background-color: var(--bg-surface-solid);
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.helper-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin-top: 0.75rem;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover:not(:disabled) {
    background: var(--color-error);
    color: white;
}

.btn-danger:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    background: rgba(255, 255, 255, 0.02);
    color: var(--text-muted);
    border-color: var(--border-color);
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.monitor-actions {
    margin-left: auto;
}

/* STATS BAR */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.15);
}

.stat-box {
    padding: 1.25rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-box:not(:last-child) {
    border-right: 1px solid var(--border-color);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#stat-status {
    color: var(--text-secondary);
    font-size: 1.125rem;
    font-weight: 600;
}

.status-active-run {
    color: var(--color-warn) !important;
}

.status-active-success {
    color: var(--color-success) !important;
}

.status-active-error {
    color: var(--color-error) !important;
}

/* TERMINAL / LOGS */
.terminal-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 380px;
    background: #08090d;
}

.terminal-header {
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.terminal-dots {
    display: flex;
    gap: 0.375rem;
}

.terminal-dots .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.terminal-dots .dot.red { background-color: #ff5f56; }
.terminal-dots .dot.yellow { background-color: #ffbd2e; }
.terminal-dots .dot.green { background-color: #27c93f; }

.terminal-title {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.terminal-body {
    flex-grow: 1;
    padding: 1.25rem;
    overflow-y: auto;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    scroll-behavior: smooth;
}

/* LOG COLORS */
.log-line {
    white-space: pre-wrap;
    word-break: break-all;
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
}

.log-line.info {
    color: #e5e7eb;
}

.log-line.success {
    color: #a7f3d0;
    background: rgba(16, 185, 129, 0.08);
    border-left: 3px solid var(--color-success);
}

.log-line.warn {
    color: #fef3c7;
    background: rgba(245, 158, 11, 0.08);
    border-left: 3px solid var(--color-warn);
}

.log-line.error {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.08);
    border-left: 3px solid var(--color-error);
}

.log-line.system {
    color: var(--text-muted);
    font-style: italic;
}

/* SPINNER */
.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

.spinner.hidden {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* FOOTER */
.main-footer {
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Switch toggle styling */
.automation-toggle-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-secondary);
    transition: .4s;
}

input:checked + .slider {
    background-color: var(--color-primary-glow);
    border-color: var(--color-primary);
}

input:checked + .slider:before {
    transform: translateX(20px);
    background-color: var(--color-primary);
    box-shadow: 0 0 8px var(--color-primary);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.auto-settings {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border-color);
    animation: fadeIn var(--transition-fast) ease-in-out;
}

.auto-settings.hidden {
    display: none;
}

.countdown-display-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
}

.countdown-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.countdown-timer {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-warn);
    font-family: var(--font-mono);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   NUEVO LAYOUT LATERAL Y DASHBOARD (ESTILO POWER BI)
   ========================================================================== */

/* Layout general */
.app-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Barra lateral (Sidebar) */
.sidebar {
    width: 240px;
    background: rgba(14, 16, 22, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    height: 100%;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-left: 0.25rem;
}

.sidebar-brand .logo-icon {
    padding: 0.5rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

.brand-text h2 {
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--color-primary);
}

.version-badge {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(255, 123, 0, 0.15);
    color: var(--color-primary);
    border: 1px solid rgba(255, 123, 0, 0.2);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex: 1;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.65rem 0.875rem;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.8125rem;
    transition: var(--transition-fast);
    border: 1px solid transparent;
}

.menu-item svg {
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.menu-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
    border-color: rgba(255, 255, 255, 0.03);
}

.menu-item.active {
    color: #fff;
    background: var(--color-primary-glow);
    border-color: rgba(79, 70, 229, 0.3);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.2);
}

.menu-item.active svg {
    color: var(--color-primary);
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.btn-logout {
    width: 100%;
    padding: 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(239, 68, 68, 0.2);
    background: rgba(239, 68, 68, 0.05);
    color: #fca5a5;
    font-size: 0.875rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fff;
}

/* Área de contenido */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    padding: 0 3rem 2.5rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.main-content.fixed-layout {
    overflow-y: hidden;
}

/* Barra superior compacta */
.top-bar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-base);
}

.top-bar-left {
    display: flex;
    align-items: center;
    margin-right: auto;
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.top-bar-user-wrapper {
    position: relative;
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 0.375rem 0.75rem;
    border-radius: 8px;
    font-size: 0.8125rem;
    font-family: var(--font-sans);
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.top-bar-user:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 123, 0, 0.3);
}

.top-bar-user svg:first-child {
    color: var(--color-primary);
    flex-shrink: 0;
}

#top-bar-username {
    font-weight: 600;
    color: var(--text-primary);
}

/* Dropdown del usuario */
.user-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
    padding: 0.35rem;
    z-index: 100;
    animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: 7px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.dropdown-item:hover {
    background: rgba(255, 123, 0, 0.1);
    color: var(--color-primary);
}

.dropdown-item svg {
    color: var(--text-muted);
    transition: var(--transition-fast);
}

.dropdown-item:hover svg {
    color: var(--color-primary);
}

.top-bar-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
    color: var(--text-secondary);
}

.top-bar-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: modalFadeIn 0.2s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--bg-surface-solid);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    line-height: 1;
    transition: var(--transition-fast);
}

.modal-close:hover {
    color: var(--color-error);
}

.modal-card form {
    padding: 1.25rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Light theme overrides */
body.light-theme .top-bar {
    background: var(--bg-base);
}

body.light-theme .top-bar-user {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .top-bar-user:hover {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme .top-bar-btn {
    background: rgba(0, 0, 0, 0.02);
    border-color: rgba(0, 0, 0, 0.08);
}

body.light-theme .top-bar-btn:hover {
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme .user-dropdown {
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

body.light-theme .dropdown-item:hover {
    background: rgba(255, 123, 0, 0.08);
}

body.light-theme .modal-overlay {
    background: rgba(0, 0, 0, 0.3);
}

body.light-theme .modal-card {
    background: #ffffff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

body.light-theme .modal-card input[type="password"] {
    background: rgba(0, 0, 0, 0.03) !important;
    color: #111827 !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.content-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--color-primary);
}

.content-header .subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Vistas de Pestañas */
.tab-view {
    display: none;
    flex-direction: column;
    gap: 2.5rem;
    animation: tabFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-view.active {
    display: flex;
}

@keyframes tabFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Grid de KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-rows: 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}

@media (min-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.kpi-card {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
    transform: translateY(-2px);
    border-color: rgba(255, 123, 0, 0.2);
}

.kpi-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

.kpi-icon.total {
    color: #a5b4fc;
    background: rgba(165, 180, 252, 0.1);
    border-color: rgba(165, 180, 252, 0.15);
}

.kpi-icon.success {
    color: var(--color-success);
    background: var(--color-success-bg);
    border-color: rgba(16, 185, 129, 0.15);
}

.kpi-icon.danger {
    color: var(--color-error);
    background: var(--color-error-bg);
    border-color: rgba(239, 68, 68, 0.15);
}

.kpi-icon.warning {
    color: var(--color-warn);
    background: var(--color-warn-bg);
    border-color: rgba(245, 158, 11, 0.15);
}

.kpi-data {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kpi-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.1;
}

.kpi-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
}

/* Grid de Gráficos */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 1300px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    min-height: 190px;
    height: auto;
    padding: 1.25rem;
}

.chart-card .card-header {
    padding: 0 0 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
}

.chart-card .card-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-container {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 160px;
    height: auto;
}

/* Grilla de Datos */
.data-card {
    margin-bottom: 2rem;
}

.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.list-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.list-title-group h3 {
    font-size: 1rem;
    font-weight: 600;
}

.table-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-filters input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.8125rem;
    width: 250px;
    outline: none;
    transition: border-color 0.2s ease;
}

.table-filters input:focus {
    border-color: var(--color-primary);
}

.table-filters select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    color: #fff;
    font-size: 0.8125rem;
    outline: none;
    cursor: pointer;
}

/* Estilo de la Tabla */
.table-wrapper {
    overflow-x: auto;
    width: 100%;
}

.db-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    text-align: left;
}

.db-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-base);
    padding: 1rem 1.25rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    font-size: 0.6875rem;
    letter-spacing: 0.05em;
}

.db-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    max-width: 250px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.db-table tbody tr {
    transition: background-color 0.15s ease;
}

.db-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.01);
}

.db-table td.text-center {
    text-align: center;
    color: var(--text-muted);
    padding: 2.5rem;
}

/* Insignias de Estado (Badges) */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.finalizada {
    background: var(--color-success-bg);
    color: var(--color-success);
    border: 1px solid rgba(16, 185, 129, 0.1);
}

.badge.cancelada, .badge.anulada {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.badge.pendiente, .badge.agendada {
    background: var(--color-warn-bg);
    color: var(--color-warn);
    border: 1px solid rgba(245, 158, 11, 0.1);
}

.badge.prioridad-alta {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.1);
}

.badge.prioridad-media {
    background: var(--color-warn-bg);
    color: var(--color-warn);
    border: 1px solid rgba(245, 158, 11, 0.1);
}

.badge.prioridad-baja {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

/* Paginación */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.01);
    border-top: 1px solid var(--border-color);
}

.pagination-info {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.pagination-buttons {
    display: flex;
    gap: 0.5rem;
}

.btn-page {
    padding: 0.4rem 0.8rem;
    font-size: 0.75rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-page:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
}

.btn-page:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Ajustes de scrollbar personalizados */
.main-content::-webkit-scrollbar,
.table-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.main-content::-webkit-scrollbar-track,
.table-wrapper::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.1);
}

.main-content::-webkit-scrollbar-thumb,
.table-wrapper::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.main-content::-webkit-scrollbar-thumb:hover,
.table-wrapper::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.hidden {
    display: none !important;
}

/* Soporte para password input en light mode */
body.light-theme input[type="password"] {
    background: rgba(255, 255, 255, 0.9) !important;
    color: #111827 !important;
    border-color: rgba(0, 0, 0, 0.12) !important;
}

/* Botón de eliminación de usuario */
.btn-delete-user {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(239, 68, 68, 0.08);
    color: var(--color-error);
    border: 1px solid rgba(239, 68, 68, 0.15);
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-delete-user:hover {
    background: var(--color-error);
    color: white;
    box-shadow: 0 4px 10px rgba(239, 68, 68, 0.2);
    border-color: var(--color-error);
}

/* Botón de edición de usuario */
.btn-edit-user {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(59, 130, 246, 0.08);
    color: var(--color-info);
    border: 1px solid rgba(59, 130, 246, 0.15);
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-edit-user:hover {
    background: var(--color-info);
    color: white;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
    border-color: var(--color-info);
}

/* Indicador visual de modo edición en el panel de configuración */
.panel-config.editing-mode {
    border-color: rgba(59, 130, 246, 0.4) !important;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.2), 0 10px 30px rgba(0, 0, 0, 0.3) !important;
    position: relative;
    overflow: hidden;
}

.panel-config.editing-mode::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--color-primary);
}

body.light-theme .panel-config.editing-mode {
    border-color: #3b82f6 !important;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.15), 0 10px 30px rgba(0, 0, 0, 0.08) !important;
}

/* Helper text visible state */
.helper-text.hidden {
    display: none !important;
}

/* Vista de Perfil */
.profile-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
    align-items: start;
}

@media (max-width: 960px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }
}

.profile-info-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2.5rem 2rem;
    gap: 1.25rem;
    text-align: center;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-primary), rgba(168, 85, 247, 0.15));
    border: 2px solid rgba(255, 123, 0, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.profile-details {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.profile-details h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-role-badge {
    display: inline-block;
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    background: rgba(255, 123, 0, 0.12);
    color: var(--color-primary);
    border: 1px solid rgba(255, 123, 0, 0.2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

body.light-theme .profile-avatar {
    background: var(--color-primary), rgba(99, 102, 241, 0.1));
}

body.light-theme .profile-info-card {
    background: rgba(255, 255, 255, 0.9);
}

/* Sección Gestión de Accesos - Layout */
.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.content-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.content-header .subtitle {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Panel colapsable de formulario */
.user-form-panel {
    margin-bottom: 1.5rem;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-form-panel.hidden {
    display: none;
}

.user-form-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-form-fields {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1.25rem;
}

@media (max-width: 960px) {
    .user-form-fields {
        grid-template-columns: 1fr;
    }
}

.user-form-body .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding-top: 0.5rem;
}

.user-form-body .form-actions .btn {
    min-width: 180px;
}

/* Botón cerrar panel */
.btn-close-panel {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    transition: var(--transition-fast);
}

.btn-close-panel:hover {
    color: var(--color-error);
}

/* Card header flex fix */
.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Dashboard Config Modal Styles */
.chart-config-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

body.light-theme .chart-config-item {
    background: rgba(0, 0, 0, 0.03);
}

.chart-config-item label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
}

.chart-config-controls {
    display: flex;
    gap: 0.25rem;
}

.btn-move {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-move:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.btn-move:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border-color);
}

/* Settings Table */
.settings-table {
    width: 100%;
    border-collapse: collapse;
}

.settings-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.settings-table tr:last-child td {
    border-bottom: none;
}

.settings-table td:first-child {
    font-weight: 500;
    width: 60%;
    color: var(--text-primary);
}

.settings-table td:last-child {
    text-align: right;
    width: 40%;
}

/* Customizations for ORDENES TEC table */
#ordenes-tec-table th, #ordenes-tec-table td,
#ordenes-tec-table-vencimiento th, #ordenes-tec-table-vencimiento td {
    padding: 0.5rem 0.75rem; /* Más compacto */
}

#ordenes-tec-table td,
#ordenes-tec-table-vencimiento td {
    white-space: normal; /* Permitir salto de línea en todas las columnas */
    line-height: 1.3;
}

#ordenes-tec-table td:first-child,
#ordenes-tec-table-vencimiento td:first-child {
    max-width: 200px; /* Tamaño aún más reducido */
    min-width: 150px;
}

/* Column config drag items */
.tec-col-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
    margin-bottom: 0.25rem;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    transition: background 0.15s, box-shadow 0.15s, opacity 0.15s;
    user-select: none;
}
.tec-col-item:hover {
    background: rgba(255,255,255,0.05);
}
.tec-col-item.dragging {
    opacity: 0.4;
}
.tec-col-item.drag-over {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.25);
}
.tec-col-drag {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    line-height: 1;
}
.tec-col-drag:active {
    cursor: grabbing;
}
.tec-col-item label span {
    font-size: 0.82rem;
    color: var(--text-primary);
}

/* Config Tabs */
.config-tabs {
    display: flex;
    gap: 1rem;
}
.config-tab {
    background: transparent;
    border: none;
    padding: 0.75rem 0.5rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
}
.config-tab:hover {
    color: var(--text-primary);
}
.config-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* Filter Dropdowns */
.tec-filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.35rem 1.5rem 0.35rem 0.5rem;
    height: 32px;
    box-sizing: border-box;
    border-radius: 6px;
    font-size: 0.75rem;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    min-width: 120px;
    max-width: 200px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    transition: border-color 0.2s;
}
.tec-filter-select:focus {
    border-color: var(--color-primary);
}

/* Detail panel */
#tec-detail-panel,
#tec-detail-panel-vencimiento {
    animation: slideInRight 0.3s ease;
    background: #0f1117;
}
body.light-theme #tec-detail-panel,
body.light-theme #tec-detail-panel-vencimiento {
    background: #ffffff;
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
#tec-detail-table th,
#tec-detail-table td,
#tec-detail-table-vencimiento th,
#tec-detail-table-vencimiento td {
    padding: 0.35rem 0.6rem;
    font-size: 0.78rem;
}
#tec-detail-table td,
#tec-detail-table-vencimiento td {
    white-space: normal;
    line-height: 1.25;
    max-width: 250px;
}

/* --- Modal System --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}
.modal-overlay.hidden {
    display: none !important;
}
.modal, .modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}
.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    padding: 0.25rem;
    line-height: 1;
    transition: color 0.15s;
}
.modal-close:hover {
    color: var(--text-primary);
}


@keyframes spin { 100% { transform: rotate(360deg); } }
