:root {
  --bg: #f1f4f8;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #0f172a;
  --muted: #5b6475;
  --line: #d8dee7;
  --brand: #1e3a5f;
  --brand-ink: #ffffff;
  --accent: #2563eb;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --obs: #b45309;
  --obs-bg: #fef3c7;
  --crit: #b91c1c;
  --crit-bg: #fee2e2;
  --none: #cbd5e1;
  --truck: #e2e8f0;
  --axle: #64748b;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(15 23 42 / 0.06), 0 2px 8px rgb(15 23 42 / 0.05);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --surface: #131c2e;
    --surface-2: #18233a;
    --ink: #e5eaf2;
    --muted: #9aa6b8;
    --line: #2a3650;
    --brand: #16304f;
    --accent: #60a5fa;
    --ok: #4ade80;
    --ok-bg: #12321f;
    --obs: #fbbf24;
    --obs-bg: #3a2c0c;
    --crit: #f87171;
    --crit-bg: #3d1414;
    --none: #475569;
    --truck: #1f2a40;
    --axle: #94a3b8;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
.loading { padding: 40px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Barra superior y pestañas */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  min-height: 56px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--brand); color: var(--brand-ink);
}
.topbar h1 { flex: 1; font-size: 1.1rem; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .actions { display: flex; gap: 4px; }
.logo { width: 32px; height: 32px; border-radius: 8px; }
.icon-btn {
  min-width: 44px; height: 44px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; color: inherit;
  font-size: 1.2rem; cursor: pointer;
}
.icon-btn.text { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; }
.icon-btn:hover { background: rgb(255 255 255 / 0.12); }

.tabs {
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 19;
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  padding: 8px 12px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.tab {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  min-height: 40px; padding: 0 12px; border: 1px solid transparent; border-radius: 999px;
  background: transparent; cursor: pointer; font-size: 0.92rem; color: var(--muted);
}
.tab.active { background: var(--brand); color: var(--brand-ink); }
.tab-num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted); font-size: 0.75rem; font-weight: 700;
}
.tab.complete .tab-num { background: var(--ok-bg); color: var(--ok); }
.tab.active .tab-num { background: rgb(255 255 255 / 0.2); color: #fff; }

/* Página */
.page { max-width: 720px; margin: 0 auto; padding: 16px; }
.page-wide { max-width: 1200px; }
.section-title { font-size: 1.25rem; margin: 4px 0 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.stack { display: grid; gap: 10px; margin-top: 16px; }
.grid3 { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn.danger-outline { color: var(--crit); border-color: var(--crit); background: transparent; margin-top: 18px; }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 0.9rem; }
.link { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Campos */
fieldset.fields { border: 0; margin: 0; padding: 0; min-width: 0; }
.field { display: block; margin-bottom: 18px; }
.label { display: block; font-weight: 600; margin-bottom: 6px; }
.req { color: var(--crit); }
input[type=text], input[type=date], input[type=time], input[type=datetime-local], input[type=email], input[type=tel], textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface);
  font-size: 16px;
}
textarea { resize: vertical; }
input:focus, textarea:focus { border-color: var(--accent); outline: 2px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.field.missing .label { color: var(--crit); }
.field.missing input, .field.missing textarea, .field.missing .chips, .field.missing .sigpad { border-color: var(--crit); }
.field.missing .chips { border: 1px dashed var(--crit); border-radius: 12px; padding: 4px; }
.hint { margin: 6px 0 0; font-size: 0.85rem; color: var(--muted); }
.suggest {
  margin: 8px 0 0; padding: 8px 10px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface)); font-size: 0.9rem;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 0.95rem;
}
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip:disabled { cursor: default; }
fieldset:disabled .chip:not(.on) { opacity: 0.55; }

.switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.switch input { width: 22px; height: 22px; accent-color: var(--accent); }

/* Fotos y firmas */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 96px; height: 96px; }
.thumb-open { width: 100%; height: 100%; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; cursor: zoom-in; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
  position: absolute; top: -8px; right: -8px; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--crit); color: #fff; font-size: 0.8rem; cursor: pointer;
}
.sigpad {
  display: block; width: 100%; height: 170px; touch-action: none;
  border: 2px dashed var(--line); border-radius: 12px; background: #fff;
}
.sig-img { display: block; max-width: 100%; height: 120px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.sig .row { justify-content: space-between; margin-top: 6px; }

.viewer {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: rgb(0 0 0 / 0.88); padding: 16px; cursor: zoom-out;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); right: 10px; color: #fff; }

/* Avisos */
.notice {
  padding: 10px 12px; margin: 0 0 14px; border-radius: 10px;
  background: var(--obs-bg); color: var(--ink); border: 1px solid color-mix(in srgb, var(--obs) 40%, transparent);
}
.recs { margin-bottom: 18px; padding: 10px 12px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); }
.recs summary { font-weight: 600; cursor: pointer; }
.recs p { margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }

/* Estados */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-obs { background: var(--obs-bg); color: var(--obs); }
.b-crit { background: var(--crit-bg); color: var(--crit); }
.tag { font-size: 0.75rem; color: var(--muted); white-space: nowrap; }
.tag-done { color: var(--ok); }
.tag-error { color: var(--crit); font-weight: 600; }
.tag-pending { color: var(--obs); }
.equip-state { display: grid; gap: 6px; justify-items: start; }
.equip-state .badge { font-size: 0.95rem; padding: 6px 14px; }

/* Lista */
.cards { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.card {
  width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left;
  padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
}
.card:hover { border-color: var(--accent); }
.card-main { display: grid; gap: 2px; min-width: 0; }
.card-main strong { font-size: 1.1rem; letter-spacing: 0.03em; }
.card-side { display: grid; gap: 4px; justify-items: end; align-content: start; }
.empty { text-align: center; padding: 40px 12px; }

.card-block { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
.card-block h2 { font-size: 1.05rem; margin-bottom: 10px; }
.provider { padding: 10px 0; border-top: 1px solid var(--line); }
.provider:first-of-type { border-top: 0; }
.provider p { margin: 2px 0 8px 32px; }
.provider .btn { margin-left: 32px; }

/* Colores de estado (verde, ámbar, rojo, azul, morado, gris) */
:root { --c-green: #15803d; --c-amber: #d97706; --c-red: #dc2626; --c-blue: #2563eb; --c-purple: #7c3aed; --c-gray: #64748b; }
.b-green { background: var(--ok-bg); color: var(--ok); }
.b-amber { background: var(--obs-bg); color: var(--obs); }
.b-red { background: var(--crit-bg); color: var(--crit); }
.b-blue { background: color-mix(in srgb, var(--c-blue) 15%, var(--surface)); color: var(--c-blue); }
.b-purple { background: color-mix(in srgb, var(--c-purple) 15%, var(--surface)); color: var(--c-purple); }
.b-gray { background: var(--surface-2); color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; background: var(--none); }
.c-green { --c: var(--c-green); } .c-amber { --c: var(--c-amber); } .c-red { --c: var(--c-red); }
.c-blue { --c: var(--c-blue); } .c-purple { --c: var(--c-purple); } .c-gray { --c: var(--c-gray); } .c-none { --c: var(--none); }
.dot[class*="c-"] { background: var(--c); }
.r-green { color: var(--ok); } .r-amber { color: var(--obs); } .r-red { color: var(--crit); font-weight: 600; } .r-blue, .r-purple, .r-gray { color: var(--muted); }

/* Campos de llenado */
.f-heading { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 26px 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.f-info { padding: 10px 12px; margin-bottom: 18px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 0.92rem; }
.f-info p { margin: 4px 0 0; color: var(--muted); white-space: pre-wrap; }
.f-image { margin: 0 0 18px; }
.f-image img { max-width: 100%; border-radius: 10px; display: block; }
.f-image figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.with-unit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.with-unit > input, .with-unit > .calc { flex: 1; min-width: 140px; }
.unit { color: var(--muted); font-weight: 600; min-width: 2.5em; }
.warn { margin: 6px 0 0; color: var(--crit); font-size: 0.85rem; font-weight: 600; }
.warn:empty { display: none; }
select { width: 100%; min-height: 48px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; }
.calc { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-height: 48px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line); font-weight: 600; }
.stopwatch { font-variant-numeric: tabular-nums; font-size: 1.2rem; }
.rating { display: flex; gap: 4px; flex-wrap: wrap; }
.star { width: 46px; height: 46px; border: 0; background: none; font-size: 2rem; color: var(--none); cursor: pointer; line-height: 1; }
.star.on { color: #f59e0b; }
.rating.faces .star { filter: grayscale(1); opacity: 0.45; }
.rating.faces .star.on { filter: none; opacity: 1; transform: scale(1.15); }
.slider { display: flex; align-items: center; gap: 12px; }
.slider input { flex: 1; accent-color: var(--accent); }
.slider-val { min-width: 4em; font-weight: 700; text-align: right; }
.quick { margin-bottom: 16px; }
.drawpad { height: auto; aspect-ratio: 4 / 3; background-size: contain; background-repeat: no-repeat; background-position: center; }
.draw-img { display: block; max-width: 100%; max-height: 360px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #fff; }
.sig .chips { margin-bottom: 8px; }
.thumb.file { width: 150px; }
.thumb.file .thumb-open { display: grid; place-items: center; gap: 4px; padding: 6px; font-size: 0.75rem; }
.file-icon { font-size: 1.8rem; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.status-box { padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.status-box.s-green { border-color: var(--ok); }
.status-box.s-amber { border-color: var(--obs); background: var(--obs-bg); }
.status-box.s-red { border-color: var(--crit); background: var(--crit-bg); }
.status-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-weight: 600; }
.status-box .badge { font-size: 0.9rem; padding: 5px 12px; }
.reasons { margin: 8px 0 0; padding-left: 20px; font-size: 0.92rem; }
.override { margin-top: 8px; font-size: 0.9rem; }
.override summary { cursor: pointer; color: var(--muted); }
.override .chips { margin-top: 8px; }
.search-list { list-style: none; padding: 0; margin: 10px 0 0; max-height: 50vh; overflow: auto; display: grid; gap: 6px; }
.search-row { width: 100%; text-align: left; display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.search-row:hover { border-color: var(--accent); }

/* Subformularios */
.items { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.item-card { width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; }
.item-card.sel, .item-card:hover { border-color: var(--accent); }
.item-num { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); font-weight: 700; font-size: 0.85rem; }
.item-label { flex: 1; font-weight: 600; }

/* Mapa de posiciones */
.diagram-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.layout-chips { margin-bottom: 12px; }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.progress-bar { height: 100%; background: var(--ok); transition: width 0.3s; }
.truck { display: block; width: 100%; max-width: 330px; margin: 8px auto; user-select: none; }
.truck .shape.cab, .truck .shape.chassis { fill: var(--none); }
.truck .shape.trailer { fill: var(--truck); stroke: var(--line); }
.truck .shape.axle { fill: var(--axle); }
.truck .dlabel { fill: var(--muted); font-family: inherit; }
.truck .dlabel.bold { font-weight: 700; fill: var(--ink); }
.truck .tire { cursor: pointer; outline: none; }
.truck .tire rect { fill: var(--c, var(--none)); stroke: #334155; stroke-width: 1.2; transition: fill 0.15s; }
.truck .tire .glyph { fill: #fff; font-size: 16px; font-weight: 800; pointer-events: none; }
.truck .tire.sel rect { stroke: var(--accent); stroke-width: 4; }
.truck .tire:hover rect, .truck .tire:focus-visible rect { stroke: var(--accent); stroke-width: 3; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; padding: 0; margin: 4px 0 12px; font-size: 0.85rem; }

/* Panel de un elemento (posición o elemento de subformulario) */
.drawer {
  position: fixed; inset: 0; z-index: 40; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); padding: 16px; padding-top: calc(16px + env(safe-area-inset-top));
}
body.panel-open { overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 12px; }
.panel-head h3 { font-size: 1.5rem; letter-spacing: 0.02em; }
.panel-head p { margin: 2px 0 0; }
.history { margin: 0 0 12px; padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 0.88rem; }
.panel-nav {
  position: sticky; bottom: calc(-16px - env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin: 16px -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.panel-nav .btn { padding: 0 8px; }
@media (min-width: 1000px) {
  .drawer { left: auto; width: min(560px, 46vw); top: 0; border-left: 1px solid var(--line); box-shadow: -8px 0 24px rgb(15 23 42 / 0.12); }
  body.panel-open { overflow: auto; }
  body.panel-open .page { margin-right: max(16px, calc(min(560px, 46vw) + 16px)); margin-left: max(16px, calc((100vw - min(560px, 46vw) - 720px) / 2)); }
}

/* Pantalla de inicio */
.form-cards { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 12px; }
.form-card { background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--fc, var(--c-blue)); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.fc-green { --fc: var(--c-green); } .fc-amber { --fc: var(--c-amber); } .fc-red { --fc: var(--c-red); } .fc-blue { --fc: var(--c-blue); } .fc-purple { --fc: var(--c-purple); } .fc-gray { --fc: var(--c-gray); }
.form-card-main { width: 100%; display: grid; gap: 4px; padding: 14px 14px 8px; text-align: left; border: 0; background: none; cursor: pointer; }
.form-card-main strong { font-size: 1.1rem; }
.form-card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 14px; }
.form-card-actions .btn { flex: 1; min-width: 100px; }
.page > .row input[type=search] { flex: 1; min-width: 160px; }
input[type=search] { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 16px; }

/* Constructor */
.btn.light { background: rgb(255 255 255 / 0.14); border-color: rgb(255 255 255 / 0.3); color: #fff; }
.builder { display: grid; gap: 16px; padding: 16px; max-width: 1500px; margin: 0 auto; }
@media (min-width: 1000px) {
  .builder { grid-template-columns: 250px minmax(0, 1fr) 380px; align-items: start; }
  .b-palette, .b-props { position: sticky; top: 72px; max-height: calc(100vh - 88px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
  body:has(.builder) { padding-bottom: 16px; }
}
.b-palette h2 { font-size: 1rem; margin-bottom: 8px; }
.pal-group h3 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 14px 0 6px; }
.pal-grid { display: grid; gap: 6px; }
.sheet .pal-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.pal-btn { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); text-align: left; cursor: pointer; font-size: 0.9rem; }
.pal-btn:hover { border-color: var(--accent); }
.pal-icon { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface-2); font-size: 0.95rem; font-weight: 700; flex: 0 0 auto; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 12px; font-size: 0.95rem; }
.b-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.b-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.b-row.sel { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.b-row.page-row { background: var(--brand); color: #fff; margin-top: 10px; }
.b-row.page-row .b-row-type { color: rgb(255 255 255 / 0.75); }
.b-row.page-row .pal-icon { background: rgb(255 255 255 / 0.15); }
.drag { width: 32px; min-height: 40px; border: 0; background: none; color: var(--muted); cursor: grab; font-size: 1.1rem; touch-action: none; }
.page-row .drag { color: rgb(255 255 255 / 0.8); }
.b-row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; min-height: 44px; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.b-row-text { display: grid; min-width: 0; }
.b-row-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-row-type { font-size: 0.78rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-row-actions { display: flex; gap: 2px; width: 100%; justify-content: flex-end; }
.icon-btn.sm { min-width: 36px; height: 36px; font-size: 1rem; color: var(--ink); }
.icon-btn.sm:hover { background: var(--surface-2); }
.icon-btn.danger { color: var(--crit); }
.sortable-ghost { opacity: 0.4; }
.props-title { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 1.05rem; }
.props-sub { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 0 8px; }
.b-props-body .field { margin-bottom: 14px; }
.b-props-body .label { font-size: 0.9rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 0.92rem; }
.hint.ok { color: var(--ok); } .hint.err { color: var(--crit); font-weight: 600; }
.checklist { display: grid; gap: 2px; }
.checklist .switch { font-weight: 400; min-height: 36px; }
.cond { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.cond select, .cond input { min-height: 40px; padding: 6px 8px; font-size: 0.9rem; }
.when .inline { display: block; margin-bottom: 8px; font-size: 0.9rem; }
.when .inline select { width: auto; min-height: 36px; padding: 4px 8px; display: inline-block; }
.rule-card { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; background: var(--surface-2); }
.rule-card > .row { margin: 0; flex-wrap: nowrap; align-items: flex-end; }
.rule-card > .row .field { flex: 1; margin: 0; }
.level-row { display: grid; grid-template-columns: auto 1fr 90px 1fr auto; gap: 6px; align-items: center; margin-bottom: 6px; }
.level-row input, .level-row select { min-height: 40px; padding: 6px 8px; font-size: 0.9rem; }
.small-chips .chip { min-height: 32px; padding: 0 10px; font-size: 0.82rem; font-family: ui-monospace, Consolas, monospace; }
.prop-img { max-width: 100%; max-height: 140px; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 6px; }
.fab { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 30; min-height: 54px; padding: 0 20px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-weight: 700; font-size: 1rem; box-shadow: 0 8px 20px rgb(37 99 235 / 0.35); cursor: pointer; }
.sheet { position: fixed; inset: 0; z-index: 60; overflow-y: auto; background: var(--bg); padding: 0 16px 40px; }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: calc(12px + env(safe-area-inset-top)) 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 12px; }
body.sheet-open { overflow: hidden; }
@media (max-width: 999px) { .cond { grid-template-columns: 1fr 1fr; } .level-row { grid-template-columns: auto 1fr 1fr auto; } .level-row input:nth-of-type(2) { grid-column: 2 / 4; } }

/* Listas */
.grid-wrap { overflow-x: auto; margin-top: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.grid { border-collapse: collapse; min-width: 100%; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 4px; vertical-align: middle; }
.grid th { background: var(--surface-2); }
.grid th { white-space: nowrap; }
.grid th input { font-weight: 700; display: inline-block; width: calc(100% - 40px); min-width: 120px; }
.grid input { min-height: 40px; padding: 6px 8px; min-width: 120px; }

/* Escáner */
.scanner { position: fixed; inset: 0; z-index: 130; display: grid; place-items: center; align-content: center; gap: 16px; background: #000; color: #fff; padding: 16px; }
.scanner video { width: 100%; max-width: 520px; border-radius: 12px; }
.scan-frame { position: absolute; width: min(70vw, 360px); height: min(40vw, 200px); border: 3px solid #4ade80; border-radius: 12px; pointer-events: none; }
.modal-wide { max-width: 640px; }

/* Barra inferior */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-between; gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-top: 1px solid var(--line);
}
.bottombar .btn { flex: 1; max-width: 260px; }

/* Final */
.done-card {
  display: grid; justify-items: center; gap: 8px; text-align: center;
  padding: 24px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.done-icon { width: 64px; height: 64px; display: grid; place-items: center; border-radius: 50%; background: var(--ok-bg); color: var(--ok); font-size: 2rem; font-weight: 800; }
.done-card h2 { font-size: 1.6rem; letter-spacing: 0.04em; }
.done-card p { margin: 0; }

/* Modales y avisos */
.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 16px; background: rgb(15 23 42 / 0.55); }
.modal { width: 100%; max-width: 440px; max-height: 85vh; overflow: auto; padding: 20px; border-radius: 16px; background: var(--surface); box-shadow: 0 20px 50px rgb(0 0 0 / 0.3); }
.modal h3 { margin-bottom: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.errlist { padding-left: 18px; margin: 0; display: grid; gap: 4px; }
.spinner { width: 28px; height: 28px; margin: 12px auto 0; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 120;
  max-width: calc(100% - 32px); padding: 12px 16px; border-radius: 12px;
  background: #0f172a; color: #fff; box-shadow: 0 8px 24px rgb(0 0 0 / 0.3); font-size: 0.95rem;
}
/* Estados de registros (bandeja) */
.state { display: inline-flex; align-items: center; gap: 2px; padding: 3px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.st-draft { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--line); }
.st-pending { background: var(--obs-bg); color: var(--obs); }
.st-sending { background: color-mix(in srgb, var(--c-blue) 15%, var(--surface)); color: var(--c-blue); animation: pulse 1.2s ease-in-out infinite; }
.st-sent, .st-done { background: var(--ok-bg); color: var(--ok); }
.st-error { background: var(--crit-bg); color: var(--crit); }
@keyframes pulse { 50% { opacity: 0.55; } }
.state-counts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.notice-error { background: var(--crit-bg); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.err-text { color: var(--crit); }
.filters { margin: 14px 0 4px; }
.filters .chip { min-height: 38px; font-size: 0.88rem; }
.rec-item { display: flex; align-items: stretch; gap: 6px; }
.rec-item .card { flex: 1; min-width: 0; }
.rec-item.sel .card { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.rec-check { display: grid; place-items: center; padding: 0 4px; }
.rec-check input { width: 22px; height: 22px; accent-color: var(--accent); }
.rec-menu { align-self: center; }
.select-bar:empty { display: none; }
.select-bar { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin: 8px 0; border-radius: 12px; background: var(--surface); border: 1px solid var(--accent); box-shadow: var(--shadow); }
.select-bar .switch { flex: 1; min-height: 36px; }
.form-card-top { display: flex; align-items: flex-start; }
.form-card-top .form-card-main { flex: 1; }
.form-card-top .icon-btn { margin: 8px 8px 0 0; }
.sync-banner {
  position: fixed; left: 50%; top: calc(64px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 70;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 24px); padding: 10px 16px; border-radius: 999px;
  background: #1e3a5f; color: #fff; box-shadow: 0 8px 24px rgb(0 0 0 / 0.25); font-size: 0.9rem;
}
.sync-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spinner.sm { width: 18px; height: 18px; margin: 0; border-width: 2px; border-color: rgb(255 255 255 / 0.3); border-top-color: #fff; flex: 0 0 auto; }

/* Lista con buscador */
.chip.static { display: inline-flex; align-items: center; gap: 6px; cursor: default; min-height: 38px; }
.chip-x { border: 0; background: rgb(255 255 255 / 0.25); color: inherit; width: 22px; height: 22px; border-radius: 50%; cursor: pointer; font-size: 0.75rem; }
.search-row.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); font-weight: 600; }
.row.tight { margin: 6px 0 0; gap: 6px; }
.serial { color: var(--muted); font-weight: 600; font-size: 0.9em; }
.counter { text-align: right; }

/* Estadísticas */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.tile { display: grid; gap: 2px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tile-label { font-size: 0.8rem; color: var(--muted); }
.tile-value { font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 0.78rem; color: var(--muted); }
.charts { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.chart-card { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.chart-card h2 { font-size: 1rem; margin-bottom: 12px; }
.chart-card select { margin-bottom: 10px; }
.hbars { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.hbars li { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; gap: 8px; align-items: center; font-size: 0.86rem; }
.hb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.hb-track { height: 14px; }
.hb-bar { display: block; height: 100%; border-radius: 0 4px 4px 0; background: var(--c, var(--accent)); }
.hb-val { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 2ch; text-align: right; }
.vbars { display: flex; align-items: flex-end; gap: 2px; height: 170px; padding-top: 16px; border-bottom: 1px solid var(--line); }
.vb { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; position: relative; }
.vb-bar { width: 70%; max-width: 34px; background: var(--accent); border-radius: 4px 4px 0 0; }
.vb:hover .vb-bar { filter: brightness(1.15); }
.vb-val { font-size: 0.75rem; color: var(--muted); }
.vb-label { position: absolute; bottom: -20px; font-size: 0.68rem; color: var(--muted); white-space: nowrap; }
.chart-table { margin-top: 26px; font-size: 0.85rem; }
.chart-table summary { cursor: pointer; color: var(--muted); }
.chart-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.chart-table td { padding: 4px 8px; }
.due-card { margin-bottom: 14px; padding: 14px; border: 1px solid color-mix(in srgb, var(--obs) 40%, transparent); background: var(--obs-bg); border-radius: var(--radius); }
.due-card h2 { font-size: 1rem; margin-bottom: 8px; }
.due-card ul { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.due-card li { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.task-actions { display: flex; flex-direction: column; gap: 4px; justify-content: center; }
.small-title { font-size: 1rem; margin-top: 18px; }
.field.compact { margin-bottom: 8px; }
.qr-preview { display: grid; justify-items: center; gap: 4px; margin-top: 16px; padding: 16px; border: 1px dashed var(--line); border-radius: var(--radius); background: #fff; color: #111; }
.qr-img { width: 220px; height: 220px; image-rendering: pixelated; }
.versions { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.versions li { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 0.88rem; }

/* Pin: marcadores sobre una imagen */
.pin-board { position: relative; margin: 8px 0 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: crosshair; }
.pin-board.locked { cursor: default; }
.pin-board img { display: block; width: 100%; user-select: none; -webkit-user-drag: none; }
.pin-marker {
  position: absolute; transform: translate(-50%, -50%); display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; background: var(--c, var(--c-red));
  color: #fff; font-weight: 800; font-size: 0.95rem; box-shadow: 0 2px 8px rgb(0 0 0 / 0.35); cursor: grab; touch-action: none; user-select: none;
}
.pin-marker.sel { outline: 3px solid var(--accent); outline-offset: 2px; }
.pin-num { background: var(--c, var(--c-red)); color: #fff; }
.item-card[role=button] { user-select: none; }

/* Enviar */
.btn.whatsapp { background: #16a34a; border-color: #16a34a; color: #fff; }

/* Dibujo sobre fotos y siluetas */
.thumb-draw {
  position: absolute; bottom: -8px; right: -8px; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--accent); color: #fff; font-size: 0.85rem; cursor: pointer;
}
.thumb-open.plain { width: auto; height: auto; border: 0; background: none; padding: 0; display: block; }
.draw-start .btn { flex: 1 1 auto; }
.annotator { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; background: #0f172a; color: #fff; }
body.ann-open { overflow: hidden; }
.ann-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
.ann-head strong { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ann-head .btn:not(.primary) { background: transparent; color: #fff; border-color: rgb(255 255 255 / 0.3); }
.ann-toolbar { display: flex; gap: 10px; overflow-x: auto; padding: 6px 12px 10px; scrollbar-width: none; border-bottom: 1px solid rgb(255 255 255 / 0.12); }
.ann-group { display: flex; gap: 4px; align-items: center; padding-right: 10px; border-right: 1px solid rgb(255 255 255 / 0.15); flex: 0 0 auto; }
.ann-group:last-child { border-right: 0; }
.ann-btn { display: grid; justify-items: center; gap: 2px; min-width: 52px; min-height: 52px; padding: 4px 6px; border: 1px solid transparent; border-radius: 10px; background: rgb(255 255 255 / 0.06); color: #fff; cursor: pointer; }
.ann-btn.on { background: #2563eb; border-color: #60a5fa; }
.ann-btn:disabled { opacity: 0.35; cursor: default; }
.ann-icon { font-size: 1.25rem; line-height: 1.2; }
.ann-name { font-size: 0.68rem; opacity: 0.85; }
.ann-dot { display: block; border-radius: 50%; background: #fff; margin: 6px 0 2px; }
.ann-color { width: 36px; height: 36px; border-radius: 50%; border: 3px solid rgb(255 255 255 / 0.25); cursor: pointer; }
.ann-color.on { border-color: #fff; box-shadow: 0 0 0 3px #2563eb; }
.ann-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 10px; padding-bottom: calc(10px + env(safe-area-inset-bottom)); overflow: hidden; }
.ann-canvas { max-width: 100%; max-height: 100%; touch-action: none; background: #fff; border-radius: 6px; box-shadow: 0 8px 30px rgb(0 0 0 / 0.4); cursor: crosshair; }
.sil-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.sil-btn { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; font-size: 0.85rem; text-align: center; }
.sil-btn:hover { border-color: var(--accent); }
.sil-btn img { width: 100%; height: 120px; object-fit: contain; background: #fff; border-radius: 8px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
