/* ==========================================================================
   App · Control de unidades
   Claro por defecto (legible bajo el sol del patio), oscuro según el sistema.
   ========================================================================== */

:root {
  --bg: var(--bone-100);
  --surface: #FFFFFF;
  --surface-2: var(--bone-50);
  --surface-3: #EFECE5;
  --line: #E2DED5;
  --line-strong: #CFCAC0;
  --text: var(--graphite-900);
  --text-2: #4E555F;
  --text-3: #7D848E;
  --shadow-1: 0 1px 2px rgba(17, 19, 22, .06), 0 1px 1px rgba(17, 19, 22, .04);
  --shadow-2: 0 10px 30px -12px rgba(17, 19, 22, .25), 0 2px 6px rgba(17, 19, 22, .06);
  --ok-bg: #E3F4EB; --ok-fg: #0E7446;
  --warn-bg: #FBF0D4; --warn-fg: #8A5D00;
  --bad-bg: #FBE4E4; --bad-fg: #B02A30;
  --info-bg: #E6EDF8; --info-fg: #3F5F99;
  --signal-bg: #F6E3E2; --signal-fg: #9A3F3D;
  --neutral-bg: #ECE9E2; --neutral-fg: #4E555F;
  --sidebar-w: 248px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0D0F12;
    --surface: #15181C;
    --surface-2: #1A1E23;
    --surface-3: #20252B;
    --line: #262B32;
    --line-strong: #353B44;
    --text: #F1EFEA;
    --text-2: #A9AFB8;
    --text-3: #7A818B;
    --shadow-1: 0 1px 0 rgba(255, 255, 255, .02);
    --shadow-2: 0 18px 40px -16px rgba(0, 0, 0, .7);
    --ok-bg: rgba(31, 164, 99, .16); --ok-fg: #4ED494;
    --warn-bg: rgba(217, 154, 0, .16); --warn-fg: #F2C14E;
    --bad-bg: rgba(217, 61, 66, .18); --bad-fg: #FF7B7F;
    --info-bg: rgba(110, 142, 196, .18); --info-fg: #A9C0E8;
    --signal-bg: rgba(181, 82, 79, .16); --signal-fg: #E8A09D;
    --neutral-bg: #23282F; --neutral-fg: #A9AFB8;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0D0F12; --surface: #15181C; --surface-2: #1A1E23; --surface-3: #20252B;
  --line: #262B32; --line-strong: #353B44; --text: #F1EFEA; --text-2: #A9AFB8; --text-3: #7A818B;
  --ok-bg: rgba(31, 164, 99, .16); --ok-fg: #4ED494; --warn-bg: rgba(217, 154, 0, .16); --warn-fg: #F2C14E;
  --bad-bg: rgba(217, 61, 66, .18); --bad-fg: #FF7B7F; --info-bg: rgba(110, 142, 196, .18); --info-fg: #A9C0E8;
  --signal-bg: rgba(181, 82, 79, .16); --signal-fg: #E8A09D; --neutral-bg: #23282F; --neutral-fg: #A9AFB8;
  color-scheme: dark;
}

body { background: var(--bg); color: var(--text); font-size: 15px; }
.i { flex: none; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
code { font-family: var(--font-mono); font-size: .9em; background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }

/* — Arranque / error — */
.boot { min-height: 100vh; display: grid; place-items: center; }
.boot .logo-mark { width: 44px; height: 44px; animation: pulse 1.2s var(--ease-in-out) infinite alternate; }

/* Camión de carga: rueda sobre una carretera en movimiento (arranque, carga de pantallas y login). */
.truck-loader { display: grid; justify-items: center; gap: 14px; color: var(--text-2); font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; }
.truck-scene { position: relative; width: 220px; }
.truck-art { display: block; width: 168px; height: auto; margin: 0 auto; overflow: visible; }
.truck-body { animation: truckBob .32s ease-in-out infinite alternate; }
.truck-wheel { transform-box: fill-box; transform-origin: center; animation: truckSpin .55s linear infinite; }
.truck-smoke circle { transform-box: fill-box; transform-origin: center; opacity: 0; animation: truckPuff 1.5s ease-out infinite; }
.truck-smoke circle:nth-child(2) { animation-delay: .5s; }
.truck-smoke circle:nth-child(3) { animation-delay: 1s; }
.truck-road { height: 4px; margin-top: 2px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--graphite-500) 0 22px, transparent 22px 40px); animation: truckRoad .45s linear infinite; mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 18%, #000 82%, transparent); }
@keyframes truckBob { to { transform: translateY(-1.2px); } }
@keyframes truckSpin { to { transform: rotate(360deg); } }
@keyframes truckPuff { 0% { opacity: .65; transform: translate(0, 0) scale(.6); } 100% { opacity: 0; transform: translate(-16px, -9px) scale(2); } }
@keyframes truckRoad { to { background-position: -40px 0; } }

/* Logo oficial (PNG con fondo transparente) directo sobre el fondo oscuro. */
.logo-plate { display: none; line-height: 0; }
.logo-plate img { height: 58px; width: auto; }
.sidebar-logo .logo-plate img { height: auto; width: 168px; max-width: 100%; }
.logo-fallback { display: inline-flex; align-items: center; gap: 10px; }
.has-logo .logo-plate { display: inline-block; }
.has-logo .logo-fallback { display: none; }
.topbar .logo-plate img { height: 38px; }
.login-brand .logo-plate img { height: 104px; }
@media (max-width: 860px) { .login-brand .logo-plate img { height: 72px; } }

.boot-logo { width: 190px; height: auto; margin-bottom: 6px; }

.login-truck { width: min(360px, 100%); margin-top: 36px; }
.login-truck .truck-art { width: 78%; margin: 0; }
@media (max-width: 860px) { .login-truck { width: 240px; margin-top: 22px; } }

/* Entre pantallas: un camioncito cruza la barra superior mientras carga. */
.view.is-loading::before {
  content: ""; position: fixed; z-index: 40; top: 0; left: var(--sidebar-w); right: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--signal), transparent); background-size: 40% 100%; background-repeat: no-repeat;
  animation: loadBar 1s ease-in-out infinite;
}
.view.is-loading::after {
  content: ""; position: fixed; z-index: 41; top: 6px; left: var(--sidebar-w); width: 34px; height: 17px;
  background: url("../assets/truck-mini.svg") no-repeat center / contain;
  animation: miniTruck 1.6s linear infinite;
}
@keyframes loadBar { from { background-position: -40% 0; } to { background-position: 140% 0; } }
@keyframes miniTruck { from { transform: translateX(-40px); } to { transform: translateX(calc(100vw - var(--sidebar-w))); } }
@media (max-width: 900px) { .view.is-loading::before, .view.is-loading::after { left: 0; top: 58px; } .view.is-loading::after { top: 64px; } }
@media (prefers-reduced-motion: reduce) { .truck-body, .truck-wheel, .truck-smoke circle, .truck-road, .view.is-loading::after { animation: none; } }
@keyframes pulse { from { opacity: .35; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
.fatal { min-height: 100vh; display: grid; place-content: center; justify-items: start; gap: 16px; padding: 32px 20px; max-width: 520px; margin: 0 auto; }
.fatal h1 { font-family: var(--font-display); font-stretch: 75%; font-weight: 800; font-size: 34px; line-height: 1.05; text-transform: uppercase; }
.fatal p { color: var(--text-2); }
.fatal-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ==========================================================================
   Botones y controles
   ========================================================================== */
.btn {
  --h: 42px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--h); padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--r-m);
  font-weight: 600; font-size: 14.5px; letter-spacing: .005em;
  text-decoration: none; white-space: nowrap;
  background: var(--surface); color: var(--text);
  transition: background .18s, border-color .18s, transform .18s var(--ease-out), box-shadow .18s;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn-lg { --h: 50px; padding: 0 22px; font-size: 15.5px; }
.btn-sm { --h: 34px; padding: 0 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--signal); color: var(--signal-ink); box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .14); }
.btn-primary:hover { background: var(--signal-strong); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); }
.btn-ghost:hover { border-color: var(--text-3); background: var(--surface-2); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(1.06); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger-ghost { background: var(--surface); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad-fg); }
.btn-danger-ghost:hover { background: var(--bad-bg); }
.btn-wa { background: #1FAF5A; color: #fff; }
.btn-wa:hover { background: #179A4E; }

.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border: 0; border-radius: var(--r-m); background: transparent; color: inherit;
  transition: background .15s;
}
.icon-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn.wa { color: #1FAF5A; }

.link-btn { border: 0; background: none; padding: 4px 0; color: var(--signal-fg); font-weight: 600; font-size: 14px; }
.link-btn:hover { text-decoration: underline; }

.field { display: grid; gap: 7px; margin: 0 0 18px; }
.field > span, .field-row > span { font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .01em; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field input, .field textarea, .field select, .item-fail textarea {
  width: 100%; min-height: 46px; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: var(--r-m);
  background: var(--surface); color: var(--text); font-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea, .item-fail textarea { resize: vertical; min-height: 0; line-height: 1.4; }
.field input:focus, .field textarea:focus, .item-fail textarea:focus, .select:focus {
  outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 22%, transparent);
}
.hint { font-size: 12.5px; color: var(--text-3); }
.form-error { color: var(--bad-fg); background: var(--bad-bg); padding: 10px 12px; border-radius: var(--r-m); font-size: 14px; margin: 0 0 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.span-2 { grid-column: span 2; }

.select {
  height: 38px; padding: 0 34px 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-m);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237D848E' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
  appearance: none; font-size: 14px; color: var(--text);
}
.field .select { height: 46px; font-size: 16px; }

.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.4; margin: 6px 0 4px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--signal); flex: none; }

.toggle { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.toggle input { width: 18px; height: 18px; accent-color: var(--signal); margin: 0; }

.switch { position: relative; display: inline-block; width: 40px; height: 24px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--line-strong); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .25s var(--ease-out); }
.switch input:checked + i { background: var(--ok); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 2px solid var(--signal); outline-offset: 2px; }
.switch input:disabled + i { opacity: .5; }

.seg { display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--surface-3); border-radius: var(--r-m); margin-bottom: 22px; width: 100%; max-width: 420px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 10px 12px; border-radius: 7px; font-weight: 600; font-size: 14.5px; color: var(--text-2); transition: background .18s, color .18s, box-shadow .18s; }
.seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg input:focus-visible + span { outline: 2px solid var(--signal); }
.seg-sm { width: auto; margin: 0; }
.seg-sm span { padding: 7px 14px; font-size: 13.5px; }

/* — Insignias — */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px;
  border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; letter-spacing: .01em;
  background: var(--neutral-bg); color: var(--neutral-fg);
}
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tone-ok { background: var(--ok-bg); color: var(--ok-fg); }
.tone-warn { background: var(--warn-bg); color: var(--warn-fg); }
.tone-bad { background: var(--bad-bg); color: var(--bad-fg); }
.tone-info { background: var(--info-bg); color: var(--info-fg); }
.tone-signal { background: var(--signal-bg); color: var(--signal-fg); }
.tone-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }
.crit {
  display: inline-block; vertical-align: 2px; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bad-fg); background: var(--bad-bg);
}

/* ==========================================================================
   Armazón
   ========================================================================== */
.demo-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap;
  padding: 7px 16px; background: var(--signal); color: var(--signal-ink);
  font-family: var(--font-mono); font-size: 11.5px; letter-spacing: .04em; text-align: center;
}
.demo-bar button { border: 1px solid rgba(0,0,0,.35); background: transparent; border-radius: 99px; padding: 2px 10px; font-size: 11px; font-family: inherit; }
.demo-bar button:hover { background: rgba(0,0,0,.1); }
@media (max-width: 900px) {
  .demo-bar { flex-wrap: nowrap; height: 31px; padding: 0 12px; font-size: 10.5px; }
  .demo-long { display: none; }
}

.shell { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 20;
  display: flex; flex-direction: column; gap: 28px; padding: 22px 14px 16px;
  background: var(--graphite-950); color: var(--bone-100);
  border-right: 1px solid rgba(255,255,255,.04);
}
body:has(.demo-bar) .sidebar { top: 31px; }
.sidebar-logo { padding: 2px 8px; }
.side-nav { display: grid; gap: 2px; }
.side-link {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-m);
  text-decoration: none; color: var(--graphite-300); font-weight: 500; font-size: 14.5px;
  transition: background .15s, color .15s;
}
.side-link:hover { background: rgba(255,255,255,.05); color: var(--bone-100); }
.side-link.active { background: rgba(255,255,255,.07); color: #fff; }
.side-link.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--signal); }
.side-link.active .i { color: var(--signal); }
.side-user { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.07); }
.side-user-text { display: grid; min-width: 0; flex: 1; line-height: 1.25; }
.side-user-text b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-text small { font-size: 12px; color: var(--graphite-400); }
.side-user .icon-btn { color: var(--graphite-400); }
.side-user .icon-btn:hover { color: #fff; }
.avatar {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: var(--graphite-700); color: var(--bone-100); border: 0;
  font-family: var(--font-mono); font-size: 12px; font-weight: 600; letter-spacing: .02em;
}

.topbar { display: none; }
.tabbar { display: none; }

.view { margin-left: var(--sidebar-w); padding: 40px clamp(20px, 4vw, 56px) 80px; max-width: calc(1160px + var(--sidebar-w)); outline: none; transition: opacity .2s; }
.view.is-loading { opacity: .45; }
.view-inner { animation: viewIn .45s var(--ease-out) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
    height: 58px; padding: 0 16px; padding-top: env(safe-area-inset-top);
    background: var(--graphite-950); color: var(--bone-100);
  }
  body:has(.demo-bar) .topbar { top: 31px; }
  .topbar a { text-decoration: none; }
  .topbar .logo-mark { width: 28px; height: 28px; }
  .topbar .logo-type b { font-size: 17px; }
  .view { margin-left: 0; padding: 22px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; inset: auto 0 0 0; z-index: 20; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px) saturate(1.4); -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border-top: 1px solid var(--line);
  }
  .tab {
    position: relative; display: grid; place-items: center; align-content: center; gap: 3px;
    border: 0; background: none; color: var(--text-3); text-decoration: none;
    font-size: 11px; font-weight: 600; letter-spacing: .01em; -webkit-tap-highlight-color: transparent;
  }
  .tab.active { color: var(--text); }
  .tab.active .i { color: var(--signal); }
  .tab.active::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 2px; border-radius: 0 0 2px 2px; background: var(--signal); }
}

.sheet-nav { display: grid; gap: 4px; margin-top: 14px; }
.sheet-link { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-m); background: var(--surface-2); text-decoration: none; font-weight: 600; }

/* ==========================================================================
   Tipografía de página
   ========================================================================== */
.eyebrow {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-3); margin-bottom: 6px;
}
.display, .page-title, .wizard-title {
  font-family: var(--font-display); font-stretch: 72%; font-weight: 800; letter-spacing: -.005em; line-height: .98; text-transform: uppercase;
}
.display { font-size: clamp(34px, 5vw, 54px); }
.page-title { font-size: clamp(30px, 4.2vw, 44px); display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.page-title .badge { font-family: var(--font-body); font-stretch: 100%; text-transform: none; letter-spacing: .01em; }
.plus { color: var(--signal); font-weight: 400; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; margin-bottom: 26px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--text-2); text-decoration: none; font-size: 14px; font-weight: 500; }
.back:hover { color: var(--text); }

.hello { margin-bottom: 26px; }
.hello .eyebrow::first-letter { text-transform: uppercase; }

/* ==========================================================================
   Bloques, filas, KPIs
   ========================================================================== */
.block { margin-top: 34px; }
.block-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.block-head h2 { font-size: 16px; font-weight: 700; letter-spacing: .005em; display: flex; align-items: center; gap: 8px; }
.block-head a { font-size: 13.5px; font-weight: 600; color: var(--signal-fg); text-decoration: none; }
.block-head a:hover { text-decoration: underline; }
.count { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 7px; border-radius: 99px; background: var(--surface-3); font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--text-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); padding: 20px 22px; box-shadow: var(--shadow-1); }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.split > .card { margin-top: 22px; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }

.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; box-shadow: var(--shadow-1); }
.rows > .empty { border: 0; }
.row {
  display: grid; grid-template-columns: 76px minmax(0, 1fr) auto 18px; align-items: center; gap: 14px;
  padding: 14px 16px; text-decoration: none; color: inherit;
  border-top: 1px solid var(--line); transition: background .15s;
}
.row:first-child { border-top: 0; }
a.row:hover { background: var(--surface-2); }
a.row:hover > .i { transform: translateX(2px); color: var(--text); }
.row > .i { color: var(--text-3); transition: transform .2s var(--ease-out), color .2s; }
.row-static { grid-template-columns: 76px minmax(0, 1fr) auto 36px; }
.row-id { font-size: 12px; color: var(--text-3); }
.row-main { display: grid; min-width: 0; gap: 2px; }
.row-main strong { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-main small { color: var(--text-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-tags { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.unit-code { font-family: var(--font-mono); font-weight: 600; color: var(--text); }
@media (max-width: 640px) {
  .row { grid-template-columns: minmax(0, 1fr) 18px; gap: 6px 10px; padding: 13px 14px; }
  .row-static { grid-template-columns: minmax(0, 1fr) 36px; }
  .row-id { grid-column: 1; grid-row: 1; }
  .row-main { grid-column: 1; grid-row: 2; }
  .row-tags { grid-column: 1; grid-row: 3; justify-content: flex-start; }
  .row > .i, .row-static > .icon-btn { grid-column: 2; grid-row: 1 / span 3; }
}

.empty { display: grid; justify-items: center; gap: 6px; padding: 34px 20px; text-align: center; color: var(--text-2); border: 1px dashed var(--line-strong); border-radius: var(--r-l); }
.empty .i { color: var(--text-3); margin-bottom: 4px; }
.empty strong { color: var(--text); font-weight: 650; }
.empty p { font-size: 14px; max-width: 34ch; }
.empty .btn { margin-top: 10px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
@media (max-width: 1100px) { .kpis-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis, .kpis-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { position: relative; display: grid; gap: 2px; padding: 16px 18px 15px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 0 3px 3px 0; background: var(--line-strong); }
.kpi-ok::before { background: var(--ok); }
.kpi-info::before { background: var(--info); }
.kpi-bad::before { background: var(--bad); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.kpi-value { font-family: var(--font-display); font-stretch: 75%; font-weight: 800; font-size: 40px; line-height: 1.05; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12.5px; color: var(--text-3); }

/* Tablero del patio */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend span::before { content: ""; width: 9px; height: 9px; border-radius: 3px; background: var(--c, var(--text-3)); }
.legend .s-disponible, .legend .l-ok { --c: var(--ok); }
.legend .s-en_taller { --c: var(--info); }
.legend .s-bloqueada, .legend .l-bad { --c: var(--bad); }
.board-group { display: grid; grid-template-columns: 70px 1fr; gap: 12px; align-items: start; padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); }
.board-group:first-of-type { border-radius: var(--r-l) var(--r-l) 0 0; }
.board-group + .board-group { border-top: 0; border-radius: 0 0 var(--r-l) var(--r-l); }
.board-label { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); padding-top: 8px; }
.board { display: flex; flex-wrap: wrap; gap: 6px; }
.unit-chip {
  --c: var(--ok);
  display: inline-flex; align-items: center; height: 32px; padding: 0 10px 0 9px; border-radius: 7px;
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--text);
  background: color-mix(in srgb, var(--c) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  box-shadow: inset 3px 0 0 var(--c);
  transition: transform .18s var(--ease-out), box-shadow .18s;
}
.unit-chip:hover { transform: translateY(-1px); box-shadow: inset 3px 0 0 var(--c), 0 4px 10px -4px color-mix(in srgb, var(--c) 60%, transparent); }
.unit-chip.s-en_taller { --c: var(--info); }
.unit-chip.s-bloqueada { --c: var(--bad); }
@media (max-width: 640px) { .board-group { grid-template-columns: 1fr; gap: 8px; } .board-label { padding: 0; } }

/* CTA operador */
.cta-card {
  position: relative; display: grid; gap: 4px; padding: 26px 26px 24px; border-radius: var(--r-xl); overflow: hidden; isolation: isolate;
  background: var(--graphite-950); color: var(--bone-100); text-decoration: none;
  box-shadow: var(--shadow-2);
  transition: transform .3s var(--ease-out);
}
.cta-card::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    repeating-linear-gradient(115deg, transparent 0 22px, rgba(181, 82, 79, .07) 22px 24px),
    radial-gradient(120% 140% at 100% 0%, rgba(181, 82, 79, .35), transparent 55%);
}
.cta-card:hover { transform: translateY(-2px); }
.cta-kicker { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--signal); }
.cta-title { font-family: var(--font-display); font-stretch: 70%; font-weight: 800; font-size: clamp(38px, 8vw, 56px); line-height: .95; text-transform: uppercase; }
.cta-meta { color: var(--graphite-300); font-size: 14px; margin-top: 6px; }
.cta-arrow { position: absolute; right: 22px; bottom: 22px; display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; background: var(--signal); color: var(--signal-ink); transition: transform .35s var(--ease-out); }
.cta-card:hover .cta-arrow { transform: translateX(4px) rotate(-8deg); }

/* ==========================================================================
   Barra de filtros
   ========================================================================== */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 99px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-size: 13.5px; font-weight: 600;
  transition: background .15s, color .15s, border-color .15s;
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip-count { font-family: var(--font-mono); font-size: 11.5px; opacity: .7; }
.chip-count:empty { display: none; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--r-m); background: var(--surface); color: var(--text-3); min-width: 220px; }
.search:focus-within { border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 20%, transparent); }
.search input { border: 0; outline: 0; background: none; width: 100%; font-size: 14.5px; color: var(--text); }
.search-mini { display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text-3); width: 150px; }
.search-mini input { border: 0; outline: 0; background: none; width: 100%; font-size: 14px; color: var(--text); }
@media (max-width: 640px) {
  .toolbar, .toolbar-right { align-items: stretch; }
  .toolbar-right, .search { width: 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
}

/* ==========================================================================
   Asistente de inspección
   ========================================================================== */
.wizard { max-width: 760px; margin: 0 auto; }
.wizard-head { position: sticky; top: 0; z-index: 5; display: flex; align-items: flex-end; gap: 16px; padding: 12px 0 14px; margin: -12px 0 18px; background: var(--bg); }
body:has(.demo-bar) .wizard-head { top: 31px; }
@media (max-width: 900px) { .wizard-head { top: 58px; } body:has(.demo-bar) .wizard-head { top: 89px; } }
.wizard-head > div { flex: 1; }
.progress { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--signal); border-radius: inherit; transition: width .5s var(--ease-out); }
.step-count { font-size: 13px; color: var(--text-2); }
.wizard-title { font-size: clamp(30px, 6vw, 42px); margin-bottom: 20px; }
.wizard-foot {
  position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap;
  margin: 26px -4px 0; padding: 14px 4px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.wizard-foot > :first-child { margin-right: auto; }
@media (max-width: 900px) { .wizard-foot { bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: 14px; } }
.foot-status { font-size: 13.5px; font-weight: 600; color: var(--warn-fg); }
.foot-status.done { color: var(--ok-fg); }

.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.pick {
  --c: var(--ok);
  position: relative; display: grid; gap: 1px; padding: 12px 12px 11px; border-radius: var(--r-m); cursor: pointer;
  background: var(--surface); border: 1.5px solid var(--line); transition: border-color .15s, background .15s, transform .15s var(--ease-out);
}
.pick[hidden] { display: none; }
.pick:hover { border-color: var(--line-strong); }
.pick:active { transform: scale(.98); }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick b { font-family: var(--font-mono); font-size: 16px; font-weight: 600; }
.pick small { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-dot { position: absolute; top: 12px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--c); }
.pick.s-en_taller { --c: var(--info); }
.pick.s-bloqueada { --c: var(--bad); }
.pick:has(input:checked) { border-color: var(--signal); background: var(--signal-bg); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 15%, transparent); }
.pick:has(input:focus-visible) { outline: 2px solid var(--signal); outline-offset: 2px; }
.pick-none b { font-family: var(--font-body); font-size: 15px; }

.notice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-m); background: var(--warn-bg); color: var(--warn-fg); font-size: 14px; line-height: 1.45; margin: 0 0 18px; }
.notice[hidden] { display: none; }
.notice .i { margin-top: 1px; }
.notice-bad { background: var(--bad-bg); color: var(--bad-fg); }
.notice-ok { background: var(--ok-bg); color: var(--ok-fg); }

.unit-banner { display: flex; align-items: baseline; gap: 12px; padding: 12px 16px; margin-bottom: 18px; border-radius: var(--r-m); background: var(--graphite-950); color: var(--bone-100); }
.unit-banner .mono { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--signal); }
.unit-banner b { font-family: var(--font-mono); font-size: 18px; }
.step-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 4px; }
.step-head .wizard-title { margin-bottom: 16px; }
.step-head .btn { margin-bottom: 18px; }

.items { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-l); padding: 14px 14px 14px 18px; transition: border-color .2s, background .2s, box-shadow .2s; }
.item.is-ok { border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.item.is-fail { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 4%, var(--surface)); }
.item.needs { animation: shake .4s var(--ease-out); border-color: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }
@keyframes shake { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.item-label { font-size: 15.5px; font-weight: 550; line-height: 1.35; }
.okfail { display: flex; gap: 6px; flex: none; }
.okfail button {
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 14px; border-radius: var(--r-m);
  border: 1.5px solid var(--line-strong); background: var(--surface); color: var(--text-2); font-weight: 650; font-size: 14px;
  transition: background .15s, color .15s, border-color .15s, transform .15s var(--ease-out);
}
.okfail button:active { transform: scale(.95); }
.okfail [data-v="ok"][aria-pressed="true"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.okfail [data-v="fail"][aria-pressed="true"] { background: var(--bad); border-color: var(--bad); color: #fff; }
.item-fail { display: grid; grid-template-columns: 1fr 112px; gap: 10px; margin-top: 12px; animation: viewIn .3s var(--ease-out); }
.photo-btn {
  position: relative; display: grid; place-items: center; align-content: center; gap: 4px; min-height: 84px; border-radius: var(--r-m); overflow: hidden; cursor: pointer;
  border: 1.5px dashed var(--bad); color: var(--bad-fg); background: var(--surface); font-size: 12px; font-weight: 650; text-align: center;
}
.photo-btn.has-photo { border-style: solid; border-color: var(--line-strong); }
.photo-btn img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-btn.is-busy { opacity: .5; pointer-events: none; }
@media (max-width: 560px) {
  .item-top { flex-direction: column; align-items: stretch; }
  .okfail button { flex: 1; justify-content: center; height: 48px; }
  .item-fail { grid-template-columns: 1fr 96px; }
  .step-head { flex-direction: column; align-items: stretch; }
  .step-head .btn { margin: -6px 0 14px; align-self: flex-start; }
}

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.summary-stat { display: grid; padding: 16px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); }
.summary-stat b { font-family: var(--font-display); font-stretch: 75%; font-weight: 800; font-size: 40px; line-height: 1; }
.summary-stat span { font-size: 13px; color: var(--text-2); }
.summary-stat.ok b { color: var(--ok-fg); }
.summary-stat.warn b { color: var(--warn-fg); }
.summary-stat.bad b { color: var(--bad-fg); }
.fail-list { list-style: none; padding: 0; margin: 0 0 22px; border: 1px solid var(--line); border-radius: var(--r-l); background: var(--surface); }
.fail-list li { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); font-size: 14.5px; }
.fail-list li:first-child { border-top: 0; }
.fail-list .mono { font-size: 12px; color: var(--text-3); width: 52px; flex: none; }
.sign-pad { width: 100%; height: 180px; border-radius: var(--r-l); background: #FFFFFF; border: 1.5px dashed var(--line-strong); touch-action: none; cursor: crosshair;
  background-image: linear-gradient(to right, transparent 24px, #E2DED5 24px, #E2DED5 calc(100% - 24px), transparent calc(100% - 24px));
  background-size: 100% 1.5px; background-repeat: no-repeat; background-position: 0 calc(100% - 42px); }

.done { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 40px 10px 10px; }
.done-icon { display: grid; place-items: center; width: 84px; height: 84px; border-radius: 50%; margin-bottom: 8px; animation: pop .6s var(--ease-out) both; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: none; opacity: 1; } }
.done-ok .done-icon { background: var(--ok); color: #fff; box-shadow: 0 0 0 10px var(--ok-bg); }
.done-warn .done-icon { background: var(--warn); color: #fff; box-shadow: 0 0 0 10px var(--warn-bg); }
.done-bad .done-icon { background: var(--bad); color: #fff; box-shadow: 0 0 0 10px var(--bad-bg); }
.done .mono { color: var(--text-3); font-size: 13px; }
.done .muted { max-width: 42ch; }

/* ==========================================================================
   Detalles (inspección, ticket, unidad)
   ========================================================================== */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; }
.facts > div { padding: 14px 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.facts dt { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 4px; }
.facts dd { margin: 0; font-weight: 600; font-size: 15px; }
.facts a { color: var(--signal-fg); text-decoration: none; }
.unit-link { font-family: var(--font-mono); }
.unit-code-lg { font-family: var(--font-mono); font-stretch: 100%; font-weight: 600; letter-spacing: -.02em; }

.decision { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 16px; padding: 18px 20px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--warn); }
.decision.aprobada { border-left-color: var(--ok); }
.decision.bloqueada { border-left-color: var(--bad); }
.decision-state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.decision-state small { color: var(--text-3); font-size: 13px; }
.decision .muted { margin-top: 6px; font-size: 14px; }
.decision-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.note { padding: 14px 16px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; }

.fail-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.fail-card { display: grid; grid-template-columns: 110px 1fr; gap: 14px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--bad); border-radius: var(--r-l); }
.fail-card h3 { font-size: 15px; font-weight: 650; margin-bottom: 4px; line-height: 1.35; }
.fail-card .muted { font-size: 14px; }
.photo { display: block; aspect-ratio: 1; border-radius: var(--r-m); overflow: hidden; background: var(--surface-3); }
.photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s var(--ease-out); }
.photo:hover img { transform: scale(1.05); }
.photo-empty { display: grid; place-items: center; font-size: 12px; color: var(--text-3); }

.checklist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); margin-bottom: 10px; }
.checklist summary { display: flex; align-items: baseline; gap: 10px; padding: 14px 18px; cursor: pointer; list-style: none; }
.checklist summary::-webkit-details-marker { display: none; }
.checklist summary .mono { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--text-3); }
.checklist summary b { font-family: var(--font-mono); font-size: 16px; }
.checklist summary small { margin-left: auto; color: var(--text-2); }
.checklist[open] summary { border-bottom: 1px solid var(--line); }
.checklist > .cl-section { padding: 14px 18px 4px; columns: 1; }
.cl-section h4 { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-2); margin-bottom: 8px; }
.cl-section ul { list-style: none; padding: 0; margin: 0 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 4px 20px; }
.cl-section li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.35; padding: 3px 0; }
.cl-section li.ok .i { color: var(--ok); }
.cl-section li.fail { color: var(--bad-fg); font-weight: 600; }
.signature { max-width: 320px; height: auto; background: #fff; border-radius: var(--r-m); border: 1px solid var(--line); padding: 6px; }
.print-head { display: none; }

.action-bar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 16px; padding: 14px; border-radius: var(--r-l); background: var(--surface-3); }
.action-sep { flex: 1; }
.inline-field { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.evidence { display: grid; grid-template-columns: 160px 1fr; gap: 16px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.evidence:not(:has(.photo)) { grid-template-columns: 1fr; }
.timeline { list-style: none; margin: 0; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.timeline li { position: relative; display: grid; padding: 0 0 18px 26px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 5px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--line-strong); background: var(--surface); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 19px; bottom: 2px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline li.done::before { background: var(--signal); border-color: var(--signal); }
.timeline b { font-size: 14.5px; }
.timeline small { color: var(--text-2); font-size: 13px; }
.timeline li:not(.done) { color: var(--text-3); }
.split + .block .evidence, .split .block .muted.small { margin-top: 10px; }
@media (max-width: 560px) {
  .evidence, .fail-card { grid-template-columns: 96px 1fr; }
  .action-bar { flex-direction: column; align-items: stretch; }
  .action-bar .select { width: 100%; }
}

/* Unidades */
.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.unit-grid > .empty { grid-column: 1 / -1; }
.unit-card {
  --c: var(--ok);
  position: relative; display: grid; gap: 8px; padding: 16px 16px 14px; border-radius: var(--r-l); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); text-decoration: none; color: inherit; box-shadow: var(--shadow-1);
  transition: transform .25s var(--ease-out), box-shadow .25s, border-color .25s;
}
.unit-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); }
.unit-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
.unit-card.s-en_taller { --c: var(--info); }
.unit-card.s-bloqueada { --c: var(--bad); }
.unit-card.inactive { opacity: .55; }
.unit-card-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.unit-card .unit-code { font-family: var(--font-mono); font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.unit-model { font-size: 14px; font-weight: 550; }
.unit-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; color: var(--text-2); }
.unit-foot { display: flex; align-items: center; gap: 6px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); }
.unit-card::before { z-index: 1; }
.unit-cover { display: block; margin: -16px -16px 6px; aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-3); }
.unit-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease-out); }
.unit-card:hover .unit-cover img { transform: scale(1.04); }
.unit-cover-empty { display: grid; place-content: center; justify-items: center; gap: 4px; height: 100%; color: var(--text-3); font-size: 12px; }

/* Fotos de la unidad: formulario y galería */
.unit-photos { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.unit-photo-slot { position: relative; display: grid; gap: 5px; }
.unit-photo-pick {
  position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; overflow: hidden; cursor: pointer;
  border-radius: var(--r-m); border: 1.5px dashed var(--line-strong); background: var(--surface-2); color: var(--text-3);
  transition: border-color .15s, color .15s;
}
.unit-photo-pick:hover { border-color: var(--signal); color: var(--signal-fg); }
.unit-photo-pick img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.unit-photo-slot.has-photo .unit-photo-pick { border-style: solid; }
.unit-photo-label { font-size: 12px; font-weight: 600; color: var(--text-2); text-align: center; }
.unit-photo-remove {
  position: absolute; top: 5px; right: 5px; display: none; place-items: center; width: 24px; height: 24px;
  border: 0; border-radius: 50%; background: rgba(11, 12, 14, .7); color: #fff;
}
.unit-photo-slot.has-photo .unit-photo-remove { display: grid; }
@media (max-width: 640px) { .unit-photos { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.unit-gallery { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.unit-gallery figure { margin: 0; display: grid; gap: 6px; }
.unit-gallery .photo { aspect-ratio: 4 / 3; }
.unit-gallery figcaption { font-size: 12.5px; font-weight: 600; color: var(--text-2); text-align: center; }
@media (max-width: 760px) { .unit-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Reportes */
.is-dim { opacity: .45; transition: opacity .2s; }
.columns { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; height: 190px; align-items: end; padding-top: 8px; }
.col { display: grid; grid-template-rows: 1fr 18px; height: 100%; align-items: end; }
.col-stack { display: flex; flex-direction: column; min-height: 2px; border-radius: 3px 3px 1px 1px; overflow: hidden; background: var(--surface-3); transition: height .6s var(--ease-out); }
.col-stack i.ok { background: var(--ok); }
.col-stack i.bad { background: var(--signal); }
.legend .l-bad { --c: var(--signal); }
.col:hover .col-stack { filter: brightness(1.12); }
.col-label { font-size: 10px; color: var(--text-3); text-align: center; padding-top: 4px; }
.hbars { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.hbars li { display: grid; grid-template-columns: minmax(110px, 38%) 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.hbar-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { height: 10px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.hbar-track i { display: block; height: 100%; border-radius: inherit; background: var(--text); animation: grow .8s var(--ease-out) both; transform-origin: left; }
.hbars li:first-child .hbar-track i { background: var(--signal); }
@keyframes grow { from { transform: scaleX(0); } }
.hbar-value { font-size: 13px; font-weight: 600; min-width: 30px; text-align: right; }
.hbar-value small { color: var(--text-3); font-weight: 400; }

/* Ajustes */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
.table tr:first-child td { border-top: 0; }
.row-pending td { background: var(--warn-bg); }
@media (max-width: 640px) { .hide-sm { display: none; } .table td, .table th { padding: 10px 12px; } }
.cl-admin { margin-top: 22px; }
.cl-admin h3 { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 8px; display: flex; gap: 10px; align-items: baseline; }
.cl-admin h3 small { text-transform: none; letter-spacing: 0; font-weight: 500; }
.cl-admin ul { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); }
.cl-admin li { display: flex; align-items: center; gap: 14px; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); }
.cl-admin li:first-child { border-top: 0; }
.cl-admin li.inactive .cl-label { color: var(--text-3); text-decoration: line-through; }
.cl-label { flex: 1; font-size: 14.5px; }
.toggle-crit { font-size: 13px; color: var(--text-2); }
@media (max-width: 560px) { .cl-admin li { flex-wrap: wrap; } .cl-label { flex-basis: 100%; } }

/* ==========================================================================
   Modal y toasts
   ========================================================================== */
#modal-root { position: relative; z-index: 60; }
.modal-backdrop {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: rgba(11, 12, 14, .55); backdrop-filter: blur(3px);
  animation: fadeIn .2s ease both;
}
.modal-backdrop.out { animation: fadeOut .16s ease both; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes fadeOut { to { opacity: 0; } }
.modal {
  width: min(480px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--surface); color: var(--text); border-radius: var(--r-xl); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5);
  animation: modalIn .35s var(--ease-out) both;
}
.modal-wide { width: min(680px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 18px 4px 22px; }
.modal-head h2 { font-family: var(--font-display); font-stretch: 75%; font-weight: 800; font-size: 24px; text-transform: uppercase; line-height: 1.1; }
.modal-body { padding: 12px 22px 4px; }
.modal-body > .field:last-child { margin-bottom: 8px; }
.modal-text { color: var(--text-2); margin-bottom: 16px; }
.modal .form-error { margin: 0 22px 8px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; }
@media (max-width: 560px) {
  .modal-backdrop { place-items: end stretch; padding: 0; }
  .modal { width: 100%; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 92vh; padding-bottom: env(safe-area-inset-bottom); animation-name: sheetIn; }
  @keyframes sheetIn { from { transform: translateY(100%); } }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .modal-foot .btn { flex: 1; }
}
.photo-field { position: relative; display: grid; place-items: center; height: 120px; border-radius: var(--r-m); border: 1.5px dashed var(--line-strong); color: var(--text-2); cursor: pointer; overflow: hidden; }
.photo-field-empty { display: grid; justify-items: center; gap: 4px; font-size: 13px; font-weight: 600; }
.photo-field img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.photo-field.has-photo .photo-field-empty { display: none; }

.toasts { position: fixed; z-index: 80; left: 50%; bottom: 24px; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; width: min(420px, calc(100% - 32px)); }
@media (max-width: 900px) { .toasts { bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom)); } }
.toast {
  padding: 12px 18px; border-radius: 99px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-2);
  background: var(--graphite-900); color: var(--bone-100); animation: toastIn .35s var(--ease-out) both;
}
.toast.tone-ok { background: var(--ok); color: #fff; }
.toast.tone-bad { background: var(--bad); color: #fff; }
.toast.out { animation: toastOut .35s ease both; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   Acceso
   ========================================================================== */
.login { display: grid; grid-template-columns: minmax(320px, 44%) 1fr; min-height: 100vh; }
.login-brand {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; padding: 36px 40px; overflow: hidden; isolation: isolate;
  background: var(--graphite-950); color: var(--bone-100);
}
.login-brand::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(to top, var(--graphite-950) 5%, transparent 60%),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(255,255,255,.04) 79px 80px),
    repeating-linear-gradient(0deg, transparent 0 79px, rgba(255,255,255,.04) 79px 80px),
    radial-gradient(90% 60% at 10% 100%, rgba(181, 82, 79, .38), transparent 70%);
}
.login-brand a { text-decoration: none; }
.login-brand .eyebrow { color: var(--signal); }
.login-title { font-family: var(--font-display); font-stretch: 65%; font-weight: 900; font-size: clamp(56px, 8.4vw, 118px); line-height: .86; text-transform: uppercase; letter-spacing: -.01em; }
.login-title em { font-style: normal; color: var(--signal); }
.login-foot { font-family: var(--font-mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--graphite-400); }
.login-panel { display: grid; place-items: center; padding: 40px 24px; }
.login-box { width: min(440px, 100%); }
.login-box h2 { font-family: var(--font-display); font-stretch: 75%; font-weight: 800; font-size: 34px; text-transform: uppercase; line-height: 1; margin-bottom: 10px; }
.login-box > .muted { margin-bottom: 24px; }
.login-box .link-btn { display: block; margin: 16px auto 0; }
.demo-accounts { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.demo-accounts summary { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-2); list-style: none; }
.demo-accounts summary::-webkit-details-marker { display: none; }
.demo-accounts summary::after { content: '▾'; margin-left: auto; transition: transform .15s; }
.demo-accounts[open] summary::after { transform: rotate(180deg); }
.demo-accounts > .muted { margin: 12px 0; font-size: 13.5px; }
.demo-roles { display: grid; gap: 10px; }
.demo-role { padding: 14px; border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); }
.demo-role-head { display: grid; margin-bottom: 10px; }
.demo-role-head b { font-size: 15px; }
.demo-role-head small { color: var(--text-2); font-size: 13px; }
.demo-people { display: flex; flex-wrap: wrap; gap: 6px; }
.demo-person { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface-2); font-size: 13.5px; font-weight: 600; transition: background .15s, border-color .15s, color .15s; }
.demo-person:hover { background: var(--signal); border-color: var(--signal); color: var(--signal-ink); }
@media (max-width: 860px) {
  .login { grid-template-columns: 1fr; }
  .login-brand { padding: 24px 20px 28px; gap: 28px; }
  .login-title { font-size: 64px; }
  .login-foot { display: none; }
  .login-panel { place-items: start center; padding: 28px 16px 40px; }
}

/* ==========================================================================
   App de viajes: tablas tipo hoja de cálculo, formulario por secciones y avisos.
   ========================================================================== */
.view { max-width: calc(1640px + var(--sidebar-w)); }

.board-hello { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.board-hello .display { text-transform: uppercase; }
.board-hello .page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi-sub a { color: inherit; }

/* Tabla tipo Excel con desplazamiento horizontal propio (la página no se desborda). */
.sheet-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-l); box-shadow: var(--shadow-1); -webkit-overflow-scrolling: touch; }
.sheet { width: 100%; border-collapse: collapse; font-size: 13.5px; white-space: nowrap; }
.sheet th { position: sticky; top: 0; z-index: 1; background: var(--surface-3); color: var(--text-2); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line-strong); }
.sheet td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sheet tbody tr:last-child td { border-bottom: 0; }
/* La primera columna (económico / ID) se queda fija al desplazar la tabla. */
.sheet th:first-child, .sheet td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.sheet th:first-child { z-index: 2; background: var(--surface-3); }
.sheet a { color: inherit; text-decoration: none; }
.sheet a:hover { color: var(--signal-fg); text-decoration: underline; }
.sheet td.clip { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.sheet td.late { color: var(--bad-fg); font-weight: 700; }
.sheet .select-sm { min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.sheet td > .empty { border: 0; white-space: normal; }
.sheet-log tbody tr { cursor: pointer; }
.sheet-log tbody tr:hover td { background: var(--surface-2); }

/* Colores de renglón: verde = entregado (como en el Excel), amarillo = devolución. */
.log-ok td { background: color-mix(in srgb, var(--ok) 9%, transparent); }
.log-devol td { background: color-mix(in srgb, var(--warn) 14%, transparent); }
.log-cancel td { color: var(--text-3); }
.obs { font-size: 12px; letter-spacing: .02em; }
.tone-row-info td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.tone-row-signal td:first-child { box-shadow: inset 3px 0 0 var(--signal); }
.tone-row-warn td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.tone-row-neutral td:first-child { box-shadow: inset 3px 0 0 var(--line-strong); }
tr.is-late td { background: color-mix(in srgb, var(--bad) 6%, transparent); }
.row-idle td { color: var(--text-2); }
.state-contenedores td { background: color-mix(in srgb, var(--warn) 12%, transparent); }
.state-dedicado td { background: color-mix(in srgb, var(--info) 10%, transparent); }
.row-idle .link-btn { padding: 0; font-weight: 500; color: inherit; }

.only-narrow { display: none; }
@media (max-width: 760px) {
  .only-wide { display: none; }
  .only-narrow { display: block; }
}
.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; }

/* Formulario del viaje */
.trip-form { display: grid; gap: 16px; max-width: 860px; }
.field[hidden], .check[hidden] { display: none; }
.folio-line { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.folio-line b { font-size: 22px; color: var(--signal-fg); }
.div-filter { margin-bottom: 14px; }
.div-filter small { font-family: var(--font-mono); opacity: .7; }
.row.is-off { opacity: .55; }

/* Operadores */
.form-sub { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; margin: 8px 0 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.form-sub .i { color: var(--signal); }
.cert-box { margin-bottom: 8px; }
.cert-box .form-grid { margin-top: 10px; }
.cert-box .form-grid[hidden] { display: none; }
.exp { font-family: var(--font-mono); font-size: 13px; }
.exp-vencido { color: var(--bad-fg); font-weight: 700; }
.exp-por_vencer { color: var(--warn-fg); font-weight: 700; }
[data-opinfo] { display: block; margin-top: 4px; }
.form-section h2 { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.form-section h2 .i { color: var(--signal); }
.form-section .field { margin-bottom: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.field-warn { color: var(--warn-fg); font-size: 12.5px; font-weight: 600; }
.field > span small { font-weight: 500; }
.seg-wrap { display: flex; flex-wrap: wrap; max-width: none; }
.seg-wrap label { flex: 1 1 auto; }

/* Detalle del viaje */
.trip-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 6px; }
.btn-danger-text { color: var(--bad-fg); }
.facts-list { grid-template-columns: 1fr; }
.remision { margin-top: 10px; word-break: break-all; }
.trip-notes { margin-top: 12px; padding: 12px 14px; border-radius: var(--r-m); background: var(--surface-3); white-space: pre-line; font-size: 14px; }
.ev-note { font-size: 14px; color: var(--text); }
.timeline li.ev-cancelado::before { background: var(--bad); border-color: var(--bad); }
.timeline li.ev-entrega::before { background: var(--ok); border-color: var(--ok); }
.timeline li.ev-nota::before { background: var(--surface); border-color: var(--text-3); }

/* ==========================================================================
   Impresión / PDF
   ========================================================================== */
@media print {
  :root { --bg: #fff; --surface: #fff; --line: #ddd; --text: #111; --text-2: #444; --text-3: #666; color-scheme: light; }
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11.5pt; }
  .sidebar, .topbar, .tabbar, .demo-bar, .page-actions, .back, .no-print, .toasts, #modal-root { display: none !important; }
  .view { margin: 0; padding: 0; max-width: none; }
  .view-inner { animation: none; }
  .print-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding-bottom: 12px; margin-bottom: 18px; border-bottom: 2px solid #111; }
  .print-head > div { display: grid; text-align: right; }
  .print-head span { font-size: 9pt; color: #555; }
  .rows, .facts, .card, .checklist, .fail-card, .decision, .kpi { box-shadow: none !important; break-inside: avoid; }
  .block { margin-top: 18px; }
  .cl-section ul { grid-template-columns: 1fr 1fr; }
  .badge { border: 1px solid currentColor; }
  a { text-decoration: none; }
}
