﻿:root {
  --bg: #f3f7fb; --panel: #ffffff; --panel-2: #f1f6f9; --text: #1d2433; --muted: #66748a;
  --line: #e3eaf2; --brand: #0d9488; --brand-2: #0f766e; --brand-soft: #d5f5ef;
  --ok: #16a34a; --ok-soft: #e3f8ea; --warn: #c2620a; --warn-soft: #fff3df;
  --bad: #dc2626; --bad-soft: #ffe9ea; --info: #4f6ef7; --info-soft: #ebefff;
  --mpesa: #2e9e44; --shadow: 0 1px 2px rgba(30,50,90,.04), 0 6px 22px rgba(30,50,90,.06);
  --pink: #f472b6; --pink-soft: #ffe4f1; --lilac: #8b5cf6; --lilac-soft: #efe8ff;
  --peach: #fb923c; --peach-soft: #ffeedd; --sky: #38bdf8; --sky-soft: #e0f4ff; --mint-soft: #dcfaf2;
  --radius: 16px; font-family: "Nunito", "Quicksand", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}
/* Dark theme: chosen in Appearance (or follows the device when set to System). */
:root[data-theme="dark"] {
  --bg: #0f1514; --panel: #172120; --panel-2: #1d2928; --text: #e6eeec; --muted: #94a5a1;
  --line: #2a3836; --brand: #2bb3a3; --brand-2: #5fd0c2; --brand-soft: #163b37;
  --ok: #4ade80; --ok-soft: #14301f; --warn: #fbbf24; --warn-soft: #3a2c10;
  --bad: #f87171; --bad-soft: #3d1717; --info: #93b4ff; --info-soft: #1a2643; --mpesa: #4cc663;
  --pink: #f9a8d4; --pink-soft: #3a1d2e; --lilac: #c4b5fd; --lilac-soft: #2a2245;
  --peach: #fdba74; --peach-soft: #3a2616; --sky: #7dd3fc; --sky-soft: #142f40; --mint-soft: #123a33;
  --shadow: none; color-scheme: dark;
}
:root { --on-brand: #fff; --zoom: 1; color-scheme: light; }
:root[data-size="sm"] { --zoom: .9; }
:root[data-size="lg"] { --zoom: 1.12; }
:root[data-size="xl"] { --zoom: 1.25; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
body { zoom: var(--zoom); }
/* Compact density */
:root[data-density="compact"] th, :root[data-density="compact"] td { padding: 5px 8px; }
:root[data-density="compact"] .card { padding: 11px; }
:root[data-density="compact"] .main { padding-top: 12px; }
:root[data-density="compact"] .field { margin-bottom: 8px; }
:root[data-density="compact"] input, :root[data-density="compact"] select, :root[data-density="compact"] textarea { padding: 6px 8px; }
:root[data-density="compact"] .nav a { padding: 6px 10px; }
:root[data-density="compact"] .stat { padding: 10px; }
a { color: var(--brand); }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.boot { padding: 40px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "Cascadia Mono", monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1; }
.spacer { height: 12px; }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 14px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-size: 18px; flex: none; overflow: hidden; }
.brand .logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand .name { line-height: 1.2; font-size: 13px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 2px; }
.nav a:hover { background: var(--panel-2); }
.nav a.on { background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.nav .count { margin-left: auto; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.who { border-top: 1px solid var(--line); margin-top: 14px; padding: 12px 8px 0; }
.who .n { font-weight: 600; }
.content { min-width: 0; }
.main { padding: 20px 24px 60px; min-width: 0; }
.banner-wrap { padding: 16px 24px 0; }
.banner-wrap .banner { margin-bottom: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 8px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.topbar .menu-btn { display: none; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.banner { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; }
.banner.sim { background: var(--warn-soft); border-color: var(--warn); color: var(--text); }
.banner.bad { background: var(--bad-soft); border-color: var(--bad); }
.banner.ok { background: var(--ok-soft); border-color: var(--ok); }
.banner.info { background: var(--info-soft); border-color: var(--info); }

/* panels */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); display: block; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 4px; }
.stat .l { color: var(--muted); font-size: 12px; }
.stat.warn { border-color: var(--warn); background: var(--warn-soft); }
.stat.bad { border-color: var(--bad); background: var(--bad-soft); }
a.stat:hover { border-color: var(--brand); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 14px; align-items: start; }

/* forms */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: transparent; }
input[type=checkbox] { width: auto; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); font-weight: 400; }
.field { margin-bottom: 12px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.filters > div { min-width: 140px; }
.filters input, .filters select { padding: 7px 9px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }

button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--brand); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); border-color: var(--bad); }
button.mpesa { background: var(--mpesa); border-color: var(--mpesa); color: #fff; }
button.big { padding: 12px 18px; font-size: 15px; width: 100%; }
button.link { border: none; background: none; color: var(--brand); padding: 0; font-weight: 600; }
button.sm, .btn.sm { padding: 4px 9px; font-size: 12px; }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--panel-2); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel-2); }
td.num, th.num { text-align: right; white-space: nowrap; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 700; letter-spacing: .02em; background: var(--panel-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.rx { background: var(--bad-soft); color: var(--bad); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 12px; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* POS */
.search-results { max-height: 320px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-top: 8px; }
.result { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.result:last-child { border-bottom: none; }
.result:hover, .result.sel { background: var(--brand-soft); }
.result.disabled { opacity: .55; cursor: not-allowed; }
.total { font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.qty { width: 72px; text-align: right; }
.paybox { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 12px; }
.pending { text-align: center; padding: 10px 0; }
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--mpesa); border-radius: 50%; animation: spin 1s linear infinite; margin: 6px auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
.sim { border: 1px dashed var(--warn); background: var(--warn-soft); border-radius: 8px; padding: 10px; margin-top: 12px; }
.sim .row button { flex: 1 1 45%; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* modal & toasts */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.wide { width: min(860px, 100%); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login .card { width: min(380px, 100%); }
.demo-hint { margin-top: 12px; font-size: 12px; }
.demo-hint table td, .demo-hint table th { padding: 4px 6px; }

/* receipt */
.receipt { width: 80mm; max-width: 100%; margin: 0 auto; background: #fff; color: #000; padding: 14px; font-family: Consolas, "Courier New", monospace; font-size: 12px; border: 1px solid var(--line); }
.receipt h2 { text-align: center; font-size: 15px; margin: 0; }
.receipt .c { text-align: center; }
.receipt hr { border: none; border-top: 1px dashed #000; margin: 8px 0; }
.receipt table td, .receipt table th { padding: 2px 0; border: none; background: none; color: #000; font-size: 12px; }
.receipt .tot td { font-weight: 700; font-size: 14px; }
.receipt-actions { max-width: 80mm; margin: 14px auto; }

/* photos, badges, chips */
.thumb { width: 38px; height: 38px; border-radius: 7px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); flex: none; display: inline-grid; place-items: center; color: var(--muted); font-size: 16px; vertical-align: middle; }
.thumb.lg { width: 180px; height: 180px; font-size: 48px; }
.item-cell { display: flex; gap: 10px; align-items: center; }
.badge.orig { background: var(--info-soft); color: var(--info); }
.badge.gen { background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.chip.EXPIRED { background: var(--bad); color: #fff; }
.chip.CRITICAL { background: var(--bad-soft); color: var(--bad); }
.chip.NEAR { background: var(--warn-soft); color: var(--warn); }
.chip.OK { background: var(--ok-soft); color: var(--ok); }
.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* scan-to-sell checkout */
.till { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin-bottom: 12px; }
.till > div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.till .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.till .v { font-size: 17px; font-weight: 800; }
.scanbar { display: flex; gap: 8px; align-items: center; }
.scanbar input.scan { font-size: 18px; padding: 12px 14px; font-weight: 600; }
.lastscan { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--brand-soft); display: flex; gap: 10px; align-items: center; }
.lastscan.err { background: var(--bad-soft); }
.lastscan .nm { font-weight: 700; }
tr.flash td { animation: flash 1s ease-out; }
@keyframes flash { from { background: var(--brand-soft); } to { background: transparent; } }
.qtyctl { display: inline-flex; align-items: center; gap: 4px; }
.qtyctl button { padding: 2px 9px; }
.keys { font-size: 11px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
kbd { border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: inherit; font-size: 11px; background: var(--panel-2); }
.notes { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.notes button { flex: 1 1 60px; }
.change-due { font-size: 26px; font-weight: 800; color: var(--ok); margin: 4px 0 8px; }
.change-due.short { color: var(--bad); }
.receipt .rlogo { max-width: 46mm; max-height: 22mm; object-fit: contain; }
.login .thumb.lg { width: 96px; height: 96px; object-fit: contain; background: #fff; display: block; margin: 0 auto 8px; }
.photo-box { display: flex; gap: 14px; align-items: flex-start; flex-wrap: wrap; }
.import-summary .stat { min-width: 120px; }
tr.row-ERROR td { background: var(--bad-soft); }
tr.row-SKIP td { color: var(--muted); }
.bad-text { color: var(--bad); }
details summary { cursor: pointer; color: var(--muted); margin: 8px 0; }
.camera video { width: 100%; border-radius: 8px; background: #000; max-height: 50vh; }

/* appearance */
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
.opt { border: 2px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--panel); cursor: pointer; font-weight: 600; min-width: 96px; text-align: center; }
.opt.on { border-color: var(--brand); background: var(--brand-soft); }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--panel); outline: 2px solid var(--line); cursor: pointer; padding: 0; }
.swatch.on { outline: 3px solid var(--text); }
.setting-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting-row:last-child { border-bottom: none; }
input[type=color] { width: 44px; height: 34px; padding: 2px; }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px; text-align: center; background: var(--panel); }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.steps { counter-reset: step; }
.step { position: relative; padding-left: 40px; margin-bottom: 18px; }
.step::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 700; }

/* ---------- grouped side menu ---------- */
.nav a.top, .grp-head { font-weight: 600; }
.nav .ico { width: 20px; text-align: center; flex: none; }
.grp { margin-bottom: 2px; }
.grp-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: none; border-radius: 8px; background: none; color: var(--text); cursor: pointer; font: inherit; font-weight: 600; text-align: left; }
.grp-head:hover { background: var(--panel-2); }
.grp-head.on { color: var(--brand-2); }
.grp-head .caret { font-size: 11px; color: var(--muted); transition: transform .15s; }
.grp-head[aria-expanded="false"] .caret { transform: rotate(-90deg); }
.grp-head[aria-expanded="true"] .count { display: none; }
.grp-head .count { background: var(--bad); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; line-height: 18px; }
.grp-items { margin: 0 0 6px 18px; padding-left: 10px; border-left: 1px solid var(--line); }
.grp-items a { padding: 6px 10px; font-size: 13.5px; }

/* ---------- top bar: search, notifications, profile ---------- */
.gsearch-wrap { position: relative; flex: 1; max-width: 620px; }
.gsearch-wrap .gs-ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-size: 13px; opacity: .6; pointer-events: none; }
input.gsearch { width: 100%; padding-left: 32px; border-radius: 20px; background: var(--panel-2); }
input.gsearch:focus { background: var(--panel); }
.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.dd-wrap { position: relative; }
.icon-btn { position: relative; border-radius: 50%; width: 38px; height: 38px; padding: 0; display: grid; place-items: center; font-size: 17px; }
.icon-btn .count { position: absolute; top: -3px; right: -3px; background: var(--bad); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; line-height: 17px; font-weight: 700; }
.profile-btn { display: flex; align-items: center; gap: 8px; border-radius: 22px; padding: 3px 10px 3px 3px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: var(--on-brand); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.profile-btn .caret { font-size: 11px; color: var(--muted); }
.dropdown { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.15); z-index: 60; min-width: 240px; max-height: 70vh; overflow-y: auto; }
.dropdown.notifs { width: 360px; }
.dropdown .pad { padding: 14px; }
.dd-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.dd-head.col { flex-direction: column; align-items: flex-start; gap: 2px; }
.dd-foot { padding: 8px 14px; border-top: 1px solid var(--line); text-align: right; }
.dd-item { display: block; width: 100%; text-align: left; padding: 10px 14px; border: none; border-radius: 0; background: none; color: var(--text); text-decoration: none; font: inherit; cursor: pointer; }
.dd-item:hover { background: var(--panel-2); }
.danger-text { color: var(--bad) !important; }
.notif { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none; }
.notif:hover { background: var(--panel-2); }
.notif .n-count { min-width: 28px; text-align: center; border-radius: 8px; padding: 2px 6px; font-weight: 700; font-size: 12px; }
.notif.bad .n-count { background: var(--bad-soft); color: var(--bad); }
.notif.warn .n-count { background: var(--warn-soft); color: var(--warn); }
.notif.ok .n-count { background: var(--ok-soft); color: var(--ok); }
.notif.info .n-count { background: var(--info-soft); color: var(--info); }
.notif .n-title { font-weight: 600; }
.search-results-panel { left: 0; right: 0; width: auto; }
.sr-group + .sr-group { border-top: 1px solid var(--line); }
.sr-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 8px 14px 4px; }
.sr-item { display: flex; align-items: center; gap: 10px; padding: 7px 14px; cursor: pointer; }
.sr-item.sel, .sr-item:hover { background: var(--brand-soft); }
.sr-ico { width: 20px; text-align: center; }

/* ---------- dashboard charts ---------- */
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-bottom: 18px; }
.charts .card + .card { margin-top: 0; }
.chart.wide { grid-column: span 2; }
@media (max-width: 760px) {
  .charts { grid-template-columns: minmax(0, 1fr); }
  .chart.wide { grid-column: auto; }
  .dropdown.notifs { width: min(360px, calc(100vw - 20px)); }
}
.chart-svg { width: 100%; height: auto; display: block; }
.chart-svg .grid { stroke: var(--line); stroke-width: 1; }
.chart-svg .axis { fill: var(--muted); font-size: 10px; }
.chart-svg .bar { fill: var(--brand); opacity: .75; }
.chart-svg .bar.hi { opacity: 1; }
.chart-svg .bar:hover { opacity: 1; fill: var(--brand-2); }
.hbars { display: grid; gap: 7px; }
.hbar { display: grid; grid-template-columns: minmax(90px, 40%) 1fr auto; gap: 8px; align-items: center; font-size: 12.5px; }
.hbar .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { background: var(--panel-2); border-radius: 6px; height: 12px; overflow: hidden; }
.hbar .fill { height: 100%; background: var(--brand); border-radius: 6px; }
.hbar .fill.bad { background: var(--bad); } .hbar .fill.bad2 { background: #e66a3d; } .hbar .fill.warn { background: var(--warn); } .hbar .fill.info { background: var(--info); }
.hbar .val { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.donut { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.donut-svg { width: 130px; height: 130px; flex: none; }
.donut-svg .seg { fill: none; stroke-width: 20; }
.donut-svg .seg.empty { stroke: var(--panel-2); }
.donut-c { fill: var(--text); font-size: 18px; font-weight: 700; }
.seg.c1, .dot.c1 { stroke: var(--brand); background: var(--brand); }
.seg.c2, .dot.c2 { stroke: var(--mpesa); background: var(--mpesa); }
.seg.c3, .dot.c3 { stroke: var(--info); background: var(--info); }
.seg.c4, .dot.c4 { stroke: var(--muted); background: var(--muted); }
.seg.ok, .dot.ok { stroke: var(--ok); background: var(--ok); }
.seg.warn, .dot.warn { stroke: var(--warn); background: var(--warn); }
.seg.bad, .dot.bad { stroke: var(--bad); background: var(--bad); }
.legend { flex: 1; min-width: 140px; display: grid; gap: 6px; font-size: 13px; }
.legend .li { display: flex; align-items: center; gap: 8px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.mini-stats .l { font-size: 11px; color: var(--muted); }
.mini-stats .v { font-weight: 700; font-size: 13px; }

/* ---------- till: directions, owed, prescriptions ---------- */
input.dir { margin-top: 4px; padding: 4px 8px; font-size: 12.5px; width: 100%; max-width: 320px; border-style: dashed; }
input.dir.saved { border-color: var(--ok); border-style: solid; }
.owed { color: var(--warn); font-weight: 600; }
.rx-files { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; align-items: center; }
.rx-file { position: relative; }
.rx-file img, .rx-file .pdf { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; background: var(--panel-2); font-weight: 700; color: var(--bad); text-decoration: none; }
.rx-file .x { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; padding: 0; border-radius: 50%; font-size: 10px; line-height: 1; }
.rx-add { display: flex; gap: 6px; }
.choice-list { display: grid; gap: 8px; margin-top: 10px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 12px 14px; white-space: normal; width: 100%; min-width: 0; }
.choice:hover { border-color: var(--brand); }
button.wa { background: #25d366; color: #fff; border-color: #1ebe5a; }
textarea.msg { width: 100%; font-family: inherit; }
.menu-picker { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-top: 8px; }
.menu-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 8px; }
.menu-groups .mg { display: grid; gap: 4px; align-content: start; }
.ref-items { display: grid; gap: 8px; margin-bottom: 10px; }
.ref-row .qty-in { width: 80px; }

/* ---------- receipts: 80 mm, 58 mm thermal, or A4 ---------- */
.receipt.p58 { width: 58mm; font-size: 10.5px; }
.receipt.p58 table td { font-size: 10.5px; }
.receipt.pa4 { width: 190mm; font-family: "Segoe UI", system-ui, sans-serif; font-size: 13px; padding: 24px 28px; }
.receipt.pa4 h2 { font-size: 20px; }
.receipt.pa4 table td { font-size: 13px; }
.receipt .dir td { font-style: italic; }
.receipt .advice { font-size: 11px; }
.receipt .ref-li { margin: 4px 0; }
.receipt .sign { margin-top: 18px; }
.receipt-actions { display: grid; gap: 10px; }
.receipt-actions .tabs { margin: 0; }

pre.json { background: var(--panel-2); padding: 10px; border-radius: 8px; overflow: auto; max-height: 380px; font-size: 12px; }

@media (max-width: 1100px) { .pos { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .menu-btn { display: inline-flex; }
  .profile-btn .pname { display: none; }
  .dropdown.notifs, .dropdown.profile { position: fixed; left: 8px; right: 8px; top: 56px; width: auto; }
  .main { padding: 16px; }
  .banner-wrap { padding: 12px 16px 0; }
  .grid2 { grid-template-columns: 1fr; }
}
@media print {
  body { background: #fff; zoom: 1; }
  .side, .topbar, .no-print, #toasts, .banner, .receipt-actions { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .receipt { border: none; padding: 0; margin: 0; }
  /* Thermal rolls: content width of the printable area; A4: full page. Chosen per receipt (Settings / receipt screen). */
  .receipt.p80 { page: roll80; width: 72mm; }
  .receipt.p58 { page: roll58; width: 48mm; font-size: 10.5px; }
  .receipt.pa4 { page: sheetA4; width: 100%; max-width: none; }
}
/* Thermal printers use the roll width set in their driver and cut after the content, so only margins are set. */
@page roll80 { margin: 2mm 3mm; }
@page roll58 { margin: 1mm 2mm; }
@page sheetA4 { size: A4; margin: 15mm; }

/* About this medicine (drug information, optional AI draft) */
.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--text); }
.side-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side-col > .card { margin: 0; }
.info-card h2 { margin: 0; }
.info-card > .row.between { margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.info-list { margin: 0; display: grid; gap: 2px; }
.info-list dt { font-weight: 600; font-size: 13px; color: var(--muted); margin-top: 8px; }
.info-list dt:first-child { margin-top: 0; }
.info-list dd { margin: 0; white-space: pre-wrap; line-height: 1.45; }
.info-field { display: block; margin-bottom: 8px; }
.info-field span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.info-field textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }

/* Side menu can be hidden on computers with the ☰ button */
.topbar .menu-btn { display: inline-flex; }
/* ☰ in the menu header: pin the menu open, or fold it to a slim icon strip that opens when you point at it */
.pin-btn { width: 30px; height: 30px; padding: 0; flex: none; font-size: 15px; border-color: transparent; background: transparent; color: var(--muted); }
.pin-btn:hover { background: var(--panel-2); color: var(--brand); border-color: var(--line); }
.pin-btn[aria-pressed="true"] { color: var(--brand); }
@media (max-width: 860px) { .pin-btn { display: none; } }
@media (min-width: 861px) {
  .shell { transition: grid-template-columns .18s; }
  .shell.nav-hidden { grid-template-columns: 68px 1fr; }
  .shell.nav-hidden .side { width: 68px; overflow-x: hidden; z-index: 45; transition: width .18s ease, box-shadow .18s ease; }
  .shell.nav-hidden .side.peek { width: 240px; box-shadow: 10px 0 34px rgba(20, 40, 80, .16); }
  .shell.nav-hidden .side:not(.peek) .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .shell.nav-hidden .side:not(.peek) .brand .name,
  .shell.nav-hidden .side:not(.peek) .pin-btn,
  .shell.nav-hidden .side:not(.peek) .nav .grow,
  .shell.nav-hidden .side:not(.peek) .nav .caret,
  .shell.nav-hidden .side:not(.peek) .grp-items { display: none; }
  .shell.nav-hidden .side:not(.peek) .nav a,
  .shell.nav-hidden .side:not(.peek) .grp-head { justify-content: center; padding: 10px 0; position: relative; }
  .shell.nav-hidden .side:not(.peek) .nav .ico { font-size: 17px; width: auto; }
  .shell.nav-hidden .side:not(.peek) .count:not(.hidden) { position: absolute; top: 3px; right: 6px; display: block; font-size: 9.5px; line-height: 14px; padding: 0 4px; }
  .shell.nav-hidden .side:not(.peek) .grp-head[aria-expanded="true"] .count { display: block; }
  .shell.nav-hidden .side.peek .pin-btn { color: var(--muted); }
}

/* Sortable tables and the column picker */
.tbl { position: relative; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th.sorted { color: var(--text); }
.sort-ind { opacity: .45; font-size: 11px; }
th.sorted .sort-ind { opacity: 1; color: var(--accent, var(--text)); }
th.gear-cell, td.gear-cell { width: 28px; padding-left: 8px; padding-right: 0; }
.col-gear { background: none; border: none; padding: 0 2px; font-size: 15px; line-height: 1; color: var(--muted); cursor: pointer; min-height: 0; }
.col-gear:hover, th.gear-cell.on .col-gear { color: var(--accent, var(--text)); }
.col-picker { position: fixed; z-index: 1000; min-width: 220px; max-height: 420px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.col-picker .row.between { margin-bottom: 6px; gap: 12px; }
.col-picker label.check { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; cursor: pointer; }
@media print { .gear-cell, .sort-ind, .col-picker { display: none !important; } }

/* Prescription box on the till */
.rx-items { margin: 6px 0 8px; line-height: 1.5; }
.help.warn-text, .warn-text { color: var(--warn); font-weight: 600; }

/* "To take payment" checklist above the pay button */
.pay-check { border: 1px dashed var(--warn); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0 10px; background: var(--warn-soft); }
.pay-check-head { font-weight: 600; margin-bottom: 6px; }
.pay-step { display: flex; align-items: flex-start; gap: 8px; padding: 5px 0; }
.pay-step + .pay-step { border-top: 1px solid var(--line); }
.pay-step .tick { width: 18px; text-align: center; font-weight: 700; color: var(--warn); flex: none; }
.pay-step.done { opacity: .7; }
.pay-step.done .tick { color: var(--ok); }
.pay-step .grow { min-width: 0; }

/* AI services in Settings */
.ai-keys { margin: 8px 0 12px; }
.ai-keys > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.ai-key-list { display: grid; gap: 4px; margin-top: 6px; }
.ai-key-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
@media (max-width: 760px) { .ai-key-row { grid-template-columns: minmax(0, 1fr); } }

/* ================= friendly "cute" look ================= */
/* search box: room for the 🔍 so it never sits on top of the words (wins over compact density) */
.topbar .gsearch-wrap input.gsearch { padding: 9px 16px 9px 40px; border-radius: 999px; border-color: transparent; }
.topbar .gsearch-wrap input.gsearch:focus { border-color: var(--brand); }
.topbar .gsearch-wrap .gs-ico { left: 15px; font-size: 14px; }

body { background: radial-gradient(1200px 500px at 100% -10%, var(--lilac-soft), transparent 60%),
                    radial-gradient(900px 500px at -10% 110%, var(--mint-soft), transparent 60%), var(--bg);
       background-attachment: fixed; }
.side { background: linear-gradient(180deg, var(--panel), var(--panel-2)); border-right-color: transparent; box-shadow: 2px 0 18px rgba(30,50,90,.05); }
.brand .logo { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, var(--brand), var(--sky)); box-shadow: 0 4px 12px rgba(13,148,136,.3); }
.brand .name { font-size: 14px; }
.topbar { background: color-mix(in srgb, var(--panel) 82%, transparent); backdrop-filter: blur(10px); border-bottom-color: transparent; box-shadow: 0 2px 14px rgba(30,50,90,.05); }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-weight: 800; }
.card { border-color: transparent; }
.card, .stat, .till > div { transition: transform .15s, box-shadow .15s; }
a.stat:hover, .till > div:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(30,50,90,.09); }
.stat { border-color: transparent; box-shadow: var(--shadow); border-left: 5px solid var(--brand-soft); }
.stat.warn { border-left-color: var(--warn); border-color: transparent; }
.stat.bad { border-left-color: var(--bad); border-color: transparent; }
.stat.ok { border-left-color: var(--ok); }
.till > div { border-color: transparent; box-shadow: var(--shadow); }
.till > div:nth-child(4n+1) { background: var(--mint-soft); }
.till > div:nth-child(4n+2) { background: var(--sky-soft); }
.till > div:nth-child(4n+3) { background: var(--peach-soft); }
.till > div:nth-child(4n+4) { background: var(--lilac-soft); }
input, select, textarea { border-radius: 12px; }
.tablewrap { border-color: transparent; box-shadow: var(--shadow); }
th { background: var(--panel-2); text-transform: uppercase; font-size: 11px; letter-spacing: .04em; }
tr.click:hover td { background: var(--brand-soft); }
.badge, .chip { border-radius: 999px; }
.banner { border-radius: 14px; }
.modal, .dropdown { border-radius: 18px; }

/* dashboard hero: shelf worth vs money */
.hero { margin-bottom: 18px; }
.hero-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 14px; }
.hero-card { display: flex; gap: 14px; align-items: center; padding: 16px 18px; border-radius: 20px; color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; }
a.hero-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(30,50,90,.12); }
.hero-card .ico { font-size: 28px; width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; background: var(--panel); flex: none; box-shadow: 0 3px 10px rgba(30,50,90,.08); }
.hero-card .l { font-size: 12px; font-weight: 700; color: var(--muted); }
.hero-card .v { font-size: 20px; font-weight: 800; margin: 2px 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hero-card .sub { font-size: 11.5px; color: var(--muted); }
.hero-card.mint { background: linear-gradient(135deg, var(--mint-soft), var(--panel)); }
.hero-card.sky { background: linear-gradient(135deg, var(--sky-soft), var(--panel)); }
.hero-card.peach { background: linear-gradient(135deg, var(--peach-soft), var(--panel)); }
.hero-card.lilac { background: linear-gradient(135deg, var(--lilac-soft), var(--panel)); }
.legend-row { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }
.legend-row > span { display: inline-flex; align-items: center; gap: 6px; }
.legend-row .dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.dot.la { background: var(--brand); } .dot.lb { background: var(--pink); }
.two-line .line { fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.two-line .line.la { stroke: var(--brand); } .two-line .line.lb { stroke: var(--pink); }
.two-line .area.la { fill: var(--brand); opacity: .12; }
.two-line circle.dot { stroke: var(--panel); stroke-width: 2; }
.two-line circle.la { fill: var(--brand); } .two-line circle.lb { fill: var(--pink); }
.two-line .axis.la { fill: var(--brand); } .two-line .axis.lb { fill: var(--pink); }
.two-line .hit { fill: transparent; }
.two-line .pt:hover .hit { fill: var(--brand); opacity: .07; }
.two-line .pt:hover circle { r: 5.5; }
.money-chart { margin-top: 0; }

/* settings: receipt details with live preview, branding */
.receipt-setup { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; margin-bottom: 8px; }
.receipt-preview { position: sticky; top: 70px; background: var(--panel-2); border-radius: 16px; padding: 12px; }
.receipt-preview .c { text-align: center; }
.receipt.mini { width: 100%; font-size: 11px; border-radius: 6px; box-shadow: 0 4px 14px rgba(30,50,90,.1); margin-top: 6px; }
.receipt.mini .rlogo { max-width: 120px; max-height: 60px; }
.brand-names { border-bottom: 1px solid var(--line); padding-bottom: 12px; margin-bottom: 4px; }
.brand-names .row button.sm { font-size: 16px; padding: 2px 9px; }
@media (max-width: 900px) { .receipt-setup { grid-template-columns: minmax(0, 1fr); } .receipt-preview { position: static; } }

/* till cards stretch to use the whole row */
.cards.fill { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

/* dashboard charts: cards in the last row grow to use the free space */
.charts { display: flex; flex-wrap: wrap; }
.charts > .card { flex: 1 1 320px; min-width: 0; }
.charts > .chart.wide { flex: 2 1 660px; }
@media (max-width: 760px) { .charts > .card, .charts > .chart.wide { flex-basis: 100%; } }

.charts .row.end { margin-top: 8px; }

/* Stock health: donut on the left, switchable detail views on the right */
.charts > .stock-health { flex: 1 1 100%; }
.sh-grid { display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: 22px; align-items: start; }
.sh-right { border-left: 1px solid var(--line); padding-left: 20px; min-width: 0; }
.sd-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.sd-tab { padding: 5px 11px; font-size: 12.5px; background: var(--panel-2); border-color: transparent; }
.sd-tab.on { background: var(--brand-soft); color: var(--brand-2); border-color: var(--brand); }
.sd-body { margin-top: 10px; min-height: 150px; }
.sd-body.pop { animation: sdpop .25s ease-out; }
@keyframes sdpop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
a.hbar.link { color: var(--text); text-decoration: none; border-radius: 8px; padding: 2px 4px; margin: -2px -4px; }
a.hbar.link:hover { background: var(--panel-2); }
.hbar .fill.ok { background: var(--ok); }
.legend .li.click { cursor: pointer; border-radius: 8px; padding: 2px 4px; margin: -2px -4px; }
.legend .li.click:hover { background: var(--panel-2); }
.seg.c5, .dot.c5 { stroke: var(--pink); background: var(--pink); }
.seg.c6, .dot.c6 { stroke: var(--lilac); background: var(--lilac); }
.empty-good { padding: 30px 10px; text-align: center; color: var(--muted); font-size: 14px; }
@media (max-width: 900px) { .sh-grid { grid-template-columns: minmax(0, 1fr); } .sh-right { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 14px; } }

.money-chart .chart-svg { max-height: 300px; }
.sh-grid { grid-template-columns: minmax(280px, 420px) minmax(0, 1fr); }
