/* NFTN POS — one stylesheet, no build step.
   Colour tokens live on :root; the dark theme redefines them. Tap targets are
   at least 44 px everywhere and 48 px or more on the till. Layout is fluid
   from 320 px up; nothing may scroll the page sideways. */

:root {
  color-scheme: light;
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #eeece4;
  --surface-3: #e4e1d6;
  --text: #1b1a17;
  --muted: #5e5a51;
  --border: #d8d4c7;
  --border-strong: #b9b4a4;
  --primary: #14532d;
  --primary-hover: #0f4424;
  --on-primary: #ffffff;
  --primary-soft: #e3f0e7;
  --danger: #b42318;
  --danger-hover: #971c13;
  --on-danger: #ffffff;
  --error-bg: #fdecea;
  --error-text: #8a1c12;
  --warn-bg: #fff3d1;
  --warn-text: #6b4300;
  --warn-border: #e7c56a;
  --ok-bg: #e3f0e7;
  --ok-text: #14532d;
  --info-bg: #e8eef8;
  --info-text: #1d3a6b;
  --focus: #1d4ed8;
  --demo-bg: #1b1a17;
  --demo-text: #ffd66b;
  --offline-bg: #1e3a5f;
  --offline-text: #ffffff;
  --offline-soft: #e6eefa;
  --offline-soft-text: #1e3a5f;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 16px rgb(0 0 0 / 0.06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --radius: 12px;
  --radius-sm: 8px;
  --tap: 48px;
  --tap-min: 44px;
  --gutter: 16px;
  --topbar-h: 56px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #111410;
    --surface: #1a1e19;
    --surface-2: #232822;
    --surface-3: #2d332c;
    --text: #ecebe6;
    --muted: #a8a699;
    --border: #343a33;
    --border-strong: #4a5248;
    --primary: #4ade80;
    --primary-hover: #86efac;
    --on-primary: #06210f;
    --primary-soft: #16301f;
    --danger: #f87171;
    --danger-hover: #fca5a5;
    --on-danger: #2a0706;
    --error-bg: #3a1512;
    --error-text: #fecaca;
    --warn-bg: #362a0c;
    --warn-text: #fde68a;
    --warn-border: #7a5d17;
    --ok-bg: #16301f;
    --ok-text: #bbf7d0;
    --info-bg: #172338;
    --info-text: #c7d7f5;
    --focus: #93c5fd;
    --demo-bg: #ffd66b;
    --demo-text: #1b1a17;
    --offline-bg: #93c5fd;
    --offline-text: #0b1b30;
    --offline-soft: #172338;
    --offline-soft-text: #c7d7f5;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.3);
  }
}

/* ---- base ------------------------------------------------------------- */

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  overflow-x: hidden;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.5em; text-wrap: balance; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); }
h2 { font-size: 1.15rem; }
p { margin: 0 0 0.75em; }
a { color: var(--primary); text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: 0.92em; overflow-wrap: anywhere; }
img, svg { max-width: 100%; }
.small { font-size: 0.875rem; }
.muted { color: var(--muted); font-weight: 400; }
.lead { font-size: 1.05rem; color: var(--muted); max-width: 65ch; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ftn { font-family: var(--mono); font-size: 0.9em; overflow-wrap: anywhere; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -9999px; top: 0; z-index: 100; }
.skip-link:focus { left: var(--gutter); top: 8px; background: var(--surface); padding: 8px 12px; }

/* ---- the demo strip: on every screen ------------------------------------ */

.demo-strip {
  margin: 0;
  padding: 4px var(--gutter);
  background: var(--demo-bg);
  color: var(--demo-text);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
  text-align: center;
}

/* ---- top bar -------------------------------------------------------------- */

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 6px var(--gutter);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
.brand {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 700; color: var(--text); text-decoration: none; min-height: var(--tap-min);
}
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--primary);
  box-shadow: inset 0 -6px 0 rgb(255 255 255 / 0.25);
}
.nav {
  display: flex; gap: 4px; flex: 1 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap-min); min-width: var(--tap-min);
  padding: 0 12px; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.who { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.who form { margin: 0; }
.who-name { font-size: 0.9rem; color: var(--muted); white-space: nowrap; }

@media (max-width: 899px) {
  .who-till { display: none; }
}
@media (max-width: 719px) {
  .topbar { padding-top: 4px; padding-bottom: 4px; }
  .nav { order: 3; flex-basis: 100%; flex-wrap: wrap; overflow: visible; }
  .nav a { padding: 0 10px; }
}

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

.page { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px var(--gutter) 48px; }
.page-narrow { max-width: 680px; }
.page-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; margin: 8px 0 16px;
}
.page-head h1, .page-head h2 { margin: 0; }
.detail-grid { display: grid; gap: var(--gutter); grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); margin-bottom: 24px; }
section + section { margin-top: 24px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.empty { color: var(--muted); text-align: center; padding: 24px 16px; }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap-min); padding: 8px 16px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center; text-decoration: none;
  cursor: pointer; touch-action: manipulation; user-select: none;
  transition: background-color 120ms ease, border-color 120ms ease, transform 60ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--danger); color: var(--on-danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-quiet { background: transparent; color: var(--muted); }
.btn-quiet:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: var(--tap-min); padding: 6px 12px; font-size: 0.9rem; }
.btn-lg { min-height: 52px; padding: 10px 20px; font-size: 1.05rem; }
.btn-xl { min-height: 64px; font-size: 1.2rem; }
.btn-block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 16px; }
.actions form { margin: 0; }

/* ---- notices ---------------------------------------------------------------- */

.messages { max-width: 1200px; margin: 12px auto 0; padding: 0 var(--gutter); }
.notice {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--info-bg); color: var(--info-text); margin: 0 0 12px;
}
.notice-success { background: var(--ok-bg); color: var(--ok-text); }
.notice-warning { background: var(--warn-bg); color: var(--warn-text); }
.notice-error { background: var(--error-bg); color: var(--error-text); }
.notice a { color: inherit; font-weight: 600; }
.notice p:last-child { margin: 0; }

.callout {
  border-radius: var(--radius); padding: 16px; margin: 0 0 20px;
  border: 1px solid var(--border); background: var(--surface);
}
.callout h2 { font-size: 1.05rem; }
.callout p:last-child { margin-bottom: 0; }
.callout-warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.callout-error { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
.callout details { margin-top: 8px; }
.callout summary { cursor: pointer; font-weight: 600; min-height: var(--tap-min); display: flex; align-items: center; }

.problem { margin-top: 8px; padding-top: 8px; border-top: 1px solid currentColor; opacity: 0.95; }
.problem-code { margin: 0 0 4px; }
.problem-detail { font-size: 0.92rem; overflow-wrap: anywhere; }
.problem-list { padding-left: 18px; font-size: 0.9rem; overflow-wrap: anywhere; }

.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--surface-2); color: var(--muted);
  white-space: nowrap;
}
.tag-ok { background: var(--ok-bg); color: var(--ok-text); }
.tag-warn, .tag-sample { background: var(--warn-bg); color: var(--warn-text); }
.tag-error { background: var(--error-bg); color: var(--error-text); }
.tag-void { background: var(--surface-3); color: var(--muted); text-decoration: line-through; }
.tag-offline { background: var(--offline-soft); color: var(--offline-soft-text); }

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

.form .field { margin-bottom: 16px; }
.field label, .field legend { display: block; font-weight: 600; margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
input[type="text"], input[type="password"], input[type="number"], input[type="search"],
input[type="date"], input[type="email"], select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 96px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); }
.help { color: var(--muted); font-size: 0.875rem; margin: 6px 0 0; }
.error { color: var(--danger); font-size: 0.9rem; margin: 6px 0 0; font-weight: 600; }
.check { display: flex; align-items: center; gap: 12px; min-height: var(--tap); font-weight: 600; cursor: pointer; }
.check input, .choice input, .person input, .seg input { width: 22px; height: 22px; accent-color: var(--primary); flex: none; }
.choice-row { display: flex; flex-wrap: wrap; gap: 8px; }
.choice {
  display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 8px 14px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); font-weight: 500 !important;
}
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; }
.search-form { margin-bottom: 16px; max-width: 520px; }

.steps { display: flex; gap: 8px; list-style: none; padding: 0; margin: 0 0 16px; counter-reset: step; flex-wrap: wrap; }
.steps li {
  counter-increment: step; font-size: 0.85rem; color: var(--muted);
  padding: 4px 10px; border-radius: 999px; background: var(--surface-2);
}
.steps li::before { content: counter(step) ". "; }
.steps li[aria-current="step"] { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.tin-list { columns: 2 180px; padding-left: 18px; }

/* ---- sign in and PIN pad ------------------------------------------------------ */

.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.person {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 8px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); font-weight: 600 !important;
}
.person small { display: block; font-weight: 400; color: var(--muted); font-size: 0.8rem; }
.person:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.pin-input { font-size: 1.6rem; letter-spacing: 0.4em; text-align: center; font-family: var(--mono); }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; max-width: 340px; margin: 0 auto; }
.key {
  min-height: 64px; border-radius: var(--radius); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font: 600 1.5rem var(--font); cursor: pointer;
  touch-action: manipulation;
}
.key:active { background: var(--surface-2); }
.key-fn { font-size: 1rem; color: var(--muted); }

/* ---- tables that become cards on narrow screens ------------------------------------ */

.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-2); }
.table th.num, .table td.num { text-align: right; }
.table tr:last-child td { border-bottom: 0; }
.table .row-action { text-align: right; white-space: nowrap; }
.table .row-action form { display: inline; margin: 0; }
.table tr.is-off td { color: var(--muted); }

@media (max-width: 767px) {
  .table.stack, .table.stack tbody { display: block; border: 0; background: none; }
  .table.stack thead { display: none; }
  .table.stack tr {
    display: block; margin-bottom: 12px; padding: 8px 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  }
  .table.stack td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 6px 0; border-bottom: 1px dashed var(--border); text-align: right; min-width: 0;
  }
  .table.stack td > * { min-width: 0; }
  .table.stack td::before {
    content: attr(data-label); flex: none; text-align: left;
    font-size: 0.8rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
  }
  .table.stack td.row-action { border-bottom: 0; justify-content: flex-end; flex-wrap: wrap; padding-top: 10px; }
  .table.stack td.row-action::before { content: none; }
  .table.stack td.ftn { font-size: 0.8rem; }
}

/* ---- facts and totals ------------------------------------------------------------ */

.facts-list, .totals, .facts { margin: 0; }
.facts-list > div, .totals > div {
  display: flex; justify-content: space-between; gap: 12px; padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.facts-list > div:last-child, .totals > div:last-child { border-bottom: 0; }
.facts-list dt, .totals dt { color: var(--muted); }
.facts-list dd, .totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; min-width: 0; overflow-wrap: anywhere; }
.totals .minor { font-size: 0.875rem; }
.totals .grand { font-size: 1.3rem; font-weight: 700; padding-top: 10px; }
.totals .grand dt { color: var(--text); }
.facts { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.facts div { display: flex; gap: 6px; font-size: 0.9rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }

/* ---- samples ------------------------------------------------------------------ */

.sample-grid { display: grid; gap: var(--gutter); grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.sample-card { display: flex; flex-direction: column; gap: 10px; }
.sample-card h2 { margin: 0; }
.sample-card p { margin: 0; color: var(--muted); }
.sample-card .btn { margin-top: auto; }
.sample-card details summary { cursor: pointer; min-height: var(--tap-min); display: flex; align-items: center; font-weight: 600; color: var(--primary); }
.sample-items { list-style: none; padding: 0; margin: 0; max-height: 280px; overflow-y: auto; font-size: 0.9rem; }
.sample-items li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.sample-skip { background: var(--surface-2); box-shadow: none; }

/* ---- end of day ------------------------------------------------------------------ */

.stat-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 170px), 1fr)); margin: 16px 0 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat p { margin: 0; }
.stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat-note { font-size: 0.85rem; color: var(--muted); }
.stat-hero { grid-column: 1 / -1; background: var(--primary); color: var(--on-primary); border-color: transparent; }
.stat-hero .stat-label, .stat-hero .stat-note { color: inherit; opacity: 0.85; }
.stat-hero .stat-value { font-size: clamp(1.8rem, 1.4rem + 2vw, 2.6rem); }
.stat-warn { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.stat-error { background: var(--error-bg); color: var(--error-text); border-color: transparent; }
.stat-warn .stat-label, .stat-warn .stat-note, .stat-error .stat-label, .stat-error .stat-note { color: inherit; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 16px 0; flex-wrap: wrap; }
.plain-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.list-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; }

/* ---- chips ------------------------------------------------------------------------ */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: thin; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: var(--tap-min); padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font: 600 0.92rem var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.chip[aria-pressed="true"], .chip[aria-current="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* ---- the till ------------------------------------------------------------------------- */

.till {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 400px);
  gap: 0;
  height: calc(100dvh - var(--topbar-h) - 26px);
  min-height: 480px;
}
.till-catalogue { min-width: 0; overflow-y: auto; padding: 12px var(--gutter) 24px; }
.till-tools { margin-bottom: 8px; }
.till-cart {
  display: flex; flex-direction: column; gap: 12px; min-width: 0; overflow-y: auto;
  padding: 12px var(--gutter) 16px; background: var(--surface); border-left: 1px solid var(--border);
}
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart-head h2 { margin: 0; }

.item-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); margin-top: 8px; }
.item {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
  min-height: 96px; padding: 12px; text-align: left;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text); font: inherit; cursor: pointer; touch-action: manipulation; box-shadow: var(--shadow);
}
.item:hover { border-color: var(--border-strong); }
.item:active { transform: scale(0.98); background: var(--surface-2); }
.item-name { font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.item-price { font-variant-numeric: tabular-nums; color: var(--primary); font-weight: 700; }
.item-flags { display: flex; flex-wrap: wrap; gap: 4px; }
.item-flags .tag { font-size: 0.7rem; padding: 0 6px; }
.item-count {
  position: absolute; top: -6px; right: -6px; min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 999px; background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; font-weight: 700; font-size: 0.85rem;
}

.cart-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.cart-line {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.cart-line-name { font-weight: 600; overflow-wrap: anywhere; }
.cart-line-total { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-line-sub { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); }
.cart-line-sub .disc { color: var(--primary); font-weight: 600; }
.qty { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.qty button {
  width: var(--tap); height: var(--tap); border-radius: var(--radius-sm); flex: none;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font: 700 1.25rem var(--font); cursor: pointer; touch-action: manipulation;
}
.qty input { width: 88px; min-height: var(--tap); text-align: center; font-variant-numeric: tabular-nums; }
.qty .remove { margin-left: auto; width: auto; padding: 0 12px; font-size: 0.9rem; color: var(--danger); }

.discount legend { font-weight: 600; margin-bottom: 6px; }
.segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.segmented-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.seg {
  display: flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap);
  padding: 6px 8px; text-align: center;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface); font-weight: 600; font-size: 0.92rem;
}
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg:has(input:checked) { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.seg:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.id-field { margin-top: 10px; }
.cart-notes p { font-size: 0.875rem; margin: 0 0 6px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--warn-bg); color: var(--warn-text); }
.cart-notes p.error { background: var(--error-bg); color: var(--error-text); font-weight: 400; }
.cart-bar { display: none; }

/* A phone, or a tablet in portrait: the cart goes below the grid. */
@media (max-width: 899px) {
  .till { display: block; height: auto; min-height: 0; }
  .till-catalogue { overflow: visible; padding-bottom: 12px; }
  .till-cart { overflow: visible; border-left: 0; border-top: 1px solid var(--border); padding-bottom: 96px; scroll-margin-top: 8px; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cart-bar {
    display: block; position: sticky; bottom: 0; z-index: 10;
    padding: 10px var(--gutter) calc(10px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(6px); border-top: 1px solid var(--border);
  }
  .cart-bar.is-empty { display: none; }
}
@media (max-width: 479px) {
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .item { min-height: 88px; padding: 10px; font-size: 0.92rem; }
  .segmented-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---- dialogs ---------------------------------------------------------------------- */

.dialog {
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 32px);
  padding: 0; border: 0; border-radius: var(--radius);
  background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / 0.35);
}
.dialog::backdrop { background: rgb(0 0 0 / 0.5); }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog .due { font-size: 1.1rem; }
.dialog .due strong { font-size: 1.6rem; display: block; font-variant-numeric: tabular-nums; }
.dialog .actions { justify-content: flex-end; }
.dialog .actions .btn { flex: 1 1 160px; }
.change { font-weight: 700; margin: 8px 0 0; min-height: 1.5em; }
.result-ftn { font-family: var(--mono); font-size: 1.05rem; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }

/* ---- offline mode ------------------------------------------------------------------------ */

/* The till's status bar: online or offline, the pool, and what waits to sync.
   Offline is unmistakable: the whole bar changes colour, not just a dot. */
.till-status {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  min-height: var(--tap-min); padding: 6px 12px; margin: 0 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); font-size: 0.9rem;
}
.till-status .status-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); flex: none; }
.till-status .status-text { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
.till-status .status-reason { font-weight: 400; }
.till-status .status-figures { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; font-variant-numeric: tabular-nums; }
.till-status .status-pool.is-low strong { color: var(--danger); }
.till-status .status-sync { font-weight: 600; }
.till-status .status-link {
  display: inline-flex; align-items: center; min-height: var(--tap-min); padding: 0 4px;
  color: inherit; font-weight: 600;
}
.till-status[data-mode="offline"] {
  background: var(--offline-bg); color: var(--offline-text); border-color: transparent;
}
.till-status[data-mode="offline"] .status-dot { background: var(--offline-text); }
.till-status[data-mode="offline"] .status-pool.is-low strong { color: inherit; text-decoration: underline; }
.notice-info-quiet { background: var(--surface-2); color: var(--muted); }

.pool-actions { margin-bottom: 28px; }
/* The receipt prints from here; it is never seen. */
.print-frame { position: absolute; width: 1px; height: 1px; border: 0; opacity: 0; pointer-events: none; left: -9999px; }
.danger-zone { border-top: 1px solid var(--border); padding-top: 16px; }
.step-list { padding-left: 22px; margin: 0 0 16px; }
.step-list li + li { margin-top: 6px; }
.ftn-list { list-style: none; padding: 0; margin: 8px 0 0; font-size: 0.9rem; display: grid; gap: 4px; }
.recon { margin: 16px 0 8px; }
.recon details summary { cursor: pointer; min-height: var(--tap-min); display: flex; align-items: center; font-weight: 600; }
.offline-panel { margin: 0 0 20px; }
.offline-panel h2 { font-size: 1.05rem; }
.offline-panel .form { margin-top: 12px; }

/* ---- print: the end-of-day summary prints plainly ---------------------------------------- */

@media print {
  .demo-strip, .topbar, .actions, .inline-form, .messages, .cart-bar { display: none !important; }
  body { background: #fff; color: #000; }
  .card, .stat { box-shadow: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
