:root{
  /* Plan: fondo blanco, secciones en gris muy claro con tarjetas blancas; azul marino manda.
     Menú lateral en computadora, barra inferior en celular. Controles de 52px para dedos y vista cansada. */
  --navy:#0f2748; --navy-2:#1b3d6e; --navy-soft:#e8eef7;
  --bg:#ffffff; --canvas:#f3f5f8; --line:#dfe4ec; --ink:#13203a; --muted:#566379;
  --ok:#157a47; --ok-bg:#e2f4e9; --ok-solid:#1d9a5b;
  --warn:#8a5d00; --warn-bg:#fdf0c4; --warn-solid:#eeb407;
  --bad:#c12a2a; --bad-bg:#fde7e5; --bad-solid:#d93a3a;
  --info:#1c5fc7; --info-bg:#e3edfc; --info-solid:#2f74e0;
  --off:#6c7689; --off-bg:#eceff3;
  --f-display:'Plus Jakarta Sans','Segoe UI',system-ui,sans-serif;
  --f-body:'Atkinson Hyperlegible','Segoe UI',system-ui,-apple-system,sans-serif;
  --r:16px; --r-sm:11px; --shadow:0 1px 2px rgba(15,39,72,.06),0 4px 14px rgba(15,39,72,.06);
  color-scheme:light;
}
*{box-sizing:border-box}
html,body{height:100%;margin:0}
body{background:var(--bg);color:var(--ink);font-family:var(--f-body);font-size:17px;line-height:1.45;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}
h1,h2,h3,h4{font-family:var(--f-display);margin:0;text-wrap:balance;letter-spacing:-.01em}
p{margin:0}
button,input,select,textarea{font:inherit;color:inherit}
button{cursor:pointer}
img{max-width:100%}
:focus-visible{outline:3px solid var(--info-solid);outline-offset:2px;border-radius:8px}
.num{font-family:var(--f-display);font-variant-numeric:tabular-nums;font-weight:700}
.muted{color:var(--muted)} .small{font-size:14.5px} .tiny{font-size:13px}
.right{text-align:right} .center{text-align:center} .grow{flex:1;min-width:0} .nowrap{white-space:nowrap}
.row{display:flex;align-items:center;gap:10px} .row.wrap{flex-wrap:wrap} .row.top{align-items:flex-start} .row.between{justify-content:space-between}
.stack{display:flex;flex-direction:column;gap:12px} .stack.s{gap:6px} .stack.l{gap:20px}
.hide{display:none!important}
svg.i{width:22px;height:22px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
svg.i.s{width:18px;height:18px} svg.i.l{width:28px;height:28px}

/* ---------- estructura ---------- */
#app{height:100%;display:flex;flex-direction:column}
.side{display:none}
#main{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;outline:none}
.page{max-width:1080px;margin:0 auto;padding:16px 16px 28px;display:flex;flex-direction:column;gap:16px}
.bnav{display:flex;background:var(--bg);border-top:1px solid var(--line);padding:4px 4px 6px;flex:none}
.bnav button{flex:1;background:none;border:0;padding:7px 2px 5px;display:flex;flex-direction:column;align-items:center;gap:2px;color:var(--muted);font-size:12.5px;font-weight:700;border-radius:12px;min-height:56px;position:relative}
.bnav button[aria-current="page"]{color:var(--navy);background:var(--navy-soft)}
.bnav .dot,.side-nav .dot{position:absolute;top:5px;left:calc(50% + 8px);min-width:19px;height:19px;padding:0 5px;border-radius:10px;background:var(--bad-solid);color:#fff;font-size:11.5px;font-weight:700;display:grid;place-items:center;font-family:var(--f-display)}
@media (min-width:900px){
  #app{flex-direction:row}
  .bnav{display:none}
  .side{display:flex;flex-direction:column;gap:18px;width:248px;flex:none;background:var(--navy);color:#fff;padding:22px 14px}
  .brand{display:flex;align-items:center;gap:11px;padding:0 8px}
  .brand-name{font-family:var(--f-display);font-weight:800;font-size:18px;line-height:1.2}
  .side-nav{display:flex;flex-direction:column;gap:4px}
  .side-nav button{display:flex;align-items:center;gap:12px;background:none;border:0;color:#c9d6ea;padding:13px 12px;border-radius:12px;font-weight:700;font-size:16.5px;text-align:left;position:relative}
  .side-nav button:hover{background:rgba(255,255,255,.07)}
  .side-nav button[aria-current="page"]{background:#fff;color:var(--navy)}
  .side-nav .dot{position:static;margin-left:auto}
  .side-user{margin-top:auto;padding:12px 10px;border-top:1px solid rgba(255,255,255,.14);font-size:14.5px;color:#c9d6ea}
  .page{padding:28px 32px 40px;gap:20px}
}
.brand-mark{width:38px;height:38px;border-radius:11px;background:#fff;color:var(--navy);display:grid;place-items:center;flex:none;overflow:hidden}
.brand-mark img{width:100%;height:100%;object-fit:cover}

/* ---------- encabezados ---------- */
.top{display:flex;align-items:center;gap:12px;justify-content:space-between}
.top h1{font-size:25px;font-weight:800;color:var(--navy)}
.top .sub{color:var(--muted);font-size:15px}
.hero{background:var(--navy);color:#fff;border-radius:20px;padding:18px;display:flex;flex-direction:column;gap:14px}
.hero h1{font-size:22px;font-weight:800;color:#fff}
.hero .sub{color:#c3d1e8;font-size:15px}
.hero-top{display:flex;gap:12px;align-items:flex-start;justify-content:space-between}
.tc-pill{background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.22);color:#fff;border-radius:14px;padding:8px 12px;text-align:right;line-height:1.2;flex:none}
.tc-pill b{font-family:var(--f-display);font-size:18px;display:block;font-variant-numeric:tabular-nums}
.tc-pill span{font-size:12.5px;color:#c3d1e8}
.tri{display:grid;grid-template-columns:1fr;gap:8px}
.tri>div{background:rgba(255,255,255,.09);border-radius:14px;padding:11px 14px;display:flex;justify-content:space-between;align-items:center;gap:10px}
.tri .lab{font-size:14px;color:#d5e0f2;font-weight:700;text-transform:uppercase;letter-spacing:.03em}
.tri .val{text-align:right;font-family:var(--f-display);font-weight:800;font-size:21px;font-variant-numeric:tabular-nums;line-height:1.2}
.tri .val small{display:block;font-size:14px;font-weight:700;color:#d5e0f2}
.tri .falta .val{color:#ffd66b}
.tri .ya .val{color:#8fe3b4}
@media (min-width:700px){.tri{grid-template-columns:repeat(3,1fr)}.tri>div{flex-direction:column;align-items:flex-start}.tri .val{text-align:left;font-size:24px}}

.sec{background:var(--canvas);border-radius:20px;padding:14px;display:flex;flex-direction:column;gap:12px}
.sec-h{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 4px}
.sec-h h2{font-size:18px;font-weight:800;color:var(--navy);display:flex;align-items:center;gap:8px}
.count{font-family:var(--f-display);font-size:13.5px;font-weight:800;border-radius:20px;padding:2px 9px;background:var(--navy-soft);color:var(--navy)}
.count.bad{background:var(--bad-solid);color:#fff} .count.warn{background:var(--warn-solid);color:#3b2900}
.link{background:none;border:0;color:var(--info);font-weight:700;padding:8px 4px;font-size:15.5px;text-decoration:none;display:inline-flex;align-items:center;gap:2px}

/* ---------- botones ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:9px;min-height:52px;padding:0 20px;border-radius:14px;border:1.5px solid transparent;background:var(--navy);color:#fff;font-weight:700;font-size:17px;text-decoration:none;font-family:var(--f-body);text-align:center;line-height:1.15}
.btn:active{transform:translateY(1px)}
.btn.block{width:100%}
.btn.ghost{background:#fff;color:var(--navy);border-color:var(--line)}
.btn.soft{background:var(--navy-soft);color:var(--navy)}
.btn.wa{background:#128c4a;color:#fff}
.btn.ok{background:var(--ok-solid);color:#fff}
.btn.danger{background:#fff;color:var(--bad);border-color:#f0c2be}
.btn.sm{min-height:44px;padding:0 14px;font-size:15.5px;border-radius:12px}
.btn[disabled]{opacity:.55;pointer-events:none}
.acts>.btn{flex:1 1 112px}
.icon-btn{width:46px;height:46px;border-radius:13px;border:0;background:transparent;display:grid;place-items:center;color:var(--navy);flex:none}
.icon-btn:hover{background:var(--navy-soft)}
.quick{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.quick button{background:#fff;border:1.5px solid var(--line);border-radius:16px;padding:14px 12px;display:flex;align-items:center;gap:11px;font-weight:700;font-size:16.5px;color:var(--navy);text-align:left;min-height:64px;line-height:1.2}
.quick button.main{background:var(--navy);color:#fff;border-color:var(--navy);grid-column:1/-1;justify-content:center;font-size:18px}
.quick .qi{width:38px;height:38px;border-radius:11px;background:var(--navy-soft);display:grid;place-items:center;flex:none}
.quick .main .qi{background:rgba(255,255,255,.16)}
.quick button.last{grid-column:1/-1}
@media (min-width:700px){.quick{grid-template-columns:repeat(6,1fr)}.quick button.main,.quick button.last{grid-column:auto}.quick button{flex-direction:column;align-items:flex-start;font-size:16px}}

/* ---------- tarjetas y estados ---------- */
.card{background:#fff;border:1px solid var(--line);border-radius:var(--r);padding:14px;display:flex;flex-direction:column;gap:10px}
button.card,a.card{text-align:left;width:100%;text-decoration:none;color:inherit}
.card.tap:hover{border-color:#b9c5d8}
.card.bad{border-left:6px solid var(--bad-solid)} .card.warn{border-left:6px solid var(--warn-solid)} .card.ok{border-left:6px solid var(--ok-solid)} .card.info{border-left:6px solid var(--info-solid)}
.card h3{font-size:17.5px;font-weight:700}
.card .amt{font-family:var(--f-display);font-weight:800;font-size:19px;font-variant-numeric:tabular-nums;white-space:nowrap}
.chip{display:inline-flex;align-items:center;gap:6px;border-radius:20px;padding:3px 11px;font-size:13.5px;font-weight:700;white-space:nowrap;background:var(--off-bg);color:var(--off)}
.chip::before{content:"";width:8px;height:8px;border-radius:50%;background:currentColor}
.chip.ok{background:var(--ok-bg);color:var(--ok)} .chip.warn{background:var(--warn-bg);color:var(--warn)} .chip.bad{background:var(--bad-bg);color:var(--bad)} .chip.info{background:var(--info-bg);color:var(--info)}
.chip.plain::before{display:none}
.avatar{width:44px;height:44px;border-radius:50%;background:var(--navy-soft);color:var(--navy);display:grid;place-items:center;font-family:var(--f-display);font-weight:800;font-size:16px;flex:none}
.empty{text-align:center;color:var(--muted);padding:22px 14px;display:flex;flex-direction:column;gap:10px;align-items:center}
.empty b{color:var(--ink);font-size:17.5px}
.banner{border-radius:14px;padding:12px 14px;display:flex;gap:10px;align-items:flex-start;font-size:15.5px;background:var(--info-bg);color:#123f86}
.banner.warn{background:var(--warn-bg);color:#5c3f00} .banner.bad{background:var(--bad-bg);color:#8c1f1f}
.kv{display:grid;grid-template-columns:auto 1fr;gap:6px 14px;font-size:16px}
.kv dt{color:var(--muted)} .kv dd{margin:0;text-align:right;font-weight:700;overflow-wrap:anywhere}
dl{margin:0}

/* resumen de lotes */
.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.stat{background:#fff;border:1px solid var(--line);border-radius:14px;padding:10px 12px;text-align:left;display:flex;flex-direction:column;gap:1px}
.stat b{font-family:var(--f-display);font-size:26px;font-weight:800;line-height:1.1;font-variant-numeric:tabular-nums}
.stat span{font-size:13.5px;color:var(--muted);font-weight:700;display:flex;align-items:center;gap:6px}
.sw{width:10px;height:10px;border-radius:3px;display:inline-block;flex:none}
.sw.disponible{background:var(--ok-solid)} .sw.apartado{background:var(--warn-solid)} .sw.vendido{background:var(--bad-solid)} .sw.liquidado{background:var(--info-solid)} .sw.bloqueado{background:#fff;border:2px solid #9aa4b5}
@media (min-width:700px){.stats{grid-template-columns:repeat(6,1fr)}}
.bar{display:flex;height:12px;border-radius:8px;overflow:hidden;background:var(--off-bg)}
.bar i{display:block;height:100%}
.bar .disponible{background:var(--ok-solid)} .bar .apartado{background:var(--warn-solid)} .bar .vendido{background:var(--bad-solid)} .bar .liquidado{background:var(--info-solid)} .bar .bloqueado{background:#b6bdc9}

/* ---------- inventario ---------- */
.seg{display:flex;gap:6px;overflow-x:auto;padding:2px;scrollbar-width:none}
.seg::-webkit-scrollbar{display:none}
.seg button,.seg label>span{flex:none;background:#fff;border:1.5px solid var(--line);border-radius:12px;padding:0 15px;min-height:46px;font-weight:700;font-size:16px;color:var(--navy);display:inline-flex;align-items:center;gap:7px;white-space:nowrap}
.seg button[aria-pressed="true"],.seg input:checked+span{background:var(--navy);border-color:var(--navy);color:#fff}
.seg label{display:contents;cursor:pointer}
.seg input{position:absolute;opacity:0;pointer-events:none}
.seg input:focus-visible+span{outline:3px solid var(--info-solid);outline-offset:2px}
.seg.fill>*{flex:1} .seg.fill label>span{flex:1;justify-content:center}
.legend{display:flex;flex-wrap:wrap;gap:6px 14px;font-size:14px;color:var(--muted);font-weight:700;padding:0 4px}
.legend span{display:inline-flex;align-items:center;gap:6px}
.mz-h{display:flex;align-items:baseline;justify-content:space-between;gap:10px;padding:4px 4px 0}
.mz-h h3{font-size:17px;color:var(--navy);font-weight:800}
.lots{display:grid;grid-template-columns:repeat(auto-fill,minmax(98px,1fr));gap:9px}
.lot{border:0;border-radius:15px;padding:10px 10px 9px;min-height:92px;display:flex;flex-direction:column;justify-content:space-between;text-align:left;color:#fff;position:relative;overflow:hidden}
.lot .n{font-family:var(--f-display);font-weight:800;font-size:26px;line-height:1;font-variant-numeric:tabular-nums}
.lot .n small{font-size:12px;font-weight:700;opacity:.85;display:block;letter-spacing:.04em;text-transform:uppercase;margin-bottom:3px}
.lot .who{font-size:12.5px;font-weight:700;line-height:1.2;overflow:hidden;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow-wrap:anywhere}
.lot.disponible{background:var(--ok-solid)} .lot.apartado{background:var(--warn-solid);color:#3b2900} .lot.vendido{background:var(--bad-solid)} .lot.liquidado{background:var(--info-solid)}
.lot.bloqueado{background:#fff;color:var(--off);border:2px dashed #aab3c2}

/* ---------- búsqueda y formularios ---------- */
.search{display:flex;align-items:center;gap:10px;background:#fff;border:1.5px solid var(--line);border-radius:14px;padding:0 14px;min-height:54px}
.search input{flex:1;border:0;outline:0;background:transparent;min-width:0;font-size:17px;height:50px}
.search:focus-within{border-color:var(--navy-2)}
form{margin:0}
.f{display:flex;flex-direction:column;gap:5px;min-width:0}
.f>span{font-size:14.5px;font-weight:700;color:var(--muted)}
.f input,.f select,.f textarea{width:100%;min-height:52px;border:1.5px solid #c9d1de;border-radius:13px;padding:0 14px;background:#fff;font-size:17px}
.f textarea{padding:12px 14px;min-height:88px;resize:vertical}
.f input:focus,.f select:focus,.f textarea:focus{border-color:var(--navy-2);outline:3px solid var(--navy-soft)}
.f .hint{font-size:13.5px;color:var(--muted);font-weight:400}
.f.big input{font-family:var(--f-display);font-weight:800;font-size:26px;min-height:62px;font-variant-numeric:tabular-nums}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:12px}
@media (max-width:420px){.grid2.wrap{grid-template-columns:1fr}}
fieldset{border:0;padding:0;margin:0;display:flex;flex-direction:column;gap:12px;min-width:0}
legend{font-family:var(--f-display);font-weight:800;color:var(--navy);font-size:16.5px;padding:0;margin-bottom:4px}
details.more{background:var(--canvas);border-radius:14px;padding:0 14px}
details.more summary{min-height:52px;display:flex;align-items:center;justify-content:space-between;font-weight:700;color:var(--navy);cursor:pointer;list-style:none}
details.more summary::-webkit-details-marker{display:none}
details.more summary::after{content:"+";font-size:24px;font-family:var(--f-display)}
details.more[open] summary::after{content:"–"}
details.more .in{padding:4px 0 16px;display:flex;flex-direction:column;gap:12px}
.calc{background:var(--navy-soft);border-radius:14px;padding:12px 14px;font-size:16px;color:var(--navy)}
.calc b{font-family:var(--f-display);font-variant-numeric:tabular-nums}
.pick{display:flex;flex-direction:column;gap:8px;max-height:260px;overflow:auto}
.pick button{background:#fff;border:1.5px solid var(--line);border-radius:13px;padding:10px 12px;text-align:left;min-height:54px}
.sw-toggle{display:flex;align-items:center;gap:12px;min-height:52px;cursor:pointer}
.sw-toggle input{width:26px;height:26px;accent-color:var(--navy);flex:none}

/* ---------- hojas (pantallas sobrepuestas) ---------- */
.sheet-wrap{position:fixed;inset:0;background:rgba(10,24,46,.48);display:flex;justify-content:center;align-items:stretch;z-index:50}
.sheet{background:var(--bg);width:100%;display:flex;flex-direction:column;min-height:0;animation:up .22s ease-out}
@keyframes up{from{transform:translateY(22px);opacity:.6}to{transform:none;opacity:1}}
@media (prefers-reduced-motion:reduce){.sheet{animation:none}}
.sh-head{display:flex;align-items:center;gap:6px;padding:8px 10px;border-bottom:1px solid var(--line);flex:none}
.sh-head h2{font-size:19px;font-weight:800;color:var(--navy);flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sh-body{flex:1;min-height:0;overflow-y:auto;padding:16px;display:flex;flex-direction:column;gap:16px;-webkit-overflow-scrolling:touch}
.sh-body>*{flex-shrink:0} /* nada dentro de una hoja se aplasta: la hoja completa es la que se desplaza */
.sh-foot{flex:none;padding:10px 16px 14px;border-top:1px solid var(--line);display:flex;gap:10px;background:#fff}
.sh-foot:empty{display:none}
.sh-foot .btn{flex:1}
@media (min-width:760px){
  .sheet-wrap{align-items:center;padding:28px}
  .sheet{max-width:620px;max-height:100%;border-radius:22px;overflow:hidden;box-shadow:0 20px 60px rgba(10,24,46,.3)}
  .sheet.wide{max-width:860px}
}
.dialog{background:#fff;border-radius:20px;padding:22px;max-width:420px;width:calc(100% - 32px);margin:auto;display:flex;flex-direction:column;gap:16px;box-shadow:0 20px 60px rgba(10,24,46,.3)}
.dialog h3{font-size:19px;color:var(--navy)}
.tabs{display:flex;gap:4px;overflow-x:auto;padding:8px 10px;border-bottom:1px solid var(--line);flex:none;scrollbar-width:none}
.tabs::-webkit-scrollbar{display:none}
.tabs button{flex:none;border:0;background:none;padding:0 13px;min-height:44px;border-radius:11px;font-weight:700;color:var(--muted);font-size:15.5px;white-space:nowrap}
.tabs button[aria-selected="true"]{background:var(--navy);color:#fff}
.progress{height:16px;border-radius:10px;background:var(--off-bg);overflow:hidden}
.progress i{display:block;height:100%;background:linear-gradient(90deg,var(--ok-solid),#35b877);border-radius:10px;min-width:4px}
.bigpct{font-family:var(--f-display);font-weight:800;font-size:34px;color:var(--ok);line-height:1}
.sched{display:flex;flex-direction:column}
.sched .li{display:flex;align-items:center;gap:10px;padding:10px 2px;border-bottom:1px solid var(--line)}
.sched .li:last-child{border-bottom:0}
.sched .d{width:54px;flex:none;text-align:center;font-family:var(--f-display);font-weight:800;line-height:1.05;color:var(--navy)}
.sched .d small{display:block;font-size:11.5px;font-weight:700;color:var(--muted);text-transform:uppercase}
.doc-cat{display:flex;flex-direction:column;gap:8px;padding:12px 0;border-bottom:1px solid var(--line)}
.doc-cat:last-child{border-bottom:0}
.thumbs{display:flex;gap:8px;flex-wrap:wrap}
.thumb{width:84px;height:84px;border-radius:12px;border:1px solid var(--line);background:var(--canvas);overflow:hidden;padding:0;display:grid;place-items:center;color:var(--navy);font-size:12px;font-weight:700}
.thumb img{width:100%;height:100%;object-fit:cover}
.viewer{flex:1;min-height:0;overflow:auto;background:#0b1626;display:block;padding:0;touch-action:pan-x pan-y pinch-zoom}
.viewer img,.viewer canvas{display:block;margin:0 auto;max-width:none}
.tbl-wrap{flex:none;overflow-x:auto;overflow-y:visible;border:1px solid var(--line);border-radius:14px;background:#fff}
table.tbl{border-collapse:collapse;width:100%;font-size:15.5px}
.tbl th,.tbl td{padding:12px 13px;text-align:left;border-bottom:1px solid var(--line);white-space:nowrap}
.tbl th{background:var(--navy-soft);font-weight:700;color:var(--navy)}
.tbl tbody tr:nth-child(even) td{background:#f8f9fb}
.tbl tbody tr:last-child td{border-bottom:0}
.tbl td.r,.tbl th.r{text-align:right;font-variant-numeric:tabular-nums}
.menu{display:flex;flex-direction:column;gap:8px}
.menu button{display:flex;align-items:center;gap:14px;background:#fff;border:1px solid var(--line);border-radius:16px;padding:14px;text-align:left;min-height:68px;width:100%}
.menu .mi{width:44px;height:44px;border-radius:13px;background:var(--navy-soft);color:var(--navy);display:grid;place-items:center;flex:none}
.menu b{display:block;font-size:17px} .menu span.d{font-size:14.5px;color:var(--muted)}
.stepper{display:flex;align-items:center;gap:8px}
.stepper button{width:48px;height:48px;border-radius:13px;border:1.5px solid var(--line);background:#fff;font-size:24px;font-weight:700;color:var(--navy)}
.stepper output{min-width:44px;text-align:center;font-family:var(--f-display);font-weight:800;font-size:22px}

/* ---------- avisos ---------- */
#toasts{position:fixed;left:0;right:0;bottom:84px;display:flex;flex-direction:column;align-items:center;gap:8px;z-index:90;pointer-events:none;padding:0 16px}
.toast{background:var(--ink);color:#fff;border-radius:14px;padding:12px 18px;font-weight:700;box-shadow:var(--shadow);max-width:520px;font-size:16px}
.toast.bad{background:var(--bad)} .toast.ok{background:var(--ok)}
.boot{height:100%;display:grid;place-content:center;justify-items:center;gap:14px;color:var(--muted);padding:24px;text-align:center}
.spinner{width:38px;height:38px;border-radius:50%;border:4px solid var(--navy-soft);border-top-color:var(--navy);animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}
@media (prefers-reduced-motion:reduce){.spinner{animation-duration:3s}}
.fab{position:sticky;bottom:10px;align-self:flex-end;box-shadow:0 8px 22px rgba(15,39,72,.28);z-index:5}
