:root {
  --bg: #f3f4f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e5e7ef;
  --line-2: #eef0f5;
  --accent: #f97316;
  --accent-2: #ea580c;
  --accent-ink: #ffffff;
  --accent-soft: #fff4ec;
  --ok: #16a34a;
  --ok-soft: #eaf8ef;
  --warn: #d97706;
  --warn-soft: #fff7e6;
  --bad: #dc2626;
  --bad-soft: #fdeeee;
  --side: #0b1220;
  --side-2: #131c2e;
  --side-ink: #9aa6bd;
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 6px 24px rgba(15, 23, 42, .06);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, .22);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.5 var(--font); color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.lucide { width: 18px; height: 18px; stroke-width: 2; flex: none; }
kbd {
  font: 500 10.5px var(--mono); padding: 2px 6px; border-radius: 5px;
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); color: inherit; opacity: .8;
}
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
[hidden] { display: none !important; }
.code { font: 500 11.5px var(--mono); color: var(--muted); }

/* ================= LAYOUT ================= */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; }

.sidebar {
  background: radial-gradient(120% 60% at 0% 0%, #1e293b 0%, var(--side) 60%);
  color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 14px; gap: 4px;
}
.brand { display: flex; gap: 12px; align-items: center; padding: 4px 6px 20px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: #fff; display: grid; place-items: center; box-shadow: 0 8px 20px rgba(249,115,22,.35);
}
.logo svg { width: 22px; height: 22px; }
.brand-name { color: #fff; font-weight: 800; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11.5px; opacity: .7; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; padding: 14px 10px 6px; opacity: .5; font-weight: 700; }
nav { display: flex; flex-direction: column; gap: 2px; }
.nav-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: none; border: 0; color: inherit; text-align: left; font-weight: 600;
  padding: 10px 12px; border-radius: 10px; cursor: pointer; transition: background .15s, color .15s;
}
.nav-btn span { flex: 1; }
.nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-btn.active { background: linear-gradient(135deg, #fb923c, #ea580c); color: #fff; box-shadow: 0 6px 18px rgba(249,115,22,.3); }
.nav-btn.active kbd { border-color: rgba(255,255,255,.35); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.today-card { background: var(--side-2); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 12px 14px; }
.tc-lbl { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.tc-lbl svg { width: 14px; height: 14px; color: #4ade80; }
.tc-val { color: #fff; font-weight: 800; font-size: 20px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tc-sub { font-size: 12px; opacity: .7; }
.clock { font-size: 12px; opacity: .6; padding: 0 4px; }

.main { overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.view { display: none; padding: 26px 30px; overflow: auto; height: 100%; }
.view.active { display: block; animation: fade .18s ease; }
#view-counter.active { display: flex; padding: 0; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

.view-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }
.view-head h1 { margin: 0; font-size: 26px; letter-spacing: -.02em; font-weight: 800; }
.view-head p { margin: 2px 0 0; }
.head-actions { display: flex; gap: 8px; }

/* ================= CONTROLS ================= */
input, select, textarea {
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 9px 12px; outline: none; min-width: 0; transition: border-color .15s, box-shadow .15s;
}
select { cursor: pointer; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(249,115,22,.14); }
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px;
  cursor: pointer; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  white-space: nowrap; transition: transform .08s, filter .15s, background .15s, border-color .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #fb923c, #ea580c); color: var(--accent-ink); box-shadow: 0 6px 16px rgba(234,88,12,.25); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { border-color: #cbd5e1; background: #fafbfc; }
.btn.danger { background: var(--bad-soft); color: var(--bad); border-color: #f8caca; }
.btn.sm { padding: 6px 11px; font-size: 13px; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 9px; color: var(--ink-2);
  width: 32px; height: 32px; cursor: pointer; display: inline-grid; place-items: center; transition: all .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.icon-btn.danger:hover { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }

.search-wrap { position: relative; flex: 1; min-width: 220px; }
.search-wrap input { width: 100%; padding-left: 38px; }
.search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-wrap.big input { font-size: 16px; padding: 15px 130px 15px 46px; border-radius: 14px; box-shadow: var(--shadow-sm); border-color: var(--line); }
.search-wrap.big .search-ico { left: 16px; width: 20px; height: 20px; }
.search-wrap.big input::-webkit-search-cancel-button { display: none; }
.search-hints { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; pointer-events: none; }
.search-hints kbd { background: var(--line-2); border-color: var(--line); color: var(--muted); }

.toolbar {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px;
  background: var(--panel); padding: 10px; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line-2);
}
.price-range { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.price-range input { width: 90px; }

/* ================= STATS ================= */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--panel); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line-2); transition: transform .15s, box-shadow .15s;
}
.stat .s-ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat .s-ico svg { width: 20px; height: 20px; }
.stat .lbl { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat .val { font-size: 22px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.25; }
.stat .sub { font-size: 12px; color: var(--muted); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(15,23,42,.1); }
.t-orange { background: #fff1e6; color: #ea580c; }
.t-green  { background: #e7f8ee; color: #16a34a; }
.t-blue   { background: #e8f0ff; color: #2563eb; }
.t-violet { background: #f1ecff; color: #7c3aed; }
.t-amber  { background: #fff6e0; color: #d97706; }
.t-red    { background: #fdecec; color: #dc2626; }

/* ================= TABLE ================= */
.table-wrap { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); overflow: auto; border: 1px solid var(--line-2); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); text-align: left; white-space: nowrap; }
.tbl th { position: sticky; top: 0; background: #f8fafc; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; user-select: none; z-index: 1; }
.tbl th[data-sort] { cursor: pointer; }
.tbl th[data-sort]:hover { color: var(--ink); }
.tbl th.sorted { color: var(--accent-2); }
.tbl th.sorted::after { content: " ↑"; }
.tbl th.sorted.desc::after { content: " ↓"; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: #fbfcfe; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .actions { display: flex; gap: 6px; justify-content: flex-end; }
.tbl tr.void td { color: var(--muted); }
.tbl tr.void td b { text-decoration: line-through; }
.item-cell { display: flex; align-items: center; gap: 12px; min-width: 240px; white-space: normal; }
.thumb {
  width: 48px; height: 48px; border-radius: 10px; flex: none; overflow: hidden; position: relative;
  background: var(--line-2); display: grid; place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sm { width: 40px; height: 40px; border-radius: 9px; }
.ic-name { font-weight: 700; line-height: 1.3; }
.ic-meta { display: flex; gap: 8px; align-items: center; margin-top: 2px; flex-wrap: wrap; }
.empty { padding: 48px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg { width: 36px; height: 36px; opacity: .5; }
.table-foot { color: var(--muted); font-size: 12px; padding: 10px 4px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.grey { background: #eef1f5; color: var(--muted); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.cat-tag { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 6px; }
.cat-tag svg { width: 12px; height: 12px; }
mark { background: #fde68a; color: inherit; border-radius: 3px; padding: 0 1px; }

/* image fallback (offline / broken) */
.img-fallback { width: 100%; height: 100%; display: grid; place-items: center; color: #fff; }
.img-fallback svg { width: 40%; height: 40%; max-width: 44px; max-height: 44px; opacity: .95; }

/* ================= POS ================= */
.pos { display: grid; grid-template-columns: 1fr 420px; width: 100%; height: 100%; }
.pos-left { padding: 22px 24px 0; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pos-top { display: flex; gap: 10px; }
.brand-select { border-radius: 14px; padding: 0 14px; min-width: 150px; box-shadow: var(--shadow-sm); font-weight: 600; }
.cats { display: flex; gap: 8px; overflow-x: auto; padding: 14px 2px 12px; scrollbar-width: thin; flex: none; }
.cat {
  display: flex; align-items: center; gap: 8px; flex: none;
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px 6px 6px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-2);
  transition: all .15s;
}
.cat .c-ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.cat .c-ico svg { width: 14px; height: 14px; }
.cat .c-n { font-size: 11px; color: var(--muted); font-weight: 700; }
.cat:hover { border-color: #cbd5e1; }
.cat.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cat.on .c-n { color: #94a3b8; }

.pos-results {
  flex: 1; overflow: auto; padding: 2px 2px 24px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; align-content: start;
}
.prod {
  background: var(--panel); border: 2px solid transparent; border-radius: 16px; overflow: hidden;
  cursor: pointer; box-shadow: var(--shadow); display: flex; flex-direction: column; position: relative;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.prod:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(15,23,42,.12); }
.prod.sel { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(249,115,22,.15), var(--shadow); }
.prod.out { opacity: .55; cursor: not-allowed; filter: grayscale(.7); }
.pos-results { grid-auto-rows: max-content; }
.prod .p-img { flex: none; height: 118px; position: relative; overflow: hidden; background: var(--line-2); }
.prod .p-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s; display: block; }
.prod:hover .p-img img { transform: scale(1.06); }
.prod .p-img::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, transparent 55%, rgba(0,0,0,.35)); pointer-events: none; }
.prod .p-cat { position: absolute; left: 8px; top: 8px; z-index: 1; color: #fff; display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; backdrop-filter: blur(6px); }
.prod .p-cat svg { width: 12px; height: 12px; }
.prod .p-stock { position: absolute; right: 8px; bottom: 8px; z-index: 1; }
.prod .p-stock .pill { background: rgba(255,255,255,.92); }
.prod .p-incart {
  position: absolute; top: 8px; right: 8px; z-index: 2; background: var(--accent); color: #fff;
  border-radius: 999px; min-width: 26px; height: 26px; padding: 0 8px; font-size: 12.5px; font-weight: 800;
  display: grid; place-items: center; box-shadow: 0 4px 10px rgba(234,88,12,.4);
}
.prod .p-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.prod .p-name { font-weight: 700; font-size: 14.5px; line-height: 1.3; }
.prod .p-meta { font-size: 12px; color: var(--muted); }
.prod .p-row { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; }
.prod .p-price { font-size: 18px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.prod .p-add { width: 32px; height: 32px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; transition: all .15s; }
.prod:hover .p-add, .prod.sel .p-add { background: var(--accent); color: #fff; }

.pos-right { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; box-shadow: -8px 0 30px rgba(15,23,42,.04); }
.cart-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 18px 12px; border-bottom: 1px solid var(--line-2); }
.cart-head h2 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.cart-head h2 svg { color: var(--accent); }
.cart { flex: 1; overflow: auto; padding: 6px 18px; }
.cart-empty { color: var(--muted); text-align: center; padding: 48px 10px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.cart-empty .ce-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 6px; }
.cart-empty .ce-ico svg { width: 28px; height: 28px; }
.cart-empty b { color: var(--ink); }
.line { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); animation: fade .2s ease; }
.line .thumb { grid-row: span 2; }
.line .l-name { font-weight: 700; line-height: 1.3; }
.line .l-meta { font-size: 12px; color: var(--muted); }
.line .l-total { font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.line .l-ctrl { grid-column: 2 / -1; display: flex; gap: 6px; align-items: center; }
.qty { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.qty button { border: 0; background: #f8fafc; width: 30px; cursor: pointer; display: grid; place-items: center; color: var(--ink-2); }
.qty button svg { width: 14px; height: 14px; }
.qty button:hover { background: var(--accent-soft); color: var(--accent-2); }
.qty input { border: 0; width: 42px; text-align: center; border-radius: 0; padding: 5px 2px; font-weight: 700; }
.qty input:focus { box-shadow: none; }
.l-price { width: 88px; padding: 5px 8px; text-align: right; border-radius: 9px; }
.l-price.changed { border-color: var(--warn); background: var(--warn-soft); }
.line .rm { margin-left: auto; }

.cart-foot { border-top: 1px solid var(--line); padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 10px; background: #fafbfd; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: end; }
.inp-ico { position: relative; }
.inp-ico svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.inp-ico input { width: 100%; padding-left: 32px; }
.lbl-stack { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 3px; font-weight: 600; }
.lbl-stack input { color: var(--ink); }
.totals > div { display: flex; justify-content: space-between; align-items: center; padding: 3px 0; font-variant-numeric: tabular-nums; }
.totals span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); }
.totals span svg { width: 15px; height: 15px; color: var(--muted); }
.disc-in { display: flex; gap: 4px; }
.disc-in input { width: 90px; text-align: right; padding: 6px 8px; }
.disc-in select { padding: 6px 8px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button {
  border: 1px solid var(--line); background: #fff; padding: 9px; cursor: pointer; font-weight: 700; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--ink-2); transition: all .15s;
}
.seg button svg { width: 16px; height: 16px; }
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.change { display: flex; flex-direction: column; align-items: flex-end; font-size: 12px; color: var(--muted); font-weight: 600; }
.change b { font-size: 22px; color: var(--ok); font-variant-numeric: tabular-nums; }
.change.neg b { color: var(--bad); }
.quick-cash { display: flex; gap: 6px; flex-wrap: wrap; }
.quick-cash button { border: 1px dashed #cbd5e1; background: #fff; border-radius: 8px; padding: 4px 10px; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.quick-cash button:hover { border-color: var(--accent); color: var(--accent-2); border-style: solid; }
.checkout { justify-content: space-between !important; padding: 15px 18px !important; font-size: 16px !important; border-radius: 14px !important; }
.checkout .co-left { display: inline-flex; align-items: center; gap: 8px; }
.checkout .co-total { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.btn.xl { width: 100%; }

/* ================= DASHBOARD ================= */
.hero {
  position: relative; border-radius: 20px; overflow: hidden; margin-bottom: 18px; min-height: 170px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 26px 28px; color: #fff;
  background: #1e293b center/cover no-repeat;
}
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(11,18,32,.88) 0%, rgba(11,18,32,.45) 55%, rgba(11,18,32,.05) 100%); }
.hero > * { position: relative; }
.hero h1 { margin: 2px 0 4px; font-size: 30px; letter-spacing: -.02em; }
.hero p { margin: 0; opacity: .8; }
.hero-greet { font-size: 13px; font-weight: 700; color: #fdba74; text-transform: uppercase; letter-spacing: .1em; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border: 1px solid var(--line-2); }
.card h3 { margin: 0 0 14px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.card h3 svg { color: var(--accent); }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.bar { height: 6px; background: var(--line-2); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, #fb923c, #ea580c); border-radius: 3px; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-2); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }

/* ================= FORMS ================= */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.form label input, .form label select, .form label textarea { color: var(--ink); font-weight: 400; }
.form label.btn { flex-direction: row; gap: 8px; font-size: 13px; font-weight: 700; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; }
.form .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .hint { font-size: 12.5px; color: var(--muted); background: #f8fafc; padding: 8px 12px; border-radius: 10px; }
.form .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.img-picker { display: flex; gap: 14px; align-items: center; padding: 12px; border: 1px dashed #cbd5e1; border-radius: 12px; background: #fafbfd; }
.img-picker .thumb { width: 96px; height: 72px; border-radius: 10px; }
.img-picker .ip-side { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.img-picker .ip-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.file-btn { cursor: pointer; }
.err { color: var(--bad); font-size: 13px; min-height: 1em; font-weight: 600; }

/* ================= MODAL ================= */
.modal-bg { position: fixed; inset: 0; background: rgba(11,18,32,.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: #fff; border-radius: 18px; width: min(600px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .2s ease; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px; overflow: auto; }
.x { border: 0; background: var(--line-2); width: 32px; height: 32px; border-radius: 9px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.x:hover { background: var(--bad-soft); color: var(--bad); }

/* ================= TOASTS ================= */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 60; align-items: center; }
.toast { background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; box-shadow: var(--shadow-lg); animation: pop .2s ease; display: flex; align-items: center; gap: 8px; font-weight: 600; }
.toast svg { width: 17px; height: 17px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: #15803d; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }

/* ================= RECEIPT ================= */
.receipt { width: 302px; margin: 0 auto; background: #fff; color: #000; font: 12px/1.4 "Courier New", ui-monospace, monospace; padding: 14px; }
.receipt-preview { background: linear-gradient(135deg, #eef1f6, #e2e7ef); padding: 20px; border-radius: 14px; }
.receipt-preview .receipt { box-shadow: 0 10px 30px rgba(15,23,42,.15); border-radius: 4px; }
.receipt .c { text-align: center; }
.receipt h2 { font-size: 17px; margin: 0; letter-spacing: .02em; }
.receipt hr { border: 0; border-top: 1px dashed #000; margin: 7px 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td { vertical-align: top; padding: 1px 0; }
.receipt td.r { text-align: right; }
.receipt .big td { font-size: 15px; font-weight: 700; padding: 3px 0; }
.receipt .void-stamp { border: 2px solid #000; text-align: center; font-weight: 700; padding: 4px; margin: 6px 0; }
.receipt-ok { text-align: center; margin-bottom: 14px; }
.receipt-ok .ok-ico { width: 52px; height: 52px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: inline-grid; place-items: center; }
.receipt-ok .ok-ico svg { width: 26px; height: 26px; }
.receipt-ok h3 { margin: 6px 0 0; }
.receipt-actions { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

#printArea { display: none; }
@media print {
  @page { size: 80mm auto; margin: 0; }
  body { background: #fff; }
  .app, .modal-bg, .toasts { display: none !important; }
  #printArea { display: block; }
  #printArea .receipt { width: 72mm; padding: 2mm; box-shadow: none; }
}

/* ================= RESPONSIVE ================= */
@media (max-width: 1100px) {
  .app { grid-template-columns: 76px 1fr; }
  .brand-text, .nav-btn span, .nav-btn kbd, .nav-label, .sidebar-foot { display: none; }
  .brand { justify-content: center; padding: 4px 0 18px; }
  .nav-btn { justify-content: center; padding: 12px; }
  .pos { grid-template-columns: 1fr 380px; }
}
/* ================= LIVE: roles, discounts, uploads, login ================= */
body.is-cashier .adm-only, body.is-cashier .adm { display: none !important; }
body:not(.ready) .app { visibility: hidden; }
.boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); font-weight: 600; z-index: 70; background: var(--bg); text-align: center; padding: 16px; }
.boot svg { width: 36px; height: 36px; color: var(--muted); }
body.ready .boot { display: none; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; border: 2px solid currentColor; border-color: rgba(255,255,255,.9) rgba(255,255,255,.3) rgba(255,255,255,.3); animation: spin .7s linear infinite; }
.btn.ghost.busy::after { border-color: var(--accent) var(--line) var(--line); }

/* user card in the sidebar */
.user-card { display: flex; align-items: center; gap: 10px; background: var(--side-2); border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 10px 10px 10px 12px; }
.user-card .avatar { background: rgba(249,115,22,.18); color: #fdba74; }
.user-card .avatar svg { width: 16px; height: 16px; }
.uc-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.uc-text b { color: #fff; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.uc-text small { font-size: 11px; opacity: .7; }
.user-card .icon-btn { background: transparent; border-color: rgba(255,255,255,.12); color: var(--side-ink); }
.user-card .icon-btn:hover { color: #fff; border-color: var(--accent); background: rgba(249,115,22,.15); }

/* discounts */
.disc-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; background: #fff1e6; color: var(--accent-2); font-size: 12px; font-weight: 800; white-space: nowrap; }
.disc-tag svg { width: 13px; height: 13px; }
.prod .p-off { position: absolute; left: 8px; top: 34px; z-index: 1; background: #dc2626; color: #fff; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; box-shadow: 0 4px 10px rgba(220,38,38,.35); }
.prod .p-price s, .line .l-total s { display: block; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.prod .p-price { display: flex; flex-direction: column-reverse; line-height: 1.15; }
.line .l-total { line-height: 1.2; }
.l-disc { grid-column: 2 / -1; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.l-disc > span { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.l-disc svg { width: 13px; height: 13px; }
.l-disc input { width: 64px; padding: 4px 6px; text-align: right; border-radius: 8px; font-size: 13px; }
.l-disc select { padding: 4px 6px; border-radius: 8px; font-size: 13px; }
.l-disc b { margin-left: auto; color: var(--accent-2); font-variant-numeric: tabular-nums; }
.l-disc.on input, .l-disc.on select { border-color: #fdba74; background: #fff8f2; }
.totals .minus { color: var(--accent-2); font-weight: 800; }
.disc-box { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 12px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.disc-box legend { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); padding: 0 6px; }
.disc-box legend svg { width: 15px; height: 15px; color: var(--accent); }
.disc-box legend .muted { font-weight: 500; }
.disc-box .hint { margin: 0; }
.seg-2 button { padding: 8px 6px; }
.inp-suffix { display: flex; align-items: stretch; }
.inp-suffix input { flex: 1; min-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.inp-suffix span { display: grid; place-items: center; padding: 0 12px; background: var(--line-2); border: 1px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0; font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.disc-val[hidden] { display: none !important; }

/* modal sizes & questions */
.modal.wide { width: min(820px, 100%); }
.ask-msg { margin: 0 0 6px; color: var(--ink-2); line-height: 1.55; }

/* empty states */
.big-empty { padding: 56px 16px; gap: 6px; }
.big-empty svg { width: 42px; height: 42px; }
.big-empty .btn { margin-top: 10px; }
.empty .empty-actions { display: flex; gap: 8px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }

/* bulk upload */
.upload-steps { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); background: #f8fafc; border-radius: 12px; padding: 12px 14px; }
.upload-steps a { color: var(--accent-2); font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.upload-steps svg { width: 14px; height: 14px; }
.drop { border: 2px dashed #cbd5e1; border-radius: 14px; padding: 22px 16px; display: flex !important; flex-direction: column; align-items: center; gap: 4px !important; text-align: center; cursor: pointer; background: #fff; transition: all .15s; }
.drop svg { width: 30px; height: 30px; color: var(--ok); }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.inline-opt { flex-direction: row !important; align-items: center; gap: 8px !important; flex-wrap: wrap; }
.imp-counts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.imp-table { max-height: 320px; }
.imp-table .tbl td { white-space: normal; vertical-align: top; }
.imp-table .tbl td.num { white-space: nowrap; }
.imp-table tr.skip td { background: #fffafa; }
.small { font-size: 12px; }
.list-row.inactive { opacity: .55; }

/* sign-in page */
.login-page { min-height: 100vh; background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { position: relative; color: #fff; padding: 36px 44px; display: flex; flex-direction: column; justify-content: space-between; overflow: hidden;
  background: linear-gradient(160deg, rgba(11,18,32,.55), rgba(11,18,32,.92)), url("https://images.unsplash.com/photo-1636761358757-0a616eb9e17e?w=1400&h=1400&fit=crop&q=70&auto=format") center / cover, var(--side); }
.la-brand { display: flex; align-items: center; gap: 12px; font-weight: 800; font-size: 18px; }
.la-copy h1 { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 12px; text-wrap: balance; }
.la-copy p { margin: 0; max-width: 42ch; opacity: .8; font-size: 15px; }
.login-card { align-self: center; justify-self: center; width: min(400px, 100%); padding: 32px 24px; display: flex; flex-direction: column; gap: 18px; }
.lc-head .logo { display: none; margin-bottom: 14px; }
.lc-head h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; }
.lc-head p { margin: 4px 0 0; }
.pw-wrap { position: relative; display: flex; }
.pw-wrap input { flex: 1; padding-right: 44px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; width: 36px; height: 36px; border-radius: 8px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.pw-eye:hover { color: var(--accent-2); background: var(--accent-soft); }
.pw-eye svg { width: 18px; height: 18px; }
.login-card .form input { padding: 12px 14px; font-size: 15px; }
.login-card .btn.xl { justify-content: center; padding: 13px; font-size: 15px; }
.lc-foot { text-align: center; margin: 0; }
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .login-card { padding: max(48px, env(safe-area-inset-top)) 20px 32px; }
  .lc-head .logo { display: grid; }
}

/* phone-only pieces are hidden on larger screens */
.m-top, .cart-bar, .sheet-bg, .m-only { display: none; }
.cart-head-actions { display: flex; gap: 8px; align-items: center; }

/* ================= PHONE ================= */
@media (max-width: 760px) {
  :root { --navh: 64px; }
  html, body { height: auto; }
  body { padding-bottom: calc(var(--navh) + env(safe-area-inset-bottom)); }
  .app { display: block; height: auto; min-height: 100vh; }

  /* top bar */
  .m-top {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 20;
    padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
    background: radial-gradient(140% 120% at 0% 0%, #1e293b 0%, var(--side) 70%); color: #fff;
  }
  .m-top .logo { width: 34px; height: 34px; border-radius: 10px; }
  .m-top .logo svg { width: 18px; height: 18px; }
  .m-shop { font-weight: 800; font-size: 17px; letter-spacing: -.01em; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .m-today { text-align: right; line-height: 1.15; }
  .m-today small { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: #fdba74; font-weight: 700; }
  .m-today b { font-size: 14px; }

  /* sidebar becomes a bottom tab bar */
  .sidebar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; flex-direction: row; justify-content: space-around;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); gap: 0; height: auto;
    background: var(--side); box-shadow: 0 -6px 24px rgba(11,18,32,.25);
  }
  .brand, .nav-label, .sidebar-foot { display: none; }
  .sidebar nav { display: contents; }
  .nav-btn {
    flex: 1; flex-direction: column; gap: 3px; padding: 7px 2px; border-radius: 12px; justify-content: center;
    font-size: 10.5px; font-weight: 700; min-width: 0;
  }
  .nav-btn span { display: block; flex: none; }
  .nav-btn kbd { display: none; }
  .nav-btn svg { width: 21px; height: 21px; }
  .nav-btn.active { box-shadow: none; }

  .main { overflow: visible; display: block; }
  .view { height: auto; padding: 16px; overflow: visible; }
  #view-counter { padding: 0; }

  /* counter */
  .pos { display: block; height: auto; }
  .pos-left { padding: 12px 12px 90px; }
  .pos-top { position: sticky; top: calc(54px + env(safe-area-inset-top)); z-index: 5; background: var(--bg); margin: -12px -12px 0; padding: 12px 12px 0; }
  .search-hints, .brand-select { display: none; }
  .search-wrap { min-width: 0; }
  .search-wrap.big input { padding: 13px 14px 13px 44px; }
  .cats { padding: 10px 2px; scrollbar-width: none; }
  .cats::-webkit-scrollbar { display: none; }
  .pos-results { max-height: none; overflow: visible; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 2px 0; }
  .prod .p-img { height: 100px; }

  /* floating cart bar */
  .cart-bar {
    display: flex; align-items: center; gap: 12px; position: fixed; z-index: 25;
    left: 12px; right: 12px; bottom: calc(var(--navh) + 10px + env(safe-area-inset-bottom));
    padding: 12px 16px; border: 0; border-radius: 16px; color: #fff; font: inherit; font-weight: 700; cursor: pointer;
    background: linear-gradient(135deg, #fb923c, #ea580c); box-shadow: 0 10px 30px rgba(234,88,12,.4);
    animation: pop .2s ease;
  }
  .cart-bar[hidden] { display: none; }
  .cb-ico { position: relative; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: rgba(255,255,255,.2); }
  .cb-ico svg { width: 18px; height: 18px; }
  .cb-ico b { position: absolute; top: -6px; right: -8px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: #fff; color: #ea580c; font-size: 11px; display: grid; place-items: center; }
  .cb-txt { flex: 1; text-align: left; font-size: 15px; }
  .cb-total { font-size: 17px; font-weight: 800; }

  /* cart as a bottom sheet */
  .pos-right {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; max-height: 92vh; height: 92vh;
    border: 0; border-radius: 22px 22px 0 0; box-shadow: 0 -20px 50px rgba(11,18,32,.3);
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
  }
  body.cart-open .pos-right { transform: none; }
  body.cart-open { overflow: hidden; }
  .sheet-bg { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(11,18,32,.5); opacity: 0; pointer-events: none; transition: opacity .25s; }
  body.cart-open .sheet-bg { opacity: 1; pointer-events: auto; }
  body.cart-open .cart-bar { display: none; }
  .cart-head { position: relative; padding-top: 22px; }
  .cart-head::before { content: ""; position: absolute; top: 8px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 4px; background: var(--line); }
  .m-only { display: inline-grid; }
  .cart-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .cart-foot .row2 { grid-template-columns: 1fr 1fr; }

  /* no iOS zoom on focus */
  input, select, textarea { font-size: 16px !important; }

  /* pages */
  .view-head { align-items: flex-start; margin-bottom: 14px; }
  .view-head h1 { font-size: 22px; }
  .head-actions { width: 100%; display: flex; gap: 8px; }
  .head-actions .btn { flex: 1; justify-content: center; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .toolbar { gap: 8px; }
  .toolbar > select { flex: 1 1 45%; min-width: 0; }
  .toolbar .search-wrap { flex: 1 1 100%; }
  .price-range { flex: 1 1 100%; }
  .price-range input { flex: 1; min-width: 0; }
  .form .grid { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .hero { padding: 20px; flex-direction: column; align-items: flex-start; gap: 14px; }
  .hero h1 { font-size: 24px; }

  /* tables become cards */
  .table-wrap { background: transparent; box-shadow: none; border: 0; overflow: visible; }
  .tbl thead { display: none; }
  .tbl, .tbl tbody { display: block; }
  .tbl tbody tr {
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px 14px; margin-bottom: 10px; padding: 12px 14px;
    background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow-sm);
  }
  .tbl td { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 0; border: 0; white-space: normal; text-align: right; }
  .tbl td.num { text-align: right; }
  .tbl td::before { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); text-align: left; }
  .tbl td:first-child { grid-column: 1 / -1; justify-content: flex-start; text-align: left; padding-bottom: 8px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px; }
  .tbl td:last-child { grid-column: 1 / -1; justify-content: flex-end; padding-top: 8px; }
  .tbl td:last-child::before { content: none; }
  .tbl td[data-label]::before { content: attr(data-label); }
  .tbl td[data-label=""]::before { content: none; }
  body.is-cashier .tbl td.adm { display: none; }
  .tbl .actions .icon-btn { width: 38px; height: 38px; }
  #salesTable td:nth-child(3) { grid-column: 1 / -1; }
  #invTable td:nth-child(6) { grid-column: 1 / -1; }
  #salesTable td:nth-child(2) { grid-column: 1 / -1; white-space: nowrap; }

  /* forms / receipts as full-height sheets */
  .modal-bg { padding: 0; place-items: end stretch; }
  .modal { width: 100%; max-height: 94vh; border-radius: 20px 20px 0 0; }
  .modal-body { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
  .toasts { bottom: calc(var(--navh) + 80px); width: calc(100% - 32px); }
  .modal kbd { display: none; }

  /* compact stat tiles */
  .stat { padding: 12px; gap: 10px; flex-direction: column; align-items: flex-start; }
  .stat .s-ico { width: 32px; height: 32px; border-radius: 9px; }
  .stat .s-ico svg { width: 16px; height: 16px; }
  .stat .val { font-size: 18px; white-space: nowrap; }
  .stat .lbl, .stat .sub { font-size: 11.5px; line-height: 1.35; }

  /* keep label left, value(s) together on the right */
  .tbl td { justify-content: flex-end; gap: 6px; }
  .tbl td::before { margin-right: auto; }
}
