/* ==========================================================================
   Bookshop POS — application styles
   No framework, no CDN: a till must work when the internet does not.
   ========================================================================== */

:root {
  color-scheme: light;

  /* Surfaces & ink (validated chart chrome values) */
  --surface-1: #ffffff;
  --surface-2: #f9f9f9;
  --surface-3: #f1f2f4;
  --page: #f6f7f9;
  --text-primary: #191919;
  --text-secondary: #666666;
  --text-tertiary: #8a8a8a;
  --border: #e3e5e8;
  --border-strong: #c2c2c2;
  --gridline: #e7e7e7;

  /* Brand / primary action */
  --accent: #257de0;
  --accent-hover: #1b64be;
  --accent-ink: #ffffff;
  --accent-wash: #eaf2fd;

  /* Chart series (single-series charts throughout) */
  --series-1: #257de0;

  /* Status — fixed, never themed. Always paired with an icon or label. */
  --good: #0aac23;
  --good-text: #006c10;
  --good-wash: #e8f7ea;
  --warning: #fbb315;
  --warning-text: #7a5200;
  --warning-wash: #fff6e2;
  --serious: #f18a59;
  --critical: #dc3c3d;
  --critical-text: #b32526;
  --critical-wash: #fdeaea;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-1: 0 1px 2px rgba(11, 11, 11, 0.06), 0 1px 3px rgba(11, 11, 11, 0.04);
  --shadow-2: 0 4px 12px rgba(11, 11, 11, 0.08), 0 2px 4px rgba(11, 11, 11, 0.04);
  --shadow-3: 0 12px 32px rgba(11, 11, 11, 0.16);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, monospace;

  --nav-w: 232px;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #191919;
    --surface-2: #202020;
    --surface-3: #2a2a2a;
    --page: #0b0b0b;
    --text-primary: #efefef;
    --text-secondary: #9c9c9c;
    --text-tertiary: #7d7d7d;
    --border: #303030;
    --border-strong: #474747;
    --gridline: #303030;
    --accent: #338ced;
    --accent-hover: #519ced;
    --accent-wash: #16263a;
    --series-1: #338ced;
    --good-text: #53c556;
    --good-wash: #102a13;
    --warning-text: #fbb315;
    --warning-wash: #2e2206;
    --critical-text: #eb6263;
    --critical-wash: #331415;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 12px 32px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-1: #191919;
  --surface-2: #202020;
  --surface-3: #2a2a2a;
  --page: #0b0b0b;
  --text-primary: #efefef;
  --text-secondary: #9c9c9c;
  --text-tertiary: #7d7d7d;
  --border: #303030;
  --border-strong: #474747;
  --gridline: #303030;
  --accent: #338ced;
  --accent-hover: #519ced;
  --accent-wash: #16263a;
  --series-1: #338ced;
  --good-text: #53c556;
  --good-wash: #102a13;
  --warning-text: #fbb315;
  --warning-wash: #2e2206;
  --critical-text: #eb6263;
  --critical-wash: #331415;
}

/* --------------------------------------------------------------- reset */

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--page);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------- shell */

.shell { display: flex; min-height: 100vh; }

.nav {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  background: var(--surface-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.nav__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.nav__mark {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px;
}
.nav__name { font-weight: 650; font-size: 0.95rem; line-height: 1.2; }
.nav__sub { font-size: 0.75rem; color: var(--text-secondary); }

.nav__scroll { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav__group + .nav__group { margin-top: 18px; }
.nav__label {
  font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--text-tertiary); font-weight: 650;
  padding: 0 8px 6px;
}
.nav__link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.9rem; font-weight: 500;
  text-decoration: none;
}
.nav__link:hover { background: var(--surface-3); text-decoration: none; }
.nav__link.is-active { background: var(--accent-wash); color: var(--accent-hover); font-weight: 600; }
.nav__link svg { flex: 0 0 18px; width: 18px; height: 18px; opacity: 0.8; }
.nav__link .pill { margin-left: auto; }

.nav__foot { border-top: 1px solid var(--border); padding: 12px; }
.nav__user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.avatar {
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: var(--surface-3); color: var(--text-primary);
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 650;
}
.nav__user-meta { min-width: 0; }
.nav__user-name {
  font-size: 0.85rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav__user-role { font-size: 0.72rem; color: var(--text-secondary); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { flex: 1; min-width: 0; }
.topbar__actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.content { padding: 24px; flex: 1; }
.content--flush { padding: 0; }

.nav-toggle { display: none; }

/* --------------------------------------------------------------- cards */

.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}
.card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.card__head h2, .card__head h3 { flex: 1; min-width: 0; }
.card__body { padding: 16px; }
.card__foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row--tight { gap: 6px; }
.row--end { justify-content: flex-end; }
.spacer { flex: 1; }

/* ------------------------------------------------------------ stat tile */

.stat {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-1);
}
.stat__label {
  font-size: 0.78rem; color: var(--text-secondary);
  font-weight: 550; letter-spacing: 0.01em; margin-bottom: 6px;
}
.stat__value { font-size: 1.75rem; font-weight: 680; line-height: 1.1; letter-spacing: -0.02em; }
.stat__value small { font-size: 0.8rem; font-weight: 550; color: var(--text-secondary); }
.stat__meta { font-size: 0.8rem; color: var(--text-secondary); margin-top: 6px; }
.stat__meta.is-good { color: var(--good-text); }
.stat__meta.is-bad { color: var(--critical-text); }

/* ------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px;
  min-height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-primary);
  font: inherit; font-size: 0.9rem; font-weight: 580;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s ease, border-color 0.12s ease, transform 0.06s ease;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }

.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn--danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn--danger:hover { background: #b32526; border-color: #b32526; }

.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: var(--surface-3); }

.btn--sm { padding: 5px 10px; min-height: 32px; font-size: 0.82rem; }
.btn--lg { padding: 14px 22px; min-height: 52px; font-size: 1rem; }
.btn--block { width: 100%; }

.field { display: block; margin-bottom: 14px; }
.field__label {
  display: block; font-size: 0.82rem; font-weight: 600;
  margin-bottom: 5px; color: var(--text-primary);
}
.field__hint { font-size: 0.78rem; color: var(--text-secondary); margin-top: 4px; }
.field__error { font-size: 0.8rem; color: var(--critical-text); margin-top: 4px; font-weight: 550; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="tel"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  min-height: 40px;
  font: inherit; font-size: 0.92rem;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
input[aria-invalid="true"], .has-error input, .has-error select {
  border-color: var(--critical);
}
textarea { min-height: 80px; resize: vertical; }
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23666'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 30px;
}

.checkbox { display: flex; align-items: flex-start; gap: 9px; margin-bottom: 10px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; min-height: 0; margin: 2px 0 0; flex: 0 0 18px; accent-color: var(--accent); }
.checkbox__text { font-size: 0.88rem; }
.checkbox__text strong { display: block; font-weight: 600; }
.checkbox__text span { color: var(--text-secondary); font-size: 0.82rem; }

.input-prefix { position: relative; }
.input-prefix__symbol {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 0.82rem; color: var(--text-secondary); font-weight: 600; pointer-events: none;
}
.input-prefix input { padding-left: 44px; }

.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 14px 16px; background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 16px;
}
.filters .field { margin-bottom: 0; }
.filters .field { min-width: 150px; }

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

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%; border-collapse: collapse; font-size: 0.88rem;
}
table.data th {
  text-align: left; font-weight: 620; font-size: 0.76rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-secondary);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
table.data td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data th.num { text-align: right; }
table.data .mono { font-family: var(--mono); font-size: 0.84rem; }
table.data tfoot td {
  padding: 11px 12px; font-weight: 650; border-top: 2px solid var(--border-strong);
  background: var(--surface-2);
}

.cell-title { font-weight: 570; }
.cell-sub { font-size: 0.8rem; color: var(--text-secondary); }

.empty {
  padding: 48px 24px; text-align: center; color: var(--text-secondary);
}
.empty__icon { font-size: 1.75rem; margin-bottom: 8px; opacity: 0.5; }
.empty h3 { margin-bottom: 6px; color: var(--text-primary); }

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 620; line-height: 1.6;
  white-space: nowrap;
  background: var(--surface-3); color: var(--text-secondary);
}
.pill--good { background: var(--good-wash); color: var(--good-text); }
.pill--warn { background: var(--warning-wash); color: var(--warning-text); }
.pill--bad { background: var(--critical-wash); color: var(--critical-text); }
.pill--accent { background: var(--accent-wash); color: var(--accent-hover); }
.pill__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

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

.alert {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  font-size: 0.88rem; margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert__icon { flex: 0 0 18px; font-weight: 700; line-height: 1.4; }
.alert--good { background: var(--good-wash); color: var(--good-text); border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.alert--warn { background: var(--warning-wash); color: var(--warning-text); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.alert--bad { background: var(--critical-wash); color: var(--critical-text); border-color: color-mix(in srgb, var(--critical) 30%, transparent); }
.alert--info { background: var(--accent-wash); color: var(--accent-hover); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------------------------------------------------------------- chart */

.chart { display: flex; flex-direction: column; gap: 8px; }
.chart__bars {
  display: flex; align-items: flex-end; gap: 6px;
  height: 160px;
  padding-top: 18px;
  border-bottom: 1px solid var(--border-strong);
  position: relative;
}
.chart__grid {
  position: absolute; inset: 18px 0 0; pointer-events: none;
}
.chart__grid span {
  position: absolute; left: 0; right: 0; height: 1px; background: var(--gridline);
}
.chart__col {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center;
  height: 100%; position: relative;
}
.chart__bar {
  width: 100%; max-width: 48px;
  /* 4px rounded data-end, square against the baseline */
  border-radius: 4px 4px 0 0;
  background: var(--series-1);
  min-height: 2px;
  transition: filter 0.12s ease;
}
.chart__col:hover .chart__bar { filter: brightness(1.12); }
.chart__val {
  position: absolute; top: -18px; left: 50%; transform: translateX(-50%);
  font-size: 0.72rem; font-weight: 620; color: var(--text-secondary);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.chart__axis { display: flex; gap: 6px; }
.chart__tick {
  flex: 1; min-width: 0; text-align: center;
  font-size: 0.72rem; color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Horizontal bar used inside tables (top titles, payment split) */
.minibar {
  height: 6px; border-radius: 3px; background: var(--surface-3);
  overflow: hidden; min-width: 60px;
}
.minibar__fill { height: 100%; border-radius: 3px; background: var(--series-1); }

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

.till {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 0;
  height: calc(100vh - 69px);
}
.till__left {
  display: flex; flex-direction: column; min-width: 0;
  border-right: 1px solid var(--border);
}
.till__right {
  display: flex; flex-direction: column;
  background: var(--surface-1);
  min-width: 0;
}

.scan {
  padding: 16px; background: var(--surface-1);
  border-bottom: 1px solid var(--border);
}
.scan__row { display: flex; gap: 10px; }
.scan input {
  font-size: 1.05rem; min-height: 52px; font-weight: 500;
}
.scan__hint { font-size: 0.78rem; color: var(--text-secondary); margin-top: 8px; }
kbd {
  font-family: var(--mono); font-size: 0.75rem;
  padding: 1px 5px; border: 1px solid var(--border-strong);
  border-bottom-width: 2px; border-radius: 4px;
  background: var(--surface-2);
}

.results { flex: 1; overflow-y: auto; padding: 12px 16px; }
.results__meta { font-size: 0.8rem; color: var(--text-secondary); margin-bottom: 10px; }

.hit-list { display: flex; flex-direction: column; gap: 6px; }
.hit {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  padding: 11px 13px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer; font: inherit;
}
.hit:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-wash); }
.hit:disabled { opacity: 0.55; cursor: not-allowed; }
.hit__main { flex: 1; min-width: 0; }
.hit__title {
  font-weight: 580; font-size: 0.92rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hit__sub {
  font-size: 0.78rem; color: var(--text-secondary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hit__right { text-align: right; flex: 0 0 auto; }
.hit__price { font-weight: 650; font-variant-numeric: tabular-nums; }
.hit__stock { font-size: 0.74rem; color: var(--text-secondary); }

.quick-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px;
}
.quick {
  padding: 12px; text-align: left; font: inherit; cursor: pointer;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); min-height: 74px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 6px;
}
.quick:hover { border-color: var(--accent); background: var(--accent-wash); }
.quick__title {
  font-size: 0.82rem; font-weight: 570; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.quick__price { font-size: 0.85rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Cart */
.cart { flex: 1; overflow-y: auto; }
.cart__head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.cart__head h2 { flex: 1; font-size: 1rem; }
.cart__empty { padding: 40px 20px; text-align: center; color: var(--text-secondary); font-size: 0.88rem; }

.line {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.line__top { display: flex; gap: 10px; align-items: flex-start; }
.line__title { flex: 1; min-width: 0; font-size: 0.88rem; font-weight: 570; line-height: 1.35; }
.line__sub { font-size: 0.76rem; color: var(--text-secondary); margin-top: 2px; }
.line__total { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.line__controls { display: flex; align-items: center; gap: 8px; margin-top: 9px; }

.stepper { display: flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.stepper button {
  width: 34px; height: 34px; border: 0; background: var(--surface-1);
  color: var(--text-primary); font-size: 1.05rem; font-weight: 600; cursor: pointer;
  display: grid; place-items: center;
}
.stepper button:hover { background: var(--surface-3); }
.stepper input {
  width: 46px; min-height: 34px; height: 34px; text-align: center;
  border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  border-radius: 0; font-variant-numeric: tabular-nums; font-weight: 600;
  padding: 0 2px;
}
.stepper input:focus { box-shadow: none; }

.line__discount { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--text-secondary); }
.line__discount input { width: 78px; min-height: 34px; height: 34px; font-size: 0.82rem; text-align: right; }

.line__remove {
  width: 34px; height: 34px; border: 1px solid transparent; background: transparent;
  color: var(--text-secondary); border-radius: var(--radius-sm); cursor: pointer;
  display: grid; place-items: center; font-size: 1rem;
}
.line__remove:hover { background: var(--critical-wash); color: var(--critical-text); }

/* Totals + tender */
.totals { border-top: 1px solid var(--border); padding: 14px 16px; background: var(--surface-2); }
.totals__row {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 0.88rem; padding: 3px 0; color: var(--text-secondary);
}
.totals__row span:last-child { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 550; }
.totals__row--grand {
  margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border-strong);
  font-size: 1.3rem; font-weight: 700; color: var(--text-primary);
}
.totals__row--grand span:last-child { font-weight: 700; font-size: 1.4rem; }
.totals__actions { display: flex; gap: 8px; margin-top: 12px; }

/* --------------------------------------------------------------- modals */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(11, 11, 11, 0.5);
  display: grid; place-items: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface-1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  width: 100%; max-width: 480px;
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
}
.modal--wide { max-width: 680px; }
.modal__head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.modal__head h2 { flex: 1; font-size: 1.05rem; }
.modal__body { padding: 18px; overflow-y: auto; }
.modal__foot {
  padding: 14px 18px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--surface-2);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal__close {
  width: 34px; height: 34px; border: 0; background: transparent;
  color: var(--text-secondary); cursor: pointer; border-radius: var(--radius-sm);
  font-size: 1.1rem; display: grid; place-items: center;
}
.modal__close:hover { background: var(--surface-3); }

.tender-due {
  background: var(--accent-wash); color: var(--accent-hover);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.tender-due__label { font-size: 0.85rem; font-weight: 600; }
.tender-due__value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.method-tabs { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.method-tab {
  flex: 1; min-width: 96px;
  padding: 11px 10px; font: inherit; font-size: 0.85rem; font-weight: 580;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  cursor: pointer; text-align: center;
}
.method-tab:hover { background: var(--surface-3); }
.method-tab[aria-selected="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
}

.quick-cash { display: grid; grid-template-columns: repeat(auto-fit, minmax(74px, 1fr)); gap: 7px; margin-top: 10px; }
.quick-cash button {
  padding: 10px 6px; font: inherit; font-size: 0.85rem; font-weight: 600;
  background: var(--surface-1); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.quick-cash button:hover { background: var(--accent-wash); border-color: var(--accent); }

.change-box {
  margin-top: 16px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--good-wash); color: var(--good-text);
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
}
.change-box__value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.change-box.is-short { background: var(--critical-wash); color: var(--critical-text); }

.stk-status { text-align: center; padding: 22px 10px; }
.stk-status__spinner {
  width: 36px; height: 36px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stk-status__msg { font-size: 0.92rem; color: var(--text-secondary); }
.stk-status__phone { font-weight: 650; color: var(--text-primary); font-size: 1.05rem; margin-bottom: 4px; }

/* Sale completed */
.done { text-align: center; padding: 10px 0 4px; }
.done__tick {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 50%;
  background: var(--good-wash); color: var(--good-text);
  display: grid; place-items: center; font-size: 1.6rem; font-weight: 700;
}
.done__receipt { font-size: 0.85rem; color: var(--text-secondary); }
.done__change { margin-top: 14px; }
.done__change-label { font-size: 0.85rem; color: var(--text-secondary); }
.done__change-value { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ pagination */

.pagination { display: flex; gap: 5px; align-items: center; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
  padding: 7px 11px; border-radius: var(--radius-sm); font-size: 0.85rem;
  border: 1px solid var(--border); background: var(--surface-1); color: var(--text-primary);
  text-decoration: none; min-width: 36px; text-align: center;
}
.pagination a:hover { background: var(--surface-3); text-decoration: none; }
.pagination .is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 620; }
.pagination .is-disabled { opacity: 0.45; }

/* ----------------------------------------------------------------- login */

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: var(--page);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-2);
  padding: 32px;
}
.login-card__brand { text-align: center; margin-bottom: 26px; }
.login-card__mark {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 13px;
  background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 1.4rem; font-weight: 700;
}
.login-card__sub { color: var(--text-secondary); font-size: 0.88rem; margin: 4px 0 0; }

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

.receipt-lines { font-family: var(--mono); font-size: 0.85rem; }
.toast-stack { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-2);
  font-size: 0.88rem; font-weight: 550;
  background: var(--text-primary); color: var(--surface-1);
  animation: toast-in 0.18s ease;
}
.toast--bad { background: var(--critical); color: #fff; }
.toast--good { background: var(--good-text); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.helptext { font-size: 0.85rem; color: var(--text-secondary); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* --------------------------------------------------------- responsive */

@media (max-width: 1100px) {
  .till { grid-template-columns: minmax(0, 1fr) 330px; }
}

@media (max-width: 900px) {
  .nav {
    position: fixed; left: 0; top: 0; z-index: 60;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-3);
  }
  body.nav-open .nav { transform: translateX(0); }
  body.nav-open::after {
    content: ""; position: fixed; inset: 0; z-index: 50;
    background: rgba(11, 11, 11, 0.45);
  }
  .nav-toggle { display: inline-flex; }
  .content { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .till { grid-template-columns: minmax(0, 1fr); height: auto; }
  .till__left { border-right: 0; }
  .till__right { border-top: 1px solid var(--border); }
  .cart { max-height: none; }
}

@media (max-width: 560px) {
  .stat__value { font-size: 1.45rem; }
  .filters { padding: 12px; }
  .filters .field { min-width: 100%; }
  .modal__foot { flex-direction: column-reverse; }
  .modal__foot .btn { width: 100%; }
}

@media print {
  .nav, .topbar, .btn, .filters, .pagination { display: none !important; }
  .content { padding: 0; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}
