/* ==========================================================================
   Horario CopyBBC · Sistema de diseño v2
   Móvil primero · modo claro y oscuro · sin dependencias externas
   --------------------------------------------------------------------------
   Orden del archivo:
     1. Tokens            8. Insignias y estados     15. Terminal
     2. Modo oscuro       9. Avatares                16. Portal
     3. Fundamentos      10. Formularios             17. Calendario
     4. Utilidades       11. Tablas                  18. Gráficos
     5. Estructura       12. Avisos                  19. Piezas sueltas
     6. Superficies      13. Cabecera y menús        20. Impresión
     7. Botones          14. Acceso y legales        21. Preferencias
   ========================================================================== */

/* --------------------------------------------------------------- 1. Tokens */
:root {
    color-scheme: light;

    /* Azul corporativo */
    --blue-50:  #eff6ff;
    --blue-100: #dbeafe;
    --blue-200: #bfdbfe;
    --blue-300: #93c5fd;
    --blue-400: #60a5fa;
    --blue-500: #3b82f6;
    --blue-600: #2563eb;
    --blue-700: #1d4ed8;
    --blue-800: #1e40af;
    --blue-900: #1e3a8a;
    --blue-950: #172554;

    /* Neutros */
    --n-0:   #ffffff;
    --n-25:  #fcfcfd;
    --n-50:  #f8fafc;
    --n-100: #f1f5f9;
    --n-150: #e9eef5;
    --n-200: #e2e8f0;
    --n-300: #cbd5e1;
    --n-400: #94a3b8;
    --n-500: #64748b;
    --n-600: #475569;
    --n-700: #334155;
    --n-800: #1e293b;
    --n-900: #0f172a;
    --n-950: #080d16;

    /* Estados (siempre acompañados de icono o texto, nunca color solo) */
    --ok-bg:     #ecfdf5;  --ok-line:   #a7f3d0;  --ok-ink:   #047857;  --ok-solid:   #059669;
    --warn-bg:   #fffbeb;  --warn-line: #fde68a;  --warn-ink: #b45309;  --warn-solid: #d97706;
    --bad-bg:    #fef2f2;  --bad-line:  #fecaca;  --bad-ink:  #b91c1c;  --bad-solid:  #dc2626;
    --info-bg:   #eff6ff;  --info-line: #bfdbfe;  --info-ink: #1e40af;  --info-solid: #2563eb;

    /* Semánticos */
    --bg:            var(--n-50);
    --bg-elevated:   var(--n-0);
    --surface:       var(--n-0);
    --surface-2:     var(--n-50);
    --surface-sunken: var(--n-100);
    --border:        var(--n-200);
    --border-strong: var(--n-300);
    --ink:           var(--n-900);
    --ink-2:         var(--n-600);
    --ink-3:         var(--n-500);
    --ink-4:         var(--n-400);
    --primary:       var(--blue-600);
    --primary-hover: var(--blue-700);
    --primary-ink:   #ffffff;
    --primary-soft:  var(--blue-50);
    --primary-soft-line: var(--blue-100);
    --primary-soft-ink:  var(--blue-800);

    /* Gráficos: paleta validada para superficie clara (#ffffff) */
    --viz-1: #2563eb;
    --viz-2: #ea580c;
    --viz-3: #0d9488;
    --viz-muted: var(--n-200);
    --viz-grid:  var(--n-150);
    --viz-axis:  var(--n-300);
    --viz-ink:   var(--n-500);

    /* Tipografía */
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
            Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --t-xs:  0.75rem;
    --t-sm:  0.8125rem;
    --t-base:0.9375rem;
    --t-md:  1rem;
    --t-lg:  1.125rem;
    --t-xl:  clamp(1.25rem, 1.1rem + 0.7vw, 1.4rem);
    --t-2xl: clamp(1.5rem, 1.3rem + 1vw, 1.875rem);
    --t-3xl: clamp(1.875rem, 1.5rem + 1.8vw, 2.5rem);

    /* Espaciado */
    --s-1: 0.25rem;  --s-2: 0.5rem;   --s-3: 0.75rem;  --s-4: 1rem;
    --s-5: 1.25rem;  --s-6: 1.5rem;   --s-8: 2rem;     --s-10: 2.5rem;
    --s-12: 3rem;    --s-16: 4rem;

    /* Radios */
    --r-sm: 8px;  --r: 12px;  --r-lg: 16px;  --r-xl: 22px;  --r-2xl: 28px;
    --r-full: 999px;

    /* Elevación: dos capas, sombra de contacto + sombra difusa */
    --e-1: 0 1px 2px rgba(15,23,42,.06);
    --e-2: 0 1px 2px rgba(15,23,42,.06), 0 2px 6px rgba(15,23,42,.05);
    --e-3: 0 1px 2px rgba(15,23,42,.06), 0 8px 20px -6px rgba(15,23,42,.12);
    --e-4: 0 2px 4px rgba(15,23,42,.06), 0 18px 40px -12px rgba(15,23,42,.18);
    --e-5: 0 4px 8px rgba(15,23,42,.08), 0 32px 64px -16px rgba(15,23,42,.24);
    --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 30%, transparent);

    /* Movimiento */
    --ease:   cubic-bezier(.4, 0, .2, 1);
    --spring: cubic-bezier(.34, 1.4, .64, 1);
    --fast: .14s;  --base: .2s;  --slow: .32s;

    /* Medidas de la interfaz */
    --sidebar-w: 268px;
    --header-h: 62px;
    --tabbar-h: 66px;
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-t: env(safe-area-inset-top, 0px);
}

/* --------------------------------------------------------- 2. Modo oscuro */
/* Los valores oscuros se declaran dos veces: la consulta de medios cubre la
   preferencia del sistema y el atributo data-theme cubre el interruptor, que
   debe ganar en ambos sentidos. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        color-scheme: dark;

        --bg:            #0b0f17;
        --bg-elevated:   #151a23;
        --surface:       #151a23;
        --surface-2:     #1b212c;
        --surface-sunken: #10151e;
        --border:        #242c3a;
        --border-strong: #303a4b;
        --ink:           #eef2f8;
        --ink-2:         #a8b4c6;
        --ink-3:         #8494aa;
        --ink-4:         #64748b;

        --primary:       var(--blue-500);
        --primary-hover: var(--blue-400);
        --primary-ink:   #08101f;
        --primary-soft:  rgba(59,130,246,.14);
        --primary-soft-line: rgba(59,130,246,.28);
        --primary-soft-ink:  #bfdbfe;

        --ok-bg:   rgba(5,150,105,.14);  --ok-line:   rgba(5,150,105,.3);   --ok-ink:   #6ee7b7;  --ok-solid:   #10b981;
        --warn-bg: rgba(217,119,6,.15);  --warn-line: rgba(217,119,6,.32);  --warn-ink: #fcd34d;  --warn-solid: #f59e0b;
        --bad-bg:  rgba(220,38,38,.15);  --bad-line:  rgba(220,38,38,.32);  --bad-ink:  #fca5a5;  --bad-solid:  #ef4444;
        --info-bg: rgba(59,130,246,.14); --info-line: rgba(59,130,246,.3);  --info-ink: #bfdbfe;  --info-solid: #3b82f6;

        --viz-1: #3d8ae8;
        --viz-2: #d4622c;
        --viz-3: #1a9c7e;
        --viz-muted: #2a3342;
        --viz-grid:  #212936;
        --viz-axis:  #303a4b;
        --viz-ink:   #8494aa;

        --e-1: 0 1px 2px rgba(0,0,0,.4);
        --e-2: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
        --e-3: 0 1px 2px rgba(0,0,0,.4), 0 8px 20px -6px rgba(0,0,0,.5);
        --e-4: 0 2px 4px rgba(0,0,0,.4), 0 18px 40px -12px rgba(0,0,0,.6);
        --e-5: 0 4px 8px rgba(0,0,0,.5), 0 32px 64px -16px rgba(0,0,0,.7);
    }
}

:root[data-theme="dark"] {
    color-scheme: dark;

    --bg:            #0b0f17;
    --bg-elevated:   #151a23;
    --surface:       #151a23;
    --surface-2:     #1b212c;
    --surface-sunken: #10151e;
    --border:        #242c3a;
    --border-strong: #303a4b;
    --ink:           #eef2f8;
    --ink-2:         #a8b4c6;
    --ink-3:         #8494aa;
    --ink-4:         #64748b;

    --primary:       var(--blue-500);
    --primary-hover: var(--blue-400);
    --primary-ink:   #08101f;
    --primary-soft:  rgba(59,130,246,.14);
    --primary-soft-line: rgba(59,130,246,.28);
    --primary-soft-ink:  #bfdbfe;

    --ok-bg:   rgba(5,150,105,.14);  --ok-line:   rgba(5,150,105,.3);   --ok-ink:   #6ee7b7;  --ok-solid:   #10b981;
    --warn-bg: rgba(217,119,6,.15);  --warn-line: rgba(217,119,6,.32);  --warn-ink: #fcd34d;  --warn-solid: #f59e0b;
    --bad-bg:  rgba(220,38,38,.15);  --bad-line:  rgba(220,38,38,.32);  --bad-ink:  #fca5a5;  --bad-solid:  #ef4444;
    --info-bg: rgba(59,130,246,.14); --info-line: rgba(59,130,246,.3);  --info-ink: #bfdbfe;  --info-solid: #3b82f6;

    --viz-1: #3d8ae8;
    --viz-2: #d4622c;
    --viz-3: #1a9c7e;
    --viz-muted: #2a3342;
    --viz-grid:  #212936;
    --viz-axis:  #303a4b;
    --viz-ink:   #8494aa;

    --e-1: 0 1px 2px rgba(0,0,0,.4);
    --e-2: 0 1px 2px rgba(0,0,0,.4), 0 2px 6px rgba(0,0,0,.3);
    --e-3: 0 1px 2px rgba(0,0,0,.4), 0 8px 20px -6px rgba(0,0,0,.5);
    --e-4: 0 2px 4px rgba(0,0,0,.4), 0 18px 40px -12px rgba(0,0,0,.6);
    --e-5: 0 4px 8px rgba(0,0,0,.5), 0 32px 64px -16px rgba(0,0,0,.7);
}

/* ---------------------------------------------------------- 3. Fundamentos */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--t-base);
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-wrap: break-word;
    transition: background-color var(--base) var(--ease), color var(--base) var(--ease);
}

h1, h2, h3, h4 { margin: 0; font-weight: 640; line-height: 1.22; letter-spacing: -0.018em; }
h1 { font-size: var(--t-2xl); letter-spacing: -0.026em; }
h2 { font-size: var(--t-xl); }
h3 { font-size: var(--t-lg); }
h4 { font-size: var(--t-md); }
p  { margin: 0 0 var(--s-3); }
p:last-child { margin-bottom: 0; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; height: auto; vertical-align: middle; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; }
s { color: var(--ink-4); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 5px;
}

::selection { background: color-mix(in srgb, var(--primary) 24%, transparent); }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
    position: absolute; left: var(--s-4); top: -100px; z-index: 999;
    background: var(--primary); color: var(--primary-ink);
    padding: var(--s-3) var(--s-4); border-radius: var(--r);
    font-weight: 600; transition: top var(--base) var(--ease);
}
.skip-link:focus { top: var(--s-4); text-decoration: none; }

/* --------------------------------------------------------- 4. Utilidades */
.stack   { display: flex; flex-direction: column; gap: var(--s-4); }
.stack-2 { display: flex; flex-direction: column; gap: var(--s-2); }
.stack-6 { display: flex; flex-direction: column; gap: var(--s-6); }
.row     { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.center  { text-align: center; }
.right   { text-align: right; }
.nowrap  { white-space: nowrap; }
.muted   { color: var(--ink-3); }
.subtle  { color: var(--ink-4); }
.small   { font-size: var(--t-sm); }
.xs      { font-size: var(--t-xs); }
.strong  { font-weight: 640; }
.mono    { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.tabular { font-variant-numeric: tabular-nums; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); } .mb-6 { margin-bottom: var(--s-6); }
.hide { display: none !important; }

.eyebrow {
    font-size: var(--t-xs); font-weight: 700; letter-spacing: .09em;
    text-transform: uppercase; color: var(--ink-4);
}

/* ---------------------------------------------------------- 5. Estructura */
.app-shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.page {
    width: 100%; max-width: 1240px; margin: 0 auto;
    padding: var(--s-5) var(--s-4) calc(var(--tabbar-h) + var(--safe-b) + var(--s-8));
}
.page-narrow { max-width: 780px; }

.page-header {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-5);
}
.page-header h1 { margin-bottom: 3px; }
.page-header .lede { color: var(--ink-3); font-size: var(--t-sm); margin: 0; }

.grid { display: grid; gap: var(--s-4); }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (min-width: 680px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1000px) {
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* --------------------------------------------------------- 6. Superficies */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--e-1);
}
.card-pad  { padding: var(--s-5); }
.card-body { padding: var(--s-5); }
.card-body-tight { padding: var(--s-3) var(--s-5); }

.card-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s-3); padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-head h2, .card-head h3 { font-size: var(--t-md); font-weight: 640; }

.card-foot {
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.card-link {
    display: block; color: inherit;
    transition: box-shadow var(--base) var(--ease), transform var(--base) var(--spring),
                border-color var(--base) var(--ease);
}
.card-link:hover {
    text-decoration: none; box-shadow: var(--e-3);
    border-color: var(--border-strong); transform: translateY(-2px);
}
.card-link:active { transform: translateY(0); }

/* Tarjeta destacada con degradado sutil */
.card-accent {
    background:
        radial-gradient(120% 140% at 0% 0%, var(--primary-soft), transparent 58%),
        var(--surface);
    border-color: var(--primary-soft-line);
}

/* Métricas */
.metric { padding: var(--s-5); }
.metric-label {
    font-size: var(--t-xs); font-weight: 650; letter-spacing: .06em;
    text-transform: uppercase; color: var(--ink-3);
}
.metric-value {
    font-size: var(--t-3xl); font-weight: 680; letter-spacing: -0.032em;
    margin-top: var(--s-1); line-height: 1.08;
}
.metric-hint { font-size: var(--t-sm); color: var(--ink-3); margin-top: var(--s-1); }
.metric-accent-1 .metric-value { color: var(--viz-1); }
.metric-accent-ok .metric-value { color: var(--ok-ink); }
.metric-accent-warn .metric-value { color: var(--warn-ink); }
.metric-accent-bad .metric-value { color: var(--bad-ink); }

/* Cifra protagonista: figuras proporcionales, nunca tabulares */
.hero-figure {
    font-family: var(--font);
    font-size: clamp(2.5rem, 1.8rem + 3.2vw, 3.5rem);
    font-weight: 300; letter-spacing: -0.04em; line-height: 1.02;
}

/* ------------------------------------------------------------ 7. Botones */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
    min-height: 44px; padding: 0 var(--s-5);
    border: 1px solid transparent; border-radius: var(--r);
    background: var(--surface); color: var(--ink);
    font-family: inherit; font-size: var(--t-base); font-weight: 600; line-height: 1;
    text-align: center; cursor: pointer; text-decoration: none; user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease), transform .08s var(--ease), color var(--fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.975); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { position: relative; color: transparent !important; }
.btn[aria-busy="true"]::after {
    content: ""; position: absolute; width: 17px; height: 17px;
    border: 2px solid currentColor; border-radius: 50%;
    border-top-color: transparent; color: var(--primary-ink);
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-primary {
    background: var(--primary); color: var(--primary-ink);
    box-shadow: var(--e-1), inset 0 1px 0 rgba(255,255,255,.14);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--e-2); }
.btn-primary:focus-visible { box-shadow: var(--ring); outline: none; }

.btn-secondary { background: var(--surface); color: var(--ink); border-color: var(--border-strong); box-shadow: var(--e-1); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-4); }

.btn-ghost { background: transparent; color: var(--ink-3); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--ink); }

.btn-ok    { background: var(--ok-solid);   color: #fff; }
.btn-ok:hover { filter: brightness(.94); }
.btn-bad   { background: var(--bad-solid);  color: #fff; }
.btn-bad:hover { filter: brightness(.94); }
.btn-warn  { background: var(--warn-solid); color: #fff; }
.btn-warn:hover { filter: brightness(.94); }
.btn-bad-soft { background: var(--bad-bg); color: var(--bad-ink); border-color: var(--bad-line); }
.btn-bad-soft:hover { background: color-mix(in srgb, var(--bad-bg) 70%, var(--bad-line)); }

.btn-sm { min-height: 34px; padding: 0 var(--s-3); font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn-lg { min-height: 54px; padding: 0 var(--s-8); font-size: var(--t-md); border-radius: var(--r-lg); }
.btn-xl { min-height: 70px; padding: 0 var(--s-10); font-size: var(--t-lg); border-radius: var(--r-lg); font-weight: 680; }
.btn-block { display: flex; width: 100%; }
.btn-icon { padding: 0; width: 40px; min-height: 40px; }
.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; }

/* Control segmentado */
.segmented {
    display: inline-flex; padding: 3px; gap: 2px;
    background: var(--surface-sunken); border: 1px solid var(--border);
    border-radius: var(--r); overflow-x: auto;
}
.segmented a, .segmented button {
    padding: 7px var(--s-4); border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-3);
    font: inherit; font-size: var(--t-sm); font-weight: 600;
    cursor: pointer; white-space: nowrap; text-decoration: none;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.segmented a:hover, .segmented button:hover { color: var(--ink); text-decoration: none; }
.segmented [aria-pressed="true"], .segmented [aria-current="page"] {
    background: var(--surface); color: var(--ink); box-shadow: var(--e-1);
}

/* ------------------------------------------------- 8. Insignias y estados */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--r-full);
    font-size: var(--t-xs); font-weight: 650; line-height: 1.5;
    white-space: nowrap; border: 1px solid transparent;
}
.badge-neutral { background: var(--surface-sunken); color: var(--ink-2); border-color: var(--border); }
.badge-ok      { background: var(--ok-bg);   color: var(--ok-ink);   border-color: var(--ok-line); }
.badge-warn    { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.badge-bad     { background: var(--bad-bg);  color: var(--bad-ink);  border-color: var(--bad-line); }
.badge-info    { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }

/* El punto nunca informa solo: siempre va junto a su texto */
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.dot-working { background: var(--ok-solid); }
.dot-break   { background: var(--warn-solid); }
.dot-out     { background: var(--ink-4); }

.pulse { position: relative; }
.pulse::after {
    content: ""; position: absolute; inset: -4px; border-radius: 50%;
    border: 2px solid var(--ok-solid); opacity: 0;
    animation: pulse 2.4s var(--ease) infinite;
}
@keyframes pulse {
    0%   { transform: scale(.7); opacity: .65; }
    70%  { transform: scale(1.55); opacity: 0; }
    100% { transform: scale(1.55); opacity: 0; }
}

/* --------------------------------------------------------- 9. Avatares */
/* El color llega desde PHP como --av; aqui se le anade el degradado y el
   brillo superior, que es lo que separa un avatar "de verdad" de un circulo
   de color plano. overflow queda visible para que el punto de estado no se
   recorte: antes se pintaba y nadie lo veia. */
.avatar {
    position: relative; display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
    background-color: var(--av, var(--primary));
    background-image: linear-gradient(152deg,
        rgba(255,255,255,.26) 0%, rgba(255,255,255,.04) 46%, rgba(0,0,0,.20) 100%);
    color: #fff;
    font-weight: 700; font-size: var(--t-sm); letter-spacing: .01em;
    text-transform: uppercase; user-select: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.28), inset 0 -1px 0 rgba(0,0,0,.12);
}
.avatar img {
    width: 100%; height: 100%; object-fit: cover;
    border-radius: inherit; position: relative;
}
.avatar-sm  { width: 30px; height: 30px; font-size: var(--t-xs); }
.avatar-lg  { width: 56px; height: 56px; font-size: var(--t-lg); }
.avatar-xl  { width: 88px; height: 88px; font-size: var(--t-2xl); }
.avatar-2xl { width: 112px; height: 112px; font-size: 2.6rem; }

.avatar-status {
    position: absolute; right: 2%; bottom: 2%; z-index: 1;
    width: 13px; height: 13px; border-radius: 50%;
    border: 2.5px solid var(--surface);
    box-shadow: 0 1px 2px rgba(15,23,42,.18);
}
.avatar-lg .avatar-status, .avatar-xl .avatar-status { width: 18px; height: 18px; border-width: 3px; }
.avatar-status-working { background: var(--ok-solid); }
.avatar-status-break   { background: var(--warn-solid); }
.avatar-status-out     { background: var(--ink-4); }

.person { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.person-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person-role { font-size: var(--t-sm); color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------- 10. Formularios */
.field { margin-bottom: var(--s-4); }
.field:last-child { margin-bottom: 0; }

.label {
    display: block; font-size: var(--t-sm); font-weight: 600;
    color: var(--ink-2); margin-bottom: var(--s-2);
}
.label .optional { font-weight: 400; color: var(--ink-4); }

.input, .select, .textarea {
    display: block; width: 100%; min-height: 44px;
    padding: 10px var(--s-3);
    font-family: inherit; font-size: var(--t-base); color: var(--ink);
    background: var(--surface); border: 1px solid var(--border-strong);
    border-radius: var(--r); appearance: none;
    transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
                background-color var(--fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: var(--ring);
}
.input:disabled, .select:disabled, .textarea:disabled {
    background: var(--surface-sunken); color: var(--ink-3); cursor: not-allowed;
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
    border-color: var(--bad-solid);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.6; }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right var(--s-3) center;
    padding-right: var(--s-8);
}
:root[data-theme="dark"] .select,
:root:not([data-theme="light"]) .select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238494aa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .select {
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    }
}

.hint { font-size: var(--t-sm); color: var(--ink-3); margin-top: var(--s-2); line-height: 1.5; }
.error-text { font-size: var(--t-sm); color: var(--bad-ink); margin-top: var(--s-2); font-weight: 500; }

.check {
    display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3);
    border: 1px solid var(--border); border-radius: var(--r); cursor: pointer;
    transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.check:hover { background: var(--surface-2); border-color: var(--border-strong); }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--primary); flex: 0 0 auto; cursor: pointer; }
.check-text { font-size: var(--t-sm); }
.check-text strong { display: block; font-size: var(--t-base); font-weight: 600; color: var(--ink); }
.check-text span { color: var(--ink-3); }
.check-inline { border: 0; padding: 0; }
.check-inline:hover { background: transparent; }

.check-grid { display: grid; gap: var(--s-2); grid-template-columns: 1fr; }
@media (min-width: 620px) { .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.field-row { display: grid; gap: var(--s-4); grid-template-columns: 1fr; }
@media (min-width: 620px) {
    .field-row-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.fieldset { border: 0; padding: 0; margin: 0 0 var(--s-6); }
.fieldset legend {
    padding: 0; font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--ink-4); margin-bottom: var(--s-3);
}

.color-swatches { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.color-swatch { position: relative; }
.color-swatch input { position: absolute; opacity: 0; width: 0; height: 0; }
.color-swatch span {
    display: block; width: 34px; height: 34px; border-radius: 50%; cursor: pointer;
    border: 3px solid transparent; box-shadow: 0 0 0 1px var(--border);
    transition: transform var(--fast) var(--spring);
}
.color-swatch input:checked + span { border-color: var(--surface); box-shadow: 0 0 0 2.5px var(--ink); transform: scale(1.08); }
.color-swatch input:focus-visible + span { box-shadow: 0 0 0 3px var(--primary); }

/* Filtros: una sola fila por encima de todo lo que filtran */
.filters { display: grid; gap: var(--s-3); grid-template-columns: 1fr; align-items: end; }
@media (min-width: 620px)  { .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .filters { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.filters .field { margin: 0; }
.filters-actions { display: flex; gap: var(--s-2); }

/* ------------------------------------------------------------ 11. Tablas */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--r-lg) var(--r-lg); }

.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th, .table td {
    padding: var(--s-3) var(--s-4); text-align: left; vertical-align: middle;
    border-bottom: 1px solid var(--border);
}
.table th {
    font-size: var(--t-xs); font-weight: 650; letter-spacing: .04em;
    text-transform: uppercase; color: var(--ink-3);
    background: var(--surface-2); white-space: nowrap;
    position: sticky; top: 0; z-index: 1;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .row-link { color: inherit; font-weight: 600; }
.table-compact th, .table-compact td { padding: var(--s-2) var(--s-3); }

@media (max-width: 767px) { .hide-mobile { display: none !important; } }
@media (min-width: 768px) { .only-mobile { display: none !important; } }

/* ------------------------------------------------------------ 12. Avisos */
.notice {
    display: flex; align-items: flex-start; gap: var(--s-3);
    padding: var(--s-4); border-radius: var(--r);
    border: 1px solid transparent; font-size: var(--t-sm); line-height: 1.55;
}
.notice-icon { flex: 0 0 auto; margin-top: 1px; }
.notice-success { background: var(--ok-bg);   color: var(--ok-ink);   border-color: var(--ok-line); }
.notice-error   { background: var(--bad-bg);  color: var(--bad-ink);  border-color: var(--bad-line); }
.notice-warning { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.notice-info    { background: var(--info-bg); color: var(--info-ink); border-color: var(--info-line); }
.notice strong { font-weight: 650; }

.toast-region {
    position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s-4));
    transform: translateX(-50%); z-index: 200;
    width: min(560px, calc(100vw - var(--s-8)));
    display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none;
}
.toast-region .notice {
    box-shadow: var(--e-4); background: var(--surface); pointer-events: auto;
    animation: toast-in var(--slow) var(--spring);
}
.toast-region .notice-success { background: var(--ok-bg); }
.toast-region .notice-error   { background: var(--bad-bg); }
.toast-region .notice-warning { background: var(--warn-bg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

@media (min-width: 1024px) {
    .toast-region { bottom: var(--s-6); left: auto; right: var(--s-6); transform: none; }
}

.empty { text-align: center; padding: var(--s-10) var(--s-5); color: var(--ink-3); }
.empty-icon {
    width: 58px; height: 58px; margin: 0 auto var(--s-4); border-radius: var(--r-lg);
    background: var(--surface-sunken); display: flex; align-items: center; justify-content: center;
    color: var(--ink-4);
}
.empty h3 { color: var(--ink); margin-bottom: var(--s-2); font-size: var(--t-md); }
.empty p { max-width: 400px; margin: 0 auto var(--s-5); font-size: var(--t-sm); }

/* Esqueletos de carga */
.skeleton {
    background: linear-gradient(90deg, var(--surface-sunken) 25%, var(--surface-2) 37%, var(--surface-sunken) 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease-in-out infinite;
    border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* -------------------------------------------------- 13. Cabecera y menús */
.topbar {
    position: sticky; top: 0; z-index: 50;
    display: flex; align-items: center; gap: var(--s-3);
    height: calc(var(--header-h) + var(--safe-t));
    padding: var(--safe-t) var(--s-4) 0;
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: var(--s-3); color: var(--ink); font-weight: 700; letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    background: linear-gradient(140deg, var(--blue-400), var(--blue-700));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: var(--t-sm); font-weight: 800; letter-spacing: -0.04em;
    box-shadow: 0 2px 10px -2px color-mix(in srgb, var(--blue-600) 60%, transparent);
    flex: 0 0 auto;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.brand-text { line-height: 1.15; }
.brand-text small { display: block; font-size: var(--t-xs); font-weight: 500; color: var(--ink-3); letter-spacing: 0; }

.sidebar { display: none; }

.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
    display: flex; align-items: center; gap: var(--s-3);
    padding: 10px var(--s-3); border-radius: var(--r);
    color: var(--ink-2); font-size: var(--t-base); font-weight: 550;
    transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.nav-link:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.nav-link[aria-current="page"] {
    background: var(--primary-soft); color: var(--primary-soft-ink); font-weight: 650;
}
.nav-link[aria-current="page"] .nav-icon { color: var(--primary); }
.nav-icon { flex: 0 0 auto; width: 20px; height: 20px; color: var(--ink-4); }
.nav-count {
    margin-left: auto; background: var(--bad-solid); color: #fff;
    font-size: var(--t-xs); font-weight: 700; min-width: 20px; height: 20px;
    padding: 0 6px; border-radius: var(--r-full);
    display: inline-flex; align-items: center; justify-content: center;
}
.nav-section {
    margin: var(--s-5) 0 var(--s-2); padding: 0 var(--s-3);
    font-size: var(--t-xs); font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--ink-4);
}

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    display: flex;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-b);
}
.tabbar a {
    flex: 1 1 0; min-width: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; gap: 3px;
    height: var(--tabbar-h); color: var(--ink-4);
    font-size: 10.5px; font-weight: 600; text-decoration: none; position: relative;
    -webkit-tap-highlight-color: transparent;
    transition: color var(--fast) var(--ease);
}
.tabbar a span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a[aria-current="page"]::before {
    content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 28px; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary);
}
.tabbar-badge {
    position: absolute; top: 8px; left: calc(50% + 6px);
    min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--r-full);
    background: var(--bad-solid); color: #fff; font-size: 9.5px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}

.menu { position: relative; }
.menu-panel {
    position: absolute; right: 0; top: calc(100% + 8px); min-width: 236px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--e-4); padding: var(--s-2); z-index: 70;
    animation: menu-in var(--fast) var(--ease);
}
.menu-panel[hidden] { display: none; }
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.menu-head { padding: var(--s-3); border-bottom: 1px solid var(--border); margin-bottom: var(--s-2); }
.menu-item {
    display: flex; align-items: center; gap: var(--s-3); width: 100%;
    padding: 9px var(--s-3); border: 0; border-radius: var(--r-sm);
    background: none; color: var(--ink-2); font: inherit; font-size: var(--t-sm);
    text-align: left; cursor: pointer;
}
.menu-item:hover { background: var(--surface-sunken); text-decoration: none; color: var(--ink); }

/* Interruptor de tema */
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: var(--r-full);
    border: 1px solid var(--border); background: var(--surface); color: var(--ink-3);
    cursor: pointer; transition: color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--border-strong); }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: block; }
    :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: none; }
}

/* Escritorio y tablet */
@media (min-width: 1024px) {
    .app-shell.with-sidebar { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }

    .sidebar {
        display: flex; flex-direction: column; position: sticky; top: 0;
        height: 100vh; height: 100dvh;
        padding: var(--s-5) var(--s-4); background: var(--surface);
        border-right: 1px solid var(--border); overflow-y: auto;
    }
    .sidebar .brand { margin-bottom: var(--s-6); padding: 0 var(--s-2); }
    .sidebar-footer { margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--border); }

    .tabbar { display: none; }
    .topbar { padding-left: var(--s-6); padding-right: var(--s-6); }
    .topbar .brand { display: none; }
    .page { padding: var(--s-6) var(--s-6) var(--s-10); }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .page { padding: var(--s-5) var(--s-5) calc(var(--tabbar-h) + var(--safe-b) + var(--s-8)); }
}

/* -------------------------------------------------- 14. Acceso y legales */
.auth-screen {
    min-height: 100vh; min-height: 100dvh;
    display: flex; align-items: center; justify-content: center;
    padding: var(--s-5);
    background:
        radial-gradient(1100px 520px at 12% -12%, var(--primary-soft), transparent 58%),
        radial-gradient(900px 480px at 108% 108%, color-mix(in srgb, var(--viz-3) 12%, transparent), transparent 55%),
        var(--bg);
}
.auth-card {
    width: 100%; max-width: 430px; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--e-4); padding: var(--s-8) var(--s-6);
}
.auth-card-wide { max-width: 580px; }
.auth-brand { display: flex; align-items: center; gap: var(--s-3); justify-content: center; margin-bottom: var(--s-6); }
.auth-card h1 { font-size: var(--t-xl); text-align: center; }
.auth-card .lede { text-align: center; color: var(--ink-3); font-size: var(--t-sm); margin-bottom: var(--s-6); }
.auth-foot { margin-top: var(--s-5); text-align: center; font-size: var(--t-sm); }

.legal-page { max-width: 780px; margin: 0 auto; padding: var(--s-8) var(--s-4) var(--s-12); }
.legal-page h1 { margin-bottom: var(--s-2); }
.legal-page h2 { font-size: var(--t-md); margin: var(--s-8) 0 var(--s-3); }
.legal-page p, .legal-page li { color: var(--ink-2); font-size: var(--t-base); line-height: 1.72; }
.legal-page ul { padding-left: var(--s-5); }
.legal-page li { margin-bottom: var(--s-2); }
.legal-updated { font-size: var(--t-sm); color: var(--ink-3); }

.cookie-bar {
    position: fixed; left: var(--s-4); right: var(--s-4);
    bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s-4)); z-index: 150;
    max-width: 580px; margin: 0 auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--e-5); padding: var(--s-5);
    animation: toast-in var(--slow) var(--spring);
}
@media (min-width: 1024px) { .cookie-bar { bottom: var(--s-6); } }

/* ----------------------------------------------------------- 15. Terminal */
/* Pantalla de tienda: una tablet colgada en la pared que se mira de lejos y se
   toca con el pulgar. Composicion centrada, tarjetas grandes y estado legible
   a dos metros. Todo entra con una animacion escalonada para que al encender
   la tablet se note que la pantalla esta viva. */

.terminal-screen {
    position: relative;
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; overflow: hidden;
    padding: var(--safe-t) 0 var(--safe-b);
    background:
        /* trama de puntos muy tenue: quita el aspecto plano del degradado */
        radial-gradient(circle at 1px 1px,
            color-mix(in srgb, var(--ink) 7%, transparent) 1px, transparent 0) 0 0 / 30px 30px,
        radial-gradient(1100px 600px at 14% -14%, color-mix(in srgb, var(--primary) 17%, transparent), transparent 62%),
        radial-gradient(980px  540px at 90%   2%, color-mix(in srgb, var(--viz-3)  14%, transparent), transparent 60%),
        radial-gradient(1200px 700px at 50% 116%, color-mix(in srgb, #7c3aed      11%, transparent), transparent 64%),
        var(--bg);
}

/* ---------------------------------------------------------- barra superior */
.terminal-topbar {
    position: relative; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s-4); padding: var(--s-5) var(--s-6) 0;
    animation: terminal-drop .5s var(--ease) both;
}
.terminal-brand { display: inline-flex; align-items: center; gap: var(--s-3); min-width: 0; }
.terminal-brand .brand-mark {
    width: 44px; height: 44px; border-radius: 14px; flex: 0 0 auto;
    box-shadow: var(--e-2);
}
.terminal-brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.terminal-brand-text b {
    font-size: var(--t-base); font-weight: 700; letter-spacing: -.012em; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.terminal-brand-text span { font-size: var(--t-xs); color: var(--ink-3); }

.terminal-store {
    display: inline-flex; align-items: center; gap: var(--s-2); flex: 0 0 auto;
    margin: 0; padding: 9px var(--s-4) 9px var(--s-3);
    background: color-mix(in srgb, var(--surface) 80%, transparent);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border: 1px solid var(--primary-soft-line);
    border-radius: var(--r-full); box-shadow: var(--e-1);
    font-size: var(--t-sm); font-weight: 700; letter-spacing: .055em;
    text-transform: uppercase; color: var(--primary-soft-ink);
}

/* ------------------------------------------------------------ cuerpo (hero) */
.terminal-body {
    position: relative; z-index: 1;
    flex: 1 1 auto; min-height: 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: clamp(var(--s-5), 3.5vh, var(--s-10));
    padding: var(--s-5) var(--s-6) var(--s-3);
}

.terminal-hero { text-align: center; animation: terminal-drop .6s var(--ease) both; }
.terminal-ask  { text-align: center; animation: terminal-drop .6s var(--ease) .07s both; }

.terminal-clock {
    display: inline-flex; align-items: baseline; gap: .02em;
    font-size: clamp(3rem, 8.6vw, 5.6rem);
    font-weight: 200; letter-spacing: -.055em;
    font-variant-numeric: tabular-nums; line-height: .94;
    color: var(--ink); margin: 0;
}
.terminal-clock .seconds {
    font-size: .28em; color: var(--ink-4); font-weight: 400;
    margin-left: .3em; letter-spacing: .01em;
}
/* Solo la inicial en mayuscula: capitalize convertia "de" en "De". */
.terminal-date {
    font-size: var(--t-md); color: var(--ink-3);
    margin: var(--s-4) 0 0; letter-spacing: .005em;
}
.terminal-date::first-letter { text-transform: uppercase; }

.terminal-question {
    font-size: clamp(1.4rem, 2.7vw, 2.1rem); font-weight: 700;
    letter-spacing: -.032em; line-height: 1.15; margin: 0; color: var(--ink);
}
.terminal-hint {
    margin: var(--s-2) 0 0; color: var(--ink-3);
    font-size: var(--t-base); letter-spacing: .005em;
}

/* --------------------------------------------------------- rejilla de fichas */
/* Pistas de ancho acotado y rejilla centrada: con 3 o con 9 empleados las
   tarjetas mantienen el tamano y quedan en el medio, no apiladas a la
   izquierda dejando media pantalla vacia. */
.employee-grid {
    --col: 198px; --gutter: 16px;
    display: grid; justify-content: center; align-content: start;
    grid-template-columns: repeat(auto-fit, minmax(148px, var(--col)));
    gap: var(--gutter);
    width: 100%;
    /* La rejilla nunca es mas ancha que las personas que hay: con cuatro
       empleados no se abren siete columnas y quedan cuatro fichas apretadas
       a la izquierda. --n lo pone la vista. */
    max-width: min(1240px, calc(var(--n, 12) * (var(--col) + var(--gutter))));
    overflow-y: auto; overscroll-behavior: contain;
    padding: var(--s-2) var(--s-1) var(--s-5);
}
@media (min-width: 720px) {
    .employee-grid {
        --col: 224px; --gutter: 20px;
        grid-template-columns: repeat(auto-fit, minmax(190px, var(--col)));
    }
}
@media (min-width: 1200px) {
    .employee-grid {
        --col: 252px; --gutter: 24px;
        grid-template-columns: repeat(auto-fit, minmax(212px, var(--col)));
    }
}

.employee-card {
    position: relative; overflow: hidden;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: var(--s-6) var(--s-4) var(--s-5);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-2xl);
    box-shadow: var(--e-2), inset 0 1px 0 rgba(255,255,255,.05);
    cursor: pointer; text-align: center; font: inherit; color: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: transform var(--base) var(--spring),
                box-shadow var(--base) var(--ease),
                border-color var(--base) var(--ease);
    animation: employee-in .52s var(--spring) both;
    animation-delay: calc(var(--i, 0) * 65ms);
}
/* Bano de color segun el estado: caracter sin gritar. */
.employee-card::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 52%;
    background: linear-gradient(180deg, var(--card-wash, transparent), transparent);
    pointer-events: none;
}
.employee-card[data-status="working"] { --card-wash: color-mix(in srgb, var(--ok-solid)   15%, transparent); }
.employee-card[data-status="break"]   { --card-wash: color-mix(in srgb, var(--warn-solid) 16%, transparent); }
.employee-card[data-status="out"]     { --card-wash: color-mix(in srgb, var(--primary)     9%, transparent); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .employee-card[data-status="out"] { --card-wash: color-mix(in srgb, var(--primary) 20%, transparent); }
}
:root[data-theme="dark"] .employee-card[data-status="out"] { --card-wash: color-mix(in srgb, var(--primary) 20%, transparent); }

.employee-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--e-4), inset 0 1px 0 rgba(255,255,255,.06);
    border-color: color-mix(in srgb, var(--primary) 45%, var(--border));
}
.employee-card:active {
    transform: translateY(-1px) scale(.972);
    box-shadow: var(--e-1);
    transition-duration: .08s;
}
.employee-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }

/* Anillo de estado: separado del avatar, con hueco, para que se lea de lejos. */
.employee-card .avatar-ring {
    position: relative; display: inline-grid; place-items: center;
    padding: 6px; border-radius: 50%;
    box-shadow: inset 0 0 0 2.5px var(--ring-color, transparent);
    transition: box-shadow var(--base) var(--ease);
}
.employee-card[data-status="working"] .avatar-ring { --ring-color: var(--ok-solid); }
.employee-card[data-status="break"]   .avatar-ring { --ring-color: var(--warn-solid); }
.employee-card[data-status="out"]     .avatar-ring { --ring-color: color-mix(in srgb, var(--ink) 8%, transparent); }

/* Latido suave solo para quien esta dentro: dice "esto esta en marcha". */
.employee-card[data-status="working"] .avatar-ring::after {
    content: ""; position: absolute; inset: 0; border-radius: 50%; pointer-events: none;
    animation: ring-pulse 2.8s var(--ease) infinite;
}
@keyframes ring-pulse {
    0%   { box-shadow: 0 0 0 0    color-mix(in srgb, var(--ok-solid) 40%, transparent); }
    70%  { box-shadow: 0 0 0 15px color-mix(in srgb, var(--ok-solid)  0%, transparent); }
    100% { box-shadow: 0 0 0 0    color-mix(in srgb, var(--ok-solid)  0%, transparent); }
}

.employee-card .avatar { width: 80px; height: 80px; font-size: 1.8rem; }
/* El anillo y la pastilla ya dicen el estado: un tercer indicador sobre el
   avatar solo ensuciaba el borde. */
.employee-card .avatar-status { display: none; }
@media (min-width: 720px) { .employee-card .avatar { width: 94px;  height: 94px;  font-size: 2.1rem; } }
@media (min-width: 1200px) { .employee-card .avatar { width: 106px; height: 106px; font-size: 2.35rem; } }

.employee-name {
    margin-top: var(--s-4);
    font-size: clamp(1.05rem, 1.45vw, 1.25rem); font-weight: 700;
    letter-spacing: -.022em; line-height: 1.2; color: var(--ink);
}
.employee-role {
    font-size: var(--t-sm); color: var(--ink-3); line-height: 1.35;
    margin-top: 2px;
}
.employee-state {
    display: inline-flex; align-items: center; gap: 7px;
    margin-top: var(--s-4); padding: 6px 13px;
    border: 1px solid transparent; border-radius: var(--r-full);
    font-size: var(--t-xs); font-weight: 700; letter-spacing: .015em;
}
.employee-state .dot { width: 7px; height: 7px; }
.state-working { background: var(--ok-bg);          color: var(--ok-ink);   border-color: var(--ok-line); }
.state-break   { background: var(--warn-bg);        color: var(--warn-ink); border-color: var(--warn-line); }
.state-out     { background: var(--surface-sunken); color: var(--ink-2);    border-color: var(--border); }

/* PIN bloqueado: se ve que no se puede tocar y por que. */
.employee-card[data-blocked="1"] { opacity: .62; }
.employee-card[data-blocked="1"]:hover { transform: none; box-shadow: var(--e-2); border-color: var(--border); }
.employee-card[data-blocked="1"]::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: repeating-linear-gradient(135deg,
        transparent 0 10px, color-mix(in srgb, var(--ink) 5%, transparent) 10px 20px);
}
.employee-lock {
    position: absolute; top: var(--s-3); right: var(--s-3); z-index: 1;
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--bad-bg); color: var(--bad-ink);
    border: 1px solid var(--bad-line);
}

@keyframes employee-in {
    from { opacity: 0; transform: translateY(26px) scale(.93); }
    to   { opacity: 1; transform: none; }
}
@keyframes terminal-drop {
    from { opacity: 0; transform: translateY(-14px); }
    to   { opacity: 1; transform: none; }
}

/* --------------------------------------------- panel: PIN, confirmar, final */
.terminal-overlay {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center; padding: var(--s-4);
    background: color-mix(in srgb, var(--n-950) 66%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    animation: fade-in var(--base) var(--ease);
}
.terminal-overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.terminal-panel {
    position: relative;
    width: 100%; max-width: 448px; max-height: calc(100dvh - var(--s-8));
    overflow-y: auto; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-2xl);
    box-shadow: var(--e-5); padding: var(--s-8) var(--s-6) var(--s-6); text-align: center;
    animation: panel-in var(--slow) var(--spring);
}
/* Mismo bano azul que las tarjetas: el panel se siente parte de la pantalla. */
.terminal-panel::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 160px;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0; pointer-events: none;
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 10%, transparent), transparent);
}
.terminal-panel > * { position: relative; }
@keyframes panel-in { from { opacity: 0; transform: translateY(24px) scale(.96); } to { opacity: 1; transform: none; } }
.terminal-panel h2 { font-size: var(--t-2xl); letter-spacing: -.028em; margin-bottom: var(--s-1); }
.terminal-panel .panel-sub { color: var(--ink-3); font-size: var(--t-base); margin-bottom: var(--s-5); }
.terminal-panel .avatar {
    box-shadow: 0 0 0 5px var(--surface),
                0 0 0 7px color-mix(in srgb, var(--primary) 26%, transparent);
}

.pin-dots { display: flex; justify-content: center; gap: var(--s-3); margin: var(--s-6) 0 var(--s-5); }
.pin-dot {
    width: 16px; height: 16px; border-radius: 50%;
    background: transparent; box-shadow: inset 0 0 0 2px var(--border-strong);
    transition: background-color var(--fast) var(--ease),
                box-shadow var(--fast) var(--ease),
                transform var(--fast) var(--spring);
}
.pin-dot.filled {
    background: var(--primary); box-shadow: inset 0 0 0 2px var(--primary);
    transform: scale(1.18);
}
.pin-dots.error .pin-dot { background: var(--bad-solid); box-shadow: inset 0 0 0 2px var(--bad-solid); }
.pin-dots.error { animation: shake .42s var(--ease); }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-9px); } 40% { transform: translateX(9px); }
    60% { transform: translateX(-5px); } 80% { transform: translateX(5px); }
}

/* Vista previa de la camara: la persona ve exactamente lo que se guardara.
   Un espejo, porque verse invertido desconcierta. */
.camera-box {
    position: relative; width: 132px; height: 132px; margin: 0 auto var(--s-3);
    border-radius: 50%; overflow: hidden;
    background: var(--surface-sunken);
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--border);
    transition: box-shadow var(--base) var(--ease);
}
.camera-box[hidden] { display: none; }
.camera-box[data-state="ok"] {
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--ok-solid);
}
.camera-box[data-state="denied"], .camera-box[data-state="failed"], .camera-box[data-state="no_camera"] {
    box-shadow: 0 0 0 3px var(--surface), 0 0 0 5px var(--warn-solid);
}
.camera-preview {
    width: 100%; height: 100%; object-fit: cover;
    transform: scaleX(-1);
    background: var(--n-900);
}
.camera-badge {
    position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: var(--r-full);
    background: color-mix(in srgb, var(--n-950) 62%, transparent);
    color: #fff; font-size: var(--t-xs); font-weight: 650; letter-spacing: .03em;
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.camera-note {
    margin: 0 0 var(--s-4); font-size: var(--t-xs); color: var(--ink-3);
    line-height: 1.45; min-height: 1.2em;
}
.camera-box[data-state="denied"] ~ .camera-note,
.camera-box[data-state="failed"] ~ .camera-note,
.camera-box[data-state="no_camera"] ~ .camera-note { color: var(--warn-ink); font-weight: 600; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-3); margin: 0 auto var(--s-5); max-width: 324px; }
.key {
    height: 74px; border: 1px solid var(--border); border-radius: var(--r-lg);
    background: var(--surface-2); color: var(--ink);
    font-family: inherit; font-size: 1.72rem; font-weight: 500;
    font-variant-numeric: tabular-nums; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    -webkit-tap-highlight-color: transparent;
    box-shadow: var(--e-1);
    transition: background-color var(--fast) var(--ease), transform .07s var(--ease),
                border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.key:hover { background: var(--surface); border-color: var(--border-strong); box-shadow: var(--e-2); }
.key:active {
    transform: scale(.93); background: var(--primary); color: var(--primary-ink);
    border-color: var(--primary); box-shadow: none;
}
.key:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.key-action { font-size: 1.25rem; font-weight: 600; color: var(--ink-3); background: transparent; box-shadow: none; }
.key-zero { grid-column: 2; }

.result-badge {
    width: 104px; height: 104px; margin: 0 auto var(--s-5); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    animation: badge-pop .45s var(--spring);
}
.result-ok   { background: var(--ok-bg);   color: var(--ok-ink);   box-shadow: 0 0 0 8px color-mix(in srgb, var(--ok-solid)   12%, transparent); }
.result-bad  { background: var(--bad-bg);  color: var(--bad-ink);  box-shadow: 0 0 0 8px color-mix(in srgb, var(--bad-solid)  12%, transparent); }
.result-warn { background: var(--warn-bg); color: var(--warn-ink); box-shadow: 0 0 0 8px color-mix(in srgb, var(--warn-solid) 12%, transparent); }
@keyframes badge-pop {
    0% { transform: scale(.35); opacity: 0; }
    60% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); }
}

.result-time {
    font-size: clamp(2.5rem, 12vw, 3.5rem); font-weight: 250;
    letter-spacing: -.045em; font-variant-numeric: tabular-nums;
    line-height: 1.04; margin: var(--s-2) 0;
}
.result-meta { color: var(--ink-3); font-size: var(--t-base); }
.result-total { margin-top: var(--s-5); padding-top: var(--s-5); border-top: 1px solid var(--border); }
.result-total .metric-value { font-size: var(--t-2xl); }

.countdown { margin-top: var(--s-6); font-size: var(--t-xs); color: var(--ink-4); }
.countdown-bar { height: 4px; border-radius: var(--r-full); background: var(--surface-sunken); overflow: hidden; margin-top: var(--s-2); }
.countdown-fill { height: 100%; background: var(--primary); border-radius: inherit; transition: width 1s linear; }

/* Con la camara encendida el panel crece y en una pantalla de 800 px de alto
   el teclado se salia por abajo. En pantallas bajas se compacta todo: en un
   terminal de pared nadie debe tener que desplazar para llegar al teclado. */
@media (max-height: 880px) {
    .terminal-panel { padding: var(--s-5) var(--s-5) var(--s-4); }
    .terminal-panel h2 { font-size: var(--t-xl); }
    .terminal-panel .panel-sub { margin-bottom: var(--s-3); font-size: var(--t-sm); }
    .terminal-panel .avatar-xl { width: 62px; height: 62px; font-size: var(--t-xl); }
    .terminal-panel .mb-4 { margin-bottom: var(--s-2) !important; }

    .camera-box { width: 96px; height: 96px; margin-bottom: var(--s-2); }
    .camera-badge { bottom: 5px; padding: 2px 7px; font-size: 10px; }
    .camera-note { margin-bottom: var(--s-3); }

    .pin-dots { margin: var(--s-3) 0; }
    .pin-dot { width: 13px; height: 13px; }

    .keypad { gap: var(--s-2); margin-bottom: var(--s-3); max-width: 280px; }
    .key { height: 56px; font-size: 1.4rem; }

    .result-badge { width: 76px; height: 76px; margin-bottom: var(--s-3); }
    .countdown { margin-top: var(--s-4); }
}

/* ------------------------------------------------------------- pie discreto */
.terminal-footer {
    position: relative; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    gap: var(--s-3); padding: var(--s-3) var(--s-6) var(--s-5);
    font-size: var(--t-xs); color: var(--ink-4); flex-wrap: wrap;
}
.offline-pill {
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px;
    border-radius: var(--r-full); background: var(--warn-bg); color: var(--warn-ink);
    border: 1px solid var(--warn-line); font-size: var(--t-xs); font-weight: 700;
}
.offline-pill[hidden] { display: none; }

/* Tablet en vertical (el caso real: colgada en la pared del mostrador).
   Sobra alto y falta ancho: menos columnas, fichas y reloj mas grandes. */
@media (min-width: 700px) and (orientation: portrait) {
    .terminal-body { gap: clamp(var(--s-8), 5vh, var(--s-16)); }
    .terminal-clock { font-size: clamp(5rem, 15vw, 9rem); }
    .terminal-date { font-size: 1.3rem; margin-top: var(--s-5); }
    .terminal-question { font-size: clamp(2.1rem, 4.6vw, 3rem); }
    .terminal-hint { font-size: 1.15rem; margin-top: var(--s-3); }

    .employee-grid {
        --col: 304px; --gutter: 24px;
        grid-template-columns: repeat(auto-fit, minmax(250px, var(--col)));
        max-width: min(700px, calc(var(--n, 12) * (var(--col) + var(--gutter))));
    }
    .employee-card { padding: var(--s-8) var(--s-5) var(--s-6); }
    .employee-card .avatar { width: 132px; height: 132px; font-size: 3rem; }
    .employee-card .avatar-ring { padding: 8px; box-shadow: inset 0 0 0 3px var(--ring-color, transparent); }
    .employee-name { font-size: 1.5rem; margin-top: var(--s-5); }
    .employee-role { font-size: 1.05rem; }
    .employee-state { font-size: .875rem; padding: 8px 17px; margin-top: var(--s-5); }
    .employee-lock { width: 38px; height: 38px; }
}

/* Movil en vertical: la tablet no siempre es una tablet. */
@media (max-width: 560px) {
    .terminal-topbar { padding: var(--s-4) var(--s-4) 0; }
    .terminal-brand-text { display: none; }
    .terminal-body { padding: var(--s-4) var(--s-4) var(--s-2); justify-content: flex-start; }
    .terminal-hero { padding-top: var(--s-2); }
    .terminal-footer { padding: var(--s-2) var(--s-4) var(--s-4); }

    /* El navegador cuenta las columnas con el MAXIMO de minmax(), no con el
       minimo: con la pista de 198 px no caben dos en un movil y salia una
       sola tarjeta por fila. Con 168 px caben dos. */
    .employee-grid { --col: 168px; --gutter: 12px; }
    .employee-card { padding: var(--s-5) var(--s-3) var(--s-4); }
    .employee-card .avatar { width: 72px; height: 72px; font-size: 1.6rem; }
    .employee-name { margin-top: var(--s-3); font-size: 1rem; }
    .employee-state { margin-top: var(--s-3); }
}

/* ----------------------------------------- Fotografias del fichaje */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--s-4); }
.photo-item { margin: 0; }
.photo-item img {
    width: 100%; aspect-ratio: 4 / 3; object-fit: cover;
    border-radius: var(--r); border: 1px solid var(--border); display: block;
    background: var(--surface-sunken);
}
.photo-item a:focus-visible img { outline: 3px solid var(--primary); outline-offset: 2px; }
.photo-missing {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--s-2); text-align: center;
    width: 100%; aspect-ratio: 4 / 3; padding: var(--s-3);
    border: 1px dashed var(--warn-line); border-radius: var(--r);
    background: var(--warn-bg); color: var(--warn-ink);
    font-size: var(--t-xs); font-weight: 600; line-height: 1.35;
}
.photo-item figcaption {
    display: flex; flex-direction: column; gap: 1px;
    margin-top: var(--s-2); font-size: var(--t-xs); line-height: 1.35;
}
.photo-item figcaption strong { font-weight: 650; }
.photo-item figcaption span { color: var(--ink-4); }

/* ------------------------------------------------------------- Avisos */
.notice-bell { position: relative; }
.notice-dot {
    position: absolute; top: 2px; right: 2px; min-width: 17px; height: 17px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0 4px; border-radius: var(--r-full);
    background: var(--bad-solid); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 1;
    border: 2px solid var(--surface);
}

.notice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }
.notice-item > a {
    display: flex; align-items: flex-start; gap: var(--s-4);
    padding: var(--s-4) var(--s-5);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r-lg); box-shadow: var(--e-1);
    color: inherit; text-decoration: none;
    transition: border-color var(--base) var(--ease), box-shadow var(--base) var(--ease),
                transform var(--base) var(--ease);
}
.notice-item > a:hover {
    border-color: var(--border-strong); box-shadow: var(--e-3); transform: translateY(-1px);
}
.notice-item.is-unread > a { border-left: 3px solid var(--primary); background: var(--primary-soft); }

.notice-icon {
    flex: 0 0 auto; width: 36px; height: 36px; border-radius: var(--r);
    display: inline-flex; align-items: center; justify-content: center;
}
.notice-icon.tone-bad  { background: var(--bad-bg);  color: var(--bad-ink); }
.notice-icon.tone-warn { background: var(--warn-bg); color: var(--warn-ink); }
.notice-icon.tone-info { background: var(--info-bg); color: var(--info-ink); }

.notice-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.notice-title { font-weight: 650; line-height: 1.35; }
.notice-body  { font-size: var(--t-sm); color: var(--ink-2); line-height: 1.5; }
.notice-meta  { font-size: var(--t-xs); color: var(--ink-4); margin-top: 2px; }
.notice-unread {
    flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
    background: var(--primary); margin-top: 13px;
}

/* ------------------------------------------------------------ 16. Portal */
.clock-hero {
    background:
        radial-gradient(130% 150% at 50% -30%, var(--primary-soft), transparent 62%),
        var(--surface);
    border: 1px solid var(--border); border-radius: var(--r-xl);
    box-shadow: var(--e-2); padding: var(--s-6) var(--s-5); text-align: center;
}
.clock-hero .now {
    font-size: clamp(2.8rem, 13vw, 3.9rem); font-weight: 220;
    letter-spacing: -0.05em; font-variant-numeric: tabular-nums; line-height: 1;
}
.clock-hero .today { color: var(--ink-3); font-size: var(--t-sm); text-transform: capitalize; margin-top: var(--s-2); }

.status-pill {
    display: inline-flex; align-items: center; gap: var(--s-2);
    margin: var(--s-5) 0; padding: 9px var(--s-4); border-radius: var(--r-full);
    font-size: var(--t-sm); font-weight: 650; border: 1px solid transparent;
}
.status-pill-working { background: var(--ok-bg);   color: var(--ok-ink);   border-color: var(--ok-line); }
.status-pill-break   { background: var(--warn-bg); color: var(--warn-ink); border-color: var(--warn-line); }
.status-pill-out     { background: var(--surface-sunken); color: var(--ink-2); border-color: var(--border); }

.worked-figure {
    font-family: var(--font);
    font-size: clamp(2.3rem, 11vw, 3.1rem); font-weight: 280;
    letter-spacing: -0.042em; font-variant-numeric: tabular-nums; line-height: 1.04;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 var(--s-5) var(--s-6); border-left: 2px solid var(--border); }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before {
    content: ""; position: absolute; left: -7px; top: 4px;
    width: 12px; height: 12px; border-radius: 50%;
    background: var(--surface); border: 2.5px solid var(--border-strong);
}
.timeline li.tl-in::before    { border-color: var(--ok-solid); }
.timeline li.tl-out::before   { border-color: var(--bad-solid); }
.timeline li.tl-break::before { border-color: var(--warn-solid); }
.timeline-time { font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline-meta { font-size: var(--t-sm); color: var(--ink-3); }

/* Anillo de progreso */
.ring { display: inline-flex; align-items: center; justify-content: center; position: relative; }
.ring svg { transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--viz-muted); }
.ring-value { fill: none; stroke: var(--viz-1); stroke-linecap: round; transition: stroke-dashoffset .6s var(--ease); }
.ring-value.over { stroke: var(--ok-solid); }
.ring-label {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
}

.progress { height: 7px; border-radius: var(--r-full); background: var(--viz-muted); overflow: hidden; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--viz-1); transition: width .5s var(--ease); }
.progress-fill.over { background: var(--ok-solid); }

/* -------------------------------------------------------- 17. Calendario */
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.calendar-weekday {
    text-align: center; font-size: var(--t-xs); font-weight: 650; color: var(--ink-4);
    text-transform: uppercase; letter-spacing: .04em; padding-bottom: var(--s-2);
}
.calendar-day {
    position: relative; min-height: 64px; padding: 5px;
    border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--surface); font-size: var(--t-xs);
    display: flex; flex-direction: column; gap: 2px;
}
@media (min-width: 768px) { .calendar-day { min-height: 94px; padding: var(--s-2); } }
.calendar-day.is-blank { background: transparent; border-color: transparent; }
.calendar-day.is-today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.calendar-day.is-weekend { background: var(--surface-2); }
.calendar-day.is-holiday { background: var(--info-bg); border-color: var(--info-line); }
.calendar-day.is-absence { background: var(--warn-bg); border-color: var(--warn-line); }
.calendar-day.is-future { opacity: .5; }
.calendar-daynum { font-weight: 650; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.calendar-day.is-today .calendar-daynum { color: var(--primary); }
.calendar-worked { font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--t-sm); }
.calendar-worked.over  { color: var(--ok-ink); }
.calendar-worked.under { color: var(--warn-ink); }
.calendar-expected { color: var(--ink-4); font-size: 10.5px; }
.calendar-tag { font-size: 10px; color: var(--info-ink); font-weight: 600; line-height: 1.2; }
.calendar-flag { position: absolute; top: 5px; right: 5px; width: 6px; height: 6px; border-radius: 50%; background: var(--warn-solid); }

.legend { display: flex; flex-wrap: wrap; gap: var(--s-4); font-size: var(--t-xs); color: var(--ink-3); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; border: 1px solid var(--border); }

/* ---------------------------------------------------------- 18. Gráficos */
/* SVG generado en el servidor (App\Core\Chart). Marcas finas, rejilla
   discreta, huecos de 2px entre barras y etiquetas selectivas. */
.viz { position: relative; }
.viz svg { display: block; width: 100%; height: auto; overflow: visible; }

.viz-grid-line { stroke: var(--viz-grid); stroke-width: 1; shape-rendering: crispEdges; }
.viz-axis-line { stroke: var(--viz-axis); stroke-width: 1; shape-rendering: crispEdges; }
.viz-ref-line  { stroke: var(--viz-axis); stroke-width: 1.5; stroke-linecap: round; }

.viz-tick {
    fill: var(--viz-ink); font-size: 10.5px; font-family: var(--font);
    font-variant-numeric: tabular-nums;
}
.viz-label { fill: var(--ink-2); font-size: 11px; font-family: var(--font); }
.viz-value { fill: var(--ink); font-size: 11px; font-weight: 650; font-family: var(--font);
             font-variant-numeric: tabular-nums; }

.viz-bar { fill: var(--viz-1); transition: opacity var(--fast) var(--ease); }
.viz-bar-2 { fill: var(--viz-2); }
.viz-bar-3 { fill: var(--viz-3); }
/* Forma de énfasis: la serie protagonista en color, el resto en gris */
.viz-bar-muted { fill: var(--viz-muted); }
.viz-mark:hover .viz-bar,
.viz-mark:focus-visible .viz-bar { opacity: .78; }
.viz-mark:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.viz-hit { fill: transparent; cursor: default; }

.viz-legend {
    display: flex; flex-wrap: wrap; gap: var(--s-4);
    font-size: var(--t-xs); color: var(--ink-2); padding: 0 var(--s-5) var(--s-3);
}
.viz-legend-item { display: flex; align-items: center; gap: 6px; }
.viz-key { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }
.viz-key-1 { background: var(--viz-1); }
.viz-key-2 { background: var(--viz-2); }
.viz-key-3 { background: var(--viz-3); }
.viz-key-muted { background: var(--viz-muted); }

/* Capa de información al pasar el cursor */
.viz-tip {
    position: absolute; z-index: 5; pointer-events: none;
    padding: 7px 10px; border-radius: var(--r-sm);
    background: var(--n-900); color: #fff; font-size: var(--t-xs);
    box-shadow: var(--e-3); white-space: nowrap; opacity: 0;
    transform: translate(-50%, -112%); transition: opacity var(--fast) var(--ease);
}
:root[data-theme="dark"] .viz-tip { background: #f8fafc; color: #0f172a; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .viz-tip { background: #f8fafc; color: #0f172a; }
}
.viz-tip[data-visible="true"] { opacity: 1; }
.viz-tip b { font-variant-numeric: tabular-nums; }

/* Gemelo en tabla: todo gráfico tiene su versión legible */
.viz-table { margin: 0; }
.viz-table > summary {
    cursor: pointer; padding: var(--s-3) var(--s-5);
    font-size: var(--t-xs); color: var(--ink-3); border-top: 1px solid var(--border);
    list-style: none;
}
.viz-table > summary::-webkit-details-marker { display: none; }
.viz-table > summary::before { content: "▸ "; }
.viz-table[open] > summary::before { content: "▾ "; }
.viz-table > summary:hover { color: var(--ink); }

/* Barras horizontales: una sola serie, un solo color, valor siempre visible */
.viz-hbars { list-style: none; margin: 0; padding: var(--s-2) var(--s-5) var(--s-4); display: flex; flex-direction: column; gap: var(--s-3); }
.viz-hbar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s-3); align-items: center; }
.viz-hbar-label { font-size: var(--t-sm); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viz-hbar-value { font-size: var(--t-sm); font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.viz-hbar-track { grid-column: 1 / -1; height: 8px; border-radius: var(--r-full); background: var(--viz-muted); overflow: hidden; }
.viz-hbar-fill { display: block; height: 100%; border-radius: var(--r-full); background: var(--viz-1); transition: width .5s var(--ease); }

.sparkline { display: block; width: 100%; height: 34px; overflow: visible; }
.sparkline path { fill: none; stroke: var(--viz-1); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline .area { fill: color-mix(in srgb, var(--viz-1) 12%, transparent); stroke: none; }

/* ----------------------------------------------------- 19. Piezas sueltas */
.schedule-day { border: 1px solid var(--border); border-radius: var(--r); padding: var(--s-4); background: var(--surface); }
.schedule-day.has-slots { border-color: var(--primary-soft-line); background: var(--primary-soft); }
.schedule-day h4 { font-size: var(--t-sm); text-transform: capitalize; margin-bottom: var(--s-3); }
.slot-row { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-2); }
.slot-row .input { min-height: 40px; }
.slot-sep { color: var(--ink-4); font-weight: 600; }

.key-value { display: grid; grid-template-columns: auto 1fr; gap: var(--s-2) var(--s-4); font-size: var(--t-sm); }
.key-value dt { color: var(--ink-3); }
.key-value dd { margin: 0; text-align: right; font-weight: 550; }

.code-box {
    display: flex; align-items: center; gap: var(--s-3);
    padding: var(--s-3) var(--s-4); background: var(--n-900); color: #e2e8f0;
    border-radius: var(--r); font-family: var(--font-mono); font-size: var(--t-sm);
    word-break: break-all;
}
.pin-reveal {
    display: inline-flex; align-items: center; gap: var(--s-3);
    padding: var(--s-4) var(--s-6); background: var(--n-900); color: #fff;
    border-radius: var(--r-lg); font-family: var(--font-mono);
    font-size: 2rem; font-weight: 700; letter-spacing: .32em;
    padding-right: calc(var(--s-6) + .32em);
}

.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-2); padding: var(--s-4); }
.pagination .current { font-size: var(--t-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; }

.install-steps { display: flex; gap: var(--s-2); margin-bottom: var(--s-6); flex-wrap: wrap; }
.install-step { flex: 1 1 auto; height: 4px; min-width: 22px; border-radius: var(--r-full); background: var(--border); }
.install-step.done { background: var(--ok-solid); }
.install-step.current { background: var(--primary); }

.check-list { list-style: none; margin: 0; padding: 0; }
.check-list li {
    display: flex; align-items: flex-start; gap: var(--s-3);
    padding: var(--s-3) 0; border-bottom: 1px solid var(--border); font-size: var(--t-sm);
}
.check-list li:last-child { border-bottom: 0; }
.check-list .status { margin-left: auto; font-weight: 650; white-space: nowrap; }
.check-ok   { color: var(--ok-ink); }
.check-warn { color: var(--warn-ink); }
.check-fail { color: var(--bad-ink); }

/* Código QR generado en el servidor */
.qr { display: block; width: 200px; height: 200px; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: var(--r); }

/* --------------------------------------------------------- 20. Impresión */
@media print {
    .topbar, .sidebar, .tabbar, .cookie-bar, .toast-region,
    .no-print, .filters, .pagination, .theme-toggle { display: none !important; }
    :root { --surface: #fff; --bg: #fff; --ink: #000; --ink-2: #333; --ink-3: #555; --border: #d0d5dd; }
    body { background: #fff; font-size: 11pt; }
    .page { max-width: none; padding: 0; }
    .card { border-color: #d0d5dd; box-shadow: none; break-inside: avoid; }
    .table th { position: static; background: #f1f5f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .viz svg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .viz-table { display: block; }
    .viz-table > summary { display: none; }
    a { color: inherit; text-decoration: none; }
}

/* ---------------------------------------------------- 21. Preferencias */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important; animation-iteration-count: 1 !important;
        transition-duration: .01ms !important; scroll-behavior: auto !important;
    }
}

@media (prefers-contrast: more) {
    :root {
        --border: var(--n-400); --border-strong: var(--n-500);
        --ink-3: var(--n-700); --ink-4: var(--n-600);
    }
    .btn, .input, .select, .textarea, .card { border-width: 1.5px; }
}

/* Colores forzados del sistema: la textura y el texto sustituyen al color */
@media (forced-colors: active) {
    .viz-bar, .viz-bar-2, .viz-bar-3 { forced-color-adjust: none; fill: CanvasText; }
    .dot, .avatar-status { forced-color-adjust: none; border: 1px solid CanvasText; }
    .badge { border: 1px solid CanvasText; }
}
