/* Estilos de la app Guía de Seguridad Relacional */
/* Layout: una columna tipo "carnet" de 680px, barra superior con pasos y barra de acción inferior fija. */
:root {
  --paper: #EEF1F6;
  --surface: #FFFFFF;
  --ink: #111A2E;
  --muted: #55607A;
  --line: #D5DBE6;
  --primary: #16306B;
  --primary-ink: #FFFFFF;
  --signal: #F2B01E;
  --signal-ink: #1C1400;
  --ok: #1B7444; --ok-bg: #E3F3EA;
  --bad: #B42318; --bad-bg: #FCEAE7;
  --warn: #7A5000; --warn-bg: #FFF2D2;
  --focus: #2F6BFF;
  --sel-bg: #E7ECF8;
  --shadow: 0 1px 2px rgba(17,26,46,.07), 0 10px 28px rgba(17,26,46,.08);
  --f-display: "Archivo", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0C1120; --surface: #151C2F; --ink: #E8ECF5; --muted: #A0A9BF; --line: #2A3452;
    --primary: #F2B01E; --primary-ink: #1C1400; --signal: #F2B01E; --signal-ink: #1C1400;
    --ok: #5CCB91; --ok-bg: #11301F; --bad: #FF8F80; --bad-bg: #3A1613; --warn: #F5C451; --warn-bg: #362908;
    --focus: #8FB0FF; --sel-bg: #2B2612; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0C1120; --surface: #151C2F; --ink: #E8ECF5; --muted: #A0A9BF; --line: #2A3452;
  --primary: #F2B01E; --primary-ink: #1C1400; --signal: #F2B01E; --signal-ink: #1C1400;
  --ok: #5CCB91; --ok-bg: #11301F; --bad: #FF8F80; --bad-bg: #3A1613; --warn: #F5C451; --warn-bg: #362908;
  --focus: #8FB0FF; --sel-bg: #2B2612; --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
img { max-width: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--f-body); font-size: 17px; line-height: 1.5; -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 1.3rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.bar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar-in { max-width: 680px; margin: 0 auto; padding: 10px 16px; display: flex; flex-direction: column; gap: 8px; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand-name { flex: 0 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--f-display); font-weight: 800; font-size: .95rem; letter-spacing: .06em; text-transform: uppercase; display: flex; align-items: center; gap: 8px; }
.brand-name::before { content: ""; width: 10px; height: 22px; border-radius: 2px; background: repeating-linear-gradient(180deg, var(--signal) 0 5px, var(--primary) 5px 8px); }
.chip { font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.steps li { font-size: .78rem; font-weight: 700; color: var(--muted); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.steps li::before { content: ""; height: 4px; border-radius: 2px; background: var(--line); }
.steps li.done::before, .steps li.now::before { background: var(--signal); }
.steps li.now { color: var(--ink); }
.steps span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.wrap { max-width: 680px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 140px; }
.view { display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.lead { color: var(--muted); }
.eyebrow { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.plan { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.plan li { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.plan b.n { width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; background: var(--signal); color: var(--signal-ink); font-family: var(--f-display); font-weight: 800; }
.plan small { display: block; color: var(--muted); font-size: .9rem; }

.btn { min-height: 50px; padding: 0 20px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.signal { background: var(--signal); color: var(--signal-ink); border-color: var(--signal); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.link { border: 0; background: none; min-height: 40px; padding: 0 4px; color: var(--muted); text-decoration: underline; font-weight: 700; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 160px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-weight: 700; }
.field .hint { font-size: .88rem; color: var(--muted); }
.field input, textarea { width: 100%; min-height: 50px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); font-size: 1.05rem; }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.field.err input, .q.err { border-color: var(--bad); }
.errmsg { color: var(--bad); font-size: .9rem; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: .95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 700; min-width: 0; overflow-wrap: anywhere; }
.tab { font-variant-numeric: tabular-nums; }

/* Lectura */
.reader-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.pg { font-family: var(--f-display); font-weight: 800; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.progress { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--signal); transition: width .25s; }
.sheet { margin: 0; position: relative; background: #fff; border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; aspect-ratio: 1240 / 1755; max-width: 100%; }
.sheet img { display: block; width: 100%; height: 100%; object-fit: contain; }
.sheet .zoom { position: absolute; right: 10px; bottom: 10px; min-height: 42px; padding: 0 14px; border-radius: 999px; border: 0; background: rgba(17,26,46,.82); color: #fff; font-weight: 700; cursor: pointer; }
.actionbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
.actionbar .row { max-width: 680px; margin: 0 auto; }
.zoomer { position: fixed; inset: 0; z-index: 50; background: #0A0F1C; display: flex; flex-direction: column; }
.zoomer-bar { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px; color: #fff; }
.zoomer-bar .zg { display: flex; gap: 8px; }
.zoomer-bar .btn { min-width: 48px; font-size: 1.2rem;  min-height: 44px; background: #1D2742; color: #fff; border-color: #34405F; padding: 0 14px; }
.zoomer-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; }
.zoomer-scroll img { display: block; max-width: none; }

/* Preguntas */
.group-head { display: flex; flex-direction: column; gap: 2px; padding-top: 6px; }
.q { background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 16px; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.q legend, .q .qt { font-weight: 700; display: flex; gap: 10px; align-items: flex-start; padding: 0; float: left; width: 100%; }
.q legend + * { clear: both; }
.qn { flex: 0 0 auto; min-width: 30px; height: 30px; border-radius: 50%; background: var(--primary); color: var(--primary-ink); display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; }
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 10px; align-items: center; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; min-height: 52px; }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt .l { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 700; }
.opt.on, .opt:has(input:checked) { border-color: var(--primary); background: var(--sel-bg); }
.opt.on .l, .opt:has(input:checked) .l { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.opt:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.count { font-size: .85rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* Firma */
.padbox { position: relative; border: 1.5px dashed var(--line); border-radius: 12px; background: #fff; height: 200px; touch-action: none; }
.padbox canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.padbox .base { position: absolute; left: 18px; right: 18px; bottom: 46px; border-bottom: 1.5px solid #9AA3B8; pointer-events: none; }
.padbox .ph { position: absolute; left: 18px; bottom: 16px; color: #6B7488; font-size: .9rem; pointer-events: none; }
.check { display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 2px 0 0; accent-color: var(--primary); }

/* Utilidades */
.small { font-size: .92rem; }
.bold { font-weight: 700; }
.mt6 { margin-top: 6px; }

/* Estados */
.note { border-radius: 12px; padding: 12px 14px; font-size: .95rem; display: flex; flex-direction: column; gap: 4px; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note b { color: inherit; }
.file { display: grid; grid-template-columns: 44px 1fr; gap: 12px; align-items: center; }
.file .ico { width: 44px; height: 54px; border-radius: 6px; background: var(--bad-bg); color: var(--bad); display: grid; place-items: center; font-weight: 800; font-size: .75rem; font-family: var(--f-display); }
.file .nm { font-weight: 700; overflow-wrap: anywhere; }
.file small { color: var(--muted); }

/* Supervisor */
.drop { border: 2px dashed var(--line); border-radius: 14px; padding: 26px 18px; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; background: var(--surface); }
.drop.over { border-color: var(--primary); }
.grid15 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.cell { border-radius: 10px; padding: 8px 4px; text-align: center; display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.cell.ok { background: var(--ok-bg); color: var(--ok); }
.cell.bad { background: var(--bad-bg); color: var(--bad); }
.cell b { font-family: var(--f-display); font-size: 1.05rem; }
.cell small { font-size: .78rem; font-weight: 700; }
.oq { display: flex; flex-direction: column; gap: 8px; }
.ans { background: var(--sel-bg); border-left: 4px solid var(--primary); padding: 10px 12px; border-radius: 0 10px 10px 0; font-style: italic; overflow-wrap: anywhere; }
.exp { font-size: .92rem; color: var(--muted); }
.exp b { color: var(--ink); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { position: relative; min-height: 46px; border: 1.5px solid var(--line); border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label.si, .seg label:has(input[value="1"]:checked) { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); }
.seg label.no, .seg label:has(input[value="0"]:checked) { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.sig { background: #fff; border-radius: 10px; border: 1px solid var(--line); height: 84px; display: grid; place-items: center; }
.sig svg { width: 100%; height: 100%; }
.score { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 680px; margin: 0 auto 10px; }
.score .big { font-family: var(--f-display); font-weight: 800; font-size: 1.6rem; font-variant-numeric: tabular-nums; line-height: 1; }
.score .tr { font-size: .9rem; font-weight: 700; text-align: right; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.demo-tag { align-self: flex-start; background: var(--warn-bg); color: var(--warn); font-weight: 700; font-size: .8rem; padding: 3px 10px; border-radius: 6px; letter-spacing: .04em; text-transform: uppercase; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--signal); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .progress i { transition: none; } }
@media (min-width: 560px) { body { font-size: 17.5px; } h1 { font-size: 2rem; } }
