:root {
  --bg: #f1f5f5; --surface: #ffffff; --ink: #0f1f2a; --muted: #55677a; --line: #d9e2e7;
  --brand: #0f766e; --brand-ink: #ffffff; --brand-soft: #d6efeb;
  --danger: #b42318; --danger-soft: #fdecea; --ok: #067647; --ok-soft: #e1f3e8; --warn: #b54708; --warn-soft: #fdefd9; --info: #1d5fa8; --info-soft: #e1edfa;
  --radius: 14px; --shadow: 0 1px 2px rgba(15, 31, 42, .06), 0 6px 18px rgba(15, 31, 42, .06);
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1418; --surface: #13232a; --ink: #e8f0f3; --muted: #9fb2bd; --line: #243a45;
    --brand: #3fd6c4; --brand-ink: #04211e; --brand-soft: #123c39;
    --danger: #ff8a7d; --danger-soft: #3b1a17; --ok: #5fd699; --ok-soft: #113424; --warn: #f5b266; --warn-soft: #3a2810; --info: #7db6f0; --info-soft: #122b45;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
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; overflow-x: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.2rem; } h3 { font-size: 1rem; margin-top: 4px; }
p { margin: 0 0 .6em; }
a { color: var(--brand); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; text-align: center; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; margin: -1px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }

.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; max-width: 720px; margin: 0 auto; background: var(--bg); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 14px 10px; background: var(--brand); color: var(--brand-ink); }
.topbar h1 { font-size: 1.1rem; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logo-dot { width: 32px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, .2); display: grid; place-items: center; font-weight: 800; }
.topbar .icon-btn { color: var(--brand-ink); }
.top-actions { display: flex; gap: 8px; }
.offline-chip { font-size: .72rem; background: rgba(0, 0, 0, .25); padding: 3px 8px; border-radius: 99px; }
.content { flex: 1; padding: 14px 14px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom)); outline: none; }
.tabs { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 720px; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); display: flex; background: var(--surface); border-top: 1px solid var(--line); z-index: 20; }
.tab { flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: .74rem; color: var(--muted); cursor: pointer; min-height: 48px; }
.tab-ico { font-size: 1.3rem; line-height: 1; }
.tab.on { color: var(--brand); font-weight: 700; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sub { color: var(--muted); font-size: .86rem; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; }
.hint { color: var(--muted); font-size: .85rem; margin: 0; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.card.hero { background: linear-gradient(135deg, var(--brand-soft), var(--surface)); }
.card.notice { display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.card.notice p { margin: 4px 0 0; }
.card.notice.warn { background: var(--warn-soft); border-color: var(--warn); }
.card.notice.ok { background: var(--ok-soft); border-color: var(--ok); }
.card.notice.danger { background: var(--danger-soft); border-color: var(--danger); }
.card.empty-card { text-align: center; }
.card.plan-card.pro { border-color: var(--ok); }
.row-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; cursor: pointer; min-height: 60px; }
.row-card.overdue { border-color: var(--danger); }
.row-card .ico, .ico { font-size: 1.6rem; width: 44px; height: 44px; display: grid; place-items: center; background: var(--brand-soft); border-radius: 12px; flex: none; }
.ico.big { width: 52px; height: 52px; font-size: 1.9rem; }
.col-end { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.chev { color: var(--muted); font-size: 1.4rem; }
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head > div:not(.ico) { flex: 1; min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }
.btn.xl { min-height: 54px; font-size: 1.05rem; width: 100%; }
.btn.wide { width: 100%; }
.danger-text { color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-row > .btn { flex: 1 1 auto; }
.btn-row.big > .btn { flex: 1 1 140px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; }

.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; background: var(--line); color: var(--ink); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); } .badge.info { background: var(--info-soft); color: var(--info); } .badge.muted { background: var(--line); color: var(--ink); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 8px 14px; min-height: 40px; cursor: pointer; font-weight: 600; font-size: .9rem; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .check span { font-weight: 600; font-size: .92rem; }
.field .req { color: var(--danger); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.err { color: var(--danger); font-size: .88rem; font-weight: 600; min-height: 0; }
input[type=text], input[type=search], input[type=tel], input[type=email], input[type=date], input[type=file], select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
textarea { resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { width: 22px; height: 22px; margin-top: 2px; flex: none; accent-color: var(--brand); }
.subform { padding: 12px; border: 1px dashed var(--line); border-radius: 12px; }
.logo-prev { max-width: 120px; max-height: 80px; border: 1px solid var(--line); border-radius: 10px; padding: 4px; background: #fff; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 1.5rem; } .stat span { font-size: .75rem; color: var(--muted); }
.stat.danger b { color: var(--danger); }
ul.ticks { list-style: none; padding: 0; margin: 8px 0 12px; } ul.ticks li::before { content: "✓ "; color: var(--ok); font-weight: 800; } ul.ticks li { padding: 3px 0; }

/* captura */
.cap-head .progress { display: flex; align-items: center; gap: 12px; margin-top: 10px; font-weight: 700; font-size: .9rem; }
.bar { flex: 1; height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; display: block; }
.bar i { display: block; height: 100%; background: var(--brand); transition: width .25s; }
.slots { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.slot { position: relative; aspect-ratio: 4 / 3; border-radius: var(--radius); overflow: hidden; border: 2px dashed var(--line); background: var(--surface); }
.slot.done { border: 2px solid var(--ok); }
.slot.optional { border-style: dotted; }
.slot-main { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: none; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 0; }
.slot-main img.photo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam { font-size: 2rem; }
.slot-label { position: relative; z-index: 1; font-weight: 700; font-size: .85rem; text-align: center; padding: 2px 8px; }
.slot.done .slot-label { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(0, 0, 0, .62); color: #fff; padding: 5px 8px; text-align: left; }
.req-tag { font-size: .68rem; color: var(--danger); font-weight: 700; text-transform: uppercase; }
.dmg-tag { position: absolute; top: 6px; right: 6px; background: var(--danger); color: #fff; border-radius: 99px; font-size: .72rem; font-weight: 800; padding: 2px 8px; z-index: 2; }
.slot-redo, .slot-del { position: absolute; top: 6px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .62); color: #fff; font-size: 1rem; cursor: pointer; z-index: 3; }
.slot-redo { left: 6px; } .slot-del { right: 6px; top: 6px; }
.slot.done .slot-del { top: 46px; }
.ref-thumb { position: absolute; bottom: 34px; right: 6px; width: 46px; height: 36px; border: 2px solid #fff; border-radius: 6px; overflow: hidden; z-index: 2; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); pointer-events: none; }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
img.photo { display: block; background: var(--line); } img.photo.missing { background: var(--danger-soft); }
.check-row { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; }
.check-row.issue { border-color: var(--danger); background: var(--danger-soft); }
.check-top { display: flex; flex-direction: column; gap: 2px; } .check-label { font-weight: 700; } .prev { font-size: .8rem; color: var(--muted); }
.segs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.seg { min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.seg.ok.on { background: var(--ok); border-color: var(--ok); color: #fff; } .seg.issue.on { background: var(--danger); border-color: var(--danger); color: #fff; } .seg.na.on { background: var(--muted); border-color: var(--muted); color: #fff; }
.sticky-cta { position: sticky; bottom: calc(var(--tabs-h) + 8px + env(safe-area-inset-bottom)); z-index: 5; }
.sticky-cta .btn { box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }

/* modales */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(8, 18, 24, .55); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92dvh; max-height: 92vh; overflow: auto; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.modal.full { height: 100%; max-height: 100%; border-radius: 0; max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px 6px; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.modal-body { padding: 8px 16px 16px; flex: 1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--surface); }
@media (min-width: 640px) { .overlay { align-items: center; } .modal { border-radius: 20px; } .modal.full { border-radius: 0; } }
.sigwrap { border: 2px solid var(--ink); border-radius: 12px; background: #fff; touch-action: none; }
.sigpad { display: block; width: 100%; height: auto; aspect-ratio: 700 / 260; touch-action: none; cursor: crosshair; }
.legal { font-size: .8rem; color: var(--muted); }
.summary { background: var(--brand-soft); }

/* visor */
.viewer { display: flex; flex-direction: column; gap: 10px; }
.viewer-stage { position: relative; width: 100%; line-height: 0; border-radius: 12px; overflow: hidden; }
.viewer-stage.editable { cursor: crosshair; }
.viewer-img { width: 100%; height: auto; display: block; border-radius: 12px; background: var(--line); }
.viewer-img.ref { opacity: .95; }
.ref-label { font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.marker { display: flex; align-items: center; justify-content: center; position: absolute; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; background: var(--danger); color: #fff; font-weight: 800; font-size: .85rem; box-shadow: 0 2px 6px rgba(0, 0, 0, .5); cursor: pointer; line-height: 1; padding: 0; }
.damage-list { margin: 0; padding-left: 22px; } .damage-list li { margin: 4px 0; }

/* detalle */
.strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.thumb { position: relative; flex: none; width: 86px; height: 66px; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: none; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.issue-list { margin: 0; padding-left: 20px; } .issue-list li { margin: 3px 0; } .issue-list li.new { color: var(--danger); }
.pairs { display: flex; flex-direction: column; gap: 14px; }
.pair-title { font-weight: 800; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); margin-bottom: 6px; }
.pair-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pair-cell { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); padding: 0; background: var(--bg); cursor: pointer; }
.pair-cell.none { display: grid; place-items: center; color: var(--muted); font-size: .85rem; cursor: default; }
.pair-cell img { width: 100%; height: 100%; object-fit: cover; }
.pair-cap { position: absolute; left: 0; bottom: 0; right: 0; background: rgba(0, 0, 0, .6); color: #fff; font-size: .72rem; font-weight: 700; padding: 3px 8px; text-align: left; }

/* QR y escáner */
.scan-video { width: 100%; border-radius: var(--radius); background: #000; max-height: 50vh; object-fit: cover; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.label { background: #fff; color: #000; border: 1px dashed #888; border-radius: 8px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; break-inside: avoid; }
.label .qr svg { width: 110px; height: 110px; display: block; }
.label-text { text-align: center; display: flex; flex-direction: column; font-size: .8rem; } .label-text strong { font-size: 1rem; }

/* toasts */
#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--tabs-h) + 14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 90; pointer-events: none; padding: 0 14px; }
.toast { pointer-events: auto; background: #12262f; color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: .92rem; box-shadow: 0 6px 20px rgba(0, 0, 0, .35); max-width: 520px; }
.toast.ok { background: var(--ok); color: #fff; } .toast.error { background: var(--danger); color: #fff; }
@media (prefers-color-scheme: dark) { .toast.ok, .toast.error { color: #04120b; } .toast.error { color: #2b0905; } }

@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; left: 0; top: 0; width: 100%; grid-template-columns: repeat(3, 1fr); gap: 6mm; }
  .label { border: 1px dashed #666; }
  .label .qr svg { width: 38mm; height: 38mm; }
  .no-print { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

.marker.ref { background: var(--warn); cursor: default; }
.ref-stage { line-height: 0; } .ref-list { font-size: .85rem; color: var(--muted); margin-top: 6px; line-height: 1.3; }

.lang-btn { border: 1px solid rgba(255,255,255,.55); background: transparent; color: var(--brand-ink); font: inherit; font-size: .72rem; font-weight: 700; letter-spacing: .04em; border-radius: 99px; padding: 4px 9px; min-height: 32px; min-width: 44px; cursor: pointer; }

/* Guía de primer uso */
.tour { display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.tour-top { display: flex; align-items: center; justify-content: space-between; }
.tour-lang { color: var(--ink); border-color: var(--line); }
.tour-ico { font-size: 4rem; text-align: center; line-height: 1.1; margin-top: 4px; }
.tour-h { margin: 0; font-size: 1.35rem; text-align: center; outline: none; }
.tour-p { margin: 0; font-size: 1.02rem; line-height: 1.5; }
.tour-dots { display: flex; justify-content: center; gap: 6px; margin: 6px 0; }
.tour-dots .dot { width: 8px; height: 8px; border-radius: 99px; background: var(--line); }
.tour-dots .dot.on { background: var(--brand); width: 22px; }
.tour-nav { display: flex; gap: 10px; justify-content: space-between; position: sticky; bottom: 0; padding-top: 8px; background: var(--surface); }
.tour-nav .btn { flex: 1; }
