/* WMS-DBS · sistema de diseño
   Marca: granate DPO + negro de tablero + oro (solo acento de marca).
   Semáforo SIC: verde / amarillo / rojo. Todo en OKLCH. */
:root {
  --brand: oklch(0.40 0.13 22);
  --brand-strong: oklch(0.33 0.11 22);
  --brand-soft: oklch(0.95 0.02 22);
  --brand-ink: oklch(0.99 0 0);
  --gold: oklch(0.80 0.13 85);
  --head: oklch(0.34 0.11 22);

  --bg: oklch(0.975 0.003 22);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.962 0.004 22);
  --surface-3: oklch(0.93 0.006 22);
  --line: oklch(0.90 0.006 22);
  --line-strong: oklch(0.82 0.008 22);
  --ink: oklch(0.22 0.012 22);
  --ink-2: oklch(0.40 0.012 22);
  --ink-3: oklch(0.50 0.010 22);

  --nav-bg: oklch(0.20 0.012 22);
  --nav-ink: oklch(0.86 0.008 22);
  --nav-ink-dim: oklch(0.68 0.010 22);
  --nav-hover: oklch(0.26 0.016 22);
  --nav-active: oklch(0.33 0.07 22);

  --ok: oklch(0.58 0.14 150);
  --ok-soft: oklch(0.95 0.04 150);
  --ok-band: oklch(0.72 0.15 148);
  --warn: oklch(0.62 0.13 75);
  --warn-soft: oklch(0.96 0.05 95);
  --warn-band: oklch(0.90 0.16 100);
  --err: oklch(0.55 0.19 27);
  --err-soft: oklch(0.95 0.03 27);
  --err-band: oklch(0.62 0.20 27);
  --info: oklch(0.55 0.12 250);
  --info-soft: oklch(0.95 0.025 250);

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-1: 0 1px 2px oklch(0.2 0.02 22 / 0.06), 0 1px 1px oklch(0.2 0.02 22 / 0.04);
  --shadow-2: 0 12px 32px oklch(0.2 0.02 22 / 0.14), 0 2px 6px oklch(0.2 0.02 22 / 0.08);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  --z-sticky: 10; --z-nav: 20; --z-backdrop: 30; --z-drawer: 40; --z-toast: 60;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: oklch(0.62 0.15 22);
  --brand-strong: oklch(0.70 0.14 22);
  --brand-soft: oklch(0.30 0.05 22);
  --bg: oklch(0.17 0.008 22);
  --surface: oklch(0.21 0.009 22);
  --surface-2: oklch(0.24 0.010 22);
  --surface-3: oklch(0.29 0.012 22);
  --line: oklch(0.30 0.010 22);
  --line-strong: oklch(0.38 0.012 22);
  --ink: oklch(0.95 0.004 22);
  --ink-2: oklch(0.80 0.008 22);
  --ink-3: oklch(0.70 0.008 22);
  --nav-bg: oklch(0.14 0.008 22);
  --nav-hover: oklch(0.21 0.012 22);
  --nav-active: oklch(0.30 0.07 22);
  --ok-soft: oklch(0.30 0.06 150);
  --warn-soft: oklch(0.32 0.06 90);
  --err-soft: oklch(0.32 0.07 27);
  --info-soft: oklch(0.30 0.05 250);
  --ok: oklch(0.75 0.15 150);
  --warn: oklch(0.82 0.14 90);
  --err: oklch(0.72 0.17 27);
  --info: oklch(0.75 0.11 250);
  --shadow-2: 0 12px 32px oklch(0 0 0 / 0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
.num, td, .tnum { font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.015em; }
h2 { font-size: 1.0625rem; font-weight: 650; letter-spacing: -0.01em; }
h3 { font-size: 0.9375rem; font-weight: 650; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }

/* ------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.shell.collapsed { grid-template-columns: 68px 1fr; }
.nav {
  background: var(--nav-bg); color: var(--nav-ink); position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; overflow-y: auto; z-index: var(--z-nav);
}
.nav-brand { display: flex; align-items: center; gap: 11px; padding: 18px 16px 14px; }
.mark {
  width: 38px; height: 38px; border-radius: 10px; flex: none; display: grid; place-items: center;
  background: var(--brand); color: #fff; font-weight: 800; font-size: 12px; letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1.5px oklch(0.80 0.13 85 / 0.7);
}
.nav-brand b { display: block; font-size: 15px; color: #fff; letter-spacing: 0.01em; }
.nav-brand span { font-size: 11.5px; color: var(--nav-ink-dim); }
.nav-group { padding: 10px 10px 4px; }
.nav-group > p { margin: 0 8px 6px; font-size: 11.5px; font-weight: 600; color: var(--nav-ink-dim); }
.nav a, .nav button.nav-link {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 8px 10px; border-radius: 8px;
  color: var(--nav-ink); text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left;
  transition: background .15s var(--ease), color .15s var(--ease); white-space: nowrap;
}
.nav a:hover, .nav button.nav-link:hover { background: var(--nav-hover); color: #fff; }
.nav a.active { background: var(--nav-active); color: #fff; font-weight: 600; }
.nav a.active svg { color: var(--gold); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.nav-foot { margin-top: auto; padding: 12px; border-top: 1px solid oklch(1 0 0 / 0.08); }
.nav-user { display: flex; align-items: center; gap: 10px; padding: 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--brand); color: #fff; font-weight: 700; font-size: 12px;
}
.nav-user b { display: block; font-size: 12.5px; color: #fff; overflow: hidden; text-overflow: ellipsis; max-width: 150px; white-space: nowrap; }
.nav-user span { font-size: 11.5px; color: var(--nav-ink-dim); }
.nav-credit {
  display: flex; align-items: center; gap: 9px; margin: 10px 4px 2px; padding-top: 12px;
  border-top: 1px solid oklch(1 0 0 / 0.07); color: var(--nav-ink-dim); font-size: 11.5px; letter-spacing: 0.01em;
}
.nav-credit .fr-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.02em; color: var(--gold);
  box-shadow: inset 0 0 0 1px oklch(0.80 0.13 85 / 0.45); background: oklch(0.80 0.13 85 / 0.06);
}
.nav-credit b { font-weight: 650; color: var(--nav-ink); }
.shell.collapsed .nav-credit { justify-content: center; }
.shell.collapsed .nav-credit .fr-text { display: none; }
.shell.collapsed .nav-brand > div, .shell.collapsed .nav-group > p, .shell.collapsed .nav a span,
.shell.collapsed .nav button.nav-link span, .shell.collapsed .nav-user > div, .shell.collapsed .nav .badge { display: none; }
.shell.collapsed .nav a, .shell.collapsed .nav button.nav-link { justify-content: center; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center; gap: 12px;
  padding: 10px 24px; background: color-mix(in oklch, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line);
}
.topbar .title { display: flex; flex-direction: column; min-width: 0; }
.topbar .title small { color: var(--ink-3); font-size: 12px; }
.topbar .spacer { flex: 1; }
.clock { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; white-space: nowrap; }
.content { padding: 20px 24px 40px; max-width: 1560px; width: 100%; }

/* ------------------------------------------------------------- controles */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .1s var(--ease), box-shadow .15s;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.danger { color: var(--err); border-color: color-mix(in oklch, var(--err) 40%, var(--line)); }
.btn.danger:hover { background: var(--err-soft); }
.btn.danger.solid { background: var(--err); color: #fff; border-color: var(--err); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.icon { width: 34px; padding: 0; }
.btn.sm.icon { width: 30px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; }
.btn.busy { pointer-events: none; opacity: .7; }
.btn.busy::after {
  content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field small { color: var(--ink-3); font-size: 12px; }
.input, select.input, textarea.input {
  height: 36px; padding: 0 11px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); min-width: 0; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.5; }
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 18%, transparent); }
.input.sm { height: 30px; font-size: 12.5px; padding: 0 9px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .18s var(--ease); box-shadow: var(--shadow-1); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(14px); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar .spacer { flex: 1; }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 5px 11px; border-radius: 7px; cursor: pointer; font-size: 13px;
  font-weight: 550; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center;
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg button .count { font-size: 11.5px; color: var(--ink-3); }

/* ------------------------------------------------------------- superficies */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.panel-h { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; flex-wrap: wrap; }
.panel-h .spacer { flex: 1; }
.panel-b { padding: 0 16px 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
}
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.st-PENDIENTE { background: var(--surface-3); color: var(--ink-2); }
.st-LIBERADO { background: var(--info-soft); color: var(--info); }
.st-ASIGNADO { background: oklch(0.94 0.04 300); color: oklch(0.48 0.14 300); }
.st-ARMADO { background: oklch(0.94 0.05 200); color: oklch(0.45 0.09 210); }
.st-EN_VERIFICACION { background: var(--warn-soft); color: oklch(0.50 0.11 70); }
.st-VERIFICADO { background: oklch(0.94 0.05 130); color: oklch(0.45 0.12 135); }
.st-EN_CARGUE { background: var(--brand-soft); color: var(--brand); }
.st-FINALIZADO { background: var(--ok-soft); color: var(--ok); }
.st-EN_PAUSA { background: var(--err-soft); color: var(--err); }
:root[data-theme="dark"] [class*="st-"] { filter: brightness(1.05); }
:root[data-theme="dark"] .st-ASIGNADO { background: oklch(0.30 0.06 300); color: oklch(0.82 0.10 300); }
:root[data-theme="dark"] .st-ARMADO { background: oklch(0.30 0.05 210); color: oklch(0.82 0.08 210); }
:root[data-theme="dark"] .st-VERIFICADO { background: oklch(0.30 0.06 135); color: oklch(0.84 0.12 135); }
:root[data-theme="dark"] .st-EN_VERIFICACION { color: var(--warn); }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: oklch(0.50 0.11 70); }
:root[data-theme="dark"] .b-warn { color: var(--warn); }
.b-err { background: var(--err-soft); color: var(--err); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-brand { background: var(--brand-soft); color: var(--brand); }

/* ------------------------------------------------------------- tabla */
.dt-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 0 16px 12px; }
.dt-bar label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.dt-wrap { overflow-x: auto; border-top: 1px solid var(--line); }
table.dt { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.dt th {
  position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--ink-2);
  font-size: 12.5px; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; user-select: none;
}
.dt th.sortable { cursor: pointer; }
.dt th.sortable:hover { color: var(--ink); }
.dt th .arrow { opacity: .35; margin-left: 4px; font-size: 11px; }
.dt th.sorted .arrow { opacity: 1; color: var(--brand); }
.dt tr.filters th { padding: 6px 8px; background: var(--surface); position: static; }
.dt td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.dt tbody tr { transition: background .12s; }
.dt tbody tr:hover { background: color-mix(in oklch, var(--surface-2) 70%, transparent); }
.dt tbody tr.sel { background: var(--brand-soft); }
.dt td.r, .dt th.r { text-align: right; }
.dt td.c, .dt th.c { text-align: center; }
.dt .actions { display: flex; gap: 5px; flex-wrap: nowrap; }
.dt .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px; }
.dt-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); }
.pager { display: inline-flex; gap: 4px; }
.pager button { min-width: 32px; height: 32px; border: 1px solid var(--line); background: var(--surface); border-radius: 7px; cursor: pointer; font-size: 13px; padding: 0 9px; }
.pager button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .45; cursor: default; }
.empty { padding: 40px 16px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); font-size: 15px; margin-bottom: 4px; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }

/* progreso por pasos */
.steps { display: inline-flex; gap: 3px; align-items: center; }
.steps i { width: 14px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.steps i.done { background: var(--ok); }
.steps i.cur { background: var(--brand); }
.steps.paused i.cur { background: var(--err); }
.steps + small { margin-left: 6px; color: var(--ink-3); font-size: 12px; }
.late { color: var(--err); font-weight: 600; }

/* ------------------------------------------------------------- contadores de etapa */
.stage-board { display: grid; grid-template-columns: 2fr 1.2fr 1fr 1fr; gap: 12px; }
.stage { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 14px; box-shadow: var(--shadow-1); }
.stage > h3 { font-size: 12.5px; color: var(--ink-2); font-weight: 650; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.stage > h3 svg { width: 15px; height: 15px; color: var(--brand); }
.stage .cells { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.cell {
  border: 0; background: var(--surface-2); border-radius: 8px; padding: 8px 10px; text-align: left; cursor: pointer;
  transition: background .15s, box-shadow .15s; min-width: 0;
}
.cell:hover { background: var(--surface-3); }
.cell.on { box-shadow: inset 0 0 0 2px var(--brand); background: var(--brand-soft); }
.cell span { display: block; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell b { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.cell.alert b { color: var(--err); }

/* ------------------------------------------------------------- asistente */
.insights { display: flex; flex-direction: column; gap: 8px; }
.insights.insights-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.insight { display: grid; grid-template-columns: 26px 1fr; gap: 10px; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); }
.insight .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; }
.insight .ic svg { width: 15px; height: 15px; }
.insight b { display: block; font-size: 13.5px; }
.insight p { margin: 2px 0 0; font-size: 13px; color: var(--ink-2); }
.insight.ok .ic { background: var(--ok-soft); color: var(--ok); }
.insight.warn .ic { background: var(--warn-soft); color: oklch(0.52 0.12 70); }
.insight.error .ic { background: var(--err-soft); color: var(--err); }
.insight.info .ic { background: var(--info-soft); color: var(--info); }

/* ------------------------------------------------------------- dialog / drawer */
dialog { border: 0; padding: 0; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
dialog::backdrop { background: oklch(0.15 0.02 22 / 0.45); backdrop-filter: blur(2px); }
dialog[open] { animation: pop .2s var(--ease); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.dlg-h { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.dlg-h h2 { flex: 1; }
.dlg-b { padding: 10px 20px 4px; overflow-y: auto; max-height: calc(100vh - 180px); }
.dlg-f { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 20px 18px; }
dialog.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; border-radius: 14px 0 0 14px; width: min(520px, 100vw); }
dialog.drawer[open] { animation: slide .25s var(--ease); display: flex; flex-direction: column; }
dialog.drawer .dlg-b { max-height: none; flex: 1; }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
dialog.wide { width: min(980px, calc(100vw - 32px)); }

.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 6px 0 16px; }
.kv div span { display: block; font-size: 12px; color: var(--ink-3); }
.kv div b { font-weight: 600; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: -6px; width: 1px; background: var(--line-strong); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 1px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
.timeline b { font-size: 13px; }
.timeline small { display: block; color: var(--ink-3); }

/* ------------------------------------------------------------- toast */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); }
.toast {
  background: var(--ink); color: var(--bg); padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow-2);
  font-size: 13.5px; max-width: 380px; display: flex; gap: 10px; align-items: flex-start; animation: pop .2s var(--ease);
}
.toast.err { background: var(--err); color: #fff; }
.toast.ok { background: oklch(0.42 0.10 150); color: #fff; }

/* ------------------------------------------------------------- login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-brand {
  background: var(--nav-bg); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.login-brand::before {
  content: ""; position: absolute; inset: auto -20% -35% auto; width: 620px; height: 620px; border-radius: 50%;
  background: radial-gradient(circle, oklch(0.40 0.13 22 / 0.55), transparent 65%);
}
.login-brand .mark { width: 54px; height: 54px; font-size: 16px; border-radius: 14px; }
.login-brand h1 { font-size: 2.6rem; letter-spacing: -0.03em; margin-top: 28px; }
.login-brand p { color: var(--nav-ink); max-width: 46ch; font-size: 15px; }
.login-brand ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 10px; color: var(--nav-ink); position: relative; }
.login-brand li { display: flex; gap: 10px; align-items: center; }
.login-brand li svg { width: 18px; height: 18px; color: var(--gold); }
.login-form { display: grid; place-items: center; padding: 32px; background: var(--bg); }
.login-form form { width: min(360px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-form .input { height: 44px; font-size: 15px; }
.login-err { color: var(--err); font-size: 13.5px; min-height: 20px; }

/* ------------------------------------------------------------- importar */
.drop {
  border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 34px 20px; text-align: center; cursor: pointer;
  background: var(--surface-2); transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--brand); background: var(--brand-soft); }
.drop svg { width: 34px; height: 34px; color: var(--brand); }
.drop b { display: block; font-size: 15px; margin: 8px 0 2px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 9px; padding: 10px 12px; }
.stat span { font-size: 12px; color: var(--ink-2); }
.stat b { display: block; font-size: 22px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line); font-family: ui-monospace, Menlo, monospace; }
.alert { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 11px 13px; border-radius: 9px; }
.alert svg { width: 18px; height: 18px; margin-top: 1px; }
.alert.warn { background: var(--warn-soft); } .alert.warn svg { color: oklch(0.55 0.12 70); }
.alert.error { background: var(--err-soft); } .alert.error svg { color: var(--err); }
.alert.info { background: var(--info-soft); } .alert.info svg { color: var(--info); }
.alert.ok { background: var(--ok-soft); } .alert.ok svg { color: var(--ok); }

/* ------------------------------------------------------------- dashboard SIC */
.dash { display: grid; gap: 14px; }
.dash-head {
  display: grid; grid-template-columns: auto auto 1fr; gap: 0; background: var(--nav-bg); color: #fff; border-radius: var(--radius);
  overflow: hidden; align-items: stretch;
}
.dash-logo { display: grid; place-items: center; padding: 12px 18px; }
.dash-logo .mark { width: 60px; height: 60px; border-radius: 50%; font-size: 17px; background: oklch(0.16 0.01 22); box-shadow: inset 0 0 0 3px var(--gold); color: #fff; }
.dash-meta { display: grid; grid-template-rows: 1fr 1fr; border-left: 1px solid oklch(1 0 0 / .1); border-right: 1px solid oklch(1 0 0 / .1); }
.dash-meta div { padding: 6px 18px; display: flex; flex-direction: column; justify-content: center; min-width: 120px; }
.dash-meta div + div { border-top: 1px solid oklch(1 0 0 / .1); }
.dash-meta b { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.dash-meta span { font-size: 11.5px; color: var(--nav-ink-dim); font-weight: 600; }
.dash-title { padding: 14px 20px; display: flex; flex-direction: column; justify-content: center; gap: 8px; min-width: 0; }
.dash-title h1 { font-size: clamp(1.15rem, 2.1vw, 1.75rem); font-weight: 800; letter-spacing: -0.01em; }
.dash-title .sub { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 12.5px; color: var(--nav-ink); }
.live { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok-band); box-shadow: 0 0 0 0 oklch(0.72 0.15 148 / .6); animation: pulse 2s infinite; }
.live.off i { background: var(--nav-ink-dim); animation: none; }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px oklch(0.72 0.15 148 / 0); } 100% { box-shadow: 0 0 0 0 oklch(0.72 0.15 148 / 0); } }

.periods { display: grid; gap: 8px; }
.months, .days { display: flex; gap: 4px; flex-wrap: wrap; }
.months button, .days button {
  border: 0; cursor: pointer; border-radius: 6px; font-weight: 600; font-variant-numeric: tabular-nums;
  background: var(--head); color: #fff; transition: background .15s, opacity .15s;
}
:root[data-theme="dark"] .months button, :root[data-theme="dark"] .days button { background: oklch(0.36 0.10 22); }
.months button { padding: 7px 16px; font-size: 13px; }
.days button { width: 34px; height: 30px; font-size: 13px; }
.months button:hover, .days button:hover { background: var(--brand); }
.months button.on, .days button.on { background: var(--nav-bg); box-shadow: inset 0 0 0 2px var(--gold); }
:root[data-theme="dark"] .months button.on, :root[data-theme="dark"] .days button.on { background: oklch(0.1 0 0); }
.days button:disabled { background: var(--surface-3); color: var(--ink-3); cursor: default; }

.dash-main { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); gap: 14px; }
.col-ab, .col-a, .col-b, .col-c { gap: 14px; min-width: 0; }
.card-title {
  background: var(--head); color: #fff; text-align: center; font-weight: 800; font-size: 14px; padding: 8px 12px;
  border-radius: var(--radius) var(--radius) 0 0; letter-spacing: 0.01em;
}
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-1); display: flex; flex-direction: column; }
.chart-card .body { padding: 10px 14px 12px; flex: 1; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg text { font-family: var(--font); }
.sic-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.sic-table th { background: var(--head); color: var(--gold); text-align: left; padding: 8px 10px; font-size: 12.5px; font-weight: 800; }
.sic-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.sic-table tr:nth-child(even) td { background: var(--surface-2); }
.sic-table td.r, .sic-table th.r { text-align: right; }
.sic-table tfoot td { font-weight: 700; border-top: 2px solid var(--line-strong); background: var(--surface) !important; }
.sem { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.sem.verde { background: var(--ok-band); } .sem.amarillo { background: var(--warn-band); } .sem.rojo { background: var(--err-band); } .sem.gris { background: var(--line-strong); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px; display: flex; align-items: center; gap: 12px; }
.kpi .ring { width: 44px; height: 44px; flex: none; }
.kpi > div { min-width: 0; }
.kpi span { font-size: 12px; color: var(--ink-2); font-weight: 600; display: block; }
.kpi b { white-space: nowrap; font-size: 24px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--ink-3); font-size: 12px; }

.cortes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cortes button { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 99px; padding: 4px 11px; font-size: 12.5px; font-weight: 600; cursor: pointer; font-variant-numeric: tabular-nums; }
.cortes button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.cortes button:disabled { opacity: .4; cursor: default; }

.acciones { display: grid; grid-template-columns: 170px 1fr; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.acciones .band { display: contents; }
.acciones .lbl { display: grid; place-items: center; text-align: center; font-weight: 800; font-size: 16px; padding: 14px; line-height: 1.25; }
.acciones .prev .lbl { background: var(--warn-band); color: oklch(0.25 0.05 90); }
.acciones .corr .lbl { background: oklch(0.66 0.18 40); color: #fff; }
.acciones ol { margin: 0; padding: 14px 18px 14px 36px; font-size: 14.5px; display: grid; gap: 6px; align-content: center; }
.acciones .band + .band ol, .acciones .corr ol { border-top: 1px solid var(--line); }
.acciones-head { grid-column: 1 / -1; background: var(--nav-bg); color: #fff; text-align: center; font-weight: 800; padding: 8px; font-size: 14px; }

.qr-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qr { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; text-align: center; }
.qr h3 { background: var(--nav-bg); color: #fff; padding: 7px; font-size: 14px; font-weight: 800; }
.qr .code { padding: 10px; display: grid; place-items: center; min-height: 150px; }
.qr .code svg { width: 100%; max-width: 150px; height: auto; background: #fff; padding: 6px; border-radius: 6px; }
.qr a { font-size: 12px; display: block; padding: 0 8px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bars-h { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr 56px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .track { height: 12px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.bar-row .track i { display: block; height: 100%; border-radius: 6px; background: var(--brand); transition: width .5s var(--ease); }
.bar-row b { text-align: right; font-variant-numeric: tabular-nums; }
.dash-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pipeline { display: flex; height: 26px; border-radius: 7px; overflow: hidden; background: var(--surface-3); }
.pipeline div { display: grid; place-items: center; font-size: 11.5px; font-weight: 700; min-width: 0; overflow: hidden; transition: flex-grow .5s var(--ease); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.rank li b { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- modo TV
   .tv: pantalla sin menú ni controles. .tv-wide (horizontal ≥ 900 px): diseño a
   1920 px lógicos en 3 columnas; dashboard.js aplica zoom para que quepa completo. */
.tv .shell, .tv .shell.collapsed { grid-template-columns: 1fr; }
.tv .nav, .tv .topbar { display: none; }
.tv .content { max-width: none; padding: 14px; }
.tv .periods, .tv .dash .toolbar, .tv [data-xls], .tv [data-edit] { display: none; }
.tv-wide .content { padding: 12px 14px; }
.tv-wide .dash { gap: 10px; }
.tv-wide .dash-head { grid-template-columns: auto auto 1fr; }
.tv-wide .dash-meta { display: grid; }
.tv-wide .dash-logo { padding: 8px 16px; }
.tv-wide .dash-title { padding: 10px 18px; gap: 6px; }
.tv-wide .dash-title h1 { font-size: 1.7rem; }
.tv-wide .dash-title .sub { font-size: 14px; }
.tv-wide .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.tv-wide .kpi b { font-size: 30px; }
.tv-wide .kpi span, .tv-wide .kpi small { font-size: 13.5px; }
.tv-wide .dash-main { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.1fr) minmax(0, 0.95fr); gap: 12px; align-items: start; }
.tv-wide .col-ab { display: contents; }
.tv-wide .col-a, .tv-wide .col-b, .tv-wide .col-c { gap: 12px; }
.tv-wide .dash-pair { grid-template-columns: 1fr 1fr; }
.tv-wide .acciones { grid-template-columns: 150px 1fr; }
.tv-wide .acciones ol { font-size: 15px; }
.tv-wide .qr .code { min-height: 0; }
.tv-wide .qr .code svg { width: 120px; height: 120px; }
.tv-wide .insight b { font-size: 14px; }
.tv-wide .insight p { font-size: 13.5px; }
.tv-wide .bar-row { grid-template-columns: 130px 1fr 54px; }

/* ------------------------------------------------------------- impresión */
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; color: #000; font-size: 12px; }
  #print-root table { width: 100%; border-collapse: collapse; }
  #print-root th, #print-root td { border: 1px solid #999; padding: 4px 6px; text-align: left; }
  #print-root th { background: #6e1a22 !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #print-root h1 { font-size: 18px; margin-bottom: 4px; }
  @page { margin: 12mm; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 1180px) {
  .dash-main { grid-template-columns: 1fr; }
  .stage-board { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell, .shell.collapsed { grid-template-columns: 1fr; }
  .nav { position: fixed; inset: 0 auto 0 0; width: 264px; transform: translateX(-100%); transition: transform .25s var(--ease); z-index: var(--z-drawer); }
  .shell.nav-open .nav { transform: none; box-shadow: var(--shadow-2); }
  .shell.collapsed .nav-brand > div, .shell.collapsed .nav-group > p, .shell.collapsed .nav a span, .shell.collapsed .nav-user > div { display: revert; }
  .content { padding: 14px 14px 32px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .title h1 { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .title small, .clock { display: none; }
  .topbar [data-fecha] { width: 132px !important; }
  .topbar .title { flex: 1; }
  .topbar .spacer { display: none; }
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px; }
  .login-brand h1 { font-size: 1.9rem; margin-top: 16px; }
  .login-brand ul { display: none; }
  .dash-head { grid-template-columns: auto 1fr; }
  .dash-meta { display: none; }
  .acciones { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 110px 1fr 44px; }
  .dash-pair { grid-template-columns: 1fr; }
  /* tabla en tarjetas */
  table.dt.cards thead { display: none; }
  table.dt.cards, table.dt.cards tbody, table.dt.cards tr, table.dt.cards td { display: block; width: 100%; }
  table.dt.cards tr { border-bottom: 1px solid var(--line); padding: 8px 4px; }
  table.dt.cards td { border: 0; padding: 4px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  table.dt.cards td::before { content: attr(data-label); color: var(--ink-3); font-size: 12px; text-align: left; font-weight: 600; }
  table.dt.cards td.cell-actions { justify-content: flex-start; }
  table.dt.cards td.cell-actions::before { display: none; }
}
@media (max-width: 560px) {
  .stage-board { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stage-board .stage:first-child { grid-column: 1 / -1; }
  .stage { padding: 10px; }
  .cell { padding: 6px 8px; }
  .cell b { font-size: 20px; }
  .days button { width: 30px; }
  .sic-table { font-size: 13px; }
  .sic-table th, .sic-table td { padding: 7px 6px; }
  .sic-table td.r, .sic-table td:first-child { white-space: nowrap; }
  .acciones ol { font-size: 13.5px; padding: 12px 14px 12px 30px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Dashboard: vista informativa de viajes distintos de V1 (no cuentan en la medición) */
.aviso-otros { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 10px; background: var(--warn-band); color: oklch(0.25 0.05 90); border: 1px solid var(--warn); font-size: 13.5px; }
.aviso-otros svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.vista-otros .kpis, .vista-otros .chart-card { outline: 2px dashed var(--warn); outline-offset: 2px; }

/* Modo TV: firma FR-Solutions centrada al pie, con el mismo estilo del menú lateral */
.dash-credit { display: none; }
.tv .dash-credit {
  display: inline-flex; justify-self: center; align-items: center; gap: 9px; margin-top: 2px;
  padding: 6px 14px 6px 8px; border-radius: 99px; background: var(--nav-bg); color: var(--nav-ink-dim);
  font-size: 12.5px; letter-spacing: 0.01em; box-shadow: var(--shadow-1);
}
.tv .dash-credit b { font-weight: 650; color: var(--nav-ink); }
.dash-credit .fr-mark {
  width: 22px; height: 22px; border-radius: 6px; flex: none; display: grid; place-items: center;
  font-size: 9.5px; font-weight: 800; letter-spacing: 0.02em; color: var(--gold);
  box-shadow: inset 0 0 0 1px oklch(0.80 0.13 85 / 0.45); background: oklch(0.80 0.13 85 / 0.06);
}
