:root{
  --bg:#F4F3EE; --card:#FFFFFF; --ink:#1A2B20; --muted:#55625A; --line:#E2E4DC;
  --green:#1F3A2B; --green-2:#2E5040; --green-soft:#E6F0E4; --orange:#B8460F; --red:#A33A2A;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%}
body{font-family:Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;background:var(--bg);color:var(--ink);display:flex;flex-direction:column;-webkit-tap-highlight-color:transparent}
button,input,select{font:inherit;color:inherit}
button{cursor:pointer}
button:disabled{cursor:not-allowed;opacity:.55}
h1,h2,h3{margin:0;font-weight:700;letter-spacing:-.3px}

.topbar{min-height:60px;display:flex;align-items:center;gap:16px;padding:8px 16px;background:var(--green);color:#fff;flex-wrap:wrap}
.brand{display:flex;align-items:center;gap:8px}
.brand-name{font-size:22px;font-weight:800;letter-spacing:-.5px}
.tabs{display:flex;gap:4px;flex:1;flex-wrap:wrap}
.tabs a{color:#DDEBD7;text-decoration:none;padding:10px 14px;border-radius:10px;font-weight:600;min-height:44px;display:flex;align-items:center}
.tabs a.on{background:var(--green-2);color:#fff}
.scale-pill{display:flex;align-items:center;gap:8px;padding:8px 14px;border-radius:999px;background:var(--green-2);border:none;color:#fff;font-size:14px;min-height:40px}
.scale-pill.live{background:#3E7A4E}

main{flex:1;min-height:0;padding:16px;overflow:auto}
.card{background:var(--card);border-radius:16px;padding:16px}
.muted{color:var(--muted)}
.row{display:flex;gap:12px;align-items:center;flex-wrap:wrap}
.grow{flex:1}
.btn{min-height:48px;padding:0 18px;border-radius:12px;border:2px solid var(--green);background:#fff;color:var(--green);font-weight:700}
.btn.primary{background:var(--green);color:#fff}
.btn.orange{background:var(--orange);border-color:var(--orange);color:#fff}
.btn.small{min-height:40px;padding:0 12px;font-size:14px}
.btn.ghost{border-color:var(--line);color:var(--ink)}
.btn.danger{border-color:#E3C5BE;color:var(--red)}
.icon-btn{width:44px;height:44px;border-radius:10px;border:none;background:transparent;color:var(--red);display:flex;align-items:center;justify-content:center}
label.f{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var(--muted);font-weight:600}
input.i,select.i{min-height:44px;border:1px solid #CFD3C8;border-radius:10px;padding:0 10px;background:#fff;font-size:16px;color:var(--ink)}
table{width:100%;border-collapse:collapse}
th,td{text-align:left;padding:10px 8px;border-bottom:1px solid var(--line);font-size:15px;vertical-align:middle}
th{font-size:12px;text-transform:uppercase;letter-spacing:.5px;color:var(--muted)}
td.n,th.n{text-align:right;font-variant-numeric:tabular-nums}
.tag{display:inline-block;padding:3px 8px;border-radius:999px;font-size:12px;font-weight:700;background:#EEF0EA;color:var(--muted)}
.tag.warn{background:#FBE5D6;color:#8A3410}
.tag.ok{background:var(--green-soft);color:var(--green)}
.scroll-x{overflow-x:auto}

/* TPV */
.pos{display:flex;gap:16px;height:100%;min-height:600px}
.pos-products{flex:1;min-width:0;display:flex;flex-direction:column;gap:12px}
.cats{display:flex;gap:8px;flex-wrap:wrap}
.cat{min-height:48px;padding:0 22px;border-radius:12px;border:2px solid #D9DCD3;background:#fff;color:var(--green);font-size:17px;font-weight:600}
.cat.on{background:var(--green);border-color:var(--green);color:#fff}
.search{min-height:48px;border-radius:12px;border:2px solid #D9DCD3;padding:0 14px;font-size:16px;flex:1;min-width:140px}
.grid{flex:1;min-height:0;overflow-y:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));grid-auto-rows:100px;gap:10px;align-content:start}
.prod{text-align:left;padding:12px 14px;border-radius:14px;border:2px solid #E2E4DC;background:#fff;display:flex;flex-direction:column;justify-content:space-between}
.prod.on{border-color:var(--green);background:var(--green-soft)}
.prod .nm{display:flex;gap:8px;align-items:center;font-size:16px;font-weight:600;line-height:1.2}
.dot{width:14px;height:14px;border-radius:50%;flex-shrink:0;background:#9AA59D}
.prod .pr{font-size:15px;color:var(--muted)}
.pos-weight{width:300px;flex-shrink:0;display:flex;flex-direction:column;gap:10px}
.wbox{background:var(--bg);border-radius:12px;padding:12px 14px;display:flex;flex-direction:column;gap:4px}
.wval{display:flex;justify-content:flex-end;align-items:baseline;gap:6px}
.wval b{font-size:44px;font-weight:700;line-height:1;font-variant-numeric:tabular-nums}
.keypad{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.key{height:54px;border-radius:12px;border:1px solid #DADDD4;background:#FAFAF7;font-size:22px;font-weight:600;display:flex;align-items:center;justify-content:center}
.key:active{background:#EDEFE8}
.pos-ticket{width:340px;flex-shrink:0;display:flex;flex-direction:column;padding:0;overflow:hidden}
.tk-head{padding:16px 18px 8px;display:flex;justify-content:space-between;align-items:baseline}
.tk-lines{flex:1;min-height:120px;overflow-y:auto;padding:0 18px}
.tk-line{display:flex;align-items:center;gap:10px;padding:10px 0;border-bottom:1px solid #ECEDE7}
.tk-foot{padding:14px 18px 18px;border-top:1px solid #ECEDE7;background:#FBFBF8;display:flex;flex-direction:column;gap:12px}
.total{display:flex;justify-content:space-between;align-items:baseline}
.total b{font-size:34px;font-variant-numeric:tabular-nums}
.pay{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.pay .btn{min-height:60px;font-size:18px}

@media (max-width:1100px){
  .pos{flex-wrap:wrap;height:auto}
  .pos-products{flex:1 1 100%}
  .grid{max-height:420px}
  .pos-weight,.pos-ticket{flex:1 1 300px;width:auto}
}

/* Layouts genéricos */
.two{display:flex;gap:16px;flex-wrap:wrap;align-items:flex-start}
.two > .main{flex:999 1 560px;min-width:0}
.two > .side{flex:1 1 340px;min-width:0}
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin-bottom:16px}
.kpi{background:#fff;border-radius:14px;padding:14px 16px}
.kpi span{font-size:13px;color:var(--muted);font-weight:600}
.kpi b{display:block;font-size:28px;margin-top:4px;font-variant-numeric:tabular-nums}
.section-title{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:12px;flex-wrap:wrap}
.stack{display:flex;flex-direction:column;gap:12px}
.pline{display:grid;grid-template-columns:minmax(0,2fr) 110px 110px 100px 44px;gap:8px;align-items:end}
@media (max-width:640px){.pline{grid-template-columns:1fr 1fr}}

#toast{position:fixed;left:50%;bottom:24px;transform:translateX(-50%);background:var(--ink);color:#fff;padding:12px 18px;border-radius:12px;font-weight:600;opacity:0;pointer-events:none;transition:opacity .2s;z-index:10}
#toast.show{opacity:1}
#toast.err{background:var(--red)}
dialog{border:none;border-radius:16px;padding:20px;max-width:420px;width:calc(100% - 32px)}
dialog::backdrop{background:rgba(20,30,24,.45)}
.login{max-width:360px;margin:10vh auto;text-align:center}
