:root {
  --ink: #1f1f1f; --ink2: #555; --line: #ddd6cc; --bg: #f5f2ec; --card: #fff;
  --wood: #b9874f; --wood-d: #8a5f2f; --wood-l: #ecdcc4; --wood-ll: #f7efe3;
  --ok: #2f7d43; --ok-l: #e3f2e6; --red: #c62828; --red-l: #fbe5e3; --orange: #e8913a; --orange-l: #fdebd5;
  --r: 12px; --sh: 0 1px 3px rgba(0,0,0,.08), 0 4px 14px rgba(0,0,0,.05);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; }
svg { display: block; }

/* barra superior */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--ink); color: #fff; }
.ico { width: 40px; height: 40px; border: 0; background: transparent; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.ico svg { width: 24px; height: 24px; stroke: #fff; stroke-width: 2; fill: none; stroke-linecap: round; }
.brand { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.brand-t { display: flex; align-items: baseline; gap: 8px; }
.brand-m { display: flex; align-items: center; gap: 6px; opacity: .8; }
.brand-m img { height: 13px; width: auto; }
.brand-m span { font-size: 10px; color: #bbb; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.brand b { font-size: 20px; letter-spacing: .08em; color: var(--wood); }
.brand span { font-size: 14px; opacity: .85; }
.sync { font-size: 12px; padding: 4px 8px; border-radius: 20px; background: #333; white-space: nowrap; }
.sync.on { background: var(--ok); }
.sync.err { background: var(--red); }

/* menú lateral */
.drawer { position: fixed; inset: 0 auto 0 0; width: min(320px, 86vw); z-index: 40; background: #fff; transform: translateX(-102%); transition: transform .22s; overflow-y: auto; }
.drawer.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,.2); }
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 30; display: none; }
.scrim.open { display: block; }
.drawer-in { padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); }
.drawer-head { font-size: 18px; margin-bottom: 14px; }
.drawer-head b { color: var(--wood); letter-spacing: .08em; }
.drawer-head small { display: block; font-size: 12px; color: var(--ink2); margin-top: 2px; }
.lbl { display: block; font-size: 12px; color: var(--ink2); margin: 10px 0 4px; text-transform: uppercase; letter-spacing: .05em; }
select, input[type=text], input:not([type]) , input[type=search] { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fff; }
#menu { margin-top: 12px; }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 11px 12px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; }
.mi:hover { background: var(--wood-ll); }
.mi.act { background: var(--wood-l); font-weight: 600; }
.mi.star { background: var(--ink); color: #fff; font-weight: 700; margin-bottom: 8px; }
.mi.star.act { outline: 3px solid var(--wood); }
.mi small { margin-left: auto; color: var(--ink2); font-weight: 400; }
.mi.star small { color: #ccc; }
.drawer-foot { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 6px; }
.link { border: 0; background: none; color: var(--red); padding: 12px 0; cursor: pointer; font-size: 14px; }

main { max-width: 760px; margin: 0 auto; padding: 12px 12px 120px; }
h1 { font-size: 22px; margin: 6px 0 2px; }
.sub { color: var(--ink2); font-size: 14px; margin-bottom: 12px; }

/* progreso */
.prog { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 12px 14px; margin-bottom: 12px; }
.prog-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; }
.prog-row b { font-size: 20px; }
.track { height: 10px; background: var(--wood-ll); border-radius: 6px; overflow: hidden; margin-top: 8px; }
.track i { display: block; height: 100%; background: var(--ok); border-radius: 6px; transition: width .3s; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 7px 12px; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip.act { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip small { opacity: .7; margin-left: 4px; }

.sec-h { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 4px 8px; font-weight: 700; }
.sec-h small { font-weight: 400; color: var(--ink2); }

/* tarjeta de barra */
.bar { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); margin-bottom: 10px; overflow: hidden; border: 2px solid transparent; }
.bar.now { border-color: var(--red); }
.bar.done { opacity: .72; background: #eef0ec; }
.bar-h { display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; }
.bar-h .nm { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.bar-h .meta { font-size: 13px; color: var(--ink2); }
.bar-h .st { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; }
.badge { font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.badge.now { background: var(--red); color: #fff; }
.badge.ok { background: var(--ok-l); color: var(--ok); }
.lock { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--ok); }
.lock svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.chev { width: 20px; height: 20px; stroke: var(--ink2); fill: none; stroke-width: 2; transition: transform .2s; }
.bar.open .chev { transform: rotate(180deg); }
.bar-b { display: none; padding: 0 14px 14px; }
.bar.open .bar-b { display: block; }

.strip { margin: 4px 0 6px; }
.strip-cap { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink2); margin-bottom: 4px; }
.strip-cap b { color: var(--red); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--ink2); margin: 4px 0 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 4px; }

.cut { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid var(--line); margin-bottom: 8px; cursor: pointer; position: relative; }
.cut .n { width: 30px; height: 30px; border-radius: 50%; background: var(--wood-l); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.cut .cod { font-weight: 800; font-size: 19px; letter-spacing: .01em; }
.cut .dst { font-size: 13px; color: var(--ink2); }
.cut .tope { text-align: right; font-variant-numeric: tabular-nums; }
.cut .tope b { display: block; font-size: 24px; line-height: 1; }
.cut .tope small { font-size: 11px; color: var(--ink2); }
.cut .tope.cambia b { color: #fff; background: var(--orange); padding: 4px 8px; border-radius: 8px; }
.cut .tope.igual b { font-size: 18px; color: var(--ink2); }
.cut.next { border: 2px solid var(--red); background: var(--red-l); }
.cut.next::before { content: "CORTA AHORA"; position: absolute; top: -9px; left: 50px; font-size: 11px; font-weight: 800; background: var(--red); color: #fff; padding: 1px 8px; border-radius: 10px; }
.cut.hecho { background: var(--ok-l); border-color: #bcdcc4; }
.cut.hecho .n { background: var(--ok); color: #fff; }
.cut.hecho .cod, .cut.hecho .tope b { opacity: .55; }
.ang { display: inline-block; margin-top: 3px; font-size: 12px; font-weight: 800; color: #fff; background: var(--red); padding: 2px 7px; border-radius: 6px; }
.resto { padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 4px 0 12px; }
.resto.sobrante { background: var(--ok-l); color: var(--ok); }
.resto.desecho { background: var(--red-l); color: var(--red); }
.resto.nada { background: #f0f0f0; color: var(--ink2); }
.start { background: var(--wood-ll); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }
.start b.nueva { color: var(--red); }

.btn { display: block; width: 100%; border: 0; border-radius: 12px; padding: 16px; font-size: 17px; font-weight: 800; cursor: pointer; }
.btn.ok { background: var(--ok); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); font-weight: 600; }
.btn.dark { background: var(--ink); color: #fff; }
.donebox { font-size: 14px; color: var(--ink2); margin-bottom: 10px; }

/* tablas como tarjetas */
.search { position: sticky; top: 60px; z-index: 5; background: var(--bg); padding: 4px 0 8px; }
.rc { background: var(--card); border-radius: 10px; box-shadow: var(--sh); padding: 10px 12px; margin-bottom: 8px; }
.rc-t { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.rc-t span:last-child { font-weight: 600; color: var(--wood-d); text-align: right; }
.rc-s { font-size: 13px; color: var(--ink2); margin-top: 2px; }
.rc-k { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; margin-top: 6px; }
.rc-k dt { color: var(--ink2); }
.rc-k dd { margin: 0; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 10px; margin-left: 4px; }
.tag.red { background: var(--red-l); color: var(--red); }
.tag.yel { background: #fff4c7; color: #7a5b00; }
.tag.ok { background: var(--ok-l); color: var(--ok); }
.more { text-align: center; color: var(--ink2); font-size: 13px; padding: 8px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.kpi { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 12px; }
.kpi small { display: block; color: var(--ink2); font-size: 12px; }
.kpi b { font-size: 22px; font-variant-numeric: tabular-nums; }
.kpi.wide { grid-column: span 2; background: var(--ink); color: #fff; }
.kpi.wide small { color: #bbb; }

/* etiquetas */
.opts { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 12px 14px; margin-bottom: 12px; }
.seg { display: flex; gap: 6px; margin: 6px 0 10px; }
.seg button { flex: 1; padding: 10px; border: 1px solid var(--line); background: #fff; border-radius: 10px; cursor: pointer; font-size: 14px; }
.seg button.act { background: var(--ink); color: #fff; border-color: var(--ink); }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 6px 0; }
.preview { overflow-x: auto; background: #ccc; padding: 10px; border-radius: var(--r); }
.preview .pg { transform-origin: top left; margin-bottom: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.2); }

.pg { width: 210mm; height: 297mm; background: #fff; padding: 8mm 10mm; overflow: hidden; position: relative; }
.pg .pfoot { position: absolute; bottom: 3mm; left: 10mm; right: 10mm; font-size: 7pt; color: #888; display: flex; justify-content: space-between; }
.bh { height: 7mm; display: flex; align-items: center; justify-content: space-between; background: #1f1f1f; color: #fff; padding: 0 3mm; font: 700 10pt system-ui, sans-serif; margin-top: 1mm; }
.bh span { font-weight: 400; font-size: 8pt; }
.lg { display: grid; }
.lb { border: .3mm dashed #999; padding: 0 3mm 2mm; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden; font-family: system-ui, sans-serif; color: #000; }
.lb .c { font-weight: 800; line-height: 1.05; }
.lb .d { font-weight: 700; }
.lb .f { color: #333; display: flex; justify-content: space-between; gap: 2mm; }
.lb .a { color: #fff; background: #c62828; font-weight: 800; padding: 0 1.5mm; border-radius: 1mm; align-self: flex-start; }
.lb.big .c { font-size: 22pt; } .lb.big .d { font-size: 12pt; } .lb.big .f { font-size: 8.5pt; } .lb.big .a { font-size: 9pt; }
.lb.sml .c { font-size: 14pt; } .lb.sml .d { font-size: 8.5pt; } .lb.sml .f { font-size: 6.5pt; } .lb.sml .a { font-size: 7pt; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; transition: transform .25s; z-index: 60; max-width: 90vw; }
.toast.show { transform: translateX(-50%) translateY(0); }

#print { display: none; }
@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff; }
  .top, .drawer, .scrim, main, .toast { display: none !important; }
  #print { display: block; }
  #print .pg { page-break-after: always; break-after: page; box-shadow: none; margin: 0; }
  #print .pg:last-child { page-break-after: auto; break-after: auto; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.lb .bs { margin: 0 -3mm 1mm; padding: .8mm 3mm; background: #1f1f1f; color: #fff; display: flex; justify-content: space-between; font-weight: 700; }
.lb .bs.alt { background: #8a5f2f; }
.lb.first { border-left: 1.2mm solid #c62828; }
.lb.big .bs { font-size: 9pt; } .lb.sml .bs { font-size: 6.5pt; }
.ro { display: flex; gap: 12px; align-items: center; background: #fff7e6; border: 1px solid #f0d49a; border-radius: var(--r); padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
.ro .btn { width: auto; padding: 12px 16px; font-size: 15px; flex: none; }
.pend-ban { display: flex; justify-content: space-between; width: 100%; border: 0; border-radius: var(--r); background: var(--red); color: #fff; font-weight: 800; font-size: 16px; padding: 14px 16px; margin-bottom: 12px; cursor: pointer; }
.cut .warn { margin-top: 6px; border: 1px solid #e6b3ae; background: #fff; color: var(--red); font-size: 12px; font-weight: 700; border-radius: 8px; padding: 4px 8px; cursor: pointer; }
.cut.pend { background: #fff1f0; border: 2px dashed var(--red); }
.cut.pend .cod { text-decoration: line-through; opacity: .6; }
.pendtag { display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 800; color: var(--red); }
.cut.añadida { border: 2px solid var(--orange); background: var(--orange-l); }
.cut.añadida.hecho { background: var(--ok-l); border-color: #bcdcc4; }
.pg-h { display: flex; gap: 6px; align-items: baseline; margin: 16px 2px 8px; font-size: 15px; }
.pg-h small { margin-left: auto; color: var(--ink2); }
.pg-h.reserva b { color: var(--red); }
.inc { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 12px; margin-bottom: 8px; border-left: 5px solid var(--red); }
.inc-t { display: flex; justify-content: space-between; align-items: center; font-size: 19px; }
.inc-t .tope b { background: var(--orange); color: #fff; padding: 3px 8px; border-radius: 8px; font-size: 20px; }
.inc-a { display: flex; gap: 8px; margin-top: 10px; }
.inc-a .btn { padding: 12px; font-size: 15px; }
.toc { display: flex; flex-direction: column; background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 8px 14px; margin-bottom: 14px; }
.toc a { padding: 7px 0; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); font-size: 15px; }
.toc a:last-child { border-bottom: 0; }
.ay { background: var(--card); border-radius: var(--r); box-shadow: var(--sh); padding: 14px 16px; margin-bottom: 12px; scroll-margin-top: 76px; }
.ay h2 { font-size: 18px; margin: 0 0 8px; }
.ay p { margin: 0 0 8px; font-size: 15px; line-height: 1.45; }
.ay figure { margin: 10px auto 2px; max-width: 300px; }
.ay img { width: 100%; border-radius: 18px; border: 6px solid #1f1f1f; box-shadow: 0 4px 16px rgba(0,0,0,.18); display: block; }
