:root { --brand: #0f9d76; --brand2: #0b5cad; --ink: #14212b; --muted: #5e6b75; --line: #dde5ec; --bg: #f1f6f9; --card: #fff;
  --good: #15803d; --bad: #b42318; --warn: #b54708; --shadow: 0 4px 16px rgba(15, 40, 70, .08); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
header { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .55rem .9rem; color: #fff;
  background: linear-gradient(120deg, var(--brand), var(--brand2)); position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow); }
.brand { display: flex; gap: .55rem; align-items: center; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
header small { color: #fff; }
.brand small { display: block; opacity: .85; font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topright { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.pill { font-size: .75rem; background: #ffffff26; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.pill.bad { background: #ffdddd; color: #7a1010; }
nav { display: flex; gap: .3rem; overflow-x: auto; padding: .45rem .7rem; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 50px; z-index: 9; scrollbar-width: none; }
nav button { border: 0; background: transparent; padding: .45rem .8rem; border-radius: 999px; white-space: nowrap; font-weight: 600; color: var(--muted); }
nav button.on { background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff; }
main { padding: .9rem; max-width: 1400px; margin: 0 auto; }
h2 { margin: .2rem 0 .7rem; font-size: 1.25rem; }
.card { background: var(--card); border-radius: 12px; padding: 1rem; box-shadow: var(--shadow); margin-bottom: .9rem; }
.narrow { max-width: 460px; margin: 2rem auto; }
.center { text-align: center; }
.muted, small { color: var(--muted); }
label { display: block; font-size: .85rem; font-weight: 600; margin: .45rem 0 .2rem; }
input, select, textarea { font: inherit; width: 100%; padding: .55rem .65rem; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus { outline: 2px solid #0f9d7655; border-color: var(--brand); }
button { font: inherit; cursor: pointer; padding: .55rem .9rem; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
button.primary { background: linear-gradient(120deg, var(--brand), var(--brand2)); color: #fff; border: 0; font-weight: 600; }
button.big { padding: .85rem 1rem; font-size: 1.05rem; width: 100%; }
button.ghost { background: transparent; color: inherit; border: 1px solid #ffffff66; }
button.danger { color: var(--bad); border-color: #f1c0c0; }
button:disabled { opacity: .55; cursor: default; }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row > * { flex: 1; min-width: 120px; }
.tabs { display: flex; gap: .3rem; margin-bottom: .6rem; }
.tabs button.on { background: var(--ink); color: #fff; }
.msg { margin-top: .6rem; font-size: .9rem; }
.msg.bad { color: var(--bad); } .msg.good { color: var(--good); }
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #eef4f8; font-size: .78rem; text-transform: uppercase; color: var(--muted); }
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e8eef4; }
.badge.good { background: #d9f2e3; color: var(--good); } .badge.bad { background: #fbdcdc; color: var(--bad); } .badge.warn { background: #fff0c2; color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .6rem; margin-bottom: .9rem; }
.stats div { background: #fff; border-radius: 12px; padding: .7rem .9rem; box-shadow: var(--shadow); border-left: 5px solid var(--c, var(--brand)); }
.stats strong { display: block; font-size: 1.35rem; color: var(--c, var(--brand)); }

/* ── Sell: products in rows, cart fixed on the right (bottom on phones) ── */
.sell { display: grid; grid-template-columns: 1fr 380px; gap: .9rem; align-items: start; }
.search { position: sticky; top: 100px; z-index: 5; background: var(--bg); padding-bottom: .5rem; }
.search input { font-size: 1.05rem; padding: .7rem .8rem; }
.prods { display: flex; flex-direction: column; gap: .4rem; }
.prod { display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: center; background: #fff; border-radius: 10px; padding: .55rem .7rem; box-shadow: var(--shadow); }
.prod .name { font-weight: 600; }
.prod .lv { display: flex; gap: .3rem; flex-wrap: wrap; justify-content: flex-end; }
.prod .lv button { padding: .4rem .6rem; font-size: .88rem; background: #f3f8fb; }
.prod .lv button:hover { background: #e3f4ee; border-color: var(--brand); }
.cart { position: sticky; top: 100px; background: #fff; border-radius: 12px; box-shadow: var(--shadow); padding: .8rem; max-height: calc(100vh - 115px); display: flex; flex-direction: column; }
.cart #cMin { flex: 0 0 auto; min-width: 44px; }
.cart .lines { overflow-y: auto; flex: 1; min-height: 80px; margin: .4rem 0; }
.cline { display: grid; grid-template-columns: 1fr auto auto; gap: .3rem; align-items: center; padding: .35rem 0; border-bottom: 1px dashed var(--line); font-size: .92rem; }
.cline .q { display: flex; gap: .2rem; align-items: center; }
.cline .q button { padding: .15rem .5rem; }
.total { font-size: 1.5rem; font-weight: 800; display: flex; justify-content: space-between; margin: .3rem 0; }
.pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.pay label { margin: .2rem 0 0; font-size: .75rem; }
@media (max-width: 900px) {
  .sell { grid-template-columns: 1fr; }
  .cart { position: fixed; left: 0; right: 0; bottom: 0; top: auto; border-radius: 14px 14px 0 0; max-height: 62vh; z-index: 20; box-shadow: 0 -6px 20px rgba(0,0,0,.15); }
  .cart.min .lines, .cart.min .payarea { display: none; }
  .cart.min .total { margin: .1rem 0 .4rem; }
  .cart #cMin { flex: 0 0 auto; min-width: 70px; }
  .prod { grid-template-columns: 1fr; }
  .prod .lv { justify-content: flex-start; }
  main { padding-bottom: 170px; }
  .search { top: 96px; }
}
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 1rem; background: #13293d; color: #fff; padding: .7rem 1rem; border-radius: 10px; z-index: 60; max-width: 92vw; box-shadow: var(--shadow); }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(560px, 94vw); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog > div { padding: 1rem; }
.receipt { font: 12px/1.35 "Courier New", monospace; white-space: pre-wrap; background: #fafafa; padding: .6rem; border-radius: 8px; border: 1px dashed var(--line); }
.qr { text-align: center; margin: .5rem 0; }
.qr svg, .qr img { width: 170px; height: 170px; }
#printArea { display: none; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; }
  .copy { width: 72mm; margin: 0 auto; page-break-after: always; font: 11px/1.3 "Courier New", monospace; white-space: pre-wrap; }
  .copy .qr svg { width: 42mm; height: 42mm; }
}
