/* Azhar Trader: premium onyx & gold theme.
   The frame (top bar, menu, sign-in) is always dark onyx with gold, matching the logo.
   The working area follows the PC's light or dark setting. Bills always print black on white. */
:root {
  color-scheme: light dark;
  --font: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-urdu: "Jameel Noori Nastaleeq", "Noto Nastaliq Urdu", "Urdu Typesetting", "Segoe UI", serif;

  /* Gold, taken from the logo */
  --gold-1: #f3dc9a;
  --gold-2: #d4ae55;
  --gold-3: #a9832f;
  --gold-grad: linear-gradient(135deg, #f5e1a4 0%, #d9b45c 45%, #b08835 100%);
  --on-gold: #1c1406;

  /* Onyx frame */
  --shell-bg: #0b0e12;
  --shell-bg-2: #11151b;
  --shell-text: #cfd4dc;
  --shell-muted: #858d9a;
  --shell-border: #1d232c;
  --shell-hover: rgb(255 255 255 / 6%);

  /* Working area (light) */
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #f3f1eb;
  --surface-3: #ebe7dd;
  --text: #121419;
  --muted: #596070;
  --border: #e4e0d5;
  --accent: #86661c;       /* gold dark enough to read on white */
  --accent-soft: #f7efdc;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #9a4a05;
  --warn-soft: #fff4e5;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --focus: #86661c;
  --shadow-sm: 0 1px 2px rgb(16 18 24 / 6%);
  --shadow: 0 1px 2px rgb(16 18 24 / 5%), 0 10px 28px -16px rgb(16 18 24 / 22%);
  --shadow-lg: 0 30px 70px -24px rgb(0 0 0 / 55%);
  --glow: 0 0 0 3px rgb(169 131 47 / 28%);
  --radius: 14px;
  --radius-sm: 10px;
  accent-color: #a9832f;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #08090c;
    --surface: #111419;
    --surface-2: #161a20;
    --surface-3: #1d222a;
    --text: #eceef2;
    --muted: #9aa2af;
    --border: #232933;
    --accent: #e2c375;
    --accent-soft: #241f13;
    --danger: #f97066;
    --danger-soft: #3a1714;
    --warn: #fdb022;
    --warn-soft: #33250a;
    --ok: #47cd89;
    --ok-soft: #10291c;
    --focus: #e2c375;
    --shadow: 0 1px 2px rgb(0 0 0 / 50%), 0 12px 32px -14px rgb(0 0 0 / 70%);
    --glow: 0 0 0 3px rgb(226 195 117 / 25%);
    accent-color: #d4ae55;
  }
}

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

html { font-size: 15px; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(1100px 520px at 100% -8%, rgb(212 174 85 / 9%), transparent 62%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--text); }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
/* Headings get focus after page changes (for screen readers) but need no visible ring. */
h1[tabindex="-1"]:focus { outline: none; }

h1, h2, h3 { font-family: var(--font-display); line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -0.01em; }
h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.12rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0 0 .75rem; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.muted { color: var(--muted); }
.urdu { font-family: var(--font-urdu); font-size: 1.1em; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--ok); }

.skip-link {
  position: absolute; inset-inline-start: 1rem; inset-block-start: -3rem; z-index: 20;
  background: var(--gold-grad); color: var(--on-gold); padding: .5rem .8rem; border-radius: var(--radius-sm); font-weight: 600;
}
.skip-link:focus { inset-block-start: .5rem; }

/* ---------- App frame ---------- */
.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  min-height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: .75rem;
  padding: .55rem 1.25rem;
  background: linear-gradient(90deg, var(--shell-bg) 0%, var(--shell-bg-2) 100%);
  border-block-end: 1px solid var(--shell-border);
  box-shadow: 0 1px 0 rgb(212 174 85 / 18%);
  position: sticky; top: 0; z-index: 5;
  color: var(--shell-text);
  color-scheme: dark;
}
.brand {
  display: flex; align-items: center; gap: .7rem;
  font-family: var(--font-display); font-weight: 700; font-size: 1.08rem; letter-spacing: .01em;
  color: #fff; text-decoration: none;
}
.topbar .brand:hover { color: var(--gold-1); }
.brand-mark {
  display: inline-grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: 10px;
  background: var(--gold-grad); color: var(--on-gold); font-weight: 800; font-size: .85rem; letter-spacing: .02em;
  box-shadow: 0 4px 14px -6px rgb(212 174 85 / 70%);
}
.brand-logo { height: 2.4rem; width: auto; max-width: 6.5rem; object-fit: contain; }
.brand-logo.plain { background: #fff; border-radius: 8px; padding: 2px 4px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--shell-muted); font-size: .9rem; margin-inline-end: .25rem; }
.topbar .btn { background: transparent; color: var(--shell-text); border-color: var(--shell-border); }
.topbar .btn:hover { background: var(--shell-hover); color: #fff; border-color: #2d3540; }
.topbar :focus-visible { outline-color: var(--gold-2); }

.sidebar {
  background: linear-gradient(180deg, var(--shell-bg) 0%, #0d1116 100%);
  border-inline-end: 1px solid var(--shell-border);
  padding: 1rem .7rem 2rem;
  overflow-y: auto;
  position: sticky; top: 3.45rem; height: calc(100vh - 3.45rem);
  color-scheme: dark;
  scrollbar-color: #2a313b transparent;
  scrollbar-width: thin;
}
.nav-group { margin-block-end: 1rem; }
.nav-group h2 {
  font-family: var(--font);
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .14em;
  color: #b89a57; margin: .3rem .7rem .4rem;
}
.nav-group ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-group a {
  display: block; padding: .48rem .75rem; border-radius: 9px;
  color: var(--shell-text); text-decoration: none; font-size: .94rem;
  transition: background-color .15s ease, color .15s ease;
}
.nav-group a:hover { background: var(--shell-hover); color: #fff; }
.nav-group a[aria-current="page"] {
  background: linear-gradient(90deg, rgb(212 174 85 / 20%), rgb(212 174 85 / 4%));
  color: var(--gold-1); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--gold-2);
}
.sidebar :focus-visible { outline-color: var(--gold-2); }

main#main { padding: 1.75rem 2.1rem 3.5rem; min-width: 0; }
main#main:focus { outline: none; }

@media (width < 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; border-inline-end: 0; border-block-end: 1px solid var(--shell-border);
    display: flex; gap: 1rem; overflow-x: auto; padding: .55rem .75rem;
  }
  .nav-group { margin: 0; flex: none; }
  .nav-group ul { display: flex; gap: .15rem; }
  .nav-group a { white-space: nowrap; }
  .nav-group a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--gold-2); }
  main#main { padding: 1.1rem 1rem 2.5rem; }
  .topbar { padding: .5rem .9rem; }
  .topbar .who { display: none; }
}

/* ---------- Page pieces ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1rem; margin-block-end: 1.2rem; }
.page-head h1 { margin: 0; flex: 1 1 auto; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.subtitle { color: var(--muted); margin: -.7rem 0 1.2rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem 1.3rem; margin-block-end: 1.1rem;
}
.card > h2:first-child { margin-block-end: .8rem; }

.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem; margin-block-end: 1.2rem; }
.stat {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem .95rem; box-shadow: var(--shadow);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.stat::before {
  content: ""; position: absolute; inset-block-start: 0; inset-inline: 0; height: 3px; background: var(--gold-grad); opacity: .9;
}
.stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--gold-2) 45%, var(--border)); }
.stat .label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; }
.stat .value { font-family: var(--font-display); font-size: 1.62rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-block: .3rem .1rem; letter-spacing: -0.01em; }
.stat .sub { color: var(--muted); font-size: .84rem; }
.stat.warn .value { color: var(--warn); }

.quick { display: flex; flex-wrap: wrap; gap: .55rem; margin-block-end: 1.3rem; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: .65rem .8rem;
  margin-block-end: 1rem;
}
.toolbar .field { min-width: 9rem; }
.toolbar .grow { flex: 1 1 14rem; }

.tabs { display: flex; gap: .3rem; border-block-end: 1px solid var(--border); margin-block-end: 1.1rem; flex-wrap: wrap; }
.tabs a {
  padding: .55rem .9rem; text-decoration: none; color: var(--muted); font-weight: 550;
  border-block-end: 2px solid transparent; margin-block-end: -1px; transition: color .15s ease;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-current="page"] { color: var(--accent); border-color: var(--gold-2); font-weight: 650; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem 1.3rem; margin: 0; }
.info-grid div { min-width: 0; }
.info-grid dt { color: var(--muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.info-grid dd { margin: .1rem 0 0; font-weight: 550; overflow-wrap: anywhere; }

.badge {
  display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .76rem; font-weight: 650;
  background: var(--surface-3); color: var(--muted); vertical-align: middle; letter-spacing: .01em;
}
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

.notice { padding: .75rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface-2); margin-block-end: 1rem; }
.notice.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.notice.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.notice.ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-size: .94rem; font-weight: 550; line-height: 1.2;
  padding: .56rem 1rem; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none;
  white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, filter .15s ease, transform .05s ease;
}
.btn:hover { background: var(--surface-2); color: var(--text); border-color: color-mix(in srgb, var(--gold-2) 35%, var(--border)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--gold-grad); border-color: #b48c38; color: var(--on-gold); font-weight: 680;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 40%), 0 8px 20px -10px rgb(169 131 47 / 75%);
}
.btn-primary:hover {
  background: var(--gold-grad); color: var(--on-gold); border-color: #a17a2c;
  filter: brightness(1.05) saturate(1.06);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 45%), 0 12px 26px -10px rgb(169 131 47 / 85%);
}
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: transparent; box-shadow: none; }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.btn-small { padding: .3rem .62rem; font-size: .84rem; border-radius: 8px; }
.btn-icon { padding: .32rem .52rem; line-height: 1; box-shadow: none; }
.btn-link { background: none; border: 0; color: var(--accent); padding: 0; text-decoration: underline; cursor: pointer; font: inherit; }
.row-actions { display: flex; gap: .35rem; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; min-width: 0; }
.field label, .field .label { font-size: .84rem; font-weight: 650; color: var(--text); }
.field .help { font-size: .8rem; color: var(--muted); }
.req { color: var(--danger); margin-inline-start: .15rem; }

input, select, textarea {
  font: inherit; font-size: .95rem; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .55rem .7rem; min-width: 0; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--gold-2) 30%, var(--border)); }
textarea { resize: vertical; min-height: 4.5rem; }
input[type="checkbox"] { width: auto; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--focus); box-shadow: var(--glow);
}
input:user-invalid, select:user-invalid, textarea:user-invalid, [aria-invalid="true"] { border-color: var(--danger); }
input[dir="rtl"], textarea[dir="rtl"] { font-family: var(--font-urdu); font-size: 1.05rem; }
input:disabled { background: var(--surface-2); color: var(--muted); }

.check { display: flex; align-items: center; gap: .55rem; font-weight: 550; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1.1rem; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.form-grid h3 { margin: .6rem 0 0; padding-block-start: .6rem; border-block-start: 1px solid var(--border); color: var(--accent); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; }
@media (width < 640px) {
  .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
}

fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem 1.1rem; margin: 0 0 1.1rem; min-width: 0; background: var(--surface); box-shadow: var(--shadow); }
legend { font-family: var(--font-display); font-weight: 650; padding: 0 .4rem; }

.form-error {
  background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: .6rem .8rem; margin-block: .8rem 0;
}
.form-actions { display: flex; flex-wrap: wrap; gap: .55rem; margin-block-start: 1.1rem; }

/* ---------- Dialogs ---------- */
dialog.dialog {
  border: 1px solid var(--border); border-radius: 18px; padding: 1.4rem 1.5rem;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
  width: min(580px, calc(100vw - 2rem)); max-height: calc(100vh - 2rem); overflow: auto;
}
dialog.dialog.dialog-wide { width: min(860px, calc(100vw - 2rem)); }
dialog.dialog > h2 { font-size: 1.25rem; margin-block-end: 1rem; }
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop {
  background: rgb(6 8 11 / 62%); backdrop-filter: blur(5px);
  overflow: hidden; overscroll-behavior: contain;
}
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .55rem; margin-block-start: 1.3rem; }
.dialog-actions .left { margin-inline-end: auto; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow: auto; max-block-size: min(70vh, 900px);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  box-shadow: var(--shadow);
}
.table-wrap.tall { max-block-size: none; }
.card .table-wrap { box-shadow: none; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .93rem; }
caption { text-align: start; font-weight: 650; padding: .7rem .9rem; }
thead th {
  position: sticky; inset-block-start: 0; z-index: 1;
  background: var(--surface-2); text-align: start; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; padding: .65rem .8rem; border-block-end: 1px solid var(--border); white-space: nowrap;
}
th.num, td.num { text-align: end; }
tbody td { padding: .6rem .8rem; border-block-end: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-block-end: 0; }
tbody tr { transition: background-color .12s ease; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
tfoot td { padding: .65rem .8rem; font-weight: 700; border-block-start: 1px solid var(--border); background: var(--surface-2); }
td.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
tr.cancelled td { color: var(--muted); text-decoration: line-through; }
tr.cancelled td:last-child, tr.cancelled td .badge { text-decoration: none; }

/* ---------- Invoice entry ---------- */
.invoice-lines td { padding: .38rem .42rem; }
.invoice-lines input { padding: .42rem .5rem; }
.invoice-lines .col-product { min-width: 15rem; }
.invoice-lines input.qty { width: 5rem; }
.invoice-lines input.rate { width: 7rem; }
.invoice-lines input.pct { width: 4.5rem; }
.invoice-lines tr.over-stock td { background: var(--warn-soft); }
.invoice-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 390px); gap: 1.1rem; align-items: start; margin-block-start: 1.1rem; }
@media (width < 900px) { .invoice-bottom { grid-template-columns: 1fr; } }
.totals { display: grid; grid-template-columns: 1fr auto; gap: .5rem .9rem; align-items: center; margin: 0; }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: end; font-variant-numeric: tabular-nums; font-weight: 600; }
.totals dd input, .totals dd select { width: 9.5rem; text-align: end; }
.totals .grand {
  font-family: var(--font-display); font-size: 1.45rem; font-weight: 750; letter-spacing: -0.01em;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
@media (prefers-color-scheme: light) {
  .totals .grand { background: none; color: var(--text); }
}
.party-info { margin-block-start: .55rem; font-size: .9rem; color: var(--muted); min-height: 1.3em; }

/* ---------- Toast ---------- */
.toast-region { position: fixed; inset-block-end: 1.1rem; inset-inline-end: 1.1rem; z-index: 50; display: grid; gap: .55rem; max-width: min(430px, calc(100vw - 2rem)); }
.toast {
  background: #12161c; color: #f1f2f4; padding: .75rem 1rem; border-radius: 12px;
  border-inline-start: 3px solid var(--gold-2); box-shadow: var(--shadow-lg);
}
.toast.error { border-inline-start-color: #f97066; background: #2a1414; }

/* ---------- Sign in (always onyx & gold) ---------- */
.login-page {
  --bg: #0b0e12; --surface: #12161c; --surface-2: #171c23; --surface-3: #1e242c;
  --text: #eef0f3; --muted: #9aa2af; --border: #262d37;
  --accent: #e2c375; --accent-soft: #241f13; --focus: #e2c375; --danger: #f97066; --danger-soft: #3a1714;
  --glow: 0 0 0 3px rgb(226 195 117 / 25%);
  color-scheme: dark;
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
  color: var(--text);
  background:
    radial-gradient(900px 520px at 12% 8%, rgb(212 174 85 / 17%), transparent 60%),
    radial-gradient(800px 560px at 92% 95%, rgb(212 174 85 / 11%), transparent 60%),
    linear-gradient(160deg, #07090c 0%, #10141a 100%);
}
.login-card {
  width: min(410px, 100%);
  background: rgb(17 20 25 / 78%);
  backdrop-filter: blur(16px);
  border: 1px solid rgb(255 255 255 / 8%);
  border-radius: 22px; padding: 2rem 2rem 1.6rem;
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgb(255 255 255 / 5%);
}
.login-card .brand {
  flex-direction: column; gap: .7rem; text-align: center; color: #fff;
  font-size: 1.3rem; margin-block-end: 1.3rem; padding-block-end: 1.2rem;
  border-block-end: 1px solid rgb(212 174 85 / 22%);
}
.login-card .brand-logo { height: 5.2rem; max-width: 12rem; }
.login-card .brand-mark { width: 3.4rem; height: 3.4rem; font-size: 1.2rem; border-radius: 14px; }
.login-card h1 { font-size: 1.35rem; text-align: center; }
.login-card form { display: grid; gap: .95rem; }
.login-card .btn-primary { padding-block: .7rem; font-size: 1rem; }

.loading { color: var(--muted); padding: 2rem 0; }

/* ---------- Import ---------- */
.import-steps { display: grid; gap: 1.1rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.import-steps .card { margin: 0; display: flex; flex-direction: column; gap: .65rem; }
.step-no {
  display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; border-radius: 50%;
  background: var(--gold-grad); color: var(--on-gold); font-weight: 800; font-size: .85rem; margin-inline-end: .45rem;
}
.result-list { margin: .25rem 0 0; padding-inline-start: 1.2rem; max-height: 14rem; overflow: auto; font-size: .9rem; }

/* ---------- Logo settings ---------- */
.logo-previews { display: flex; flex-wrap: wrap; gap: 1rem; align-items: stretch; margin-block-end: .8rem; }
.logo-previews figure { margin: 0; display: grid; gap: .35rem; justify-items: start; }
.logo-previews figcaption { font-size: .8rem; color: var(--muted); }
.logo-preview { max-height: 110px; max-width: 260px; object-fit: contain; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.logo-preview.on-paper { background: #fff; }
.logo-preview.on-dark { background: var(--shell-bg); border-color: var(--shell-border); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
  .stat:hover { transform: none; }
}

/* ---------- Print document (invoice) ---------- */
body.print-mode .topbar, body.print-mode .sidebar { display: none; }
body.print-mode .app { display: block; }
body.print-mode main#main { padding: 1rem; }
.print-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .55rem; margin-block-end: 1rem; }

/* The bill: black on white like a printed shop receipt, in every colour theme. */
.bill {
  color-scheme: light; background: #fff; color: #000;
  font-family: Arial, "Segoe UI", Helvetica, sans-serif; line-height: 1.3;
  margin: 0 auto; padding: 5mm 4mm; border: 1px solid var(--border); border-radius: 4px;
  box-shadow: var(--shadow-lg);
}
.bill.size-80mm { width: 76mm; font-size: 11px; }
.bill.size-A5 { width: 140mm; font-size: 12.5px; }
.bill.size-A4 { width: 190mm; max-width: 100%; font-size: 13.5px; }
.bill .b-logo { display: block; margin: 0 auto 1.5mm; max-width: 62%; max-height: 32mm; object-fit: contain; }
.bill.size-A4 .b-logo { max-width: 45mm; }
.bill .b-name { text-align: center; font-weight: 700; font-size: 1.75em; line-height: 1.15; }
.bill .b-addr { text-align: center; font-size: .98em; }
.bill .b-title { text-align: center; font-weight: 700; letter-spacing: .08em; margin-top: 1.5mm; }
.bill .b-cancelled { border: 2px solid #000; padding: .5mm 2mm; width: fit-content; margin-inline: auto; }
.bill .b-upper { text-transform: uppercase; }
.bill .b-box { border: 1.5px solid #000; margin-top: 2mm; padding-bottom: .8mm; }
.bill table { width: 100%; border-collapse: collapse; font-size: inherit; }
.bill thead th {
  position: static; background: none; color: #000; text-transform: none; letter-spacing: 0;
  font-size: inherit; font-weight: 700; white-space: normal; padding: .6mm 1mm;
}
.bill tbody td { padding: .6mm 1mm; border: 0; vertical-align: top; }
.bill tbody tr:hover td { background: none; }
.bill .b-meta th, .bill .b-meta td { text-align: center; border: 0; }
.bill .b-line { padding: .4mm 1mm; }
.bill .b-label { font-weight: 600; }
.bill .b-items { margin-top: 1.5mm; border: 1.5px solid #000; }
.bill .b-items th, .bill .b-items td { border: 1px solid #000; padding: .7mm 1mm; }
.bill .b-items th { text-align: start; }
.bill .b-items .num { text-align: end; }
.bill .b-items tfoot td { background: none; font-weight: 700; border-top: 1.5px solid #000; font-size: .95em; }
.bill .b-desc { text-transform: uppercase; }
.bill .b-disc { text-transform: none; font-size: .9em; }
.bill .b-small { font-size: .85em; margin-top: .8mm; }
.bill .b-totals { margin-top: 1.5mm; }
.bill .b-totals th, .bill .b-totals td { border: 1.5px solid #000; padding: 1mm 1.5mm; font-weight: 700; font-size: 1.12em; }
.bill .b-totals th { text-align: center; width: 62%; }
.bill .b-totals td { text-align: end; }
.bill.size-A4 .b-totals, .bill.size-A5 .b-totals { width: 60%; margin-inline-start: auto; }
.bill .b-note { margin-top: 1.5mm; }
.bill .b-thanks { text-align: center; font-weight: 700; margin-top: 5mm; }

/* ---------- Printing ---------- */
@media print {
  :root { color-scheme: light; --bg: #fff; --surface: #fff; --surface-2: #f2f2f2; --text: #000; --muted: #444; --border: #bbb; }
  html { font-size: 12px; }
  body { background: #fff; }
  .topbar, .sidebar, .no-print, .toolbar, .page-head .actions, .print-toolbar, .toast-region, .skip-link, .tabs { display: none !important; }
  .app { display: block; }
  main#main { padding: 0; }
  .card, .stat, .table-wrap, fieldset { box-shadow: none; break-inside: avoid; }
  .stat::before { display: none; }
  .table-wrap { max-block-size: none; overflow: visible; border: 0; }
  thead th { position: static; }
  .bill { border: 0; border-radius: 0; padding: 0; margin: 0 auto; box-shadow: none; }
  .bill.size-80mm { width: 74mm; }
  .bill.size-A4, .bill.size-A5 { width: auto; }
  a { color: inherit; text-decoration: none; }
}
