/* FarmaTurnos · sistema visual */
:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --surface-2: #f9f9f7;
  --surface-3: #f0efea;
  --chart: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #6f6d67;
  --line: #e4e3dc;
  --line-2: #d3d2ca;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --accent: #0d7a6f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2ef;
  --accent-strong: #095e55;
  --good: #0ca30c; --good-ink: #006300; --good-soft: #e6f5e6;
  --warn: #fab219; --warn-ink: #7a5200; --warn-soft: #fff4dc;
  --serious: #ec835a; --serious-ink: #9a3d17; --serious-soft: #fdebe3;
  --crit: #d03b3b; --crit-ink: #a52828; --crit-soft: #fbe7e7;
  --info-soft: #e7f0fb; --info-ink: #1c5cab;
  --closed: repeating-linear-gradient(135deg, #efeee9 0 4px, #e6e5df 4px 8px);
  --shadow-1: 0 1px 2px rgba(11, 11, 11, .06), 0 1px 1px rgba(11, 11, 11, .04);
  --shadow-2: 0 8px 28px rgba(11, 11, 11, .12), 0 2px 6px rgba(11, 11, 11, .06);
  --ring: 0 0 0 3px rgba(13, 122, 111, .28);
  --radius: 10px;
  --radius-sm: 7px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs: 14px;
  --side-w: 248px;
  --top-h: 56px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28; --chart: #1a1a19;
    --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #9a988f; --line: #2e2e2b; --line-2: #3b3b37; --grid: #2c2c2a; --axis: #383835;
    --accent: #2bb3a3; --accent-ink: #06201d; --accent-soft: #12302c; --accent-strong: #5fd0c2;
    --good-ink: #3fd03f; --good-soft: #142a14; --warn-ink: #fcc95a; --warn-soft: #2f2610; --serious-ink: #f3a07f; --serious-soft: #33201a;
    --crit-ink: #f08080; --crit-soft: #351b1b; --info-soft: #14243a; --info-ink: #86b6ef;
    --closed: repeating-linear-gradient(135deg, #232321 0 4px, #1d1d1b 4px 8px);
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5); --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f0e; --surface: #1a1a19; --surface-2: #20201f; --surface-3: #2a2a28; --chart: #1a1a19;
  --ink: #f0efec; --ink-2: #c3c2b7; --ink-3: #9a988f; --line: #2e2e2b; --line-2: #3b3b37; --grid: #2c2c2a; --axis: #383835;
  --accent: #2bb3a3; --accent-ink: #06201d; --accent-soft: #12302c; --accent-strong: #5fd0c2;
  --good-ink: #3fd03f; --good-soft: #142a14; --warn-ink: #fcc95a; --warn-soft: #2f2610; --serious-ink: #f3a07f; --serious-soft: #33201a;
  --crit-ink: #f08080; --crit-soft: #351b1b; --info-soft: #14243a; --info-ink: #86b6ef;
  --closed: repeating-linear-gradient(135deg, #232321 0 4px, #1d1d1b 4px 8px);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5); --shadow-2: 0 10px 30px rgba(0, 0, 0, .55);
}
:root[data-density="compact"] { --fs: 13px; }
:root[data-scale="large"] { --fs: 16px; }

* { box-sizing: border-box; }
/* El atributo «hidden» oculta siempre, también en elementos con display propio (p. ej. una .opt-row, que es flex) */
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: var(--fs); line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 6px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.55em; }
h2 { font-size: 1.15em; }
h3 { font-size: 1em; }
p { margin: 0 0 .6em; }
.muted { color: var(--ink-2); }
.subtle { color: var(--ink-3); font-size: .9em; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }
.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.brand-name { font-weight: 700; font-size: 1.05em; letter-spacing: -.02em; }
.brand-sub { font-size: .78em; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-group { margin-top: 10px; }
.nav-title { font-size: .72em; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); padding: 6px 10px; font-weight: 600; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.nav a .ico { width: 18px; height: 18px; flex: none; }
.nav a .count { margin-left: auto; font-size: .78em; background: var(--crit-soft); color: var(--crit-ink); border-radius: 10px; padding: 0 7px; font-weight: 600; }
.side-foot { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid var(--line); font-size: .82em; color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h); display: flex; align-items: center; gap: 10px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top .crumbs { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .crumbs .muted { font-weight: 500; }
.top .spacer { flex: 1; }
.content { padding: 20px; max-width: 1560px; width: 100%; margin: 0 auto; }
.mobile-only { display: none !important; }

.bottom-nav { display: none; }

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; z-index: 60; left: 0; top: 0; width: min(300px, 86vw); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow-2);
  }
  .side.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 55; }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .top { padding: 0 12px; }
  #yearSel { flex: none; }
  .content { padding: 14px 16px 92px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .7em; color: var(--ink-3); padding: 4px 0; font-weight: 600; }
  .bottom-nav a.active { color: var(--accent); }
  .bottom-nav a:hover { text-decoration: none; }
  .bottom-nav .ico { width: 22px; height: 22px; }
}

/* ---------- Componentes ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 45%, var(--line-2)); }
.btn.danger:hover { background: var(--crit-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: .9em; }
.btn.icon { width: 36px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 0; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin-right: auto; }
.card-b { padding: 14px 16px 16px; }
.card-b.tight { padding: 8px 10px; }
.card + .card { margin-top: 16px; }
.section-title { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title .grow { flex: 1; min-width: 200px; }
.section-title p { margin: 4px 0 0; color: var(--ink-2); }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
/* minmax(0, 1fr): una columna «1fr» crece hasta el ancho mínimo de su contenido (un <pre>, una fila de botones) y
   desborda la pantalla en móvil */
.grid > * { min-width: 0; }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1); position: relative; }
.kpi.link { cursor: pointer; }
.kpi.link:hover { border-color: var(--accent); }
.kpi .k-label { font-size: .82em; color: var(--ink-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 1.75em; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.kpi .k-value small { font-size: .5em; font-weight: 600; color: var(--ink-2); margin-left: 2px; }
.kpi .k-sub { font-size: .8em; color: var(--ink-3); margin-top: 4px; }
.kpi .meter { height: 6px; border-radius: 4px; background: var(--surface-3); margin-top: 10px; overflow: hidden; }
.kpi .meter > i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: .78em; font-weight: 650;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap; border: 1px solid transparent;
}
.badge .ico { width: 13px; height: 13px; }
.badge.good { background: var(--good-soft); color: var(--good-ink); }
.badge.warn { background: var(--warn-soft); color: var(--warn-ink); }
.badge.serious { background: var(--serious-soft); color: var(--serious-ink); }
.badge.crit { background: var(--crit-soft); color: var(--crit-ink); }
.badge.info { background: var(--info-soft); color: var(--info-ink); }
.badge.accent { background: var(--accent-soft); color: var(--accent-strong); }
.badge.outline { background: transparent; border-color: var(--line-2); }
.badge.wrap { white-space: normal; height: auto; min-height: 22px; padding: 2px 8px; line-height: 1.3; }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px; border-radius: 15px; border: 1px solid var(--line-2);
  background: var(--surface); cursor: pointer; font-weight: 550; font-size: .9em; user-select: none;
}
.chip:hover { background: var(--surface-3); }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
/* Casilla de un chip: invisible pero enfocable con el teclado (con «hidden» no recibe el foco) */
.chip { position: relative; }
.chip > .chip-in { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.chip:has(> .chip-in:focus-visible) { box-shadow: var(--ring); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .72em; font-weight: 700; color: #fff; flex: none;
}
.avatar.lg { width: 44px; height: 44px; font-size: .9em; }
.emp-tag { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }

.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.seg.tabs { display: flex; width: max-content; }
.seg button { border: 0; background: transparent; height: 30px; padding: 0 12px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--ink-2); font-size: .9em; white-space: nowrap; flex: none; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .lbl { font-size: .82em; font-weight: 650; color: var(--ink-2); }
.field .hint { font-size: .78em; color: var(--ink-3); }
.input, select.input, textarea.input {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--surface); width: 100%; min-width: 0;
}
textarea.input { height: auto; padding: 8px 10px; min-height: 80px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }
.input.sm { height: 30px; font-size: .9em; padding: 0 8px; }
.input[aria-invalid="true"] { border-color: var(--crit); box-shadow: 0 0 0 3px color-mix(in srgb, var(--crit) 22%, transparent); }
.err-txt { color: var(--crit-ink); font-weight: 600; }
.plain-list { margin: 4px 0 0; padding-left: 18px; }
.plain-list li + li { margin-top: 2px; }
.input[type="color"] { padding: 2px; width: 46px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.form-grid .span2 { grid-column: span 2; }
@media (max-width: 520px) { .form-grid .span2 { grid-column: auto; } }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; padding: 4px 0; }
.check input { width: 17px; height: 17px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.check b { font-weight: 600; display: block; }
.check span.subtle { display: block; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch i { position: absolute; inset: 0; background: var(--line-2); border-radius: 11px; transition: .15s; cursor: pointer; }
.switch i::after { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { box-shadow: var(--ring); }
.opt-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.opt-row:last-child { border-bottom: 0; }
.opt-row .grow { flex: 1; min-width: 0; }
.opt-row b { display: block; font-weight: 600; }
.opt-row:has(> .seg) { flex-wrap: wrap; }
.range { width: 100%; accent-color: var(--accent); }

/* Tablas */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.t { width: 100%; border-collapse: collapse; font-size: .92em; }
table.t th { text-align: left; font-size: .8em; color: var(--ink-2); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line-2); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:hover td { background: var(--surface-2); }
table.t td.r, table.t th.r { text-align: right; font-variant-numeric: tabular-nums; }
table.t tr.clickable { cursor: pointer; }
/* Festivos y cierres: en el móvil, el tipo, el horario y la verificación van dentro de las columnas que se ven */
.days-t .sm { display: none; }
@media (max-width: 640px) { .days-t .lg { display: none; } .days-t .sm { display: block; } }
/* Huecos del generador: tabla en pantallas anchas; en el móvil, una ficha por hueco con los motivos en lista */
.gap-list { display: none; }
@media (max-width: 640px) {
  .gaps-table { display: none; }
  .gap-list { display: block; max-height: 560px; overflow: auto; }
  .gap-item { padding: 10px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
  .gap-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .gap-h { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
  .gap-item ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: .9em; }
  .gap-item li { margin: 2px 0; }
}

/* Estado / alertas */
.alert { display: flex; gap: 10px; padding: 11px 14px; border-radius: 9px; background: var(--info-soft); color: var(--ink); border: 1px solid color-mix(in srgb, var(--info-ink) 25%, transparent); align-items: flex-start; }
.alert .ico { width: 18px; height: 18px; flex: none; margin-top: 1px; color: var(--info-ink); }
.alert.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.alert.warn .ico { color: var(--warn-ink); }
.alert.crit { background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.alert.crit .ico { color: var(--crit-ink); }
.alert.good { background: var(--good-soft); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.alert.good .ico { color: var(--good-ink); }
.empty { text-align: center; padding: 34px 16px; color: var(--ink-2); }
.empty .ico { width: 34px; height: 34px; color: var(--ink-3); margin-bottom: 8px; }

.issue { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: flex-start; cursor: pointer; }
.issue:hover { background: var(--surface-2); }
.issue:last-child { border-bottom: 0; }
.issue .sev { width: 4px; align-self: stretch; border-radius: 2px; flex: none; }
.issue .body { flex: 1; min-width: 0; }
.issue .t { font-weight: 600; }
.issue .d { color: var(--ink-2); font-size: .9em; }
.sev-CRITICO { background: var(--crit); } .sev-COBERTURA { background: var(--serious); } .sev-LABORAL { background: var(--warn); }
.sev-DATOS { background: var(--info-ink); } .sev-CALIDAD { background: var(--axis); }

/* Estado de servicio */
.status-hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.status-pill { display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px; font-weight: 750; font-size: 1.05em; letter-spacing: .01em; }
.status-pill .pulse { width: 10px; height: 10px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 0 currentColor; animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
.status-pill.open { background: var(--good-soft); color: var(--good-ink); }
.status-pill.guard { background: var(--info-soft); color: var(--info-ink); }
.status-pill.closed { background: var(--surface-3); color: var(--ink-2); }
.status-pill.closed .pulse { animation: none; }

/* ---------- Línea de tiempo (gantt) ---------- */
.tl { position: relative; }
.tl-axis { display: grid; position: relative; height: 22px; font-size: .74em; color: var(--ink-3); margin-left: var(--lane-label, 120px); }
.tl-axis span { position: absolute; transform: translateX(-50%); top: 3px; font-variant-numeric: tabular-nums; }
.tl-row { display: flex; align-items: center; min-height: 34px; border-top: 1px solid var(--line); }
.tl-label { width: var(--lane-label, 120px); flex: none; padding-right: 10px; font-size: .88em; font-weight: 600; display: flex; align-items: center; gap: 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tl-track { position: relative; flex: 1; height: 34px; cursor: copy; }
.tl-bg { position: absolute; top: 4px; bottom: 4px; border-radius: 4px; }
.tl-bg.open { background: var(--surface-3); }
.tl-bg.guard { background: color-mix(in srgb, var(--info-ink) 12%, transparent); }
.tl-bg.rec { background: color-mix(in srgb, var(--warn) 18%, transparent); }
.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--grid); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--crit); z-index: 3; }
.bar {
  position: absolute; top: 6px; bottom: 6px; border-radius: 5px; color: #fff; font-size: .74em; font-weight: 650; padding: 0 6px;
  display: flex; align-items: center; overflow: hidden; white-space: nowrap; cursor: pointer; z-index: 2; box-shadow: 0 0 0 2px var(--surface);
}
.bar:hover { filter: brightness(1.08); }
.bar.plan { opacity: .5; }
.bar.actual { top: 13px; bottom: 3px; }
.bar.open-in { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.28) 0 5px, transparent 5px 10px); }
.bar.off-shift { outline: 2px dashed var(--warn); }
.bar.draft { background-image: linear-gradient(transparent, transparent); }
.bar.night::before { content: "☾"; margin-right: 4px; }
.cov-strip { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 1px; margin-left: var(--lane-label, 120px); }
.cov-strip i { flex: 1; }
.cov-ok { background: var(--good); }
.cov-def { background: var(--serious); }
.cov-zero { background: var(--crit); }
.cov-none { background: var(--surface-3); }

/* ---------- Calendario anual ---------- */
.year-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); gap: 14px; }
.mini-month { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 10px 12px; box-shadow: var(--shadow-1); }
.mini-month .mm-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.mini-month .mm-h b { font-size: .95em; }
.mm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.mm-grid .wd { font-size: .66em; color: var(--ink-3); text-align: center; font-weight: 650; padding-bottom: 2px; }
.dcell {
  aspect-ratio: 1; border-radius: 6px; display: grid; place-items: center; font-size: .76em; font-weight: 600; cursor: pointer; position: relative;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid transparent; font-variant-numeric: tabular-nums;
}
.dcell:hover { border-color: var(--ink-3); }
.dcell.closed { background: var(--closed); color: var(--ink-3); }
.dcell.ok { background: color-mix(in srgb, var(--good) 22%, var(--surface)); color: var(--ink); }
.dcell.def { background: color-mix(in srgb, var(--serious) 40%, var(--surface)); color: var(--ink); }
.dcell.zero { background: var(--crit); color: #fff; }
.dcell.today { box-shadow: inset 0 0 0 2px var(--ink); }
.dcell.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.dcell .g { position: absolute; top: 1px; right: 2px; font-size: .78em; line-height: 1; color: var(--info-ink); }
.dcell .h { position: absolute; bottom: 1px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--crit-ink); }
.dcell .a { position: absolute; bottom: 1px; right: 2px; width: 5px; height: 5px; border-radius: 50%; background: var(--warn-ink); }
.dcell.emp { color: #fff; }
.dcell.pending { outline: 2px dashed var(--warn); outline-offset: -2px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82em; color: var(--ink-2); align-items: center; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Matriz mensual ---------- */
.matrix-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.matrix { border-collapse: separate; border-spacing: 0; font-size: .8em; min-width: 100%; }
table.matrix th, table.matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 0; text-align: center; }
table.matrix thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); font-weight: 650; padding: 5px 2px; min-width: 50px; }
table.matrix thead th.we { background: var(--surface-2); }
table.matrix th.rowh { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 6px 10px; min-width: 150px; font-weight: 600; }
table.matrix thead th.rowh { z-index: 4; }
table.matrix tfoot td, table.matrix tfoot th { position: sticky; bottom: 0; background: var(--surface-2); z-index: 2; font-weight: 600; padding: 4px 2px; }
table.matrix tfoot th.rowh { z-index: 4; background: var(--surface-2); }
table.matrix td.cell { height: 46px; min-width: 50px; cursor: pointer; vertical-align: middle; }
table.matrix td.cell:hover { background: var(--surface-3); }
table.matrix td.closedc { background: var(--closed); }
.mcell { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; line-height: 1.1; }
.mcell .ty { display: inline-grid; place-items: center; min-width: 22px; height: 18px; border-radius: 4px; color: #fff; font-weight: 750; font-size: .95em; padding: 0 3px; }
.mcell .hr { font-size: .82em; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mcell .ab { font-size: .8em; font-weight: 700; color: var(--warn-ink); }
.dayh { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.dayh .n { font-size: 1.15em; font-weight: 700; }
.dayh .w { font-size: .82em; color: var(--ink-3); }
.dayh .f { font-size: .85em; }

/* Agenda (móvil) */
.agenda-day { border-bottom: 1px solid var(--line); padding: 10px 0; }
.agenda-day .ad-h { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.agenda-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); margin-top: 4px; cursor: pointer; }
.agenda-item .bar-mini { width: 4px; align-self: stretch; border-radius: 2px; }

/* ---------- Drawer / Modal / Toast / Tooltip ---------- */
.overlay { position: fixed; inset: 0; background: rgba(10, 10, 10, .42); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .12s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 14px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-2); animation: pop .14s ease-out; }
.modal.wide { width: min(980px, 100%); }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-h h2 { flex: 1; }
.modal-b { padding: 16px 18px; overflow: auto; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer-ov { position: fixed; inset: 0; z-index: 70; background: rgba(10, 10, 10, .3); animation: fade .12s; }
.drawer { position: fixed; z-index: 71; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--surface); box-shadow: var(--shadow-2); display: flex; flex-direction: column; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
@media (max-width: 640px) {
  .overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }
}
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
@media (max-width: 960px) { .toasts { bottom: 84px; } }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-2); display: flex; gap: 12px; align-items: center; font-weight: 550; max-width: min(560px, 92vw); animation: pop .15s; }
.toast button { background: transparent; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; filter: brightness(1.4); }
.toast.err { background: var(--crit); color: #fff; }
.tip {
  position: fixed; z-index: 120; pointer-events: none; background: var(--surface); color: var(--ink); border: 1px solid var(--line-2); border-radius: 8px;
  box-shadow: var(--shadow-2); padding: 8px 10px; font-size: .84em; max-width: 300px; line-height: 1.4;
}
.tip b { font-weight: 700; }

/* ---------- Gráficos ---------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .gl { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .lbl { fill: var(--ink-2); font-size: 11.5px; font-weight: 600; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .82em; color: var(--ink-2); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 14px; height: 4px; border-radius: 2px; display: inline-block; }
.chart-legend i.sq { width: 11px; height: 11px; border-radius: 3px; }
.heat { display: grid; gap: 2px; font-size: .72em; }
.heat .hc { height: 18px; border-radius: 3px; }
.heat .hl { color: var(--ink-3); display: flex; align-items: center; font-weight: 600; }

/* ---------- Pasos (asistente) ---------- */
.steps { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.step { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 9px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; white-space: nowrap; font-weight: 600; color: var(--ink-2); }
.step .n { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); display: grid; place-items: center; font-size: .8em; }
.step.on { border-color: var(--accent); color: var(--accent-strong); background: var(--accent-soft); }
.step.on .n { background: var(--accent); color: var(--accent-ink); }
.step.done .n { background: var(--good); color: #fff; }
.progress { height: 10px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.check-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check-item:last-child { border-bottom: 0; }
.check-item .st { flex: none; margin-top: 1px; }

/* Empleados */
.emp-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.emp-card .top-row { display: flex; gap: 12px; align-items: center; }
.emp-card .name { font-weight: 700; font-size: 1.05em; }
.hbar { height: 8px; background: var(--surface-3); border-radius: 4px; position: relative; overflow: hidden; }
.hbar > i { position: absolute; top: 0; bottom: 0; left: 0; border-radius: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .9em; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; font-weight: 600; }

.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.login { width: min(400px, 100%); padding: 28px; }
.demo-banner { background: var(--warn-soft); color: var(--ink); border-bottom: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); padding: 6px 20px; font-size: .84em; display: flex; gap: 8px; align-items: center; }
.kbd { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8em; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px; color: var(--ink-2); background: var(--surface-2); }
.palette-list { max-height: 50vh; overflow: auto; }
.palette-list a { display: flex; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--ink); align-items: center; }
.palette-list a.sel, .palette-list a:hover { background: var(--accent-soft); text-decoration: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .88em; background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
pre.code { background: var(--surface-3); padding: 12px; border-radius: 8px; overflow: auto; font-size: .82em; max-width: 100%; }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 14px 0; }
.mt { margin-top: 16px; } .mt-s { margin-top: 8px; } .mb { margin-bottom: 16px; } .mb-s { margin-bottom: 6px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }

@media print {
  .side, .top, .bottom-nav, .no-print, .demo-banner { display: none !important; }
  .app { display: block; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  .matrix-wrap { max-height: none; overflow: visible; }
  body { background: #fff; }
}

/* Ajustes */
.grid > .card + .card, .grid > * + .card { margin-top: 0; }
svg.ico { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.card-h a { display: inline-flex; align-items: center; gap: 4px; }
