:root {
  --bg: #f1f4f9;
  --panel: #ffffff;
  --ink: #142033;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #1d4ed8;
  --brand-ink: #ffffff;
  --brand-soft: #e0e9ff;
  --side: #0b1424;
  --side-ink: #b6c2d6;
  --side-active: #16233b;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --run: #1d4ed8;
  --run-soft: #dbeafe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --f-ont: #2563eb;
  --f-stb: #7c3aed;
  --f-extender: #0d9488;
  --f-emta: #ea580c;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; }

/* Shell */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--side); color: var(--side-ink); padding: 18px 12px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 18px; color: #fff; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #2563eb, #22d3ee);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.brand b { display: block; font-size: 15px; letter-spacing: .2px; }
.brand span { display: block; font-size: 11.5px; color: var(--side-ink); }
.nav-group { margin-top: 14px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: .09em; color: #6d7d97; padding: 6px 10px; }
.nav a {
  display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px;
  color: var(--side-ink); font-weight: 500;
}
.nav a:hover { background: #111d31; text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #3b82f6; }
.nav svg, .btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; gap: 14px;
}
.topbar h1 { font-size: 18px; }
.burger { display: none; background: none; border: 0; padding: 4px; cursor: pointer; color: var(--ink); }
.burger svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.user-chip b { display: block; font-size: 13px; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: 11.5px; }
.demo-banner {
  background: var(--warn-soft); color: #7c4a03; border-bottom: 1px solid #f3d98b; padding: 7px 24px;
  font-size: 12.5px; font-weight: 500;
}
.content { padding: 24px; width: 100%; max-width: 1440px; }

/* Cards & layout */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-h h2 { font-size: 15px; }
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.page-h { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-h h2 { font-size: 20px; }
.page-h p { margin: 4px 0 0; color: var(--muted); }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 30px; font-weight: 700; letter-spacing: -.5px; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12.5px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.chart { position: relative; height: 260px; }
.chart.short { height: 220px; }
.chart.tall { height: 330px; }
.donut-row { display: flex; align-items: center; gap: 20px; }
.donut-row table { flex: 1; min-width: 0; }
.donut-row .table th, .donut-row .table td { padding: 9px 8px; }
.donut-row .chart { width: 160px; height: 160px; flex: none; }
.table td.mono { white-space: nowrap; }
@media (max-width: 560px) { .donut-row { flex-direction: column; } }

/* Buttons & forms */
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f8fafc; text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: #1e40af; }
.btn.danger { color: var(--bad); border-color: #f1b3b3; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 8px; font: inherit; color: var(--ink); background: #fff;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #93b4ff; border-color: var(--brand); }
.field { margin-bottom: 14px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.err { color: var(--bad); font-size: 12.5px; margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 130px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 0; cursor: pointer; }
.check input { width: auto; }

.flash { padding: 10px 14px; border-radius: 9px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #a7e3bb; }
.flash.bad { background: var(--bad-soft); color: var(--bad); border: 1px solid #f1b3b3; }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #f8fafd; }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 36px; text-align: center; color: var(--muted); }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.b-pass { background: var(--ok-soft); color: var(--ok); }
.b-fail { background: var(--bad-soft); color: var(--bad); }
.b-run { background: var(--run-soft); color: var(--run); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-muted { background: #eef2f7; color: var(--muted); }
.fam { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; color: #fff; }
.fam-ont { background: var(--f-ont); }
.fam-stb { background: var(--f-stb); }
.fam-extender { background: var(--f-extender); }
.fam-emta { background: var(--f-emta); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.pass { background: #16a34a; } .dot.fail { background: #dc2626; } .dot.run { background: #2563eb; } .dot.warn { background: #d97706; }
.pager { display: flex; gap: 6px; padding: 12px 14px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); }
.pager nav { display: flex; gap: 6px; align-items: center; }
.pager .pg { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 7px; background: #fff; color: var(--ink); font-weight: 600; }
.pager .pg.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager .pg.dis { opacity: .4; }

/* Station board */
.board-head { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.scanbar { display: flex; gap: 10px; flex: 1; min-width: min(440px, 100%); }
.scanbar input { font-size: 16px; padding: 11px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: .5px; }
.scanbar input::placeholder { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 14px; letter-spacing: 0; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-weight: 600; font-size: 12.5px; }
.chip b { font-variant-numeric: tabular-nums; }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 12px; }
.slot {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 148px;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer; position: relative; box-shadow: var(--shadow);
  border-top: 4px solid var(--line-strong);
}
.slot:hover { border-color: #9bb4e6; }
.slot.sel { outline: 2px solid var(--brand); }
.slot.st-empty { border-style: dashed; border-top-style: dashed; background: #f8fafc; box-shadow: none; cursor: default; align-items: center; justify-content: center; color: #94a3b8; }
.slot.st-running { border-top-color: #2563eb; }
.slot.st-passed { border-top-color: #16a34a; background: #f6fdf8; }
.slot.st-failed { border-top-color: #dc2626; background: #fff7f7; }
.slot.st-ready { border-top-color: #94a3b8; }
.slot.st-awaiting { border-top-color: #d97706; background: #fffbf0; animation: ask 1.6s ease-in-out infinite; }
@keyframes ask { 0%, 100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 3px #f6c766, var(--shadow); } }
.slot-ask { font-size: 12.5px; font-weight: 600; color: #7c4a03; margin-top: 2px; padding-left: 8px; border-left: 3px solid #d97706; }
.chip.warn { background: var(--warn-soft); border-color: #f3d98b; color: #7c4a03; }
.slot.st-unrecognized { border-top-color: #d97706; background: #fffbf0; cursor: default; }
.slot-h { display: flex; align-items: center; gap: 6px; }
.slot-n { font-weight: 800; font-size: 15px; color: #334155; min-width: 24px; }
.slot-h .badge { margin-left: auto; }
.slot-serial { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; word-break: break-all; }
.slot-model { font-size: 12.5px; color: var(--muted); }
.slot-prog { height: 6px; background: #e8eef7; border-radius: 99px; overflow: hidden; margin-top: 4px; }
.slot-prog i { display: block; height: 100%; background: #2563eb; border-radius: 99px; transition: width .9s linear; }
.slot-foot { font-size: 12px; color: var(--muted); margin-top: auto; min-height: 32px; }
.slot-foot.fail { color: var(--bad); font-weight: 600; }
.slot-verdict { font-size: 26px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; margin-top: 4px; }
.slot-verdict.pass { color: #15803d; } .slot-verdict.fail { color: #b91c1c; }
.slot-actions { display: flex; gap: 6px; margin-top: 6px; }
.slot select { font-size: 12px; padding: 5px 6px; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); background: #fff; z-index: 50;
  border-left: 1px solid var(--line-strong); box-shadow: -12px 0 32px rgba(15, 23, 42, .12);
  transform: translateX(105%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-h { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-b { padding: 6px 18px 18px; overflow-y: auto; flex: 1; }
.x { background: none; border: 0; font-size: 22px; line-height: 1; cursor: pointer; color: var(--muted); margin-left: auto; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 22px 1fr auto; gap: 8px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: start; }
.steps li:last-child { border-bottom: 0; }
.steps .nm { font-weight: 600; }
.steps .sub { grid-column: 2 / 4; color: var(--muted); font-size: 12.5px; }
.steps .msg { grid-column: 2 / 4; color: var(--bad); font-size: 12.5px; font-weight: 600; }
.steps .val { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; }
.steps li.sk { opacity: .5; }
.toasts { position: fixed; top: 70px; right: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #0f1c30; color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 380px; font-weight: 500; }
.toast.bad { background: #991b1b; }
.scrim { position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 40; display: none; }
.scrim.open { display: block; }

/* Misc */
.pon { display: grid; grid-template-columns: repeat(16, 1fr); gap: 5px; max-width: 520px; }
.pon i { aspect-ratio: 1; border-radius: 4px; background: #e6ecf5; }
.pon i.on { background: #2563eb; }
.res-list { display: flex; flex-direction: column; }
.res { display: grid; grid-template-columns: minmax(180px, 1.3fr) 3fr 56px 116px; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line); align-items: center; }
.res:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; }
pre.code { background: #0f1c30; color: #d6e2f5; padding: 14px 16px; border-radius: 10px; overflow-x: auto; font-size: 12.5px; line-height: 1.55; margin: 0; }
.token { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1f5f9; border: 1px dashed var(--line-strong); padding: 8px 12px; border-radius: 8px; word-break: break-all; }
.tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: #eef2f7; color: #475569; }

/* Login */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: #fff; }
.login-side {
  background: radial-gradient(1200px 600px at 10% 0%, #1e3a8a 0%, #0b1424 60%); color: #dbe6fb; padding: 56px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-side h1 { font-size: 34px; color: #fff; letter-spacing: -.5px; margin: 26px 0 14px; max-width: 460px; }
.login-side p { max-width: 460px; color: #b3c3e0; font-size: 15.5px; }
.login-points { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 12px; }
.login-points li { display: flex; gap: 10px; color: #cfdbf3; }
.login-points li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #38bdf8; margin-top: 8px; flex: none; }
.login-main { display: grid; place-items: center; padding: 32px; }
.login-box { width: min(380px, 100%); }
.login-box h2 { font-size: 24px; margin-bottom: 6px; }
.login-box .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }

.err-page { min-height: 100vh; display: grid; place-items: center; text-align: center; padding: 24px; }
.err-page h1 { font-size: 64px; color: var(--brand); }

@media (max-width: 1100px) {
  .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols-21, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 60; width: 260px; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .burger { display: block; }
  .content { padding: 16px; }
  .topbar { padding: 10px 16px; }
  .login { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .cols-2, .form-grid { grid-template-columns: 1fr; }
  .res { grid-template-columns: 1fr; gap: 4px; }
  .user-chip .who { display: none; }
}
@media (max-width: 560px) {
  .cols-4 { grid-template-columns: 1fr; }
}
@media print {
  .sidebar, .topbar, .demo-banner, .no-print, .toasts { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; }
}

/* Valor agregado: alertas, medidores, destinos */
.nav-badge { margin-left: auto; background: #dc2626; color: #fff; border-radius: 99px; font-size: 11px; font-weight: 800; padding: 1px 7px; }
.alert-card { border-left: 5px solid #d97706; }
.alert-card.sev-high { border-left-color: #dc2626; }
.alert-h { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.meters { display: grid; gap: 8px; margin-bottom: 12px; max-width: 620px; }
.meter-row { display: grid; grid-template-columns: 150px 1fr 64px; gap: 12px; align-items: center; }
.meter { height: 9px; background: #e8eef7; border-radius: 99px; overflow: hidden; }
.meter i { display: block; height: 100%; background: #64748b; border-radius: 99px; }
.meter.bad i { background: #dc2626; }
.reco { background: #f6f8fc; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; }
.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tile { display: block; padding: 16px 18px; color: inherit; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); border-top: 4px solid var(--line-strong); }
.tile:hover { text-decoration: none; border-color: #9bb4e6; }
.tile .label { color: var(--muted); font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tile .big { font-size: 22px; font-weight: 800; letter-spacing: -.3px; margin: 4px 0 2px; line-height: 1.2; }
.tile .sub { color: var(--muted); font-size: 12.5px; }
.tile.t-bad { border-top-color: #dc2626; } .tile.t-ok { border-top-color: #16a34a; } .tile.t-run { border-top-color: #2563eb; } .tile.t-warn { border-top-color: #d97706; }
.dest { display: inline-block; font-size: 12px; font-weight: 800; padding: 2px 9px; border-radius: 6px; margin-top: 4px; width: fit-content; }
.dest-stock { background: var(--ok-soft); color: var(--ok); }
.dest-reparacion { background: var(--warn-soft); color: var(--warn); }
.dest-descarte { background: var(--bad-soft); color: var(--bad); }
@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: 1fr; } .meter-row { grid-template-columns: 1fr; } }
