:root {
  /* POMBE PLUS colours: logo orange + logo black, warm neutral greys */
  --bg: #f6f5f3; --surface: #ffffff; --surface-2: #faf8f6; --border: #e8e3de; --text: #1c1917; --muted: #6b625b;
  --brand: #e2560d; --brand-2: #c2410c; --brand-soft: #fff0e5; --accent: #292524; --on-brand: #ffffff; --veil: rgba(246,245,243,.8);
  --ok: #15803d; --ok-soft: #e8f6ec; --warn: #b45309; --warn-soft: #fdf3e3; --bad: #b91c1c; --bad-soft: #fdecec; --info: #1d4ed8; --info-soft: #e9effd;
  --shadow: 0 1px 2px rgba(16,24,20,.06), 0 4px 16px rgba(16,24,20,.05); --radius: 12px; --side: 236px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #121110; --surface: #1b1917; --surface-2: #23201d; --border: #35302b; --text: #efeae5; --muted: #a8a29e;
  --brand: #fb8a3c; --brand-2: #fdba74; --brand-soft: #3a2112; --accent: #d6d3d1; --on-brand: #1c1917; --veil: rgba(18,17,16,.78);
  --ok: #4ade80; --ok-soft: #12301e; --warn: #fbbf24; --warn-soft: #33270f; --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #172343;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #121110; --surface: #1b1917; --surface-2: #23201d; --border: #35302b; --text: #efeae5; --muted: #a8a29e;
  --brand: #fb8a3c; --brand-2: #fdba74; --brand-soft: #3a2112; --accent: #d6d3d1; --on-brand: #1c1917; --veil: rgba(18,17,16,.78);
  --ok: #4ade80; --ok-soft: #12301e; --warn: #fbbf24; --warn-soft: #33270f; --bad: #f87171; --bad-soft: #3a1717; --info: #93b4ff; --info-soft: #172343;
  --shadow: 0 1px 2px rgba(0,0,0,.3); color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; } h2 { font-size: 16px; margin: 0 0 12px; } h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 12px; } .right { text-align: right; } .nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* layout */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); position: sticky; top: 0; height: 100vh; overflow-y: auto; padding: 14px 10px 30px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; font-weight: 700; font-size: 17px; }
.brand .logo { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-size: 15px; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* POMBE PLUS logo: the artwork has a white background, so it sits on a white chip (invisible in light mode, a clean badge in dark mode) */
.brand-logo { display: block; background: #fff; border-radius: 10px; padding: 6px 8px; height: auto; }
.side-brand { flex-direction: column; align-items: stretch; gap: 6px; padding: 2px 4px 14px; }
.side-brand .brand-logo { width: 100%; max-width: 210px; }
.side-brand small { max-width: none; padding: 0 4px; }
.auth-brand { padding: 0 0 12px; }
.auth-brand .brand-logo { width: min(260px, 70%); padding: 0; }
.nav-group { margin: 10px 0 2px; padding: 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.nav a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav .ico { width: 18px; text-align: center; opacity: .85; }
.nav .badge { margin-left: auto; }
.main { min-width: 0;
  /* shop photo behind the working area, softened by a theme-coloured veil so cards and text stay readable */
  background: linear-gradient(var(--veil), var(--veil)), url('../img/background.webp') center / cover no-repeat fixed, var(--bg); }
.top { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.top .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 22px 24px 60px; max-width: 1440px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .spacer { flex: 1; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; min-width: 0; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.kpi .l { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .v { font-size: 21px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; overflow-wrap: anywhere; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.accent { border-left: 4px solid var(--brand); }
.up { color: var(--ok); } .down { color: var(--bad); }
.section { margin-top: 18px; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; white-space: nowrap; cursor: default; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--text); }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tr.clickable { cursor: pointer; }
tfoot td { font-weight: 700; background: var(--surface-2); }
.card .tbl-wrap { border: 0; border-radius: 0; margin: 0 -16px -16px; width: calc(100% + 32px); }

/* forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); } .btn.primary:hover { background: var(--brand-2); }
:root[data-theme="dark"] .btn.primary, :root:not([data-theme="light"]) .btn.primary { color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #06201d; } }
:root[data-theme="dark"] .btn.primary { color: #06201d; }
.btn.danger { color: var(--bad); border-color: var(--bad); background: transparent; }
.btn.sm { padding: 4px 9px; font-size: 12px; border-radius: 7px; }
.btn.lg { padding: 12px 18px; font-size: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
input[type=checkbox] { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 14px; }
.filters label.f { min-width: 140px; }
.chk { display: flex; gap: 8px; align-items: center; font-weight: 500; color: var(--text); font-size: 13px; }

/* chips */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); } .badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); } .badge.info { background: var(--info-soft); color: var(--info); }
.badge.brand { background: var(--brand); color: var(--on-brand); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 8px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--brand); border-color: var(--brand); text-decoration: none; }

/* modal & toast */
.overlay { position: fixed; inset: 0; background: rgba(10,16,14,.45); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(980px, 100%); }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 18px 20px; overflow-y: auto; }
.modal footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: calc(100vw - 36px); }
.toast { background: var(--text); color: var(--surface); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 520px; font-weight: 500; white-space: pre-line; }
.toast.bad { background: var(--bad); color: #fff; } .toast.ok { background: var(--ok); color: #fff; }
.alert { padding: 10px 14px; border-radius: 10px; border: 1px solid transparent; margin-bottom: 12px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); } .alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.info { background: var(--info-soft); color: var(--info); } .alert.ok { background: var(--ok-soft); color: var(--ok); }
.empty { padding: 30px; text-align: center; color: var(--muted); }

/* POS */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 14px; align-items: start; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: calc(100vh - 250px); overflow-y: auto; padding: 2px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer; text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 4px; min-height: 92px; }
.pcard:hover { border-color: var(--brand); }
.pcard .n { font-weight: 600; font-size: 13px; line-height: 1.25; }
.pcard .p { font-weight: 700; color: var(--brand); margin-top: auto; }
.pcard.out { opacity: .5; }
.cart { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 10px; }
.cart-lines { max-height: 38vh; overflow-y: auto; }
.cline { display: grid; grid-template-columns: 1fr 78px 62px 92px 26px; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.cline input, .cline select { padding: 5px 6px; }
.pcard .pk { display: flex; gap: 4px; flex-wrap: wrap; margin-top: auto; }
.pcard .pk .btn { padding: 3px 7px; font-size: 11px; color: var(--brand); }
.totals div { display: flex; justify-content: space-between; padding: 2px 0; }
.totals .grand { font-size: 22px; font-weight: 800; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--brand); color: var(--on-brand); }

/* assistant */
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 900px; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--on-brand); padding: 9px 14px; border-radius: 14px 14px 4px 14px; }
.msg.ai { background: var(--surface); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 14px 16px; box-shadow: var(--shadow); }
.msg.ai h3 { font-size: 15px; }
.basis { margin-top: 10px; font-size: 12px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 8px; }
.basis ul { margin: 4px 0 0; padding-left: 18px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px; cursor: pointer; color: var(--text); }
.suggest button:hover { border-color: var(--brand); color: var(--brand); }
.rec { border-left: 4px solid var(--brand); padding: 8px 12px; background: var(--surface-2); border-radius: 0 8px 8px 0; margin-bottom: 8px; }
.rec.p1 { border-color: var(--bad); } .rec.p2 { border-color: var(--warn); }
.rec .why { font-size: 12px; color: var(--muted); margin-top: 3px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.progress > div { height: 100%; background: var(--brand); }
.chart-box { position: relative; height: 260px; }
.notif { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.notif.unread { background: var(--surface-2); }
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; flex: none; }
.dot.critical { background: var(--bad); } .dot.warning { background: var(--warn); } .dot.info { background: var(--info); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  /* shop photo under a dark warm overlay; the gradient alone shows if the photo is missing */
  background: linear-gradient(135deg, rgba(20,14,10,.72), rgba(28,25,23,.45) 55%, rgba(226,86,13,.4)), url('../img/background.webp') center / cover no-repeat fixed, #1c1917; }
.auth .card { box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.auth .card { width: min(440px, 100%); padding: 28px; }

/* print */
.print-only { display: none; }
@media print {
  body { background: #fff; color: #000; }
  .side, .top, .no-print, .toasts, .filters, .btn { display: none !important; }
  .app { display: block; } .content { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .print-only { display: block; }
  .overlay { position: static; background: none; padding: 0; display: block; }
  .modal { box-shadow: none; max-height: none; width: 100% !important; }
  .modal header, .modal footer { display: none; }
  body.printing-modal .app { display: none; }
}
.receipt { font-family: "Courier New", monospace; font-size: 12px; max-width: 320px; margin: 0 auto; }
.receipt table td, .receipt table th { padding: 2px 0; border: 0; background: none; }
.invoice-doc { max-width: 800px; margin: 0 auto; }

@media (max-width: 1100px) { .pos { grid-template-columns: 1fr; } .cart { position: static; } .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; left: 0; top: 0; width: 260px; transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .app.nav-open .side { transform: none; }
  .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 60px; } .top { padding: 10px 16px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .kpi .v { font-size: 17px; }
  .top .hide-sm { display: none; }
}
