/* ==========================================================================
   Brevan POS — design system (responsive edition)
   Breakpoints (mobile-first thinking, desktop-first code):
     phone        < 640px
     large phone  < 768px
     tablet       768px – 1023px
     laptop       1024px – 1439px
     desktop      1440px+   |  large desktop 1920px+
   Tenant branding arrives as CSS variables (--primary / --accent) injected
   by base.html.
   ========================================================================== */

:root {
  /* tenant brand (Kenya theme default; overridden per workspace in base.html) */
  --primary: #BB0000;
  --accent: #006600;
  --kenya-black: #111827;
  --kenya-red: #BB0000;
  --kenya-red-hover: #990000;
  --kenya-red-dark: #940000;
  --kenya-green: #006600;
  --kenya-green-hover: #004D00;
  --kenya-light-green: #E6F2E6;
  --kenya-light-red: #FCEAEA;
  --obsidian: #111827;

  /* neutrals */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-2: #F9FAFB;
  --border: #E2E8F0;
  --border-strong: #D0D5DD;
  --text: #0F172A;
  --text-muted: #5B6779;      /* a bit darker than before: better contrast on small text */
  --text-subtle: #7B8798;
  --slate-50: #f8fafc;
  --slate-200: #e2e8f0;
  --slate-900: #0f172a;

  /* semantic */
  --danger: #d92d20;
  --danger-ink: #b42318;
  --danger-soft: #fef3f2;
  --danger-border: #fecdca;
  --success-ink: #067647;
  --success-soft: #ecfdf3;
  --success-border: #abefc6;
  --warning-ink: #b54708;
  --warning-soft: #fffaeb;
  --warning-border: #fedf89;

  /* shape & depth */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .16), 0 4px 8px -2px rgba(16, 24, 40, .06);
  --elev: 0 1px 2px rgba(15, 17, 21, .04), 0 8px 24px rgba(15, 17, 21, .06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--primary) 28%, transparent);
  --tnum: tabular-nums;

  /* app shell */
  --shell-header: #FFFFFF;
  --shell-surface: #FFFFFF;
  --shell-canvas: #F8FAFC;
  --shell-border: #E2E8F0;
  --shell-text: #0F172A;
  --shell-muted: #64748B;
  --shell-hover: #F1F5F9;
  --shell-panel: #F3F4F6;
  --shell-radius: 8px;
  --lime: #84CC16;
  --lime-strong: #65A30D;
  --lime-bg: #F7FEE7;
  --lime-text: #4D7C0F;

  /* responsive sizing tokens (changed inside media queries below) */
  --sidebar-w: 260px;
  --header-h: 60px;
  --page-pad: 1rem;
  --content-max: 1480px;
  --tap: 44px;                 /* minimum touch target */
}

/* ---------- reset & base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 16px;
  scrollbar-width: thin;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}
html.scroll-smooth { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  font-size: 1rem;
  line-height: 1.6;
  color: var(--obsidian);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;                       /* never allow sideways page scroll */
  overflow-wrap: break-word;
}

img, svg, video, canvas { max-width: 100%; height: auto; }
svg { height: auto; }
.icon, .nav-link svg, .brand-mark svg, .action-card .glyph svg { height: unset; }

::selection { background: var(--kenya-green); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

h1, h2, h3 { line-height: 1.25; letter-spacing: -.011em; margin: 0 0 .5rem; color: var(--shell-text); }
h1 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.9rem); font-weight: 700; }
h2 { font-size: clamp(1.15rem, 1.05rem + .5vw, 1.35rem); font-weight: 650; }
h3 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd, samp, .mono {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .85em;
}
pre { overflow-x: auto; max-width: 100%; }
small { font-size: .88rem; }

.num, .mono, .money, .price, kbd, samp, code { font-variant-numeric: var(--tnum); }
.price, .money { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- layout ---------- */

main {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.5rem var(--page-pad) 3rem;
  min-height: calc(100vh - 130px);
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
}
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--text-muted); margin: .3rem 0 0; font-size: 1rem; }
.page-actions { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }

footer {
  max-width: 1140px;
  margin: 0 auto;
  padding: 1.1rem var(--page-pad) 1.6rem;
  border-top: 1px solid var(--border);
  color: var(--text-subtle);
  font-size: .88rem;
}

/* ---------- top bar (sticky, 60/64px) ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: 0;
  padding: 0 max(var(--page-pad), env(safe-area-inset-right)) 0 max(var(--page-pad), env(safe-area-inset-left));
  background: var(--shell-header);
  border-bottom: 1px solid var(--shell-border);
  box-shadow: var(--shadow-sm);
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 1.02rem;
  letter-spacing: -.01em;
  min-width: 0;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 220px; }
.topbar .logo { height: 30px; width: auto; border-radius: 6px; background: #fff; }
.topbar-right { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.topbar .user-zone { display: flex; align-items: center; gap: .6rem; margin-left: auto; min-width: 0; }

.topbar nav {
  display: flex;
  align-items: center;
  gap: .2rem;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.topbar nav::-webkit-scrollbar { display: none; }

/* legacy plain topbar links (platform pages) */
.topbar a:not(.nav-link):not(.brand):not(.button):not(.user-chip) {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 550;
  padding: .4rem .6rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.topbar a:not(.nav-link):not(.brand):not(.button):not(.user-chip):hover { color: var(--text); background: var(--surface-2); }

.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.25rem; height: 2.25rem; flex: none;
}
.brand-mark img, .brand-mark svg { width: 100%; height: 100%; object-fit: contain; }
.auth-mark .brand-mark { width: 2.5rem; height: 2.5rem; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-name { font-weight: 800; letter-spacing: -.01em; text-transform: lowercase; font-size: 1.05rem; }
.brand-sub { font-size: .62rem; letter-spacing: .22em; text-transform: uppercase; color: #6b7280; font-weight: 600; }
.workspace-name {
  margin-left: .5rem; padding: .15rem .6rem; border-radius: 999px; white-space: nowrap;
  background: #F8FAFC; border: 1px solid #E2E8F0; font-size: .82rem; color: #374151;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis;
}

.icon { width: 18px; height: 18px; flex: none; }
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--shell-border); border-radius: var(--shell-radius);
  background: var(--shell-surface); color: var(--shell-muted); cursor: pointer; padding: 0;
  box-shadow: none;
}
.icon-btn:hover { background: var(--shell-hover); color: var(--shell-text); }
.menu-toggle { border-radius: var(--shell-radius); }

.user-chip { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.avatar {
  width: 36px; height: 36px; border-radius: 999px; flex: none;
  background: linear-gradient(135deg, var(--lime), var(--lime-strong)); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .78rem; text-transform: uppercase;
}
.user-chip .email {
  display: block; font-weight: 700; text-transform: uppercase; font-size: .8rem;
  color: var(--shell-text); line-height: 1.1;
  max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ---------- nav links ---------- */

.nav-link {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .55rem .65rem;
  margin: .1rem 0;
  border-radius: var(--shell-radius);
  color: var(--shell-text);
  font-size: .95rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover { background: var(--shell-hover); text-decoration: none; }
.nav-link .icon, .nav-link svg { width: 18px; height: 18px; flex: none; color: var(--shell-muted); }
.nav-link.active { background: var(--lime-bg); color: var(--lime-text); font-weight: 650; }
.nav-link.active .icon, .nav-link.active svg { color: var(--lime-strong); }
.nav-link.nested { margin-left: 1rem; }

/* ---------- buttons ---------- */

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  background: var(--primary);
  color: #fff;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .55rem 1.05rem;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:hover, .button:hover {
  background: color-mix(in srgb, var(--primary) 88%, #0b1b3a);
  text-decoration: none;
  color: #fff;
}
button:active, .button:active { transform: scale(.97); }
button:disabled, .button[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }

.btn-danger, button.btn-danger { background: var(--danger); }
.btn-danger:hover, button.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, #0b1b3a); }
.btn-ghost, a.btn-ghost, button.btn-ghost {
  background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: none;
}
.btn-ghost:hover, a.btn-ghost:hover, button.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm, button.btn-sm, .button-sm { padding: .36rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn:hover { color: var(--shell-text); }

/* keyboard focus */
button:focus-visible, .button:focus-visible, a:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(187, 0, 0, .25);       /* fallback */
  box-shadow: var(--ring);
}

/* ---------- forms ---------- */

label {
  display: grid;
  gap: .35rem;
  font-weight: 600;
  font-size: .9rem;
  color: #344054;
}
label small { font-weight: 400; color: var(--text-muted); line-height: 1.45; }

input, select, textarea {
  max-width: 100%;
  padding: .6rem .75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 5.5rem; }
input:hover, select:hover, textarea:hover { border-color: #b6bcc7; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
input::placeholder { color: var(--text-subtle); }
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent); width: 18px; height: 18px; padding: 0; cursor: pointer;
}
input[type="color"] { padding: .2rem; height: 42px; width: 68px; cursor: pointer; background: var(--surface); }
input[type="file"] { padding: .45rem .6rem; background: var(--surface-2); width: 100%; }
select { cursor: pointer; }

.form, form.form { display: grid; gap: 1rem; max-width: 480px; }
.form-card { max-width: 560px; }
.form-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.form-row > input, .form-row > select { flex: 1 1 160px; min-width: 0; }

fieldset {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem 1.1rem 1rem;
  margin: 0 0 1rem;
  background: var(--surface);
}
legend {
  font-weight: 650; font-size: .85rem; text-transform: capitalize; color: var(--text-muted);
  padding: .15rem .55rem; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px;
}
.check-row { display: flex; gap: .6rem; align-items: center; font-weight: 450 !important; margin: .4rem 0; font-size: .95rem; }
.check-row code { color: var(--text-muted); }

/* ---------- cards & panels ---------- */

.card, .auth-card, .stat, .pos-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--elev);
}
.card { padding: 1.25rem 1.35rem; min-width: 0; }
.card + .card { margin-top: 1rem; }
.card h2 { margin-top: 0; }
.card.p0 { padding: 0; overflow: hidden; }
.card p { color: var(--text-muted); margin: 0; font-size: .98rem; line-height: 1.55; }
.card h3 { margin: .1rem 0 .4rem; }

.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .95rem 1.25rem; border-bottom: 1px solid var(--border);
}
.card-head h2, .card-head h3 { margin: 0; font-size: 1rem; }
.card-head .sub { color: var(--text-muted); font-size: .88rem; margin: .15rem 0 0; }

.card .icon-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 11px; font-size: 1.25rem; margin-bottom: .8rem;
  background: color-mix(in srgb, var(--primary) 9%, white);
  border: 1px solid color-mix(in srgb, var(--primary) 16%, white);
}

.hint-box {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .7rem .9rem; color: var(--text-muted); font-size: .88rem; overflow-x: auto;
}
.hint-box code, .code-box {
  background: color-mix(in srgb, var(--primary) 6%, var(--surface-2));
  border: 1px solid var(--border); border-radius: 6px; padding: .12rem .4rem;
  color: color-mix(in srgb, var(--primary) 70%, #0b1b3a); word-break: break-all;
}

/* ---------- tables ---------- */

.table-wrap { overflow: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }

.table {
  width: 100%;
  border-collapse: separate;      /* keeps sticky header borders intact */
  border-spacing: 0;
  background: var(--surface);
  font-size: .92rem;
}
.table th, .table td {
  text-align: left; padding: .65rem .9rem; border-bottom: 1px solid #f1f3f6; vertical-align: middle;
}
.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--text-muted);
  font-size: .74rem; font-weight: 650; text-transform: uppercase; letter-spacing: .045em;
  padding: .6rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table tbody tr:hover { background: #fafbfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: var(--tnum); }
.table form { display: inline-flex; gap: .4rem; align-items: center; }
.table input:not([type="checkbox"]):not([type="hidden"]) { padding: .4rem .5rem; font-size: .88rem; }
.table input[name="delta"], .table input[size="4"] { width: 68px; text-align: center; }
.table td.empty, td.empty { text-align: center; color: var(--text-subtle); padding: 2.2rem 1rem; }
.table .error.cell-error, .cell-error {
  display: inline-block; margin: 0 .25rem .25rem 0; padding: .14rem .5rem; font-size: .78rem; border-radius: 6px;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .16rem .6rem; border-radius: 999px;
  font-size: .78rem; font-weight: 650; letter-spacing: .01em; white-space: nowrap;
  background: #f2f4f7; color: #475467; border: 1px solid transparent;
}
.badge-active { background: var(--success-soft); color: var(--success-ink); border-color: var(--success-border); }
.badge-suspended { background: var(--danger-soft); color: var(--danger-ink); border-color: var(--danger-border); }
.badge-warning { background: var(--warning-soft); color: var(--warning-ink); border-color: var(--warning-border); }
.badge-primary {
  background: color-mix(in srgb, var(--primary) 10%, white);
  color: color-mix(in srgb, var(--primary) 82%, #0b1b3a);
  border-color: color-mix(in srgb, var(--primary) 22%, white);
}

/* ---------- alerts ---------- */

.error, .alert-error, .alert-success, .alert-notice {
  padding: .7rem .95rem; border-radius: var(--radius-sm); font-size: .92rem; margin: 0 0 .9rem;
}
.error, .alert-error { color: var(--danger-ink); background: var(--danger-soft); border: 1px solid var(--danger-border); }
.alert-success { color: var(--success-ink); background: var(--success-soft); border: 1px solid var(--success-border); }
.alert-notice { color: var(--warning-ink); background: var(--warning-soft); border: 1px solid var(--warning-border); }

/* ---------- stats / KPI / action cards ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr));
  gap: .9rem;
  margin: 0 0 1.4rem;
}
.stat { padding: .95rem 1.1rem; min-width: 0; }
.stat .k { color: var(--text-muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat .v {
  font-size: clamp(1.15rem, 1rem + .8vw, 1.5rem); font-weight: 700; letter-spacing: -.015em;
  margin-top: .15rem; font-variant-numeric: var(--tnum); overflow-wrap: anywhere;
}
.stat .d { color: var(--text-subtle); font-size: .82rem; margin-top: .1rem; }

.kpi { display: flex; gap: .8rem; flex-wrap: wrap; }
.kpi .k {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .85rem; flex: 1 1 120px; min-width: 0;
}
.kpi .k small { color: var(--text-muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.kpi .k div { font-weight: 700; font-size: 1.05rem; font-variant-numeric: var(--tnum); }
.kpi .k.total { background: color-mix(in srgb, var(--primary) 8%, white); border-color: color-mix(in srgb, var(--primary) 20%, white); }

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
  gap: .9rem;
}
.action-card {
  display: flex; gap: .85rem; align-items: flex-start; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem; color: var(--text); text-decoration: none; box-shadow: var(--shadow-sm);
}
.action-card:hover {
  text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow);
  border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
}
.action-card .glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  background: color-mix(in srgb, var(--primary) 10%, white);
  color: color-mix(in srgb, var(--primary) 82%, #0b1b3a);
}
.action-card .glyph svg { width: 19px; height: 19px; }
.action-card h3 { margin: 0 0 .15rem; font-size: .98rem; }
.action-card p { margin: 0; color: var(--text-muted); font-size: .88rem; line-height: 1.45; }

/* ---------- app shell: sticky header + sidebar drawer ---------- */

.app-shell { display: flex; min-height: calc(100vh - var(--header-h)); min-height: calc(100dvh - var(--header-h)); background: var(--shell-canvas); }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--shell-surface);
  border-right: 1px solid var(--shell-border);
  padding: .75rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.app-shell > main {
  flex: 1;
  width: 100%;
  min-width: 0;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: var(--page-pad) var(--page-pad) calc(2.5rem + env(safe-area-inset-bottom));
  background: var(--shell-canvas);
}

.sidebar-section { margin-bottom: 1rem; }
.sidebar-section + .sidebar-section { border-top: 1px solid var(--shell-border); padding-top: 1rem; }
.sidebar-title {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--shell-muted); padding: .25rem .5rem .5rem;
}

/* ---------- auth pages ---------- */

.auth-page {
  display: grid;
  place-items: center;
  row-gap: 1rem;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(1.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right))
           max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background:
    radial-gradient(1100px 560px at 12% -8%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 62%),
    radial-gradient(900px 480px at 108% 8%, color-mix(in srgb, var(--accent) 13%, transparent), transparent 58%),
    linear-gradient(180deg, #f7f9fc 0%, #eef1f6 100%);
}
.auth-card {
  display: grid; gap: .95rem; width: min(430px, 100%);
  padding: 2.3rem 2.1rem 2rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.auth-card h1 { font-size: 1.4rem; text-align: center; margin: 0; }
.auth-card > .muted.sub { text-align: center; margin: -.4rem 0 .3rem; font-size: .95rem; }
.auth-card form { display: grid; gap: .95rem; }
.auth-card button[type="submit"], .auth-card .button { width: 100%; padding: .72rem 1rem; font-size: .98rem; }
.auth-card input { width: 100%; padding: .65rem .8rem; }
.auth-card .switch { text-align: center; color: var(--text-muted); font-size: .92rem; margin: .1rem 0 0; }
.auth-mark { display: flex; justify-content: center; margin-bottom: .2rem; }
.auth-logo { height: 68px; width: auto; display: block; }
.auth-foot { text-align: center; color: var(--text-subtle); font-size: .84rem; margin: .4rem 0 0; }
.auth-foot code { font-size: .8rem; }

.code-input {
  font-family: "JetBrains Mono", monospace; font-size: 1.4rem; letter-spacing: .2em;
  text-align: center; font-weight: 600;
}
.code-input::placeholder { letter-spacing: .2em; color: var(--text-subtle); }

.avail-line { margin: -.3rem 0 0; font-size: .88rem; font-weight: 600; }
.avail-ok { color: var(--success-ink); }
.avail-bad { color: var(--danger-ink); }
.preview-flag { text-align: center; font-size: .82rem; margin: 0; padding: .4rem .7rem; }
.preview-panel {
  width: min(430px, 100%); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); background: var(--surface);
}
.preview-head { display: flex; align-items: center; gap: .6rem; padding: .55rem .8rem; border-bottom: 1px solid var(--border); }
.preview-head code { font-size: .8rem; color: var(--text-muted); word-break: break-all; }
.preview-panel iframe { display: block; width: 100%; height: clamp(360px, 60vh, 520px); border: 0; background: var(--bg); }

/* ---------- landing / SaaS homepage ---------- */

.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .95); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid #E2E8F0;
}
.site-header-inner {
  max-width: 1200px; margin: 0 auto; padding: .75rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.site-nav { display: flex; gap: 1.1rem; align-items: center; font-size: .95rem; font-weight: 600; color: #475569; }
.site-nav a { color: inherit; }
.site-nav a:hover { color: #111827; text-decoration: none; }
.site-nav .button { color: #fff; }

.landing-nav { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.5rem; max-width: 1140px; margin: 0 auto; }
.landing-nav .links { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.landing-nav a { color: var(--text-muted); font-weight: 550; font-size: .92rem; padding: .4rem .65rem; border-radius: var(--radius-sm); }
.landing-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.landing { max-width: 1080px; margin: 0 auto; padding: 0 1.5rem; }

.hero-split {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 2.5rem; align-items: center;
  max-width: 1200px; margin: 0 auto; padding: 4rem 1.5rem;
}
.hero-split .hero-copy { min-width: 0; }
.hero-split .hero-copy h1 { font-size: clamp(1.9rem, 1.2rem + 2.4vw, 3rem); line-height: 1.12; margin: .5rem 0 1rem; letter-spacing: -.025em; }
.hero-split .lead { font-size: 1.12rem; line-height: 1.6; max-width: 46ch; }
.hero-split .eyebrow { font-size: .85rem; }
.hero-pos { min-width: 0; border: 1px solid #E2E8F0; border-radius: var(--radius); }

.hero:not(.hero-split) { text-align: center; padding: 4.2rem 1rem 3rem; }
.hero:not(.hero-split) .eyebrow {
  display: inline-flex; align-items: center; gap: .45rem;
  background: color-mix(in srgb, var(--primary) 9%, white);
  border: 1px solid color-mix(in srgb, var(--primary) 22%, white);
  color: color-mix(in srgb, var(--primary) 80%, #0b1b3a);
  font-size: .85rem; font-weight: 650; padding: .3rem .85rem; border-radius: 999px; margin-bottom: 1.1rem;
}
.hero:not(.hero-split) h1 {
  font-size: clamp(2rem, 1.2rem + 3.4vw, 3.05rem); line-height: 1.12; letter-spacing: -.025em; font-weight: 800; margin: .3rem 0;
}
.hero:not(.hero-split) h1 .grad {
  background: linear-gradient(92deg, var(--primary), color-mix(in srgb, var(--accent) 70%, var(--primary)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero:not(.hero-split) p.lead { font-size: 1.12rem; color: var(--text-muted); max-width: 660px; margin: .9rem auto 1.7rem; line-height: 1.6; }

.cta { display: inline-flex; gap: .8rem; flex-wrap: wrap; justify-content: center; }
.cta .button { padding: .8rem 1.45rem; font-size: 1rem; border-radius: 10px; }
.trust-line { margin-top: 1.1rem; color: var(--text-subtle); font-size: .88rem; }

.subdomain-claim { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: var(--radius); padding: .9rem; margin: 1rem 0; }
.subdomain-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .3rem 0 .6rem; }
.subdomain-row input { flex: 1; min-width: 90px; }

.pos-showcase {
  background: linear-gradient(160deg, color-mix(in srgb, var(--primary) 8%, white), color-mix(in srgb, var(--accent) 6%, white));
  border: 1px solid color-mix(in srgb, var(--primary) 16%, white);
  border-radius: var(--radius-lg); padding: 2.2rem 2rem; margin: 1.5rem 0 3rem;
}
.pos-showcase h2 { text-align: center; margin: 0 0 1.4rem; }
.pos-screen {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border);
  padding: 1.1rem 1.2rem 1.2rem; box-shadow: var(--shadow-lg); max-width: 720px; margin: 0 auto; overflow-x: auto;
}
.pos-screen .chrome { display: flex; gap: .35rem; margin-bottom: .9rem; }
.pos-screen .chrome i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.pos-screen .chrome i:first-child { background: #fda29b; }
.pos-screen .chrome i:nth-child(2) { background: #fedf89; }
.pos-screen .chrome i:nth-child(3) { background: #abefc6; }
.pos-screen table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.pos-screen th, .pos-screen td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid #f1f3f6; }
.pos-screen thead th { color: var(--text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 650; border-bottom: 1px solid var(--border); }
.pos-screen td.num, .pos-screen th.num { text-align: right; font-variant-numeric: var(--tnum); }
.pos-screen input { width: 56px; text-align: center; padding: .3rem .4rem; }
.pos-screen .cart { margin-top: 1rem; }
.pos-screen .cta { display: flex; justify-content: center; margin-top: 1.1rem; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 1rem; margin: 1.6rem 0 3rem; }
.feature-grid .card { padding: 1.25rem 1.3rem; }
.feature-grid .card:hover { border-color: #CBD5E1; box-shadow: 0 10px 28px rgba(15, 17, 21, .10); transform: translateY(-2px); }

.section { max-width: 1200px; margin: 0 auto; padding: 3.5rem 1.5rem; }
.section-alt { background: #fff; border-top: 1px solid #E2E8F0; border-bottom: 1px solid #E2E8F0; max-width: none; }
.section-alt > * { max-width: 1200px; margin-left: auto; margin-right: auto; }
.section-title { text-align: center; font-size: clamp(1.5rem, 1.2rem + 1vw, 1.9rem); font-weight: 800; margin: 0 0 .4rem; letter-spacing: -.02em; }
.section-sub { text-align: center; color: #64748b; max-width: 600px; margin: 0 auto 1.6rem; font-size: 1.02rem; }

.pricing-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem; }
.price-card { text-align: center; }
.price-card.featured { border-color: var(--kenya-green); box-shadow: 0 8px 28px rgba(0, 102, 0, .12); }
.price { font-size: clamp(1.6rem, 1.3rem + 1vw, 1.95rem); font-weight: 800; margin: .5rem 0; }
.price .muted { font-size: .92rem; font-weight: 400; }

.faq-list { max-width: 760px; margin: 0 auto; display: grid; gap: .6rem; }
.faq-item { background: #fff; border: 1px solid #E2E8F0; border-radius: var(--radius); padding: .8rem 1rem; font-size: 1rem; }
.faq-item summary { cursor: pointer; font-weight: 600; font-size: 1.02rem; min-height: 28px; }

.cta-panel {
  text-align: center; margin: 3rem 0 3.4rem; padding: 2.6rem 1.5rem; border-radius: var(--radius-lg);
  background: radial-gradient(700px 300px at 50% -40%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 70%), var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.cta-panel h2 { margin-bottom: .3rem; }
.cta-panel .button { margin-top: .8rem; padding: .75rem 1.4rem; }

.site-footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .75rem 1rem;
  padding: 2.25rem 1.5rem calc(2.25rem + env(safe-area-inset-bottom)); text-align: center;
  font-size: .95rem; line-height: 1.5;
  background: var(--kenya-black); color: #cbd5e1; border-top: 1px solid #1f2937;
}
.site-footer .brand-mark { width: 32px; height: 32px; }
.site-footer strong { font-size: 1rem; }
.site-footer a { color: #cbd5e1; }
footer.landing-footer { text-align: center; color: var(--text-subtle); padding: 1.8rem 0 2.6rem; border-top: 1px solid var(--border); max-width: none; margin: 0; font-size: .88rem; }

/* Kenyan flag accent bar */
.kenya-flag-bar { display: flex; height: 6px; width: 100%; }
.kenya-flag-bar span { display: block; }
.kenya-flag-bar .kf-black { background: #111827; flex: 0 0 32%; }
.kenya-flag-bar .kf-white { background: #fff; flex: 0 0 2%; }
.kenya-flag-bar .kf-red { background: #BB0000; flex: 0 0 30%; }
.kenya-flag-bar .kf-green { background: #006600; flex: 1; }

/* ---------- POS screen ---------- */

.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}
.pos-side { position: sticky; top: calc(var(--header-h) + 1rem); display: grid; gap: .9rem; min-width: 0; }
.qty-input { width: 74px; text-align: center; font-variant-numeric: var(--tnum); }
.pos-total-row { display: flex; justify-content: space-between; align-items: baseline; padding: .35rem 0; font-size: .95rem; color: var(--text-muted); }
.pos-total-row.grand {
  border-top: 1px solid var(--border); margin-top: .4rem; padding-top: .7rem;
  color: var(--text); font-weight: 700; font-size: 1.15rem; font-variant-numeric: var(--tnum);
}
.pos-summary .value { font-variant-numeric: var(--tnum); color: var(--text); font-weight: 600; }
.product-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(15, 17, 21, .10); border-color: #CBD5E1; }

/* horizontal pill scroll for category filters */
.pills, .filter-pills, .tabs {
  display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-bottom: .25rem;
}
.pills::-webkit-scrollbar, .filter-pills::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
.pills > *, .filter-pills > *, .tabs > * { flex: none; scroll-snap-align: start; }

/* ---------- misc utilities ---------- */

.muted { color: var(--shell-muted); font-size: .95rem; }
.stack { display: grid; gap: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt0 { margin-top: 0; }
.mb0 { margin-bottom: 0; }
.hide-mobile { }
.show-mobile { display: none !important; }
.back-link { display: inline-flex; align-items: center; gap: .4rem; color: var(--text-muted); font-size: .9rem; font-weight: 550; margin-top: 1rem; }
.back-link:hover { color: var(--text); text-decoration: none; }
.report-list { list-style: none; margin: 0; padding: 0; display: grid; }
.report-list li {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .75rem .2rem; border-bottom: 1px solid #f1f3f6; font-size: .95rem;
}
.report-list li:last-child { border-bottom: 0; }
.report-list .exports { display: inline-flex; gap: .4rem; flex-wrap: wrap; }

/* ---------- smooth transitions (kept off for reduced-motion users below) ---------- */

button, .button, .card, .nav-link, input, select, textarea, .qty-input, .badge, .icon-chip,
.action-card, .icon-btn, .product-card {
  transition: background-color .15s ease, color .15s ease, border-color .15s ease,
              box-shadow .15s ease, transform .15s ease;
}
.sidebar { transition: transform .22s ease, width .22s ease, padding .22s ease, opacity .22s ease; }


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/* ---- Large desktop (1920+): a touch more breathing room ---- */
@media (min-width: 1920px) {
  html { font-size: 18px; }
  :root { --sidebar-w: 280px; --content-max: 1680px; --page-pad: 2rem; }
}

/* ---- Desktop (1440+) ---- */
@media (min-width: 1440px) {
  :root { --page-pad: 2rem; }
  .pos-layout { grid-template-columns: minmax(0, 1fr) 360px; }
}

/* ---- Laptop and up (1024+): sidebar sits beside content, can collapse ---- */
@media (min-width: 1024px) {
  html { font-size: 17px; }
  :root { --header-h: 64px; --page-pad: 1.5rem; }

  body.sidebar-collapsed .sidebar { width: 0; padding: 0; opacity: 0; border-right: 0; }
  .sidebar { position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); align-self: flex-start; }

  /* POS: viewport-locked panes, scroll independently */
  .pos-layout { height: calc(100vh - var(--header-h) - 7.5rem); height: calc(100dvh - var(--header-h) - 7.5rem); min-height: 480px; }
  .pos-layout > .card.p0 { height: 100%; display: flex; flex-direction: column; min-height: 0; }
  .pos-layout > .card.p0 .table-wrap { overflow-y: auto; flex: 1; min-height: 0; }
  .pos-side { max-height: 100%; overflow-y: auto; }
}

/* ---- Short laptop screens: don't lock the POS height ---- */
@media (min-width: 1024px) and (max-height: 680px) {
  .pos-layout { height: auto; min-height: 0; }
  .pos-layout > .card.p0 .table-wrap { max-height: 60vh; }
  .pos-side { position: static; max-height: none; }
}

/* ---- Tablet + phone (<1024): sidebar becomes an overlay drawer ---- */
@media (max-width: 1023.98px) {
  .sidebar {
    position: fixed; z-index: 45; top: var(--header-h); bottom: 0; left: 0;
    width: min(300px, 86vw);
    padding: .75rem .75rem calc(.75rem + env(safe-area-inset-bottom));
    transform: translateX(-100%);
    box-shadow: none;
  }
  body:not(.sidebar-collapsed) .sidebar { transform: translateX(0); box-shadow: 0 8px 30px rgba(0, 0, 0, .18); }
  /* dim backdrop; tapping it targets <body>, see JS note */
  body:not(.sidebar-collapsed)::after {
    content: ""; position: fixed; inset: var(--header-h) 0 0 0; z-index: 44; background: rgba(15, 23, 42, .4);
  }
  body:not(.sidebar-collapsed) { overflow: hidden; }
  .app-shell > main { margin-inline: 0; max-width: none; }

  /* POS collapses to a single column, summary below the product list */
  .pos-layout { grid-template-columns: minmax(0, 1fr); height: auto; }
  .pos-side { position: static; }
  .workspace-name { display: none; }
}

/* ---- Tablet only (768–1023): a bit more air than phones ---- */
@media (min-width: 768px) and (max-width: 1023.98px) {
  :root { --page-pad: 1.5rem; }
  /* summary + payment side by side on tablets */
  .pos-side { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
  .stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- Hero stacks earlier than the sidebar ---- */
@media (max-width: 880px) {
  .hero-split { grid-template-columns: 1fr; gap: 1.75rem; padding: 2.5rem 1.25rem; }
  .hero-split .lead { max-width: none; }
  .site-nav a:not(.button):not([href="/login"]) { display: none; }
}

/* ---- Large phones (<768) ---- */
@media (max-width: 767.98px) {
  :root { --page-pad: 1rem; }

  /* 16px inputs stop iOS from zooming on focus */
  input, select, textarea, .table input:not([type="checkbox"]):not([type="hidden"]) { font-size: 1rem; }

  .page-head { align-items: flex-start; flex-direction: column; gap: .75rem; }
  .page-actions { width: 100%; }
  .page-actions > .button, .page-actions > button { flex: 1 1 auto; }

  .form, form.form, .form-card { max-width: none; }
  .card { padding: 1rem 1.05rem; }
  .card-head { padding: .85rem 1rem; }

  .section { padding: 2.5rem 1.1rem; }
  .pos-showcase { padding: 1.4rem 1rem; margin: 1rem 0 2rem; }
  .cta-panel { padding: 2rem 1.1rem; margin: 2rem 0; }
  .cta .button, .cta { width: 100%; }
  .landing { padding: 0 1rem; }
  .landing-nav { padding: .7rem 1rem; }

  .hide-mobile { display: none !important; }
  .show-mobile { display: initial !important; }
  .hero:not(.hero-split) { padding: 2.8rem .5rem 2rem; }
  .auth-card { padding: 1.8rem 1.4rem 1.6rem; }
  .user-chip .email { display: none; }
  .topbar .brand strong { max-width: 150px; }
  .brand-sub { display: none; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .7rem; }
  .pos-side { grid-template-columns: 1fr; }
  .pos-total-row.grand { font-size: 1.25rem; }

  /* tables keep scrolling inside their wrapper; make the wrapper obvious */
  .table th, .table td { padding: .6rem .7rem; }
  .table-wrap { border-radius: var(--radius); }
  .table { min-width: 560px; }
  .pos-screen table, .table.table-stack { min-width: 0; }

  /* opt-in card-style rows: <table class="table table-stack"> and <td data-label="Price"> */
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: .6rem .85rem; border-bottom: 1px solid var(--border); }
  .table-stack td { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border: 0; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); text-align: left; }
  .table-stack td.num { white-space: normal; }
}

/* ---- Small phones (<640) ---- */
@media (max-width: 639.98px) {
  .feature-grid, .pricing-grid { grid-template-columns: 1fr; }
  .topbar-right { gap: .5rem; }
  .site-header-inner { padding: .6rem 1rem; gap: .5rem; }
  .site-nav { gap: .6rem; font-size: .9rem; }
  .site-footer { padding: 1.75rem 1rem calc(1.75rem + env(safe-area-inset-bottom)); font-size: .9rem; }
  .preview-panel iframe { height: 380px; }
}

/* ---- Very small phones (<380) ---- */
@media (max-width: 379.98px) {
  html { font-size: 15px; }
  .stats-grid { grid-template-columns: 1fr; }
  .auth-card { padding: 1.5rem 1.1rem; }
  .topbar .brand strong, .brand-text { max-width: 110px; }
}

/* ---- Landscape phones: short viewports ---- */
@media (max-height: 480px) and (orientation: landscape) {
  :root { --header-h: 52px; }
  .auth-page { place-items: start center; }
  .hero-split { padding-top: 1.5rem; padding-bottom: 1.5rem; }
}

/* ---- Touch devices: comfortable tap targets ---- */
@media (pointer: coarse) {
  button, .button, .nav-link, .icon-btn, select, input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]) { min-height: var(--tap); }
  .icon-btn { min-width: var(--tap); }
  .btn-sm, button.btn-sm, .button-sm { min-height: 38px; }
  .check-row { min-height: var(--tap); }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; }
  .qty-input { width: 64px; }
  /* hover lifts feel sticky on touch */
  .action-card:hover, .feature-grid .card:hover, .product-card:hover { transform: none; }
}

/* ---- Respect users who prefer less motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* ---- Dark-mode safe scrollbars/forms (app itself stays light) ---- */
@media (prefers-contrast: more) {
  :root { --border: #94a3b8; --text-muted: #334155; --shell-muted: #334155; }
}

/* ---------- print (receipts / shelf lists) ---------- */

@media print {
  html { font-size: 12pt; }
  body * { visibility: hidden; }
  #printable-receipt, #printable-receipt *,
  .printable, .printable * { visibility: visible; }
  #printable-receipt { position: fixed; left: 0; top: 0; width: 100%; box-shadow: none !important; }
  .printable { position: absolute; left: 0; top: 0; width: 100%; }
  .kenya-flag-bar, header.topbar, .topbar, .sidebar, nav, footer, .page-actions, .back-link,
  button, .button, .pos-side { display: none !important; }
  body { background: #fff; overflow: visible; }
  body::after { display: none !important; }
  .card { box-shadow: none; border-color: #ccc; }
  main, .app-shell > main { max-width: none; padding: 0; }
  .table { min-width: 0; }
  .table thead th { position: static; }
  .table-wrap { overflow: visible; }
  tr { break-inside: avoid; }
}