/* Desktop-first styling. Colours are variables so a different business can be re-branded in one place. */
:root {
  --brand: #2f4c7e;
  --brand-dark: #223a63;
  --accent: #e8845a;
  --bg: #f3f5f9;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #6a7488;
  --line: #dde2ec;
  --ok: #1f7a4d;
  --ok-bg: #e3f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --bad: #b3261e;
  --bad-bg: #fde7e5;
  --info-bg: #e6eefb;
  /* Text and highlights on the bar. Superuser > Appearance changes these (with --brand) from script. */
  --on-brand: #ffffff;
  --on-brand-soft: #dbe5f7;
  --on-brand-hover: rgba(255, 255, 255, .12);
  --on-brand-line: rgba(255, 255, 255, .5);
  --nav-active-bg: #ffffff;
  --nav-active-fg: #223a63;
  /* The brand colour as text on white (links, headings in notices): always dark enough to read. */
  --brand-ink: #2f4c7e;
  --brand-ink-dark: #223a63;
  --test: #8a4b00;
  --test-bg: #fff1c2;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 60, .08), 0 2px 8px rgba(20, 30, 60, .05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .6rem; }
a { color: var(--brand-ink); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 14px 4px; }
.pre { white-space: pre-wrap; }
.grow { flex: 1; }
.error { color: var(--bad); min-height: 1.2em; }
.owed { color: var(--bad); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--brand); color: var(--on-brand);
}
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: .2px; white-space: nowrap; display: flex; align-items: center; gap: 10px; }
#nav { display: flex; gap: 4px; flex: 1; }
#nav a {
  color: var(--on-brand-soft); text-decoration: none; padding: 8px 14px; border-radius: 6px; font-weight: 500;
}
#nav a:hover { background: var(--on-brand-hover); color: var(--on-brand); }
#nav a.active { background: var(--nav-active-bg); color: var(--nav-active-fg); }
.who { display: flex; align-items: center; gap: 12px; font-size: .9rem; white-space: nowrap; }
.who .btn { background: transparent; color: var(--on-brand); border-color: var(--on-brand-line); }
.who .btn:hover { background: var(--on-brand-hover); }

.main { max-width: 1560px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.back { font-size: .9rem; text-decoration: none; display: inline-block; margin-bottom: 4px; }

/* ---------- cards and grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h3 { margin: 0; }
.grid2, .grid3, .grid4 { display: grid; gap: 12px; }
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }
.grid3 .span3, .grid2 .span3 { grid-column: 1 / -1; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; min-width: 0; }
.field label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.help { font-size: .8rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: inherit; width: 100%;
  padding: 8px 10px; border: 1px solid #c5ccda; border-radius: 6px; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, .result-row:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input.invalid { border-color: var(--bad); background: var(--bad-bg); }
input[type=checkbox] { width: auto; }
.check { display: flex; align-items: center; gap: 6px; white-space: nowrap; font-size: .9rem; }
details summary { cursor: pointer; font-weight: 600; margin: 6px 0 10px; color: var(--brand-ink); }
.addr-head { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--muted); font-size: .85rem; }

/* ---------- buttons ---------- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px; border-radius: 6px; border: 1px solid #b9c2d3; background: #fff; color: var(--text);
}
.btn:hover:not(:disabled) { background: #eef1f7; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1d17; }
.btn-danger-ghost { color: var(--bad); border-color: #e2b3af; }
.btn-danger-ghost:hover:not(:disabled) { background: var(--bad-bg); }
.btn-small { padding: 4px 10px; font-size: .85rem; }
.btn-big { padding: 12px 22px; font-size: 1.05rem; }
.btn.is-busy { cursor: progress; opacity: .7; }
.link { background: none; border: 0; color: var(--brand-ink); text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
.icon-btn { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); padding: 2px 8px; border-radius: 6px; }
.icon-btn:hover { background: #eef1f7; color: var(--bad); }

/* ---------- search and results ---------- */
.search-row { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.search-row input[type=search] { flex: 1; min-width: 200px; }
.results { display: flex; flex-direction: column; gap: 6px; }
.results.tall { max-height: calc(100vh - 210px); overflow: auto; padding-right: 2px; }
.result-row {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; text-align: left; font: inherit; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px; color: inherit;
}
.result-row:hover { border-color: var(--brand); background: #f6f9ff; }
.result-row.product .p-price { font-weight: 700; text-align: right; }
.result-row.product .stock { justify-self: end; }
.result-row:not(.product) { grid-template-columns: 1fr auto; }
.tag { font-size: .72rem; background: #eef1f7; border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px; color: var(--muted); font-weight: 600; text-transform: capitalize; }
.stock { font-size: .78rem; font-weight: 700; padding: 1px 9px; border-radius: 10px; white-space: nowrap; }
.stock-in { background: var(--ok-bg); color: var(--ok); }
.stock-low { background: var(--warn-bg); color: var(--warn); }
.stock-out { background: var(--bad-bg); color: var(--bad); }
.sku-tag { font: 600 .78rem ui-monospace, Consolas, monospace; color: var(--muted); }

/* ---------- till layout ---------- */
.till { display: grid; grid-template-columns: minmax(320px, 2fr) minmax(0, 3fr); gap: 16px; align-items: start; }
.sticky { position: sticky; top: 76px; }
.chip { display: inline-block; background: var(--info-bg); border-radius: 12px; padding: 2px 12px; margin-bottom: 8px; font-size: .85rem; }
.save-row { display: flex; align-items: center; gap: 10px; }
.notice { padding: 9px 12px; border-radius: 6px; margin-bottom: 10px; font-size: .92rem; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f0d58a; }
.notice.info { background: var(--info-bg); color: var(--brand-ink-dark); border: 1px solid #c3d4f2; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 2px solid var(--line); padding: 8px 8px; white-space: nowrap; }
.table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table .num, .num { text-align: right; }
.table.clickable tbody tr { cursor: pointer; }
.table.clickable tbody tr:hover { background: #f6f9ff; }
.row-archived { opacity: .55; }
.lines td { vertical-align: top; }
.lines input, .lines select { padding: 6px 8px; }
.lines .l-item { min-width: 230px; }
.lines .l-item .sub { margin-top: 4px; font-size: .88rem; color: var(--muted); }
.lines input.num { width: 84px; text-align: right; }
.lines td:nth-child(2) select { min-width: 112px; }
.lines td:nth-child(3) { min-width: 120px; }
.lines th, .lines td { padding-left: 6px; padding-right: 6px; }
.line-warn { color: var(--warn); font-size: .82rem; font-weight: 600; margin-top: 2px; }
.line-warn:empty { display: none; }

.totals { margin: 14px 0 6px auto; max-width: 380px; }
.totals > div { display: flex; justify-content: space-between; padding: 3px 0; }
.totals .grand { font-size: 1.25rem; font-weight: 700; border-top: 2px solid var(--line); margin-top: 4px; padding-top: 8px; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 10px; }
.meta { margin-top: 12px; }

/* ---------- badges and chips ---------- */
.badge { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 10px; border-radius: 10px; vertical-align: middle; margin-left: 6px; }
.badge-draft { background: #e8ebf2; color: #4a5468; }
.badge-open { background: var(--warn-bg); color: var(--warn); }
.badge-paid { background: var(--ok-bg); color: var(--ok); }
.badge-cancelled { background: var(--bad-bg); color: var(--bad); }
.badge-returned { background: #ebe5f8; color: #5b3f9e; }
.chips { display: flex; gap: 6px; }
.chip-btn { font: inherit; font-size: .88rem; cursor: pointer; padding: 5px 12px; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.chip-btn.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 22, 40, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 10px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); }
.modal-wide { max-width: 860px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); background: #fafbfd; border-radius: 0 0 10px 10px; }
.confirm-msg { font-size: 1rem; }
.short-list { margin: 8px 0 0; padding-left: 20px; }
.pay-total { display: flex; justify-content: space-between; align-items: baseline; font-size: 1.1rem; background: var(--info-bg); padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; }
.pay-total strong { font-size: 1.5rem; }
.linkinfo { display: flex; align-items: center; gap: 8px; min-height: 36px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: 420px; pointer-events: none; }
.toast { background: #263248; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); transition: opacity .4s; }
.toast-ok { background: var(--ok); }
.toast-error { background: var(--bad); }
.toast-warn { background: #b26a00; }
.toast-out { opacity: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; padding: 28px; }
.login-card h1 { margin-bottom: 4px; }
.login-card .btn { width: 100%; margin-top: 8px; }

/* ---------- narrower screens ---------- */
@media (max-width: 1200px) {
  .topbar { gap: 12px; padding: 0 14px; }
  #nav { gap: 0; }
  #nav a { padding: 8px 9px; }
  .who { gap: 8px; }
}
@media (max-width: 1100px) {
  .till { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .results.tall { max-height: 320px; }
  .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  #nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .grid2, .grid3, .grid4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .main { padding: 12px; }
}

/* Saving overlay: shown when a save takes longer than a moment */
.modal-backdrop.modal-over-saving { z-index: 1100; }     /* a question asked during a save sits above the Saving panel */
.saving-overlay { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.72); cursor: progress; }
.saving-box { background: #fff; border: 1px solid #d0d5dd; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 22px 30px; max-width: 380px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.saving-box strong { font-size: 1.15rem; }
.spinner { width: 30px; height: 30px; border: 4px solid #d0d5dd; border-top-color: #1d4ed8; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Admin lock screen */
.lock-card { max-width: 420px; margin: 60px auto; padding: 24px; }
.lock-card h1 { margin-top: 0; }
#nav a { white-space: nowrap; }

/* ---------------- Invoice (A4) ---------------- */
.inv-tools { display: flex; justify-content: space-between; align-items: center; max-width: 190mm; margin: 0 auto 6px; }
.inv-hint { max-width: 190mm; margin: 0 auto 12px; }
.invoice { width: 190mm; margin: 0 auto 30px; background: #fff; color: #000; padding: 6mm 0; font-family: Calibri, Carlito, "Segoe UI", Arial, sans-serif; font-size: 10pt; line-height: 1.25; box-shadow: 0 2px 14px rgba(0,0,0,.18); position: relative; }
.invoice table { border-collapse: collapse; }
.inv-flag { text-align: center; font-weight: 700; letter-spacing: .1em; color: #b42318; border: 2px solid #b42318; margin: 0 6mm 3mm; padding: 2mm; }
.inv-logo { text-align: center; margin: 0 0 3mm; }
.inv-logo img { width: 112mm; height: auto; aspect-ratio: 1260 / 443; display: inline-block; }
.ibox { border: 1.3px solid #000; }
.ibox th, .ibox td { border: 1.3px solid #000; padding: 1mm 1.6mm; text-align: left; vertical-align: top; }
.ibox th { font-weight: 700; }
.inv-head { display: flex; justify-content: space-between; align-items: flex-start; margin: 0 0 3mm; }
.inv-cust .ibox { width: 100mm; }
.inv-cust .ibox th { width: 24mm; }
.inv-cust .ibox td { height: 6.4mm; }
.inv-co { width: 80mm; text-align: right; }
.inv-co .ibox { margin-left: auto; width: 76mm; }
.inv-co .ibox th { width: 26mm; text-align: left; }
.inv-co-lines { margin-top: 3mm; font-size: 11pt; }
.inv-dp { width: 118mm; margin: 0 0 0 40mm; table-layout: fixed; }
.inv-dp th { text-align: center; }
.inv-dp td { height: 11mm; }
.inv-dp .dbox, .inv-dp .pbox { font-size: 9.5pt; }
.inv-dp .none { border: 0; border-left: 1.3px solid #000; }
.inv-dp .paid { text-align: left; height: 6mm; }
.inv-items { width: 100%; border: 1.3px solid #000; margin-top: 0; }
.inv-items th, .inv-items td { border: 1.3px solid #000; padding: 1mm 1.6mm; vertical-align: top; }
.inv-items thead th { background: #d9d9d9; text-align: left; font-weight: 700; }
.inv-items .q { width: 22mm; } .inv-items .up, .inv-items .lt { width: 26mm; text-align: right; }
.inv-items .it { width: 45mm; }
.inv-items td.c { text-align: center; } .inv-items td.r { text-align: right; white-space: nowrap; }
.inv-items tr.blank td { height: 6mm; }
.inv-items tr { break-inside: avoid; }
.inv-items .sn { font-size: 9pt; color: #333; }
.inv-foot { display: flex; justify-content: space-between; align-items: flex-start; margin: 3mm 0 3mm; break-inside: avoid; }
.inv-left { width: 90mm; text-align: center; }
.leftbox { border: 1.3px solid #000; height: 17mm; display: flex; align-items: center; justify-content: center; font-size: 15pt; font-weight: 700; }
.leftlbl { font-weight: 700; margin-top: 1mm; }
.inv-tot { width: 62mm; }
.inv-tot th { width: 26mm; } .inv-tot td { text-align: right; }
.inv-tot tr.tot th, .inv-tot tr.tot td { font-weight: 700; font-size: 11.5pt; }
.inv-bar { width: 100%; margin-bottom: 3mm; }
.inv-bar td { height: 7mm; vertical-align: middle; }
.inv-bar td.cn { width: 90mm; text-align: center; font-weight: 700; font-size: 12pt; }
.inv-notes { border: 1.3px solid #000; min-height: 20mm; padding: 2mm; margin-bottom: 2.5mm; white-space: pre-wrap; }
.inv-terms { text-align: center; font-size: 8pt; line-height: 1.25; break-inside: avoid; }
.inv-terms p { margin: 0 0 .8mm; }
.inv-terms .thanks { font-weight: 700; font-size: 9.5pt; }
.inv-terms .tc-h { text-decoration: underline; }

@page { size: A4; margin: 8mm 10mm; }
@media print {
  html, body { background: #fff !important; }
  .topbar, #toasts, #modal-root, .no-print { display: none !important; }
  .main { padding: 0 !important; max-width: none !important; }
  .invoice { width: 100%; box-shadow: none; margin: 0; padding: 0; font-size: 10pt; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.invoice.pdf-mode { box-shadow: none; margin: 0; padding: 0; }

.pdf-stage { position: fixed; left: 0; top: 0; z-index: -1; width: 190mm; background: #fff; pointer-events: none; }

/* ---------------- Returns, exchanges and credit notes ---------------- */
.ret-table td { vertical-align: middle; }
.ret-table input.num { width: 92px; text-align: right; }
.ret-table select { width: auto; min-width: 170px; }
.ret-sum { background: var(--info-bg); border-radius: 6px; padding: 10px 14px; margin: 12px 0; }
.ret-sum > div { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; }
.ret-sum .grand { font-weight: 700; font-size: 1.15rem; border-top: 1px solid #c3d4f2; margin-top: 4px; padding-top: 6px; }
.ret-choice { display: flex; gap: 10px; margin: 8px 0 12px; }
.ret-choice label { flex: 1; display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; cursor: pointer; }
.ret-choice label.on { border-color: var(--brand); background: #f6f9ff; }
.ret-choice input { width: auto; margin-top: 4px; }
.notice.exchange { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.totals .credit { color: var(--ok); }
.tag-plain { text-transform: none; }
.cn-title { text-align: center; font-weight: 700; font-size: 16pt; letter-spacing: .12em; margin: 0 0 3mm; }

/* ---------------- Reports ---------------- */
.print-only { display: none; }
.rp-tabs { flex-wrap: wrap; gap: 0; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.rp-tabs .chip-btn { border: 0; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: 8px 16px; font-size: .95rem; font-weight: 600; color: var(--muted); }
.rp-tabs .chip-btn:hover { color: var(--text); }
.rp-tabs .chip-btn.active { background: none; color: var(--brand-ink-dark); border-bottom-color: var(--brand); }
.rp-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 12px 16px; }
.rp-controls .chips { flex-wrap: wrap; }
.rp-custom { display: flex; gap: 12px; }
.rp-custom label { display: flex; align-items: center; gap: 6px; font-size: .88rem; color: var(--muted); }
.rp-custom input { width: auto; padding: 4px 8px; }
.rp-stale { opacity: .5; }

.rp-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.rp-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.rp-tile-label { font-size: .82rem; font-weight: 600; color: var(--muted); }
.rp-tile-value { font-size: 1.65rem; font-weight: 700; line-height: 1.25; font-variant-numeric: tabular-nums; }
.rp-delta { margin: 1px 0 3px; font-weight: 600; }
.rp-delta.good { color: var(--ok); }
.rp-delta.bad { color: var(--bad); }
.rp-delta.muted { font-weight: 400; }

.rp-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.card > .rp-filters { align-items: center; margin-bottom: 12px; }
.rp-filter { display: flex; flex-direction: column; gap: 4px; min-width: 170px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.rp-filter select { font-weight: 400; color: var(--text); }
.rp-filters input[type=search] { flex: 1; width: auto; min-width: 260px; }
.rp-filters .chips { flex-wrap: wrap; }
.rp-wide { flex-basis: 100%; margin: 0; }

.rp-table td { vertical-align: middle; font-variant-numeric: tabular-nums; }
.rp-table td { white-space: nowrap; }
.rp-table td:first-child, .rp-table td.wrap { white-space: normal; }
.rp-table td.nw { white-space: nowrap; }
.rp-table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; }
.rp-barcell { width: 156px; }
.rp-minibar { display: block; }
.rp-foot { display: flex; justify-content: flex-end; margin-top: 10px; }

/* Charts. The two series colours were checked to stay apart for colour-blind readers; the grey is "last year". */
.rp-chart { position: relative; margin: 10px 0 12px; overflow-x: auto; }
.rp-chart svg { display: block; }
.rp-s1 { fill: #2a78d6; }
.rp-s2 { fill: #eb6834; }
.rp-s0 { fill: #8791a5; }
.rp-grid { stroke: var(--line); stroke-width: 1; }
.rp-zero { stroke: #8791a5; stroke-width: 1; }
.rp-axis { fill: var(--muted); font-size: 11px; }
.rp-hit { fill: transparent; }
.rp-hit:hover { fill: rgba(47, 76, 126, .07); }
.rp-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 4px; font-size: .85rem; }
.rp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.rp-tip { position: absolute; z-index: 5; pointer-events: none; white-space: nowrap; background: #fff; border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 4px 14px rgba(20, 30, 60, .16); padding: 8px 10px; font-size: .85rem; }
.rp-tip-head { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.rp-tip > div + div { display: flex; align-items: center; gap: 8px; }
.rp-tip strong { min-width: 78px; text-align: right; font-variant-numeric: tabular-nums; }

/* Reports print on their side (the tables are wide): reports.js adds a landscape page rule while the Reports
   page is showing and takes it away on leaving, so invoices and credit notes still print upright. */
@media print {
  .print-only { display: block; font-weight: 600; margin: 0 0 3mm; }
  .rp-page .page-head { margin-bottom: 2mm; }
  .rp-page .card { box-shadow: none; padding: 10px 12px; margin-bottom: 10px; }
  .rp-tiles { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
  .rp-tile { box-shadow: none; break-inside: avoid; padding: 8px 10px; }
  .rp-tile-value { font-size: 1.15rem; }
  .rp-table { font-size: 9pt; }
  .rp-table th, .rp-table td { padding: 3px 5px; }
  .rp-table th { white-space: normal; }
  .rp-table tr { break-inside: avoid; }
  .rp-table tfoot { display: table-row-group; }      /* the Total once, at the end, not at the foot of every page */
  .rp-chart, .rp-page .table-wrap { overflow: visible; }
  .rp-chart { break-inside: avoid; }
  .rp-chart svg { max-width: 100%; height: auto; }
  .rp-barcell { display: none; }
}

/* ---------------- Stock: lists and the three prices ---------------- */
.pick-new { display: flex; align-items: center; gap: 10px; }
.pick-new input { flex: 1; min-width: 0; }
.pick-new .link { white-space: nowrap; font-size: .85rem; }
.st-table td.num { white-space: nowrap; }
.st-acts { flex-wrap: nowrap; }
.st-key { margin: 10px 0 0; }
.lm-list { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px; }
.lm-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.lm-row:last-child { border-bottom: 0; }
.lm-list p { margin: 8px 0; }
.lm-add { display: flex; gap: 6px; margin-top: 8px; }
.lm-add input { flex: 1; min-width: 0; }
.st-table .sku-tag { white-space: nowrap; }
.st-table td:nth-child(2) { min-width: 210px; }
.result-row.product .stock { align-self: start; }
@media (max-width: 1250px) {
  .st-acts { flex-direction: column; align-items: stretch; gap: 4px; }
  .st-table { font-size: .88rem; }
  .st-table th, .st-table td { padding-left: 4px; padding-right: 4px; }
  .st-table td:nth-child(2) { min-width: 150px; }
  .st-acts .btn { padding: 3px 6px; }
}

/* ---------------- Stock: the bar that stays at the top, filters, sorting, printing ---------------- */
.st-bar { position: sticky; top: 56px; z-index: 15; background: var(--bg); margin-top: -20px; padding: 14px 0 10px; }
.st-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.st-top h1 { margin: 0; }
.st-top #stq { flex: 1; min-width: 220px; width: auto; }
.st-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.st-filters select { width: auto; max-width: 190px; padding: 5px 8px; font-size: .88rem; }
.st-filters .link { font-size: .88rem; white-space: nowrap; }
.st-last { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 5px 10px; background: var(--info-bg); border: 1px solid #c3d4f2; border-radius: 6px; font-size: .9rem; white-space: nowrap; min-width: 0; }
.st-last .muted { overflow: hidden; text-overflow: ellipsis; min-width: 0; color: #4a5468; }
.st-last-label { font-size: .72rem; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--brand-ink-dark); }
.st-count { margin-bottom: 8px; font-size: .9rem; color: var(--muted); }
.st-count strong { color: var(--text); }
.st-arch { margin: -4px 0 8px; }
.st-arch:empty { display: none; }
.st-added { white-space: nowrap; }
.st-table .tag { white-space: nowrap; }
.th-sort { font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.th-sort:hover { color: var(--text); }
th[aria-sort] .th-sort { color: var(--brand-ink-dark); }
.th-arrow { font-size: .62rem; }
.st-table tr.row-new { animation: st-new 3s ease-out 1; }
@keyframes st-new { from { background: #fff1b8; } to { background: transparent; } }
/* On a short or narrow screen a pinned bar would leave too little room for the list. */
@media (max-height: 620px), (max-width: 900px) { .st-bar { position: static; } }
@media print {
  .st-bar { position: static; margin: 0; padding: 0; background: none; }
  .st-top h1 { font-size: 1.2rem; }
  .st-card { box-shadow: none; border: 0; padding: 0; }
  .st-card .table-wrap { overflow: visible; }
  .st-table { font-size: 9pt; }
  .st-table th, .st-table td { padding: 3px 5px; }
  .st-table tr { break-inside: avoid; }
  .st-table td:nth-child(2) { min-width: 0; }
  .st-table .small { font-size: inherit; }
  .st-nocost .c-cost { display: none; }
  .th-arrow { display: none; }
  .row-archived { opacity: 1; }
}

/* ---------------- Menu: the Admin drop-down and the Feedback button ---------------- */
.nav-admin { position: relative; display: flex; }
.nav-drop-btn {
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  color: var(--on-brand-soft); background: none; border: 0; padding: 8px 14px; border-radius: 6px;
}
.nav-drop-btn:hover, .nav-drop-btn[aria-expanded="true"] { background: var(--on-brand-hover); color: var(--on-brand); }
.nav-drop-btn.active { background: var(--nav-active-bg); color: var(--nav-active-fg); }
.nav-caret { font-size: .7rem; }
.nav-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; min-width: 190px; padding: 6px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(20, 30, 60, .22);
}
#nav .nav-menu a { color: var(--text); padding: 9px 12px; white-space: nowrap; }
#nav .nav-menu a:hover, #nav .nav-menu a:focus-visible { background: #eef1f7; color: var(--brand-ink-dark); }
#nav .nav-menu a.active { background: var(--info-bg); color: var(--brand-ink-dark); font-weight: 600; }
.fb-btn { gap: 6px; }
.fb-icon { flex: none; display: block; }

/* ---------------- Useful links ---------------- */
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-bottom: 12px; }
.link-card {
  display: flex; align-items: center; gap: 12px; padding: 14px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
}
.link-card:hover { border-color: var(--brand); background: #f8faff; }
.link-badge {
  flex: none; width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: var(--brand); color: var(--on-brand); font-weight: 700; font-size: 1.1rem;
}
.link-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.link-text strong, .link-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-go { color: var(--muted); font-size: 1.1rem; }
.le-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.le-row .le-name { flex: 2; min-width: 0; }
.le-row .le-url { flex: 3; min-width: 0; }
.le-row .btn { flex: none; }
#leErr { margin-top: 8px; }
@media (max-width: 720px) {
  .le-row { flex-wrap: wrap; }
  .le-row .le-name, .le-row .le-url { flex: 1 1 100%; }
}
@media (max-width: 1200px) { .nav-drop-btn { padding: 8px 9px; } }
@media (max-width: 900px) { .fb-btn span { display: none; } }
/* A narrow window: the menu drops to its own line under the name and buttons, so nothing is pushed off the edge. */
@media (max-width: 860px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .brand { flex: 1; }
  #nav { order: 3; flex-basis: 100%; overflow: visible; flex-wrap: wrap; }
}
/* On a phone the Admin drop-down opens as a strip across the screen under the bar, so it can never be cut off by an edge. */
@media (max-width: 480px) {
  .nav-admin { position: static; }
  .nav-menu { top: 100%; left: 8px; right: 8px; min-width: 0; }
}

/* ---------------- 0.6.0: superuser, test sales, removing records, appearance, message to all tills ---------------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nw { white-space: nowrap; }
.role-chip { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; padding: 1px 8px; border-radius: 10px;
  background: var(--accent); color: #1d2433; vertical-align: middle; }
.role-chip-light { background: #fde4d6; color: #7a3410; }
.bar-logo { display: inline-flex; align-items: center; background: #fff; border-radius: 6px; padding: 3px 6px; }
.bar-logo img { height: 30px; width: auto; display: block; }
.rp-tabs a.chip-btn { text-decoration: none; }

/* The message to all tills, under the bar */
.till-msg { display: flex; align-items: center; gap: 10px; padding: 8px 20px; font-size: .95rem; border-bottom: 1px solid var(--line); }
.till-msg-info { background: var(--info-bg); color: var(--brand-ink-dark); }
.till-msg-warning { background: var(--warn-bg); color: var(--warn); border-bottom-color: #f0d58a; }
.till-msg-icon { font-size: 1.05rem; }
.till-msg-text { flex: 1; font-weight: 600; white-space: pre-wrap; }
.till-msg-when { font-size: .8rem; opacity: .8; white-space: nowrap; }

/* The superuser's idle warning */
.idle-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1200; max-width: 560px; padding: 12px 18px;
  background: #263248; color: #fff; border-radius: 8px; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); font-weight: 600; text-align: center; }

/* Test sales */
.badge-test { background: var(--test-bg); color: var(--test); border: 1px solid #f0c75e; }
.notice.test { background: repeating-linear-gradient(-45deg, var(--test-bg), var(--test-bg) 12px, #ffe8a3 12px, #ffe8a3 24px);
  color: var(--test); border: 1px solid #f0c75e; }
.till.till-test .till-right > .card { border-color: #f0c75e; box-shadow: 0 0 0 2px #f8dc85; }
.test-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.test-switch { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1px solid #f0c75e; border-radius: 16px; background: #fffaf0; cursor: pointer; white-space: nowrap; }
.test-switch input { width: auto; }
.row-test td { background: #fffbeb; }
.s-test { width: auto; }
.inv-flag.inv-test { color: #8a4b00; border-color: #8a4b00; background: #fff1c2; }

/* Picking sales to remove */
.pick-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border: 1px solid #e2b3af; background: var(--bad-bg); border-radius: 6px; }
.table .pick-col { width: 36px; padding-right: 0; }
.pick-box { display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 2px; }
.pick-box input { width: 18px; height: 18px; }
.rm-table td { vertical-align: middle; }
.rm-confirm { margin-top: 12px; }
.rr-table td { vertical-align: top; }

/* Users, System, Activity */
.us-acts { flex-wrap: wrap; gap: 4px; }
.us-table td { vertical-align: middle; }
.sy-kv th { text-transform: none; letter-spacing: 0; font-size: .88rem; width: 46%; border-bottom: 1px solid var(--line); color: var(--muted); font-weight: 600; white-space: normal; }
.sy-kv td { font-size: .92rem; }
.sy-ok { color: var(--ok); font-weight: 700; }
.sy-bad { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--bad); color: #fff; font-weight: 700; font-size: .75rem; }
.sy-inline { flex-direction: row; align-items: center; gap: 8px; margin: 0; }
.sy-inline select { width: auto; }
.sy-meter { width: 100%; height: 12px; margin-bottom: 10px; }
.al-table td { font-size: .9rem; }
.al-detail { white-space: pre-wrap; word-break: break-word; min-width: 260px; }
.fi-card { padding: 12px 14px; }
.fi-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.fi-msg { margin-bottom: 8px; }
.fi-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fi-edit select { width: auto; }
.fi-edit input { flex: 1; min-width: 220px; width: auto; }
#fiChips { margin-bottom: 12px; }

/* Appearance */
.colour-row { display: flex; gap: 8px; align-items: center; }
.colour-row input[type=color] { width: 54px; height: 38px; padding: 2px; cursor: pointer; }
.colour-row input[type=text] { width: 120px; font-family: ui-monospace, Consolas, monospace; }
.ap-sample { margin: 8px 0 12px; }

/* Useful links marked Admin only */
.link-admin { flex: none; }
.le-admin { flex: none; font-size: .85rem; }
