/* Traza Mat — interfaz de almacén. Paleta acero + naranja de seguridad. */
:root {
  --bg: #f2f2ee;
  --surface: #ffffff;
  --surface-2: #f7f7f4;
  --line: #dddcd5;
  --line-strong: #c4c3ba;
  --ink: #1b1e21;
  --ink-2: #4a4f55;
  --muted: #767b80;
  --steel: #1d2125;
  --steel-2: #2a3036;
  --steel-ink: #c9ced3;
  --accent: #e0661b;
  --accent-ink: #ffffff;
  --accent-soft: #fbe9dc;
  --green: #2f7d43; --green-soft: #e1f1e4;
  --amber: #a86b00; --amber-soft: #fbefd3;
  --red: #b3261e;   --red-soft: #fbe3e1;
  --blue: #23609e;  --blue-soft: #e1ecf7;
  --grey: #5f6368;  --grey-soft: #ebebe7;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 24, .06), 0 2px 8px rgba(20, 22, 24, .04);
  --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --side: 232px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141719; --surface: #1c2024; --surface-2: #22272b; --line: #2f353a; --line-strong: #444b52;
    --ink: #e9ebec; --ink-2: #b8bdc2; --muted: #8b9197; --steel: #0f1214; --steel-2: #1a1f23;
    --accent-soft: #3a2516; --green-soft: #183322; --amber-soft: #3a2c10; --red-soft: #3d1a17; --blue-soft: #172a3d; --grey-soft: #2a2f33;
    --green: #6cc485; --amber: #e3a640; --red: #f0817a; --blue: #7fb2e5; --grey: #a3a8ad;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #141719; --surface: #1c2024; --surface-2: #22272b; --line: #2f353a; --line-strong: #444b52;
  --ink: #e9ebec; --ink-2: #b8bdc2; --muted: #8b9197; --steel: #0f1214; --steel-2: #1a1f23;
  --accent-soft: #3a2516; --green-soft: #183322; --amber-soft: #3a2c10; --red-soft: #3d1a17; --blue-soft: #172a3d; --grey-soft: #2a2f33;
  --green: #6cc485; --amber: #e3a640; --red: #f0817a; --blue: #7fb2e5; --grey: #a3a8ad;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 var(--font); }
body.no-scroll { overflow: hidden; }
a { color: inherit; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 19px; margin: 0 0 8px; }
h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); margin: 0 0 12px; font-weight: 600; }
h4 { margin: 0 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mt { margin-top: 22px; }
.ok-text { color: var(--green); }
.err-text { color: var(--red); }
.grow { flex: 1 1 200px; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side); background: var(--steel); color: var(--steel-ink);
  display: flex; flex-direction: column; z-index: 30;
}
.sidebar nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; text-decoration: none;
  color: var(--steel-ink); font-weight: 500; margin-bottom: 2px;
}
.sidebar nav a i { font-style: normal; width: 20px; text-align: center; opacity: .8; }
.sidebar nav a:hover { background: var(--steel-2); color: #fff; }
.sidebar nav a.active { background: var(--steel-2); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar nav a.nav-scan { color: #fff; background: var(--accent); margin: 6px 0 10px; }
.sidebar nav a.nav-scan.active { box-shadow: inset 0 0 0 2px #fff3; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; color: #fff; }
.brand b { display: block; font-size: 16px; }
.brand small { display: block; color: var(--steel-ink); font-size: 12px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px; background: var(--accent);
  color: var(--steel); font: 700 13px var(--mono); flex: none;
}
.user-box { padding: 12px; border-top: 1px solid #ffffff14; }
.user-btn { width: 100%; text-align: left; background: none; border: 0; color: #fff; padding: 8px; border-radius: 8px; cursor: pointer; font: inherit; }
.user-btn:hover { background: var(--steel-2); }
.user-btn small { display: block; color: var(--steel-ink); }
.topbar { display: none; }
.bottombar { display: none; }
#view { margin-left: var(--side); padding: 26px 32px 60px; max-width: 1280px; }

@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s; }
  body.menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax #0006; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 20;
    background: var(--steel); color: #fff; padding: 0 8px 0 4px; height: 54px;
  }
  .topbar .brand { padding: 0 8px; }
  .topbar .brand-mark { width: 28px; height: 28px; font-size: 11px; }
  .topbar .icon-btn { color: #fff; font-size: 22px; }
  #view { margin: 0; padding: 16px 16px calc(90px + var(--safe-b)); }
  .bottombar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface);
    border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
  }
  .bottombar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 7px;
    text-decoration: none; color: var(--muted); font-size: 11px; font-weight: 500;
  }
  .bottombar a i { font-style: normal; font-size: 19px; line-height: 1.1; }
  .bottombar a.active { color: var(--accent); }
  .bottombar a.nav-scan i {
    display: grid; place-items: center; width: 52px; height: 52px; margin-top: -24px; border-radius: 50%;
    background: var(--accent); color: #fff; font-size: 24px; box-shadow: 0 3px 10px #e0661b55; border: 4px solid var(--bg);
  }
  .bottombar a.nav-scan { color: var(--ink); }
  h1 { font-size: 21px; }
}

/* ---------- Page ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.back { display: inline-block; text-decoration: none; color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.back:hover { color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); gap: 16px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + * { margin-top: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; margin-bottom: 16px; }
.cards .card { margin: 0; }
.link-card { text-decoration: none; display: block; transition: border-color .15s; }
.link-card:hover { border-color: var(--accent); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius); }
.empty.err { color: var(--red); }
.loading { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 30px; color: var(--muted); }
.loading.boot { min-height: 100vh; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; display: inline-block; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.fatal { max-width: 520px; margin: 15vh auto; padding: 16px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font: 500 14px var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #c95714; border-color: #c95714; }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--grey-soft); border-color: transparent; }
.btn-ghost.danger { color: var(--red); }
.btn-ghost.light { color: #fff; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xl { min-height: 56px; font-size: 17px; padding: 0 24px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon { min-width: 40px; padding: 0 8px; }
.icon-btn { background: none; border: 0; cursor: pointer; font-size: 16px; color: var(--muted); width: 36px; height: 36px; border-radius: 8px; flex: none; }
.icon-btn:hover { background: var(--grey-soft); color: var(--ink); }
.icon-btn.light { color: #fff; font-size: 20px; }
.icon-btn.light:hover { background: #ffffff22; }
.icon-btn.on { background: #ffd54a; color: #000; }

input, select, textarea, .input {
  font: 15px var(--font); color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: 8px; padding: 9px 11px; min-height: 40px; width: 100%; max-width: 100%;
}
input.mono, .input.mono, select.mono { font-family: var(--mono); letter-spacing: .02em; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=checkbox] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); flex: none; }
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: var(--ink-2); font-weight: 500; }
label > input, label > select, label > textarea, label > .input-group { margin-top: 5px; }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 400; color: var(--ink); font-size: 14px; }
.form label { margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 0 14px; }
.grid-form .span-2 { grid-column: span 2; }
@media (max-width: 520px) { .grid-form .span-2 { grid-column: auto; } }
.input-group { display: flex; gap: 6px; }
.search-inline { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.search-inline .input { flex: 1 1 180px; width: auto; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; align-items: center; }
.filters select, .filters .input { width: auto; flex: 0 1 180px; }
.filters .grow { flex: 1 1 240px; }
@media (max-width: 600px) { .filters select, .filters .input { flex: 1 1 calc(50% - 8px); } }

/* ---------- Badges, tags, chips ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-grey { background: var(--grey-soft); color: var(--grey); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 5px; background: var(--grey-soft); color: var(--ink-2); white-space: nowrap; }
.tag.warn { background: var(--amber-soft); color: var(--amber); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 99px; background: var(--grey-soft); color: var(--ink-2); font-size: 12px; text-align: center; margin-left: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); text-decoration: none; cursor: pointer; font: 14px var(--font); color: var(--ink); }
.chip.mono { font-family: var(--mono); }
.chip small { color: var(--muted); }

/* ---------- Folio ---------- */
.folio { font-family: var(--mono); font-weight: 600; white-space: nowrap; letter-spacing: .01em; }
.f-item { color: var(--ink); }
.f-proy { color: var(--accent); }
.f-cons { color: var(--blue); }
.f-sep { color: var(--muted); padding: 0 1px; }
.folio-title .folio { font-size: 26px; }
@media (max-width: 520px) { .folio-title .folio { font-size: 20px; } }

/* ---------- Dashboard ---------- */
.scan-hero {
  display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: var(--radius); margin-bottom: 18px;
  background: var(--steel); color: #fff; text-decoration: none; box-shadow: var(--shadow);
}
.scan-hero-icon { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 50%; background: var(--accent); font-size: 24px; flex: none; }
.scan-hero b { display: block; font-size: 18px; }
.scan-hero small { color: var(--steel-ink); }
.scan-hero .chev { margin-left: auto; font-size: 28px; color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 160px), 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; display: block; box-shadow: var(--shadow); }
.stat b { display: block; font: 600 26px/1.1 var(--mono); }
.stat span { font-size: 13px; color: var(--muted); }
a.stat:hover { border-color: var(--accent); }
.stat.warn b { color: var(--amber); }
.stat.err b { color: var(--red); }
.stat.ok b { color: var(--green); }
.stat.info b { color: var(--blue); }
.stats.compact { grid-template-columns: repeat(auto-fill, minmax(min(100%, 130px), 1fr)); margin: 14px 0 0; }
.stats.compact .stat { box-shadow: none; background: var(--surface-2); padding: 10px 12px; }
.stats.compact .stat b { font-size: 21px; }
.status-bars { display: grid; gap: 6px; }
.sb-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 4px; text-decoration: none; border-bottom: 1px solid var(--line); }
.sb-num { font: 600 15px var(--mono); }
.hbar { display: grid; grid-template-columns: minmax(80px, 140px) 1fr 50px; gap: 10px; align-items: center; margin-bottom: 7px; font-size: 13px; }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 10px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; }
.hbar-track span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.hbar-n { text-align: right; font-family: var(--mono); }
.feed, .timeline { list-style: none; margin: 0; padding: 0; }
.feed li, .timeline li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.feed li:last-child, .timeline li:last-child { border-bottom: 0; }
.feed a { text-decoration: none; }
.feed p, .timeline p { margin: 3px 0; font-size: 14px; }
.feed small, .timeline small { color: var(--muted); font-size: 12px; }
.feed-tipo, .tl-tipo { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-left: 8px; }
.tl-tipo { margin-left: 0; color: var(--accent); font-weight: 600; }

/* ---------- Scan page ---------- */
.scan-panel { display: grid; gap: 12px; margin-bottom: 18px; }
.scan-panel .btn-xl { width: 100%; }
.scan-panel .search-inline { margin: 0; }
.read-strip { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 14px; }
.read-strip img { width: 140px; max-height: 80px; object-fit: cover; border-radius: 6px; flex: none; background: #000; }
.material-card { border-top: 4px solid var(--accent); }
.mc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mc-head .folio { font-size: 22px; }
.mc-desc { font-size: 18px; margin: 10px 0 14px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 140px), 1fr)); gap: 12px 18px; margin: 0; }
.kv > div { min-width: 0; }
.kv .full { grid-column: 1 / -1; }
.kv dt { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 2px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.sticky-actions { margin: 0 0 16px; }
@media (max-width: 860px) {
  .actions .btn { flex: 1 1 auto; }
}
.notes { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; white-space: pre-wrap; margin: 14px 0 0; }
.notice { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.notice.warn { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.notice.info { background: var(--blue-soft); color: var(--blue); }
.notice.ok { background: var(--green-soft); color: var(--green); }
.notice .btn { margin: 6px 6px 0 0; }

/* ---------- Lists & tables ---------- */
.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; padding: 10px 4px; border-bottom: 1px solid var(--line); text-decoration: none; }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-row .icon-btn { margin-left: auto; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr[data-href], .table tr[data-i] { cursor: pointer; }
.table tr[data-href]:hover td, .table tr[data-i]:hover td { background: var(--surface-2); }
.table.small { font-size: 12px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; padding: 14px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a, .tabs button { padding: 10px 14px; border: 0; background: none; font: 500 14px var(--font); color: var(--muted); text-decoration: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs .on { color: var(--ink); border-bottom-color: var(--accent); }
.tabs-mini { display: inline-flex; background: var(--grey-soft); border-radius: 8px; padding: 3px; margin-bottom: 12px; }
.tabs-mini button { border: 0; background: none; padding: 7px 12px; border-radius: 6px; font: 500 13px var(--font); cursor: pointer; color: var(--ink-2); }
.tabs-mini .on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.pick-list { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; margin: 8px 0 14px; }
.pick { text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font: 14px var(--font); color: var(--ink); }
.pick small { display: block; color: var(--muted); margin-top: 2px; }
.pick:hover { border-color: var(--ink-2); }
.pick.sel { border-color: var(--accent); background: var(--accent-soft); }

/* ---------- Material form ---------- */
.folio-builder { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; }
.folio-builder > label { flex: 1 1 150px; margin-bottom: 0; }
.folio-builder .f-sep { font: 600 22px var(--mono); padding-bottom: 8px; }
@media (max-width: 600px) { .folio-builder .f-sep { display: none; } .folio-builder > label { flex-basis: 100%; } }
.folio-preview { font-size: 15px; margin: 14px 0 4px; }
.folio-preview .folio { font-size: 18px; }
.folio-preview .warn .folio, [data-preview].warn { outline: 2px dashed var(--amber); outline-offset: 3px; border-radius: 3px; }

/* ---------- Trazabilidad pieza ---------- */
.trace { display: grid; gap: 10px; }
.trace-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); }
.trace-row p { margin: 4px 0; }
.trace-certs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; justify-content: flex-end; }
.cert-chip { text-decoration: none; padding: 4px 10px; border-radius: 99px; background: var(--green-soft); color: var(--green); font-size: 13px; font-weight: 600; }
@media (max-width: 640px) { .trace-row { grid-template-columns: 1fr auto; } .trace-certs { grid-column: 1 / -1; justify-content: flex-start; } }

/* ---------- Certificado ---------- */
.preview { padding: 0; overflow: hidden; min-height: 300px; }
.preview iframe { width: 100%; height: 75vh; border: 0; display: block; }
.preview img { width: 100%; display: block; }
.preview p { padding: 18px; }

/* ---------- Chequeo ---------- */
.progress { height: 12px; background: var(--grey-soft); border-radius: 99px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); transition: width .3s; }
.scan-box { border-left: 4px solid var(--accent); }
.scan-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: stretch; margin-bottom: 10px; }
.scan-row .search-inline { margin: 0; align-items: center; }

/* ---------- Importar ---------- */
.import-card h3 { display: flex; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 16px; color: var(--ink); }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--steel); color: #fff; font: 600 12px var(--mono); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px 14px; margin-bottom: 14px; }
.wizard h3 { margin-top: 20px; }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; background: #0f1214a6; z-index: 50; display: grid; place-items: center; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 12px; width: min(520px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px #0005; }
.modal.wide { width: min(760px, 100%); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--ink); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
@media (max-width: 600px) {
  .modal-wrap { place-items: end stretch; padding: 0; }
  .modal, .modal.wide { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; padding-bottom: var(--safe-b); }
}
@keyframes fade { from { opacity: 0; } }

/* ---------- Toasts ---------- */
#toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); bottom: calc(84px + var(--safe-b)); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 8px; background: var(--steel); color: #fff; box-shadow: 0 6px 20px #0004; font-size: 14px; animation: up .2s; border-left: 4px solid var(--green); }
.toast-err { border-left-color: #f0645a; }
.toast-warn { border-left-color: #f2b33d; }
.toast.out { opacity: 0; transition: opacity .3s; }
@keyframes up { from { transform: translateY(10px); opacity: 0; } }
@media (min-width: 861px) { #toasts { left: auto; right: 24px; transform: none; bottom: 24px; } }

/* ---------- Scanner (pantalla completa) ---------- */
.scanner { position: fixed; inset: 0; z-index: 80; background: #000; color: #fff; display: flex; flex-direction: column; }
.scanner-top, .scanner-bottom { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; gap: 10px; }
.scanner-top { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.scanner-bottom { padding-bottom: calc(18px + var(--safe-b)); justify-content: space-around; }
.scanner-stage { position: relative; flex: 1; overflow: hidden; }
.scanner-stage video, .scanner-still { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scanner-still { object-fit: contain; background: #000; }
.scanner-guide {
  position: absolute; left: 6%; right: 6%; top: 50%; height: 26%; transform: translateY(-50%);
  border: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 0 0 100vmax #0008;
  display: flex; align-items: flex-end; justify-content: center;
}
.scanner-guide span { transform: translateY(32px); font-size: 14px; color: #fff; text-shadow: 0 1px 3px #000; }
.scanner-msg { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000c; padding: 10px 16px; border-radius: 99px; display: flex; gap: 10px; align-items: center; max-width: 90%; text-align: center; }
.shutter { width: 74px; height: 74px; border-radius: 50%; border: 5px solid #fff; background: var(--accent); cursor: pointer; flex: none; }
.shutter:active { transform: scale(.94); }
.scanner-engine { font-size: 11px; color: #bbb; width: 90px; text-align: center; }
.scanner label.btn { cursor: pointer; width: 90px; }

/* ---------- Login ---------- */
body.login-page { background: var(--steel); }
.login { max-width: 360px; margin: 14vh auto; padding: 28px; background: var(--surface); border-radius: 14px; display: grid; gap: 14px; }
.login .brand { color: var(--ink); padding: 0 0 10px; }
.login .brand small { color: var(--muted); }

/* ---------- Print (reporte de pieza) ---------- */
@media print {
  .sidebar, .topbar, .bottombar, .head-actions, .actions, .search-inline, .icon-btn, .btn, #toasts { display: none !important; }
  #view { margin: 0; padding: 0; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
}
