/* ==================== INSIGHTS · +MÓVIL PANAMÁ DESIGN SYSTEM ==================== */

/* Typography */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&display=swap');

:root {
    /* ====== BRAND ====== */
    --brand:       #FF6A00;
    --brand-deep:  #E65C00;
    --brand-light: #FF8A33;
    --brand-soft:  #FFF0E5;
    --brand-dark:  #1A1A1A;

    /* ====== THEME TOKENS (light) ====== */
    --bg:         #FAFAFA;
    --surface:    #FFFFFF;
    --surface-2:  #F5F5F5;
    --ink:        #1A1A1A;
    --ink-2:      #444444;
    --ink-3:      #8A8A8A;
    --line:       #E8E8E8;
    --line-2:     #F0F0F0;
    --accent:       var(--brand);
    --accent-soft:  var(--brand-soft);

    /* ====== SEMANTIC (paleta sobria corporativa) ====== */
    --good:      #0F7A53;   /* esmeralda sobrio */
    --warn:      #B45309;   /* mostaza oscuro */
    --danger:    #B91C1C;   /* rojo corporativo */
    --data-blue: #1E4D8C;   /* azul marino para datos (neutral vs. naranja brand) */

    /* Fondos suaves semánticos */
    --good-soft:      #E7F2EC;
    --warn-soft:      #FBF0E0;
    --danger-soft:    #FBEAEA;
    --data-blue-soft: #E7EDF6;

    /* ====== DENSIDADES ====== */
    --pad: 20px;

    /* ====== RADIOS ====== */
    --radius-card: 10px;
    --radius-btn: 7px;
    --radius-pill: 10px;
    --radius-input: 6px;

    /* ====== FUENTES ====== */
    --font-ui:   'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SF Mono, Menlo, Consolas, monospace;
    --font-serif:'Instrument Serif', Georgia, serif;

    /* ====== SOMBRAS ====== */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px -4px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 30px -10px rgba(0,0,0,0.15);
    --shadow-xl: 0 24px 48px -12px rgba(0,0,0,0.20);
    --shadow-glow: 0 0 0 3px rgba(255,106,0,0.18);

    /* ====== TRANSICIONES ====== */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition: 240ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* ====== Z-INDEX ====== */
    --z-dropdown: 1000;
    --z-sticky:   1020;
    --z-fixed:    1030;
    --z-drawer:   1035;
    --z-modal:    1040;
    --z-tooltip:  1050;

    /* ====== ALIASES LEGACY (compat con CSS y pages existentes) ====== */
    --color-navy:              var(--ink);
    --color-navy-light:         var(--ink-2);
    --color-electric:           var(--brand);
    --color-electric-bright:    var(--brand-deep);
    --color-orange:             var(--brand);
    --color-orange-light:       var(--brand-light);
    --color-graphite:           var(--ink-2);
    --color-pearl:              var(--line);
    --color-snow:               var(--bg);
    --color-white:              var(--surface);

    --primary-color:  var(--brand);
    --primary-hover:  var(--brand-deep);
    --accent-color:   var(--brand);
    --background:     var(--bg);
    --surface-elevated: var(--surface);
    --text-primary:   var(--ink);
    --text-secondary: var(--ink-2);
    --text-tertiary:  var(--ink-3);
    --border:         var(--line);

    --success: var(--good);
    --warning: var(--warn);
    --error:   var(--danger);

    --space-xs:   4px;
    --space-sm:   8px;
    --space-md:  16px;
    --space-lg:  24px;
    --space-xl:  32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    --radius-sm: 6px;
    --radius:    10px;
    --radius-lg: 12px;
    --radius-xl: 20px;

    --font-body:    var(--font-ui);
    --font-display: var(--font-ui);
    --font-primary: var(--font-ui);
}

/* ====== DARK THEME ====== */
[data-theme="dark"] {
    --bg:        #121212;
    --surface:   #1C1C1C;
    --surface-2: #262626;
    --ink:       #F5F5F5;
    --ink-2:     #C4C4C4;
    --ink-3:     #8A8A8A;
    --line:      #2E2E2E;
    --line-2:    #242424;
    --accent:         #FF8A33;
    --accent-soft:    #3A2414;
    --good-soft:      #102720;
    --warn-soft:      #2A1E10;
    --danger-soft:    #2A1414;
    --data-blue-soft: #15223A;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.20);
    --shadow-md: 0 4px 12px -4px rgba(0,0,0,0.40);
    --shadow-lg: 0 10px 30px -10px rgba(0,0,0,0.55);
    --shadow-xl: 0 24px 48px -12px rgba(0,0,0,0.70);
}

/* ====== DENSIDADES ====== */
[data-density="compact"]  { --pad: 14px; }
[data-density="balanced"] { --pad: 20px; }
[data-density="spacious"] { --pad: 28px; }

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-ui);
    background: var(--bg);
    color: var(--ink);
    font-size: 13.5px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    position: relative;
}

/* Fondo sutil: naranja muy tenue en top-right */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 90% 0%, rgba(255, 106, 0, 0.04) 0%, transparent 40%);
    z-index: -1;
    pointer-events: none;
}

@keyframes pulseBackground {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Container */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 4px var(--space-lg) var(--space-lg);
    min-height: 100vh;
    position: relative;
}

/* ==================== HEADER ==================== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 10px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
}

.header-left {
    position: relative;
    flex: 1;
}

.header-title {
    font-family: var(--font-ui);
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.02em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

/* Info Icon */
.info-icon {
    background: transparent;
    border: 1px solid var(--line);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ink-2);
    transition: all var(--transition-fast);
    position: relative;
    padding: 0;
}

.info-icon:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: none;
    box-shadow: none;
}

.info-icon::before {
    display: none;
}

.info-icon:hover::before {
    display: none;
}

/* Tooltip */
.info-tooltip {
    position: fixed;
    top: auto;
    left: auto;
    z-index: var(--z-tooltip);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition);
    pointer-events: none;
}

.info-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.tooltip-content {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    padding: var(--space-xl);
    min-width: 700px;
    max-width: 850px;
    position: relative;
}

.tooltip-content::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 32px;
    width: 16px;
    height: 16px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    border-top: 1px solid var(--border);
    transform: rotate(45deg);
}

.tooltip-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all var(--transition-fast);
    line-height: 1;
}

.tooltip-close:hover {
    background: var(--background);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.tooltip-content h3 {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    padding-right: 40px;
}

.tooltip-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.info-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.info-item {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line-2);
    border-radius: var(--radius-card);
    border-left: 2px solid var(--accent);
    transition: background var(--transition-fast);
}

.info-item:hover {
    transform: none;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.info-item-highlight {
    background: var(--accent-soft);
    border-left: 2px solid var(--accent);
    box-shadow: none;
}

.info-item strong {
    display: block;
    color: var(--ink);
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.005em;
}

.info-item div {
    color: var(--ink-2);
    font-size: 12px;
    line-height: 1.5;
}

/* ==================== BUTTONS (topbar) ==================== */
.btn-home,
.btn-calendar,
.btn-share,
.filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    color: var(--ink-2);
    font-size: 12.5px;
    font-weight: 500;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    overflow: visible;
}

.btn-home::before,
.btn-share::before,
.filter-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left var(--transition-slow);
    pointer-events: none;
}

.btn-home::after,
.btn-share::after,
.filter-toggle::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
    overflow: hidden;
    pointer-events: none;
}

.btn-home:hover::before,
.btn-share:hover::before,
.filter-toggle:hover::before {
    left: 100%;
}

.btn-home:hover,
.btn-share:hover,
.filter-toggle:hover,
.btn-calendar:hover {
    border-color: var(--ink-3);
    color: var(--ink);
    background: var(--surface-2);
}

/* Grupo de acciones del header — 3 subgrupos con divisores automáticos */
.header-actions {
    display: flex;
    align-items: center;
    gap: 0;
}
.action-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
    position: relative;
}
.action-group:first-child { padding-left: 0; }
.action-group:last-child  { padding-right: 0; }
/* Línea vertical sutil antes de cada grupo que no sea el primero */
.action-group + .action-group::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 1px;
    height: 20px;
    background: var(--line);
}

/* Legado: mantenido por si alguien lo usa en inline style */
.header-divider {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: var(--line);
    margin: 0 4px;
}

/* Botón icono-solo (sin etiqueta) */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    color: var(--ink-2);
    cursor: pointer;
    transition: all var(--transition-fast);
    flex-shrink: 0;
    position: relative;
}
.icon-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
.icon-btn:active {
    transform: scale(0.96);
}
.icon-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.18);
}
.icon-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}
/* Variante sin borde para usar dentro de otros containers (ej. session) */
.icon-btn-ghost {
    border-color: transparent;
    background: transparent;
    width: 26px;
    height: 26px;
}
.icon-btn-ghost:hover {
    background: var(--surface-2);
    border-color: transparent;
}

/* Sesión en el header (avatar + user + logout icon) */
.header-session {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 4px 0 4px;
    height: 32px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-btn);
    font-size: 12.5px;
    transition: border-color var(--transition-fast);
}
.header-session:hover {
    border-color: var(--ink-3);
}

/* Avatar con inicial — se setea color/letra por JS */
.session-avatar {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    user-select: none;
}

.header-session .session-info {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-weight: 500;
    padding-right: 2px;
}
.header-session #sessionUser {
    font-weight: 500;
    color: var(--ink);
}
.header-session #sessionAdminLink {
    font-size: 11.5px;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--accent-soft);
}
.header-session #sessionAdminLink:hover {
    background: var(--brand);
    color: #fff;
}
.header-session .logout-btn {
    color: var(--ink-3);
    margin-left: 2px;
}
.header-session .logout-btn:hover {
    color: var(--danger);
    background: var(--danger-soft);
}

/* Wrapper del menú de usuario (dropdown) */
.session-wrapper {
    position: relative;
    display: inline-flex;
}
button.header-session {
    cursor: pointer;
    font-family: var(--font-ui);
    color: var(--ink);
}
button.header-session:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
.header-session[aria-expanded="true"] {
    border-color: var(--accent);
}
.session-chevron {
    color: var(--ink-3);
    margin: 0 4px 0 2px;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}
.header-session[aria-expanded="true"] .session-chevron {
    transform: rotate(180deg);
}

/* Dropdown — position:fixed para escapar del overflow:hidden del .header.
   top/right se setean por JS desde openSessionMenu() usando getBoundingClientRect. */
.session-menu {
    position: fixed;
    min-width: 210px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    padding: 4px;
    display: none;
    z-index: 1100;
}
.session-menu.show { display: block; }
.session-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-input);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.session-menu-item:hover {
    background: var(--surface-2);
}
.session-menu-item:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}
.session-menu-item svg {
    flex-shrink: 0;
    color: var(--ink-3);
}
.session-menu-item-danger { color: var(--danger); }
.session-menu-item-danger svg { color: var(--danger); }
.session-menu-item-danger:hover { background: var(--danger-soft); }
.session-menu-separator {
    height: 1px;
    background: var(--line);
    margin: 4px 2px;
}

/* Modal: cambiar contraseña */
.modal-content.password-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 420px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.25s ease-out;
}
.password-modal .modal-close {
    font-size: 26px;
    width: 32px;
    height: 32px;
}
.password-form {
    padding: 18px 22px 22px;
}
.password-field {
    margin-bottom: 12px;
}
.password-field label {
    display: block;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-3);
    margin-bottom: 5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.password-field input {
    width: 100%;
    padding: 9px 11px;
    font-size: 13px;
    font-family: var(--font-ui);
    border: 1px solid var(--line);
    border-radius: var(--radius-input);
    outline: none;
    background: var(--surface);
    color: var(--ink);
    box-sizing: border-box;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.password-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.12);
}
.password-hint {
    font-size: 11px;
    color: var(--ink-3);
    margin-top: 4px;
}
.password-error {
    display: none;
    background: var(--danger-soft);
    color: var(--danger);
    padding: 8px 10px;
    border-radius: var(--radius-input);
    font-size: 12px;
    margin: 8px 0 0;
}
.password-error.show { display: block; }
.password-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.pwd-btn {
    padding: 8px 16px;
    border-radius: var(--radius-btn);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.pwd-btn:hover { background: var(--surface-2); }
.pwd-btn-primary {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.pwd-btn-primary:hover:not(:disabled) {
    background: var(--brand-deep);
    border-color: var(--brand-deep);
}
.pwd-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    background: var(--ink);
    color: var(--surface);
    padding: 10px 14px;
    border-radius: var(--radius-btn);
    font-size: 12.5px;
    font-family: var(--font-ui);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.22s ease-out;
    min-width: 200px;
    max-width: 360px;
}
.toast-success { background: #059669; color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
.toast.hide { animation: toastOut 0.28s ease-out forwards; }
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-8px); }
}

/* Mobile: ajustar dropdown y modal */
@media (max-width: 768px) {
    .session-menu { min-width: 200px; }
    .modal-content.password-modal {
        max-width: 100%;
    }
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
    }
    .toast { max-width: 100%; }
}

.btn-share.copied {
    border-color: var(--good);
    color: var(--good);
    background: var(--good-soft);
}

.filter-toggle.active {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.filter-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--accent);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    box-shadow: 0 2px 6px rgba(255, 106, 0, 0.35);
    z-index: 10;
}

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

/* ==================== FILTERS DRAWER (derecha, 460px, slide-in 240ms) ==================== */
.filters-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition), visibility var(--transition);
    z-index: var(--z-drawer);
}

.filters-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.filters-container {
    position: fixed;
    top: 0;
    right: 0;
    width: 460px;
    max-width: 100vw;
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-xl);
    transform: translateX(100%);
    transition: transform var(--transition);
    z-index: calc(var(--z-drawer) + 1);
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.filters-container.show {
    transform: translateX(0);
}

.filters-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line-2);
    margin: 0;
}

.filters-header h3 {
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.filters-close {
    width: 28px;
    height: 28px;
    border: 1px solid var(--line);
    border-radius: 50%;
    background: transparent;
    color: var(--ink-2);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: all var(--transition-fast);
}

.filters-close:hover {
    color: var(--ink);
    border-color: var(--ink-3);
}

.filters-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 0;
}

.filter-group label {
    display: block;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--ink-3);
    margin-bottom: 6px;
    font-family: var(--font-ui);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.filter-group input,
.filter-group select {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-input);
    font-size: 13px;
    font-family: var(--font-ui);
    background: var(--surface);
    color: var(--ink);
    transition: all var(--transition-fast);
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 106, 0, 0.12);
}

/* Filtro con valor aplicado — acento naranja para destacar lo que está activo */
.filter-group.filter-active label {
    color: var(--accent);
}
.filter-group.filter-active input,
.filter-group.filter-active select {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--ink);
    font-weight: 500;
}
.filter-group.filter-active::before {
    content: '';
    position: absolute;
    top: 10px;
    right: -4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
.filter-group { position: relative; }

.filter-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding-top: 14px;
    border-top: 1px solid var(--line-2);
    margin-top: auto;
    position: sticky;
    bottom: 0;
    background: var(--surface);
}

.btn-primary,
.btn-secondary {
    height: 34px;
    padding: 0 16px;
    border-radius: var(--radius-btn);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-ui);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-deep);
}

.btn-primary:active {
    background: var(--brand-deep);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink-2);
    border-color: var(--line);
}

.btn-secondary:hover:not(:disabled) {
    color: var(--ink);
    border-color: var(--ink-3);
    background: var(--surface-2);
}

/* ==================== NAVIGATION MENU (horizontal, 44px) ==================== */
.horizontal-menu {
    display: flex;
    align-items: stretch;
    gap: 2px;
    background: var(--surface);
    padding: 0 6px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    margin-bottom: 12px;
    box-shadow: var(--shadow-sm);
    position: relative;
    height: 44px;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.horizontal-menu::before {
    display: none;
}

.menu-item {
    position: relative;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    transition: color var(--transition-fast);
    white-space: nowrap;
    user-select: none;
    color: var(--ink-2);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.menu-item::before {
    display: none;
}

.menu-item:hover:not(.has-submenu) {
    transform: none;
    color: var(--ink);
}

.menu-item:hover:not(.has-submenu)::before {
    display: none;
}

.menu-item.active::before {
    display: none;
}

.menu-item.active {
    color: var(--ink);
    box-shadow: none;
    border-bottom-color: var(--accent);
}

.menu-item.active .menu-label {
    color: var(--ink);
    text-shadow: none;
    font-weight: 600;
}

.menu-item.active .arrow {
    color: var(--ink);
}

.menu-label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 500;
    color: inherit;
    transition: color var(--transition-fast);
    font-family: var(--font-ui);
    letter-spacing: -0.005em;
}

.menu-icon {
    flex-shrink: 0;
    color: var(--ink-3);
    transition: color var(--transition-fast);
}

.menu-item:hover .menu-icon,
.menu-item.active .menu-icon {
    color: var(--accent);
}

.menu-item:hover .menu-label {
    color: var(--ink);
}

.menu-item.active:hover .menu-label {
    color: var(--ink);
}

.arrow {
    font-size: 9px;
    margin-left: 4px;
    transition: transform var(--transition-fast);
    display: inline-block;
    color: var(--ink-3);
}

.menu-item.open .arrow {
    transform: rotate(180deg);
}

/* Submenu */
.submenu {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-lg);
    min-width: 220px;
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: all var(--transition-fast);
    z-index: var(--z-dropdown);
    pointer-events: none;
}

.menu-item.open .submenu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.submenu-item {
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    position: relative;
    color: var(--ink-2);
    font-size: 13px;
}

.submenu-item::before {
    display: none;
}

.submenu-item:hover {
    background: var(--surface-2);
    color: var(--ink);
    padding-left: 12px;
}

.submenu-item:hover::before {
    display: none;
}

.submenu-item.active {
    background: rgba(27, 152, 224, 0.08);
    padding-left: 24px;
}

.submenu-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.submenu-item.active span {
    color: var(--accent);
    font-weight: 600;
}

.submenu-item span {
    font-size: 13px;
    color: inherit;
    display: block;
    font-family: var(--font-ui);
    transition: color var(--transition-fast);
}

/* ==================== CONTENT AREA ==================== */
.content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: var(--pad);
    box-shadow: var(--shadow-sm);
    min-height: 500px;
    height: auto;
    position: relative;
    overflow: hidden;
}

.content::before {
    display: none;
}

/* ==================== WELCOME PAGE ==================== */
.welcome-page {
    animation: fadeInUp var(--transition-slow);
}

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

.welcome-card {
    text-align: center;
    max-width: 900px;
    margin: 0 auto;
}

.welcome-card h2 {
    font-family: var(--font-ui);
    font-size: 26px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 8px;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.welcome-card h2 em {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--accent);
    font-weight: 400;
}

.welcome-subtitle {
    font-size: 14px;
    color: var(--ink-2);
    margin-bottom: 32px;
    font-weight: 400;
}

.welcome-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: var(--pad);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    position: relative;
    overflow: hidden;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 14px;
}

.stat-card::before {
    display: none;
}

.stat-card:hover {
    border-color: var(--ink-3);
    box-shadow: var(--shadow-sm);
    transform: none;
}

.stat-card:hover::before {
    display: none;
}

.stat-icon {
    font-size: 28px;
    line-height: 1;
    animation: none;
    flex-shrink: 0;
    opacity: 0.85;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.stat-content {
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-feature-settings: "ss02","zero";
}

.stat-label {
    font-size: 10.5px;
    color: var(--ink-3);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.welcome-info {
    background: var(--surface-2);
    border-radius: var(--radius-card);
    padding: 28px;
    text-align: left;
    border: 1px solid var(--line);
}

.welcome-info h3 {
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 12px;
    letter-spacing: -0.01em;
}

.welcome-info ul {
    list-style: none;
    margin-bottom: var(--space-xl);
}

.welcome-info li {
    padding: var(--space-md) 0;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    color: var(--text-secondary);
}

.welcome-info li:last-child {
    border-bottom: none;
}

.welcome-info strong {
    color: var(--text-primary);
    font-weight: 700;
}

/* ========================================================================
   HOME · Página de bienvenida spectacular
   ======================================================================== */

.welcome-page {
    display: flex;
    flex-direction: column;
    gap: 28px;
    animation: homeFadeIn 500ms ease-out;
}

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

/* ─── HERO ───────────────────────────────────────────────────────────── */
.home-hero {
    position: relative;
    padding: 40px 28px 36px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
}

.home-hero-decoration {
    position: absolute;
    top: -80px;
    right: -80px;
    width: 320px;
    height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle at center, rgba(255, 106, 0, 0.18) 0%, rgba(255, 106, 0, 0.04) 40%, transparent 70%);
    pointer-events: none;
    animation: heroPulse 8s ease-in-out infinite;
}

@keyframes heroPulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50%      { transform: scale(1.08); opacity: 1; }
}

.home-hero-eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-3);
    margin-bottom: 14px;
    position: relative;
    z-index: 2;
}
.home-hero-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.2);
    animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 0 4px rgba(255, 106, 0, 0.2); }
    50%      { box-shadow: 0 0 0 6px rgba(255, 106, 0, 0.08); }
}

.home-hero-title {
    font-family: var(--font-ui);
    font-size: 44px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0 0 14px;
    position: relative;
    z-index: 2;
    max-width: 640px;
}
.home-hero-title em {
    font-family: var(--font-serif);
    font-style: italic;
    font-weight: 400;
    color: var(--accent);
    letter-spacing: -0.015em;
}

.home-hero-subtitle {
    font-family: var(--font-ui);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-2);
    margin: 0 0 22px;
    max-width: 620px;
    position: relative;
    z-index: 2;
}

.home-hero-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    position: relative;
    z-index: 2;
}
.home-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--line);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-2);
}

/* ─── Section headers ──────────────────────────────────────────────── */
.home-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.home-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-eyebrow {
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink);
    position: relative;
    padding-left: 14px;
}
.section-eyebrow::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 2px;
    background: var(--accent);
    border-radius: 2px;
}

.section-note {
    font-family: var(--font-ui);
    font-size: 11.5px;
    color: var(--ink-3);
}

/* ─── KPI cards del home ───────────────────────────────────────────── */
.home-kpis {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
}

.home-kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    position: relative;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}
.home-kpi:hover {
    border-color: var(--ink-3);
    box-shadow: var(--shadow-sm);
}

.home-kpi-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.home-kpi-label {
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
}

.home-kpi-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 500;
    line-height: 1.15;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-feature-settings: "ss02","zero";
}
.home-kpi-value.good { color: var(--good); }
.home-kpi-value.warn { color: var(--warn); }
.home-kpi-value.bad  { color: var(--danger); }

.home-kpi-sub {
    font-family: var(--font-ui);
    font-size: 11.5px;
    color: var(--ink-2);
    margin-top: 2px;
}

@media (max-width: 1300px) {
    .home-kpis { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
    .home-kpis { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 500px) {
    .home-kpis { grid-template-columns: 1fr; }
    .home-hero-title { font-size: 32px; }
}

/* ─── Capabilities (shortcuts) ─────────────────────────────────────── */
.home-capabilities {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.capability {
    position: relative;
    text-align: left;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 20px 22px;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow: hidden;
}
.capability::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,106,0,0.03) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--transition-fast);
    pointer-events: none;
}
.capability:hover {
    border-color: var(--accent);
    box-shadow: 0 10px 25px -10px rgba(255, 106, 0, 0.22);
    transform: translateY(-2px);
}
.capability:hover::before { opacity: 1; }
.capability:active { transform: translateY(0); }

.capability-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.capability:hover .capability-icon {
    background: var(--accent);
    color: #fff;
}

.capability h3 {
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    margin: 0;
    letter-spacing: -0.01em;
}

.capability p {
    font-family: var(--font-ui);
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--ink-2);
    margin: 0;
    flex: 1;
}

.capability-arrow {
    align-self: flex-end;
    font-size: 18px;
    color: var(--ink-3);
    transition: color var(--transition-fast), transform var(--transition-fast);
    margin-top: auto;
}
.capability:hover .capability-arrow {
    color: var(--accent);
    transform: translateX(4px);
}

@media (max-width: 900px) {
    .home-capabilities { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .home-capabilities { grid-template-columns: 1fr; }
}

/* ─── Tip específico del home ──────────────────────────────────────── */
.home-tip { margin-top: 0; }

.welcome-tip {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--surface-2);
    padding: 14px 16px;
    border-radius: var(--radius-card);
    border-left: 3px solid var(--accent);
    margin-top: 20px;
    font-size: 13px;
    color: var(--ink);
}

.welcome-tip svg {
    color: var(--accent);
    flex-shrink: 0;
    margin-top: 1px;
}

.welcome-tip strong {
    color: var(--ink);
    font-weight: 600;
}

.welcome-tip span {
    color: var(--ink-2);
}

/* ==================== RESPONSIVE ==================== */
/* Toggle hamburguesa: oculto en desktop */
.action-group-mobile-only { display: none; }

@media (max-width: 768px) {
    .container {
        padding: var(--space-md);
    }

    /* Header: mantener todo en UNA fila con solo iconos */
    .header {
        padding: 8px 12px;
        gap: 6px;
    }
    .header-title { font-size: 17px; }
    .header-title::before { width: 5px; height: 5px; }

    .header-actions {
        flex-wrap: nowrap;
        gap: 0;
        flex-shrink: 0;
    }
    .action-group { padding: 0 4px; gap: 4px; }
    .action-group + .action-group::before { display: none; }
    .action-group-mobile-only { display: flex; }

    /* Menú colapsable en mobile: oculto por default, vertical al abrirse */
    #menuContainer { display: none; }
    #menuContainer.menu-open { display: block; }

    .horizontal-menu {
        flex-direction: column;
        align-items: stretch;
        height: auto;
        overflow: visible;
        padding: 6px;
        gap: 2px;
    }
    .menu-item {
        width: 100%;
        padding: 10px 12px;
        border-bottom: none !important;
        margin-bottom: 0;
    }
    .menu-item .menu-label {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .menu-item .arrow { margin-left: auto; }

    /* Submenus inline (no floating) */
    .submenu {
        position: static !important;
        opacity: 1 !important;
        visibility: visible !important;
        transform: none !important;
        pointer-events: auto !important;
        display: none;
        box-shadow: none;
        border: none;
        background: var(--surface-2);
        margin-top: 6px;
        padding: 4px;
        min-width: 0;
        width: 100%;
        border-radius: 8px;
    }
    .menu-item.has-submenu.open .submenu { display: block; }
    .submenu-item { padding: 10px 14px; }

    /* Botón hamburguesa activo */
    #btnMenuToggle.active {
        background: var(--accent-soft);
        color: var(--accent);
        border-color: var(--accent);
    }

    /* Botones con texto pasan a solo-icono cuadrado */
    .btn-home,
    .filter-toggle {
        width: 34px;
        height: 34px;
        padding: 0;
        gap: 0;
        justify-content: center;
        font-size: 0;  /* oculta el text-node "Inicio" / "Filtros" */
    }
    .btn-home svg,
    .filter-toggle svg { flex-shrink: 0; }
    .filter-toggle .filter-badge {
        font-size: 9px;
        min-width: 14px;
        height: 14px;
        padding: 0 3px;
        position: absolute;
        top: -4px;
        right: -4px;
    }

    /* Session: sólo avatar + logout, se oculta el nombre de usuario y badge */
    .header-session .session-info { display: none; }
    .header-session { padding: 0 3px; gap: 4px; }

    /* Resto */
    .tooltip-content {
        min-width: 280px;
        max-width: calc(100vw - 40px);
    }
    .info-section { grid-template-columns: 1fr; }
    .filters-grid { grid-template-columns: 1fr; }

    .horizontal-menu {
        overflow-x: auto;
        scrollbar-width: thin;
    }
    .horizontal-menu::-webkit-scrollbar { height: 6px; }
    .horizontal-menu::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }

    .content { padding: var(--space-lg); }
    .welcome-card h2 { font-size: 32px; }
    .welcome-subtitle { font-size: 16px; }
    .welcome-stats { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    /* Filter drawer ocupa toda la pantalla */
    .filters-container {
        width: 100vw;
        padding: 16px 14px;
    }
    /* iOS no hace zoom al focus si el font-size >= 16px */
    .filter-group input,
    .filter-group select { font-size: 16px; }

    .home-kpis { grid-template-columns: repeat(2, 1fr) !important; }
    .loader-content { padding: 20px; }
    .welcome-card { padding-left: var(--space-md); padding-right: var(--space-md); }
}

@media (max-width: 420px) {
    .header { padding: 6px 10px; }
    .header-title { font-size: 15px; }
    .action-group { padding: 0 3px; }
    .btn-home, .filter-toggle { width: 32px; height: 32px; }
    .icon-btn { width: 32px; height: 32px; }
    .home-kpis { grid-template-columns: 1fr !important; }
}

/* ==================== SUBPAGES STYLES ==================== */

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: var(--pad);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    color: var(--ink);
    position: relative;
    overflow: hidden;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.kpi-card::before {
    display: none;
}

.kpi-card:hover {
    border-color: var(--ink-3);
    transform: none;
    box-shadow: var(--shadow-sm);
}

.kpi-card:nth-child(n) {
    background: var(--surface);
}

/* KPI cards con gradiente inline (patrón ranking-agentes): texto blanco + burbuja decorativa */
.kpi-card[style*="linear-gradient"],
.kpi-card[style*="gradient"] {
    color: #fff;
    border: none;
    padding: 22px 24px;
    border-radius: 12px;
    box-shadow: none;
}
.kpi-card[style*="linear-gradient"]::after,
.kpi-card[style*="gradient"]::after {
    content: '';
    position: absolute;
    top: -20px;
    right: -20px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
}
.kpi-card[style*="gradient"]:hover {
    border-color: transparent;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.2);
}
.kpi-card[style*="gradient"] .kpi-label {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.9;
    color: #fff;
    margin-bottom: 8px;
}
.kpi-card[style*="gradient"] .kpi-value {
    font-family: var(--font-ui);
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 4px;
    color: #fff;
    letter-spacing: -0.01em;
    font-feature-settings: normal;
    text-shadow: none;
}
.kpi-card[style*="gradient"] .kpi-change,
.kpi-card[style*="gradient"] .kpi-sub {
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
    color: #fff;
    opacity: 0.85;
}
.kpi-card[style*="gradient"] .kpi-change.up,
.kpi-card[style*="gradient"] .kpi-change.down,
.kpi-card[style*="gradient"] .kpi-change.flat {
    color: #fff;
}

.kpi-label {
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    margin-bottom: 8px;
}

.kpi-value {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 500;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 6px;
    text-shadow: none;
    font-feature-settings: "ss02","zero";
    line-height: 1.1;
}

.kpi-change {
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-2);
    opacity: 1;
}

.kpi-change.up   { color: var(--good); }
.kpi-change.down { color: var(--danger); }
.kpi-change.flat { color: var(--ink-3); }

/* Cards Grid */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: var(--pad);
    box-shadow: var(--shadow-sm);
}

.card-title {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

/* Chart Container */
.chart-container {
    background: var(--surface);
    padding: var(--pad);
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
    transition: border-color var(--transition-fast);
}

.chart-container:hover {
    box-shadow: var(--shadow-sm);
    transform: none;
    border-color: var(--line);
}

.chart-title {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line-2);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border-radius: var(--radius-card);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--line);
}

.data-table thead {
    background: var(--surface-2);
}

.data-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-family: var(--font-ui);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-3);
    border-bottom: 1px solid var(--line);
}

.data-table tbody tr {
    transition: background var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--surface-2);
}

.data-table tbody tr:not(:last-child) {
    border-bottom: 1px solid var(--line-2);
}

.data-table tbody td {
    padding: 10px 14px;
    color: var(--ink);
    font-size: 13px;
    font-family: var(--font-ui);
}

.data-table tbody td.mono,
.data-table tbody td[data-type="number"] {
    font-family: var(--font-mono);
    font-feature-settings: "ss02","zero";
    letter-spacing: -0.01em;
}

/* Pills (reemplazo moderno de badges) */
.pill,
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 7px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    line-height: 1.4;
    border: 1px solid transparent;
}

.pill.good,
.badge-success {
    background: var(--good-soft);
    color: var(--good);
}

.pill.warn,
.badge-warning {
    background: var(--warn-soft);
    color: var(--warn);
}

.pill.bad,
.badge-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.pill.accent,
.badge-info {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3xl);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 500;
}

/* Score Colors */
.score-green {
    color: var(--success);
    font-weight: 700;
}

.score-yellow {
    color: var(--warning);
    font-weight: 700;
}

.score-red {
    color: var(--error);
    font-weight: 700;
}

.score-light-red {
    color: #f87171;
    font-weight: 700;
}
/* ==================== MODAL DE CALENDARIO ==================== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    z-index: 10000;
    padding: 20px;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content.calendar-modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 32px;
    color: var(--text-tertiary);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    transition: all var(--transition);
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
    transform: rotate(90deg);
}

.year-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 24px;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.year-select {
    padding: 12px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-primary);
    min-width: 120px;
    text-align: center;
}

.year-select:hover {
    border-color: var(--primary-color);
}

.year-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(27, 152, 224, 0.1);
}

.year-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    color: var(--text-secondary);
}

.year-nav-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.year-nav-btn:active {
    transform: scale(0.95);
}

.weeks-table-container {
    max-height: 500px;
    overflow-y: auto;
    padding: 0;
}

.weeks-table {
    width: 100%;
    border-collapse: collapse;
}

.weeks-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.weeks-table th {
    background: var(--surface-2);
    color: var(--ink-3);
    padding: 10px 20px;
    text-align: left;
    font-weight: 500;
    font-size: 10.5px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--line);
    font-family: var(--font-ui);
}

.weeks-table td {
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
}

.weeks-table td:first-child {
    color: var(--text-primary);
}

.weeks-table tbody tr {
    transition: all var(--transition);
}

.weeks-table tbody tr:hover {
    background: var(--surface-2);
    transform: none;
}

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

/* Scrollbar personalizado para la tabla */
.weeks-table-container::-webkit-scrollbar {
    width: 8px;
}

.weeks-table-container::-webkit-scrollbar-track {
    background: var(--background);
}

.weeks-table-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.weeks-table-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* ==================== GLOBAL LOADER ==================== */
.global-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

.global-loader.hidden {
    opacity: 0;
    visibility: hidden;
    display: none;
}

.loader-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 24px;
    border: 3px solid var(--line);
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.loader-title {
    color: var(--ink);
    font-size: 20px;
    font-weight: 600;
    margin: 0 0 8px 0;
    font-family: var(--font-ui);
    letter-spacing: -0.01em;
}

.loader-text {
    color: var(--ink-2);
    font-size: 13px;
    margin: 0 0 20px 0;
    font-family: var(--font-ui);
}

.loader-progress {
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar {
    flex: 1;
    height: 4px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-percent {
    color: var(--ink-2);
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    min-width: 40px;
    text-align: right;
    letter-spacing: -0.01em;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content.calendar-modal {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .weeks-table th,
    .weeks-table td {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .year-selector {
        padding: 16px;
    }
    
    .loader-content {
        padding: 20px;
    }
    
    .spinner {
        width: 60px;
        height: 60px;
    }
    
    .loader-title {
        font-size: 20px;
    }
}

/* ==================== UTILITY CLASSES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--ink-3); }
.text-xs { font-size: 11.5px; }
.text-sm { font-size: 12px; }
.text-mono { font-family: var(--font-mono); font-feature-settings: "ss02","zero"; }
.text-accent { color: var(--accent); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.nowrap { white-space: nowrap; }

/* Delta arrows (▲/▼) con color semántico */
.delta-up   { color: var(--good); }
.delta-down { color: var(--danger); }
.delta-flat { color: var(--ink-3); }

/* Score badge — heredado de pages; remapeado a paleta nueva */
.score-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 11.5px;
    font-weight: 500;
    border: 1px solid transparent;
    letter-spacing: -0.01em;
}
.score-badge.score-high,
.score-high { background: var(--good-soft);   color: var(--good);   }
.score-badge.score-mid,
.score-mid  { background: var(--warn-soft);   color: var(--warn);   }
.score-badge.score-low,
.score-low  { background: var(--danger-soft); color: var(--danger); }

.score-green     { color: var(--good);   font-weight: 600; }
.score-yellow    { color: var(--warn);   font-weight: 600; }
.score-red       { color: var(--danger); font-weight: 600; }
.score-light-red { color: var(--danger); font-weight: 600; opacity: 0.8; }

/* Hack para evitar que el fondo animado viejo aparezca */
body::before { animation: none !important; }