:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d2330;
    --muted: #5d6677;
    --border: #dfe3ea;
    --accent: #3b4fd8;
    --accent-text: #ffffff;
    --danger: #b42318;
    --sidebar: #1d2330;
    --sidebar-text: #d7dbe4;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--text);
    background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
a { color: var(--accent); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--sidebar); color: var(--sidebar-text); padding: 1rem; }
.sidebar .brand { display: block; color: #fff; font-weight: 700; text-decoration: none; margin-bottom: 1.5rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 0.25rem; }
.sidebar nav a { color: var(--sidebar-text); text-decoration: none; padding: 0.4rem 0.6rem; border-radius: 6px; }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255, 255, 255, 0.1); color: #fff; }

.content { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: 1rem; padding: 0.75rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .user { color: var(--muted); }
.topbar form { margin: 0; }
main { padding: 1.5rem; }

button { font: inherit; padding: 0.5rem 1rem; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-text); cursor: pointer; }
button.link { background: none; color: var(--accent); padding: 0; }
input { font: inherit; width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; }
label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }

.auth { max-width: 360px; margin: 10vh auto; padding: 2rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.auth button { width: 100%; margin-top: 1.25rem; }
.error, .validation-message { color: var(--danger); }

#blazor-error-ui { display: none; position: fixed; bottom: 0; left: 0; right: 0; padding: 0.75rem 1.5rem; background: #fff4e5; border-top: 1px solid #f5c26b; }

@media (max-width: 700px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { padding: 0.75rem 1rem; }
}

.language { display: flex; gap: 0.5rem; font-size: 0.875rem; }
.language a { text-decoration: none; }
.auth .language { justify-content: center; margin-top: 1.5rem; }

.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
a.button { display: inline-block; padding: 0.5rem 1rem; border-radius: 6px; background: var(--accent); color: var(--accent-text); text-decoration: none; }
.muted { color: var(--muted); }

.search { display: flex; gap: 0.5rem; margin-bottom: 1rem; max-width: 520px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
table.grid th, table.grid td { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); text-align: left; }
table.grid th { font-size: 0.8125rem; color: var(--muted); font-weight: 600; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.inactive td { color: var(--muted); }

.form { max-width: 720px; }
.form fieldset { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 1rem 1.25rem; margin: 0 0 1rem; }
.form legend { font-weight: 700; padding: 0 0.25rem; }
.form select { font: inherit; width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0 1rem; }
.form .actions { display: flex; align-items: center; gap: 1rem; }

.notice { padding: 0.75rem 1rem; background: #ecfdf3; border: 1px solid #a6f4c5; border-radius: 6px; }
.picker { list-style: none; padding: 0; margin: 0 0 1rem; max-width: 520px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.picker li { padding: 0.5rem 0.75rem; border-bottom: 1px solid var(--border); }
.picker li:last-child { border-bottom: 0; }
.picker button.link { text-align: left; }

.till { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.5rem; align-items: start; }
.till .pay { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 1rem 1.25rem; position: sticky; top: 1rem; }
.till .pay .total { font-size: 1.25rem; display: flex; justify-content: space-between; margin: 0 0 0.5rem; }
.till .pay .inline { display: flex; gap: 0.5rem; align-items: center; }
.till .pay .inline button { white-space: nowrap; }
.till .settle { display: grid; grid-template-columns: 1fr auto; gap: 0.25rem 1rem; margin: 1rem 0; }
.till .settle dd { margin: 0; text-align: right; }
button.big { width: 100%; margin-top: 1rem; padding: 0.9rem; font-size: 1.1rem; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.qty { white-space: nowrap; }
button.step { padding: 0.15rem 0.55rem; margin: 0 0.35rem; background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.override { display: flex; gap: 0.5rem; margin-top: 0.35rem; }
.override input:first-child { max-width: 8rem; }
.close-drawer { margin-top: 2rem; max-width: 480px; }
.close-drawer summary { cursor: pointer; color: var(--accent); }
@media (max-width: 900px) { .till { grid-template-columns: 1fr; } }

h2 { font-size: 1.1rem; margin: 2rem 0 0.75rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.search input[type=date] { width: auto; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin: 1rem 0; }
.kpis div { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.75rem 1rem; display: flex; flex-direction: column; gap: 0.25rem; }
.kpis span { color: var(--muted); font-size: 0.8125rem; }
.kpis strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }

.form p.label { font-weight: 600; margin: 0.75rem 0 0.25rem; }
label.check { display: flex; align-items: baseline; gap: 0.5rem; font-weight: 400; margin: 0.35rem 0; }
label.check input { width: auto; }
button.danger { background: var(--danger); }

.search select { font: inherit; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.form textarea { font: inherit; width: 100%; padding: 0.5rem; border: 1px solid var(--border); border-radius: 6px; }

.form.wide { max-width: 960px; }
input.narrow { width: 7rem; text-align: right; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1.5rem; margin: 0 0 1rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.status { display: inline-block; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.8125rem; background: #eef0f4; color: var(--text); }
.status.s-ordered { background: #e8edff; color: #2d3fb0; }
.status.s-partiallyreceived { background: #fff4e5; color: #9a5b00; }
.status.s-received { background: #ecfdf3; color: #0f7a3d; }
.status.s-cancelled, .status.s-closed { background: #f2f4f7; color: var(--muted); }

.nowrap { white-space: nowrap; }
table.audit td { vertical-align: top; }
ul.changes { list-style: none; margin: 0; padding: 0; font-size: 0.875rem; }
ul.changes li { margin: 0.1rem 0; overflow-wrap: anywhere; }
.status.s-added { background: #ecfdf3; color: #0f7a3d; }
.status.s-modified { background: #e8edff; color: #2d3fb0; }
.status.s-deleted { background: #fef3f2; color: var(--danger); }

/* Receipt: 80 mm thermal paper, about 72 mm printable. */
.receipt-page { background: #fff; min-height: 100vh; padding: 1rem; }
.receipt { width: 72mm; margin: 0 auto; font: 12px/1.35 ui-monospace, "Cascadia Mono", Consolas, monospace; color: #000; }
.receipt h1 { font-size: 15px; text-align: center; margin: 0 0 0.25rem; }
.receipt header p, .receipt footer { text-align: center; margin: 0; }
.receipt .meta { border-top: 1px dashed #000; border-bottom: 1px dashed #000; padding: 0.35rem 0; margin: 0.5rem 0; }
.receipt table { width: 100%; border-collapse: collapse; }
.receipt td, .receipt th { padding: 0.05rem 0; text-align: left; font-weight: 400; }
.receipt .num { text-align: right; white-space: nowrap; }
.receipt td.name { padding-top: 0.3rem; }
.receipt .totals { border-top: 1px dashed #000; margin-top: 0.4rem; padding-top: 0.2rem; }
.receipt .totals tr:first-child td, .receipt .totals .due td { font-weight: 700; font-size: 14px; }
.receipt .vat { margin-top: 0.5rem; font-size: 11px; border-top: 1px dashed #000; }
.receipt footer { border-top: 1px dashed #000; margin-top: 0.5rem; padding-top: 0.35rem; }
.no-print { width: 72mm; margin: 1rem auto; display: flex; gap: 1rem; align-items: center; }
@media print {
  @page { size: 80mm auto; margin: 4mm; }
  .no-print { display: none; }
  .receipt-page { padding: 0; }
}
.receipt .vat th + th, .receipt .vat td + td { padding-left: 0.6rem; }
table.grid tr.stale td, table.grid tr.variance td { background: #fff8eb; }

.warning { padding: 0.75rem 1rem; background: #fffaeb; border: 1px solid #fedf89; border-radius: 6px; margin: 0 0 1rem; }
.warning label.check { margin-top: 0.5rem; }
button.secondary, a.button.secondary { background: var(--surface); color: var(--accent); border: 1px solid var(--accent); }
.buttons { display: flex; gap: 0.5rem; }
.upload { margin: 1rem 0; }
.form.wide details { margin: 0.5rem 0 1rem; }

/* Blazor moves focus to the page heading after navigation, for screen readers; no visible box. */
h1:focus { outline: none; }
.picker li.active { background: #e8edff; }
.keys { font-size: 0.8125rem; margin: -0.5rem 0 0.75rem; }

.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { background: none; color: var(--muted); border-radius: 6px 6px 0 0; padding: 0.5rem 0.9rem; }
.tabs button.active { color: var(--text); background: var(--surface); border: 1px solid var(--border); border-bottom-color: var(--surface); margin-bottom: -1px; }
.tabs .count { font-size: 0.75rem; background: var(--bg); border-radius: 999px; padding: 0 0.45rem; margin-left: 0.25rem; }
.bulk { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 0.75rem; }
a.button.disabled { pointer-events: none; opacity: 0.5; }
.columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem 2rem; align-items: start; margin: 1rem 0; }
.facts.money dd { text-align: right; }
.facts dd.attention { color: #9a5b00; font-weight: 700; }
.steps { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0 1.5rem; align-items: center; }
.steps .inline { display: inline-flex; gap: 0.5rem; }
.steps .inline input { width: 12rem; }
.status.p-paid, .status.f-delivered { background: #ecfdf3; color: #0f7a3d; }
.status.p-awaitingpayment, .status.p-unpaid, .status.f-pickfailed, .status.f-cancelrequested { background: #fff4e5; color: #9a5b00; }
.status.p-partiallyrefunded, .status.p-refunded, .status.f-cancelled { background: #f2f4f7; color: var(--muted); }
.status.f-reserved, .status.f-picking, .status.f-picked, .status.f-packed, .status.f-readyforpickup, .status.f-shipped { background: #e8edff; color: #2d3fb0; }

/* A4 picking list */
.print-page { background: #fff; color: #000; padding: 1.5rem; max-width: 190mm; margin: 0 auto; font-size: 11pt; }
.print-page h1 { font-size: 18pt; margin: 0; }
.print-page h2 { font-size: 13pt; margin: 1.25rem 0 0.25rem; }
.print-page h3 { font-size: 11.5pt; margin: 0 0 0.25rem; }
.print-head p { margin: 0.2rem 0; }
.sheet { width: 100%; border-collapse: collapse; margin: 0.25rem 0 0.75rem; }
.sheet th, .sheet td { border-bottom: 1px solid #bbb; padding: 0.3rem 0.4rem; text-align: left; }
.sheet .num { text-align: right; }
.sheet .tick { width: 2rem; text-align: center; font-size: 14pt; }
.pack { border: 1px solid #999; border-radius: 4px; padding: 0.5rem 0.75rem; margin-bottom: 0.75rem; break-inside: avoid; }
.pack .unpaid { font-weight: 700; margin: 0.25rem 0 0; }
@media print { .print-page { padding: 0; } @page { size: A4; margin: 12mm; } }
.print-page .no-print { width: auto; margin: 0.5rem 0; display: block; }
.warning .actions { margin-top: 0.6rem; }
.payment-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 0.9rem 1.1rem; margin-bottom: 0.9rem; }
.payment-card header { display: flex; gap: 1rem; align-items: baseline; flex-wrap: wrap; margin-bottom: 0.5rem; }
.payment-card .amount { font-size: 1.2rem; }
.payment-card .steps { margin: 0.75rem 0 0; }
.status.problem { background: #fee4e2; color: #b42318; }
.warning-inline { color: #b42318; font-weight: 600; }
.edit-lines { margin: 0 0 1rem; }
.edit-lines summary { cursor: pointer; color: var(--accent); }
