/* Documentación · hoja de estilos unica (sin estilos en linea: la CSP lo prohibe). Claro/oscuro automatico, movil primero, estilos de impresion para las hojas. */
:root {
  --bg: #f6f3ec; --panel: #fffdf8; --ink: #1d2a2b; --muted: #5d6b6c; --line: #ddd6c6;
  --accent: #1f5f5b; --accent-ink: #ffffff; --warn: #a34a00; --warn-bg: #fff0dd; --bad: #a3261f; --bad-bg: #fde7e5; --ok: #20704a; --ok-bg: #e4f4ea; --info-bg: #e6f0f0;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 17px; line-height: 1.45;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #131b1c; --panel: #1b2627; --ink: #e8efee; --muted: #98aaa9; --line: #2c3a3b; --accent: #55b7ae; --accent-ink: #0c1b1a; --warn: #ffb066; --warn-bg: #3a2a15; --bad: #ff8d84; --bad-bg: #3b1f1d; --ok: #7fd6a5; --ok-bg: #173325; --info-bg: #1b2f30; --shadow: none; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { min-height: 100vh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; }
.boot { padding: 3rem 1rem; text-align: center; color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: .88rem; } .mono { font-family: ui-monospace, Consolas, monospace; }
.hidden { display: none !important; }

/* estructura */
.shell { max-width: 860px; margin: 0 auto; padding: 0 1rem 5rem; }
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); margin: 0 -1rem 1rem; padding: .6rem 1rem 0; }
.bar { display: flex; align-items: center; gap: .6rem; justify-content: space-between; }
.brand { font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; display: flex; gap: .5rem; align-items: center; }
.brand img { width: 26px; height: 26px; border-radius: 6px; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; padding: .5rem 0 .55rem; scrollbar-width: none; }
.tabs a { flex: 0 0 auto; text-decoration: none; padding: .4rem .8rem; border-radius: 999px; color: var(--ink); border: 1px solid transparent; font-size: .95rem; }
.tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.chip { font-size: .8rem; padding: .15rem .55rem; border-radius: 999px; background: var(--info-bg); color: var(--muted); border: 0; cursor: default; }
.chip.warn { background: var(--warn-bg); color: var(--warn); cursor: pointer; } .chip.bad { background: var(--bad-bg); color: var(--bad); cursor: pointer; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: 0 0 1rem; box-shadow: var(--shadow); }
.card.warn { background: var(--warn-bg); border-color: var(--warn); } .card.bad { background: var(--bad-bg); border-color: var(--bad); } .card.ok { background: var(--ok-bg); border-color: var(--ok); } .card.info { background: var(--info-bg); }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; } .row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem; }

/* controles */
.btn { font: inherit; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; min-height: 44px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; } .btn.small { min-height: 36px; padding: .3rem .7rem; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: default; }
.field { margin: 0 0 .9rem; } .field label { display: block; font-weight: 600; margin-bottom: .25rem; font-size: .95rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .25rem 0 0; }
input, select, textarea { font: inherit; width: 100%; padding: .55rem .65rem; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 44px; }
input[type="checkbox"] { width: auto; min-height: 0; } textarea { min-height: 7rem; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.err { color: var(--bad); font-weight: 600; margin: .4rem 0; } .okmsg { color: var(--ok); font-weight: 600; margin: .4rem 0; }

/* listas */
.list { list-style: none; margin: 0; padding: 0; }
.item { display: flex; gap: .75rem; align-items: center; padding: .7rem 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.item:last-child { border-bottom: 0; } .item .t { font-weight: 600; } .item .s { color: var(--muted); font-size: .9rem; }
.badge { display: inline-block; font-size: .78rem; padding: .1rem .5rem; border-radius: 999px; background: var(--info-bg); color: var(--muted); white-space: nowrap; }
.badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.bad { background: var(--bad-bg); color: var(--bad); } .badge.ok { background: var(--ok-bg); color: var(--ok); }
.days { min-width: 5.2rem; text-align: right; font-variant-numeric: tabular-nums; font-size: .9rem; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.kpi .n { font-size: 1.45rem; font-weight: 700; } .kpi .l { color: var(--muted); font-size: .85rem; }
.thumbs { display: flex; gap: .5rem; flex-wrap: wrap; } .thumb { display: flex; flex-direction: column; gap: .25rem; align-items: center; font-size: .8rem; }
.thumb img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); } .thumb .pdf { width: 84px; height: 84px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--info-bg); font-weight: 700; }

/* superposiciones */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 30; padding: 1rem; }
.dialog { background: var(--panel); border-radius: var(--radius); padding: 1.2rem; max-width: 420px; width: 100%; }
.lock { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: grid; place-items: center; padding: 1rem; overflow: auto; }
.lock .box { width: 100%; max-width: 380px; }
.toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(150%); background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 10px; z-index: 50; transition: transform .2s; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); } .toast.err { background: var(--bad); color: #fff; }
.auth { max-width: 460px; margin: 0 auto; padding: 2rem 1rem; }
.code { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .06em; word-break: break-word; padding: .8rem; border: 2px dashed var(--line); border-radius: 10px; background: var(--bg); user-select: all; }
.steps { padding-left: 1.2rem; } .steps li { margin: .35rem 0; }
.qr { width: 190px; height: 190px; background: #fff; }

/* hojas imprimibles */
.sheet { background: #fff; color: #000; padding: 1.5rem; border: 1px solid var(--line); border-radius: 8px; }
.sheet h1 { font-size: 1.5rem; } .sheet .code { color: #000; background: #fff; border-color: #000; font-size: 1.35rem; line-height: 1.8; }
.sheet .cols { display: flex; gap: 1.5rem; align-items: flex-start; flex-wrap: wrap; }
@media print {
  body { background: #fff; } .top, .tabs, .noprint, .toast, .lock { display: none !important; }
  .shell { max-width: none; padding: 0; } .sheet { border: 0; padding: 0; } .card { box-shadow: none; }
  .pagebreak { break-after: page; }
}

/* hojas: solo se imprime la hoja elegida (clase .now), el resto de la pantalla se oculta */
@media screen { .printonly { display: none; } }
@media print {
  body.printing #app * { visibility: hidden; }
  body.printing .sheet.now, body.printing .sheet.now * { visibility: visible; }
  body.printing .sheet.now { position: absolute; left: 0; top: 0; width: 100%; display: block; }
  .printonly .sheet:not(.now) { display: none; }
}
