:root {
  --harbour: #16507A;      /* primary: Port Louis harbour blue */
  --harbour-ink: #0F3B5C;
  --ink: #1C2A44;
  --muted: #5D6B80;
  --paper: #F6F8FA;
  --surface: #FFFFFF;
  --line: #D5DDE8;
  --wash: #E8EFF6;
  --fiscal: #1E7A55;       /* cleared by MRA */
  --fiscal-wash: #E3F2EA;
  --queued: #9A6410;
  --queued-wash: #FBF0DC;
  --reject: #B3261E;
  --reject-wash: #FBE6E4;
  --radius-s: 6px;
  --radius-m: 10px;
  --font: "Public Sans", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --harbour: #6FA8D6; --harbour-ink: #9CC4E6; --ink: #E4EAF2; --muted: #9AA8BC;
    --paper: #0E1624; --surface: #152033; --line: #2A3A52; --wash: #1B2A40;
    --fiscal: #5CC79A; --fiscal-wash: #143327; --queued: #E2AE5A; --queued-wash: #33270F;
    --reject: #F08A82; --reject-wash: #3A1A18;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper);
  font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
}
a { color: var(--harbour); }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 4px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 1rem; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
:focus-visible { outline: 3px solid var(--harbour); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 0 8px 14px; color: var(--ink); text-decoration: none; }
.brand img { width: 30px; height: 30px; }
.biz-switch { margin: 0 4px 14px; }
.biz-switch select { width: 100%; }
.nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--wash); }
.nav a.on { background: var(--harbour); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side .spacer { flex: 1; }
.main { padding: 28px 32px 48px; max-width: 1180px; width: 100%; }
.topline { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.tabbar { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px calc(84px + env(safe-area-inset-bottom, 0px)); }
  .mobile-head { display: flex !important; }
  .tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom, 0px); }
  .tabbar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; font-size: 0.72rem; color: var(--muted); text-decoration: none; }
  .tabbar a.on { color: var(--harbour); font-weight: 600; }
  .tabbar svg { width: 22px; height: 22px; }
  h1 { font-size: 1.35rem; }
}
.mobile-head { display: none; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.mobile-head select { max-width: 60%; }

/* ---------- components ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px; margin-bottom: 16px; }
.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)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.figure { padding: 14px 16px; border-left: 3px solid var(--harbour); background: var(--surface); border-radius: 0 var(--radius-s) var(--radius-s) 0; }
.figure .v { font-size: 1.45rem; font-weight: 700; }
.figure .l { color: var(--muted); font-size: 0.85rem; }
.figure.warn { border-left-color: var(--queued); }
.figure.bad { border-left-color: var(--reject); }

label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 9px 10px; min-height: 42px;
}
textarea { min-height: 72px; }
input:focus, select:focus, textarea:focus { border-color: var(--harbour); outline: none; box-shadow: 0 0 0 3px var(--wash); }
.field { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; min-height: 0; }
.hint { font-size: 0.8rem; color: var(--muted); margin-top: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: inherit; font-weight: 600; border-radius: var(--radius-s);
  padding: 9px 16px; min-height: 42px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; }
.btn:hover { background: var(--wash); }
.btn.primary { background: var(--harbour); border-color: var(--harbour); color: #fff; }
.btn.primary:hover { background: var(--harbour-ink); }
.btn.danger { color: var(--reject); }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 0.85rem; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 0.8rem; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--wash); }
td.num, th.num { text-align: right; white-space: nowrap; }

.pill { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; background: var(--wash); color: var(--muted); }
.pill.fiscalised { background: var(--fiscal-wash); color: var(--fiscal); }
.pill.queued { background: var(--queued-wash); color: var(--queued); }
.pill.rejected, .pill.failed { background: var(--reject-wash); color: var(--reject); }

.notice { padding: 12px 14px; border-radius: var(--radius-s); margin-bottom: 14px; background: var(--wash); }
.notice.bad { background: var(--reject-wash); color: var(--reject); }
.notice.warn { background: var(--queued-wash); color: var(--queued); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters > * { width: auto; flex: 1 1 150px; }
.filters > .btn { flex: 0 0 auto; }
.empty { text-align: center; padding: 36px 12px; color: var(--muted); }

/* ---------- the fiscal seal: the one memorable thing ---------- */
.seal { display: flex; gap: 18px; align-items: center; padding: 16px 18px; border: 2px solid var(--fiscal); border-radius: var(--radius-m);
  background: var(--fiscal-wash); position: relative; }
.seal::before { content: ""; position: absolute; inset: 5px; border: 1px dashed var(--fiscal); border-radius: 6px; opacity: 0.45; pointer-events: none; }
.seal img { width: 112px; height: 112px; background: #fff; padding: 6px; border-radius: 4px; flex: none; }
.seal .t { font-weight: 700; color: var(--fiscal); font-size: 1.05rem; }
.seal .irn { font-size: 0.85rem; word-break: break-all; }
.seal.stamp { animation: stamp 420ms cubic-bezier(.2,1.4,.4,1) both; }
@keyframes stamp { from { transform: scale(1.12) rotate(-2deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .seal.stamp { animation: none; } }
.seal.pending { border-color: var(--queued); background: var(--queued-wash); }
.seal.pending::before { border-color: var(--queued); }
.seal.pending .t { color: var(--queued); }
@media (max-width: 520px) { .seal { flex-direction: column; align-items: flex-start; } }

/* invoice editor */
.lines td { padding: 6px 4px; }
.lines input, .lines select { min-height: 38px; padding: 6px 8px; }
.lines .desc { min-width: 180px; }
.lines .qty { width: 80px; } .lines .price { width: 120px; } .lines .tax { width: 120px; }
.totals { margin-left: auto; max-width: 320px; }
.totals div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals .grand { font-weight: 700; font-size: 1.15rem; border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 8px; }
@media (max-width: 860px) {
  .lines thead { display: none; }
  .lines tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .lines td { border: 0; padding: 0; }
  .lines td.desc-cell, .lines td.prod-cell { grid-column: 1 / -1; }
  .lines .qty, .lines .price, .lines .tax { width: 100%; }
}

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { justify-content: center; font-size: 1.4rem; padding-bottom: 6px; }
.auth .tag { text-align: center; color: var(--muted); margin-bottom: 22px; }
.lang-row { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.lang-row button { background: none; border: 0; color: var(--muted); font: inherit; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
.lang-row button.on { color: var(--harbour); font-weight: 700; }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--paper);
  padding: 10px 18px; border-radius: var(--radius-s); opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 50; max-width: 90vw; }
#toast.show { opacity: 1; }
dialog { max-height: calc(100vh - 40px); overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px; background: var(--surface); color: var(--ink); max-width: 520px; width: calc(100% - 28px); }
dialog::backdrop { background: rgba(10, 20, 35, 0.45); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* referral programme */
.refer-strip { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px; border: 1px dashed var(--harbour);
  border-radius: var(--radius-s); color: var(--harbour); text-decoration: none; font-weight: 600; }
.refer-strip svg { width: 20px; height: 20px; flex: none; }
.refer-strip:hover { background: var(--wash); }
.refer-card { padding: 20px; border: 2px solid var(--harbour); border-radius: var(--radius-m); background: var(--surface); position: relative; }
.refer-card::before { content: ""; position: absolute; inset: 5px; border: 1px dashed var(--harbour); border-radius: 6px; opacity: .35; pointer-events: none; }
.refer-card .code { font-size: 2.2rem; font-weight: 700; letter-spacing: 0.12em; color: var(--harbour); margin: 2px 0 14px; user-select: all; }
.steps { margin: 0 0 10px; padding-left: 1.3em; } .steps li { margin-bottom: 6px; }

/* quick sale */
.sale-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.sale-side { position: sticky; top: 16px; }
.sale-cust { min-width: 240px; } .sale-cust .field { margin: 0; }
.scanbar { display: flex; gap: 8px; }
.scanbar input { font-size: 1.05rem; min-height: 50px; }
.scanbar .btn { min-height: 50px; white-space: nowrap; }
.scanbar svg, .inline-scan svg, .btn svg { width: 20px; height: 20px; }
.sres { display: flex; flex-direction: column; margin-top: 6px; border-radius: var(--radius-s); overflow: hidden; }
.sitem { display: flex; justify-content: space-between; gap: 10px; align-items: center; text-align: left; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-top: 0; padding: 12px 14px; cursor: pointer; min-height: 48px; }
.sitem:first-child { border-top: 1px solid var(--line); border-radius: var(--radius-s) var(--radius-s) 0 0; }
.sitem:hover { background: var(--wash); }
.cline { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.cline:last-child { border-bottom: 0; }
.cname strong { display: block; overflow: hidden; text-overflow: ellipsis; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty input { width: 58px; min-height: 34px; padding: 4px; text-align: center; }
.camt { font-weight: 600; min-width: 92px; text-align: right; }
.sale-total { font-size: 1.6rem !important; }
.paygrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 14px; }
.paygrid .btn { padding: 8px 4px; font-size: 0.86rem; }
.btn.big { width: 100%; min-height: 56px; font-size: 1.1rem; margin-top: 14px; }
.change { display: flex; justify-content: space-between; align-items: baseline; margin-top: 12px; padding: 10px 14px; background: var(--wash); border-radius: var(--radius-s); }
.change strong { font-size: 1.4rem; }
.inline-scan { display: flex; gap: 6px; } .inline-scan .btn { flex: none; }
@media (max-width: 860px) {
  .sale-grid { grid-template-columns: 1fr; }
  .sale-side { position: static; }
  .sale-cust { min-width: 0; width: 100%; }
  .scanbar .btn span { display: none; }
  .cline { grid-template-columns: auto minmax(0, 1fr) auto; row-gap: 6px; }
  .cline .cname { grid-column: 1 / -1; }
  .cline .camt { text-align: right; }
}

/* camera scanner */
dialog.scan-dialog { padding: 0; width: min(560px, 100vw); max-width: 100vw; max-height: 100vh; background: #000; color: #fff; border: 0; overflow: hidden; }
.scan-head, .scan-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; background: #0b1220; }
.scan-head { padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.scan-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); min-height: 52px; }
.scan-view { position: relative; aspect-ratio: 4 / 3; background: #000; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; left: 12%; right: 12%; top: 32%; bottom: 32%; border: 3px solid rgba(255, 255, 255, 0.9); border-radius: 10px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35); }
.scan-frame::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff4d4d; animation: scanline 1.6s ease-in-out infinite; }
@keyframes scanline { 0%, 100% { transform: translateY(-22px); } 50% { transform: translateY(22px); } }
@media (prefers-reduced-motion: reduce) { .scan-frame::after { animation: none; } }
@media (max-width: 600px) { dialog.scan-dialog { width: 100vw; height: 100vh; } .scan-view { aspect-ratio: auto; height: calc(100vh - 120px); } }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--harbour); border-bottom-color: var(--harbour); }
.tabs a:hover { color: var(--ink); }

/* payments on an invoice */
.pay-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.pay-head h2 { margin: 0; }
.pay-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.bad-text { color: var(--reject); }
.due-strip:hover .figure { background: var(--wash); }

/* getting-started checklist */
.checklist ul { list-style: none; padding: 0; margin: 10px 0 12px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; }
.checklist li a { color: var(--ink); text-decoration: none; display: block; padding: 4px 0; }
.checklist li.ok a { color: var(--fiscal); text-decoration: line-through; }
.ck-bar { height: 6px; background: var(--wash); border-radius: 3px; overflow: hidden; }
.ck-bar span { display: block; height: 100%; background: var(--fiscal); }
@media (max-width: 860px) { .checklist ul { grid-template-columns: 1fr; } }

/* branding */
.logo-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 6px; }
.logo-prev { width: 180px; height: 72px; border: 1px dashed var(--line); border-radius: var(--radius-s); display: grid; place-items: center; background: #fff; overflow: hidden; }
.logo-prev img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* two-step sign-in */
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.codes code { background: var(--wash); padding: 6px 10px; border-radius: 4px; text-align: center; font-size: 1rem; letter-spacing: .05em; }

/* stock */
.stock-now { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.stock-now strong { font-size: 1.2rem; }

/* offline bar on the till */
.offbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -6px 0 12px; }
.offbar .check { margin: 0; }

/* help */
.help-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.help-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 16px; }
.help-nav a { padding: 7px 10px; border-radius: var(--radius-s); color: var(--ink); text-decoration: none; }
.help-nav a.on, .help-nav a:hover { background: var(--wash); }
.help-body p { max-width: 70ch; }
.help-card { display: flex; flex-direction: column; gap: 2px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.help-card:hover strong { color: var(--harbour); }
@media (max-width: 860px) { .help-grid { grid-template-columns: 1fr; } .help-nav { position: static; flex-direction: row; overflow-x: auto; } .help-nav a { white-space: nowrap; } }

/* public quote page */
.pubq { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.pubq-head { display: flex; gap: 14px; align-items: center; }
.pubq-logo { max-height: 64px; max-width: 160px; object-fit: contain; }
.pubq h1 { font-size: 1.3rem; }

/* growth chart */
.bars { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; align-items: end; height: 160px; margin: 8px 0 12px; }
.bar { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.bar span { width: 100%; background: var(--harbour); border-radius: 3px 3px 0 0; min-height: 2px; }
.bar small { color: var(--muted); font-size: 0.7rem; margin-top: 4px; }
details summary { cursor: pointer; }
