:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1b2430; --muted: #5f6b7a; --line: #dfe3e8;
  --brand: #1f4e79; --brand-ink: #fff; --accent: #2f7ed8; --ok: #1e8a4c; --warn: #b7791f; --bad: #c0392b;
  --chip: #eef2f6; --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12161c; --card: #1b2129; --ink: #e6e9ee; --muted: #9aa5b3; --line: #2c3440; --chip: #252d37;
          --brand: #2a5f91; --accent: #5aa0ee; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 22px; margin: 4px 0 12px; } h2 { font-size: 17px; margin: 18px 0 8px; } h3 { font-size: 15px; margin: 12px 0 6px; }
header#top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  background: var(--brand); color: var(--brand-ink); padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
header .brand { color: #fff; font-weight: 700; font-size: 17px; }
header nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
header nav a { color: #dbe7f3; padding: 6px 10px; border-radius: 8px; }
header nav a.on, header nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 22px; cursor: pointer; display: none; }
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
#tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: none; background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom)); z-index: 10; }
#tabbar a { flex: 1; text-align: center; padding: 10px 4px; color: var(--muted); font-weight: 600; border-radius: 10px; }
#tabbar a.primary { background: var(--brand); color: #fff; }
#tabbar a.on:not(.primary) { color: var(--accent); }
@media (max-width: 760px) {
  header nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--brand); flex-direction: column; padding: 8px; }
  header nav.open { display: flex; }
  .icon-btn { display: block; margin-left: auto; }
  #tabbar:not([hidden]) { display: flex; gap: 6px; }
}
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.kpi .n { font-size: 28px; font-weight: 700; } .kpi .l { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--ink); padding: 9px 14px;
  border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); }
button.big { width: 100%; justify-content: center; min-height: 52px; font-size: 17px; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 11px; width: 100%; min-height: 42px; }
textarea { min-height: 80px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--chip); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.almacen, .chip.listo, .chip.nuevo { background: #e3f3ea; color: #17663a; }
.chip.instalado { background: #e4eefb; color: #1e4f8c; }
.chip.transito, .chip.reservado, .chip.pendiente_revision { background: #fdf1dc; color: #8a5a12; }
.chip.baja, .chip.averiado { background: #fbe4e1; color: #96281b; }
@media (prefers-color-scheme: dark) { .chip.almacen,.chip.listo,.chip.nuevo,.chip.instalado,.chip.transito,.chip.reservado,.chip.pendiente_revision,.chip.baja,.chip.averiado { background: var(--chip); color: var(--ink); } }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choices button { min-height: 46px; }
.choices button.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.wizard { max-width: 560px; margin: 0 auto; }
.wizard .step-title { font-size: 20px; font-weight: 700; margin: 6px 0 4px; }
.wizard .actions { display: flex; gap: 8px; margin-top: 18px; }
.wizard .actions > * { flex: 1; justify-content: center; }
.progress { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; margin-bottom: 12px; }
.progress > div { height: 100%; background: var(--accent); }
.photos { display: flex; gap: 8px; flex-wrap: wrap; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }
.photos .sel img { outline: 3px solid var(--accent); }
.scanner { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 4/3; max-height: 60vh; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner .frame { position: absolute; inset: 22% 12%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline li.voided { opacity: .5; text-decoration: line-through; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; word-break: break-word; }
.missing { color: var(--warn); font-weight: 600; }
#toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px;
  border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 90vw; }
#toast.show { opacity: .95; } #toast.err { background: var(--bad); }
dialog { border: 0; border-radius: 14px; padding: 0; max-width: min(560px, 94vw); width: 100%; background: var(--card); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
#modalBody { padding: 18px; }
.alert { border-left: 4px solid var(--warn); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 24px; }
.login { max-width: 380px; margin: 10vh auto; }
