:root{
  --bg:#faf6ef; --card:#ffffff; --ink:#2a1f16; --muted:#7d6b5b; --line:#eadfd0;
  --accent:#c4512a; --accent-ink:#ffffff; --ok:#2e7d4f; --warn:#a85d00; --danger:#b3261e;
  --wa:#25d366; --shadow:0 4px 16px rgba(60,35,10,.07); --radius:14px;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#17120d; --card:#221a13; --ink:#f6eee3; --muted:#b3a18d; --line:#3a2d20;
    --accent:#e0703f; --accent-ink:#1a1009; --ok:#5fbf86; --warn:#f0b25a; --danger:#ff8a80; --shadow:none;
  }
}
:root[data-theme="dark"]{
  --bg:#17120d; --card:#221a13; --ink:#f6eee3; --muted:#b3a18d; --line:#3a2d20;
  --accent:#e0703f; --accent-ink:#1a1009; --ok:#5fbf86; --warn:#f0b25a; --danger:#ff8a80; --shadow:none;
}
*{box-sizing:border-box}
[hidden]{display:none !important}
html,body{background:var(--bg)}
body{margin:0;color:var(--ink);font:15px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;padding-bottom:96px}
button{font:inherit;color:inherit;cursor:pointer}
input,select,textarea{font:inherit;font-size:16px;color:inherit;background:var(--card);border:1px solid var(--line);border-radius:12px;padding:10px 12px;min-height:44px;width:100%}
h3,h4{margin:0}
.muted{color:var(--muted)}
.small{font-size:13px}
.ok{color:var(--ok)}
.empty{color:var(--muted);text-align:center;padding:24px 8px}

/* header */
header.top{display:flex;flex-wrap:wrap;align-items:center;gap:10px 12px;padding:12px 16px;border-bottom:1px solid var(--line)}
.brand{font-weight:800;font-size:18px;line-height:1.1;margin-right:auto}
.brand small{display:block;font-size:12px;font-weight:500;color:var(--muted)}
.svc{display:flex;gap:8px;width:100%}
.svc select{flex:1;min-width:0}
.pill{font-size:13px;padding:6px 10px;border-radius:999px;border:1px solid var(--line);background:var(--card);white-space:nowrap}
.pill.ok{color:var(--ok);border-color:var(--ok);font-weight:600}
@media(min-width:900px){ .svc{width:auto} .svc select{width:340px;flex:none} }

/* tabs */
.tabs{display:flex;gap:6px;padding:8px 16px 0;border-bottom:1px solid var(--line);overflow-x:auto}
.tab-btn{background:none;border:0;padding:10px 12px;border-bottom:3px solid transparent;color:var(--muted);font-weight:600;white-space:nowrap}
.tab-btn[aria-selected="true"]{color:var(--ink);border-bottom-color:var(--accent)}
main{max-width:1200px;margin:0 auto;padding:16px}

/* buttons */
.btn{min-height:44px;padding:10px 16px;border-radius:12px;border:1px solid var(--line);background:var(--card);font-weight:600}
.btn.primary{background:var(--accent);border-color:var(--accent);color:var(--accent-ink)}
.btn.ghost{background:transparent}
.btn.wa{background:var(--wa);border-color:var(--wa);color:#063d1f}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn.grow{flex:1}
.link{background:none;border:0;padding:6px 0;font-weight:600}
.link.danger{color:var(--danger)}
.row{display:flex;gap:8px;flex-wrap:wrap}

/* catalog */
.cats{display:flex;gap:8px;overflow-x:auto;padding:2px 0 12px;scrollbar-width:none}
.chip{flex:none;min-height:40px;padding:8px 14px;border-radius:999px;border:1px solid var(--line);background:var(--card);font-weight:600;white-space:nowrap}
.chip.on{background:var(--accent);color:var(--accent-ink);border-color:var(--accent)}
.products{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
@media(min-width:600px){.products{grid-template-columns:repeat(3,minmax(0,1fr))}}
.tile{position:relative;display:flex;flex-direction:column;align-items:flex-start;gap:4px;min-height:92px;padding:12px;text-align:left;border-radius:var(--radius);background:var(--card);border:1px solid var(--line);box-shadow:var(--shadow);transition:transform .08s}
.tile:active{transform:scale(.97)}
.t-name{font-weight:700;line-height:1.2;padding-right:30px}
.t-sub{font-size:12px;color:var(--muted);line-height:1.3}
.t-price{color:var(--accent);font-weight:700;margin-top:auto}
.t-price.tbd{color:var(--warn);font-weight:600}
.badge{position:absolute;top:8px;right:8px;min-width:26px;height:26px;padding:0 7px;border-radius:999px;background:var(--accent);color:var(--accent-ink);display:grid;place-items:center;font-size:13px;font-weight:700}

/* sell layout + cart */
.sell{display:block}
@media(min-width:900px){
  .sell{display:grid;grid-template-columns:minmax(0,1fr) 380px;gap:20px;align-items:start}
  .products{grid-template-columns:repeat(auto-fill,minmax(160px,1fr))}
}
.cart{position:fixed;left:0;right:0;bottom:0;z-index:20;display:flex;flex-direction:column;background:var(--card);border-top:1px solid var(--line);border-radius:18px 18px 0 0;box-shadow:0 -10px 30px rgba(0,0,0,.12)}
.cart.expanded{max-height:82vh}
.cart-head{display:flex;align-items:center;gap:10px;width:100%;padding:14px 16px;background:none;border:0;font-weight:700;text-align:left}
.cart-title{margin-right:auto}
#cartSummary{font-weight:600}
.chev{transition:transform .2s;font-size:12px}
.cart.expanded .chev{transform:rotate(180deg)}
.cart-body{display:none;flex-direction:column;gap:12px;padding:0 16px 16px;overflow:auto;min-height:0}
.cart.expanded .cart-body{display:flex}
.lines{list-style:none;margin:0;padding:0}
.line{display:grid;grid-template-columns:minmax(0,1fr) auto auto auto;align-items:center;gap:8px;padding:10px 0;border-bottom:1px dashed var(--line)}
.trash{width:36px;height:36px;display:grid;place-items:center;border-radius:10px;border:1px solid var(--line);background:transparent;color:var(--danger);padding:0}
.trash svg{width:18px;height:18px}
.btn.danger{color:var(--danger);border-color:var(--danger);display:inline-flex;align-items:center;gap:6px}
.btn.danger:not(:disabled){background:#b3261e;border-color:#b3261e;color:#fff}
.btn.danger svg{width:18px;height:18px}
.l-name{font-weight:600}
.seg{display:grid;grid-template-columns:repeat(var(--n,4),minmax(0,1fr));gap:6px}
.seg button{min-height:40px;padding:6px 4px;border-radius:10px;border:1px solid var(--line);background:var(--card);font-weight:600;font-size:13px}
.seg button.on{background:var(--ink);color:var(--bg);border-color:var(--ink)}
.l-warn{font-size:12px;color:var(--warn);font-weight:600}
.line.adj .l-price{color:var(--ok)}
.l-detail{font-size:12px;color:var(--muted)}
.l-price{font-weight:700;min-width:64px;text-align:right}
.stepper{display:flex;align-items:center;gap:6px}
.stepper button{width:36px;height:36px;border-radius:50%;border:1px solid var(--line);background:var(--card);font-size:18px;line-height:1;padding:0}
.stepper button:disabled{opacity:.35;cursor:not-allowed}
.stepper b{min-width:22px;text-align:center}
.cart-foot{display:flex;flex-direction:column;gap:10px}
.sum{display:flex;justify-content:space-between;font-size:18px}
@media(min-width:900px){
  .cart,.cart.expanded{position:sticky;top:16px;max-height:calc(100vh - 32px);border-radius:var(--radius);border:1px solid var(--line);box-shadow:var(--shadow)}
  .cart-head{cursor:default}
  .chev{display:none}
  .cart-body{display:flex !important}
}
@media(min-width:900px){body{padding-bottom:0}}

/* orders & totals */
.orders{display:flex;flex-direction:column;gap:12px}
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;box-shadow:var(--shadow)}
.card h3{margin-bottom:10px}
.order header{display:flex;flex-wrap:wrap;gap:6px 10px;align-items:baseline}
.order .amt{margin-left:auto}
.who{font-weight:600}
.order ul{margin:8px 0;padding-left:18px}
.stats{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px;margin-bottom:12px}
.stat{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:12px}
.stat span{display:block;font-size:12px;color:var(--muted)}
.stat b{font-size:20px}
.two{display:grid;gap:12px;margin-bottom:12px}
@media(min-width:800px){.two{grid-template-columns:1fr 1fr}}
.tbl{width:100%;border-collapse:collapse}
.tbl th,.tbl td{padding:8px 4px;border-bottom:1px solid var(--line);text-align:left}
.tbl th:not(:first-child),.tbl td:not(:first-child){text-align:right}
.tbl tfoot th{font-weight:700}
.pgroup{margin-bottom:12px}
.pgroup h4{font-size:14px;color:var(--accent);margin-bottom:4px;display:flex;justify-content:space-between}
.plist{list-style:none;margin:0;padding:0}
.plist li{display:flex;justify-content:space-between;padding:4px 0;border-bottom:1px dashed var(--line)}
.export{min-height:300px;font:13px/1.45 ui-monospace,Menlo,Consolas,monospace;resize:vertical;margin-bottom:12px}

/* dialogs */
dialog{border:0;border-radius:18px;padding:0;width:min(560px,calc(100vw - 24px));max-height:90vh;background:var(--card);color:var(--ink);box-shadow:0 20px 60px rgba(0,0,0,.35)}
dialog::backdrop{background:rgba(20,12,6,.55)}
.dlg{display:flex;flex-direction:column;gap:14px;padding:18px;max-height:90vh;overflow:auto}
.dlg-title{font-size:20px;display:flex;justify-content:space-between;gap:10px;align-items:baseline}
.price{color:var(--accent)}
.need{display:flex;justify-content:space-between;align-items:center;gap:10px;font-weight:700}
.flav-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
@media(min-width:520px){.flav-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
.fl{display:flex;justify-content:space-between;align-items:center;gap:6px;padding:6px 8px 6px 12px;border:1px solid var(--line);border-radius:12px}
.fl.has{border-color:var(--accent)}
.fl > span{font-weight:700}
.chips{display:flex;flex-wrap:wrap;gap:8px}
.b-actions{display:flex;justify-content:flex-end;gap:8px;flex-wrap:wrap}
.field{display:flex;flex-direction:column;gap:6px;font-weight:600}

/* toast */
.toast{position:fixed;left:50%;bottom:104px;transform:translate(-50%,12px);background:var(--ink);color:var(--bg);padding:10px 16px;border-radius:999px;font-weight:600;opacity:0;transition:opacity .2s,transform .2s;pointer-events:none;z-index:40;white-space:nowrap;max-width:90vw;overflow:hidden;text-overflow:ellipsis}
.toast.show{opacity:1;transform:translate(-50%,0)}
@media(min-width:900px){.toast{bottom:24px}}

/* ---- additions for the server version ---- */
.userbar{display:flex;gap:8px;align-items:center;margin-left:auto}
.userbar form{margin:0}
.link-btn{display:inline-flex;align-items:center;min-height:40px;padding:8px 12px;border-radius:12px;border:1px solid var(--line);text-decoration:none;color:inherit;font-weight:600}
.login-body{min-height:100vh;display:grid;place-items:center;padding:16px}
.login-card{width:min(380px,100%);background:var(--card);border:1px solid var(--line);border-radius:18px;padding:24px;box-shadow:var(--shadow)}
.login-card h1{margin:0 0 4px;font-size:22px}
.login-card form{display:flex;flex-direction:column;gap:14px;margin-top:16px}
.err{color:var(--danger);font-weight:600;margin:8px 0 0}
.btn.danger.solid,.btn.danger:not(:disabled){background:#b3261e;border-color:#b3261e;color:#fff}
.btn.danger:disabled{background:transparent;color:var(--danger);border-color:var(--danger)}
.order.cancelled{opacity:.6;text-decoration:line-through}
.order.cancelled .l-warn{text-decoration:none;display:block}
.admin-grid{display:grid;gap:12px}
.tbl td,.tbl th{font-size:14px}
.diff{font:12px/1.4 ui-monospace,Menlo,Consolas,monospace;white-space:pre-wrap;background:var(--bg);border:1px solid var(--line);border-radius:12px;padding:10px;overflow:auto;max-height:340px}
.diff .add{color:var(--ok)}
.diff .del{color:var(--danger)}
.verdict{font-size:18px;font-weight:800;margin:4px 0 8px}
.verdict.ok{color:var(--ok)}
.verdict.bad{color:var(--danger)}
.verdict.warn{color:var(--warn)}
textarea.paste{min-height:200px;font:13px/1.45 ui-monospace,Menlo,Consolas,monospace;resize:vertical}
.tab-pane[hidden]{display:none!important}
