/* Theme ------------------------------------------------------------------
   Every colour is a variable. To rebrand, change --primary and its -hover and -soft shades. */
@font-face {
  font-family: "Figtree";
  src: url("../fonts/figtree.024d2b45be4a.woff2") format("woff2");
  font-weight: 300 900;
  font-display: swap;
}

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eff1f4;
  --line: #dfe3e9;
  --ink: #15181e;
  --muted: #586170;
  --primary: #0a7a45;
  --primary-hover: #086538;
  --primary-ink: #ffffff;
  --primary-soft: #e2f4ea;
  --nav-bg: #ffffff;
  --nav-ink: #4a5362;
  --nav-ink-strong: #15181e;
  --nav-hover: #eff1f4;
  --nav-active: #e2f4ea;
  --nav-active-ink: #086538;
  --good: #0a7a45;
  --good-soft: #e2f4ea;
  --warn: #8a5200;
  --warn-soft: #fff1cf;
  --bad: #b42318;
  --bad-hover: #991d13;
  --bad-soft: #fde7e4;
  --shadow: 0 10px 30px rgb(21 24 30 / 0.14);
  --radius: 10px;
  --radius-sm: 8px;
  --elev: 0 1px 2px rgb(16 24 40 / 0.05), 0 1px 3px rgb(16 24 40 / 0.04);
  --glow: rgb(10 122 69 / 0.10);
  --blue: #1f5fbf; --blue-soft: #e4eefc;
  --violet: #6d3fc4; --violet-soft: #efe8fb;
  --teal: #0b7285; --teal-soft: #e0f3f6;
  --pink: #b0306f; --pink-soft: #fbe6f0;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #16191f;
    --surface-2: #1e2229;
    --line: #2a2f39;
    --ink: #eceef2;
    --muted: #9aa3b2;
    --primary: #34c27a;
    --primary-hover: #50d08e;
    --primary-ink: #04190c;
    --primary-soft: #14301f;
    --nav-bg: #12151a;
    --nav-ink: #9aa3b2;
    --nav-ink-strong: #eceef2;
    --nav-hover: #1e2229;
    --nav-active: #14301f;
    --nav-active-ink: #63dc9b;
    --good: #4ccb87;
    --good-soft: #14301f;
    --warn: #f5b94a;
    --warn-soft: #3a2e12;
    --bad: #ff8a7a;
    --bad-hover: #ffa397;
    --bad-soft: #43201c;
    --shadow: 0 10px 30px rgb(0 0 0 / 0.5);
    --elev: 0 1px 0 rgb(255 255 255 / 0.03) inset;
    --glow: rgb(52 194 122 / 0.10);
    --blue: #7fb0ff; --blue-soft: #16263f;
    --violet: #b99cff; --violet-soft: #251d40;
    --teal: #5fd0e0; --teal-soft: #12303a;
    --pink: #ff8fc0; --pink-soft: #3a1a2a;
    --elev: 0 1px 0 rgb(255 255 255 / 0.03) inset;
  --glow: rgb(52 194 122 / 0.10);
  --blue: #7fb0ff; --blue-soft: #16263f;
  --violet: #b99cff; --violet-soft: #251d40;
  --teal: #5fd0e0; --teal-soft: #12303a;
  --pink: #ff8fc0; --pink-soft: #3a1a2a;
  color-scheme: dark;
}
}

:root[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #16191f;
  --surface-2: #1e2229;
  --line: #2a2f39;
  --ink: #eceef2;
  --muted: #9aa3b2;
  --primary: #34c27a;
  --primary-hover: #50d08e;
  --primary-ink: #04190c;
  --primary-soft: #14301f;
  --nav-bg: #12151a;
  --nav-ink: #9aa3b2;
  --nav-ink-strong: #eceef2;
  --nav-hover: #1e2229;
  --nav-active: #14301f;
  --nav-active-ink: #63dc9b;
  --good: #4ccb87;
  --good-soft: #14301f;
  --warn: #f5b94a;
  --warn-soft: #3a2e12;
  --bad: #ff8a7a;
  --bad-hover: #ffa397;
  --bad-soft: #43201c;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.5);
  --elev: 0 1px 0 rgb(255 255 255 / 0.03) inset;
  --glow: rgb(52 194 122 / 0.10);
  --blue: #7fb0ff; --blue-soft: #16263f;
  --violet: #b99cff; --violet-soft: #251d40;
  --teal: #5fd0e0; --teal-soft: #12303a;
  --pink: #ff8fc0; --pink-soft: #3a1a2a;
  color-scheme: dark;
}

/* Base ------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1rem/1.45 "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-variant-numeric: tabular-nums;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.125rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
a { color: var(--primary); }
button, input, select, textarea { font: inherit; color: inherit; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Shell ------------------------------------------------------------------ */
.shell { min-height: 100dvh; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius-sm); z-index: 50; }
.skip-link:focus { left: 8px; }

.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 16px;
  background: var(--nav-bg); color: var(--nav-ink-strong);
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(145deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #0b3d6b));
  color: var(--primary-ink); font-weight: 800; font-size: 1rem;
  box-shadow: 0 4px 12px var(--glow);
}
.brand-mark-lg { width: 48px; height: 48px; border-radius: 13px; margin-bottom: 16px; }
.brand-mark-lg .icon { width: 26px; height: 26px; }
.topbar .brand { font-weight: 700; font-size: 1.0625rem; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .icon-btn { color: var(--nav-ink-strong); }
.topbar select {
  background: var(--surface-2); color: var(--nav-ink-strong);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 8px; max-width: 42vw; min-height: 40px;
}

.main { padding: 16px 16px 96px; max-width: 1280px; margin: 0 auto; }

.bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 6px; min-height: 56px;
  color: var(--muted); text-decoration: none; font-size: 0.75rem; font-weight: 500;
}
.bottomnav a[aria-current="page"] { color: var(--primary); font-weight: 700; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 232px 1fr; }
  .shell.is-collapsed { grid-template-columns: 68px 1fr; }
  .topbar, .bottomnav { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px;
    position: sticky; top: 0; height: 100dvh;
    padding: 20px 12px 12px;
    background: var(--nav-bg); color: var(--nav-ink);
    border-right: 1px solid var(--line);
  }
  .sidebar .brand-row { display: flex; align-items: center; gap: 10px; padding: 0 6px 14px; min-width: 0; }
  .sidebar .brand-text { min-width: 0; }
  .sidebar .brand { color: var(--nav-ink-strong); font-size: 1.0625rem; font-weight: 700; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar .who { font-size: 0.8125rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar select {
    width: 100%; margin-bottom: 12px; min-height: 40px;
    background: var(--surface-2); color: var(--nav-ink-strong);
    border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px 8px;
  }
  .sidebar a, .sidebar .nav-btn {
    display: flex; align-items: center; gap: 12px;
    width: 100%; min-height: 44px; padding: 8px 12px;
    border: 0; border-radius: var(--radius-sm); background: none;
    color: var(--nav-ink); text-decoration: none; font-weight: 500; text-align: left; cursor: pointer;
  }
  .sidebar a:hover, .sidebar .nav-btn:hover { background: var(--nav-hover); color: var(--nav-ink-strong); }
  .sidebar a[aria-current="page"] { background: var(--nav-active); color: var(--nav-active-ink); font-weight: 700; box-shadow: inset 3px 0 0 var(--primary); }
  .sidebar .spacer { flex: 1; }
  .sidebar .foot { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 2px; }
  .is-collapsed .sidebar .label, .is-collapsed .sidebar .brand-text, .is-collapsed .sidebar select { display: none; }
  .is-collapsed .sidebar .brand-row { justify-content: center; padding-inline: 0; }
  .is-collapsed .sidebar a, .is-collapsed .sidebar .nav-btn { justify-content: center; padding: 8px; }
  .main { padding: 28px 32px 48px; width: 100%; }
}

/* Page header ------------------------------------------------------------ */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.page-head h1 { margin-right: auto; }
.page-head .sub { flex-basis: 100%; color: var(--muted); margin-top: -6px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 24px 0 12px; }
.section-head h2 { margin-right: auto; }

/* Buttons ---------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn { transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s; box-shadow: var(--elev); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); box-shadow: 0 1px 2px rgb(0 0 0 / 0.12), 0 4px 14px var(--glow); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--bad); border-color: var(--bad); color: var(--surface); }
.btn-danger:hover { background: var(--bad-hover); border-color: var(--bad-hover); }
.btn-quiet { border-color: transparent; background: none; box-shadow: none; }
.btn-link { border: 0; background: none; color: var(--primary); text-decoration: underline; min-height: 44px; cursor: pointer; padding: 0 4px; font-weight: 500; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 1.125rem; font-weight: 700; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: rgb(128 128 128 / 0.16); }

/* Segmented choices and filter chips -------------------------------------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin: -2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { display: grid; grid-template-columns: repeat(4, 1fr); overflow: visible; }
@media (max-width: 520px) { .chips.wrap { grid-template-columns: repeat(2, 1fr); } }
.chips.wrap .chip { padding-inline: 6px; }
.chips.wrap .chip { justify-content: center; min-height: 44px; }
.chip {
  flex: none; display: inline-flex; align-items: center; min-height: 40px; padding: 6px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink); font-weight: 500; text-decoration: none; cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="true"], .chip[aria-current="true"], .chip.is-on {
  background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 700;
}
.choice { display: flex; flex-wrap: wrap; gap: 8px; }
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; }
.choice span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface);
  font-weight: 500; cursor: pointer;
}
.choice input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 700; }
.choice input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Cards, tiles, tables ---------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: var(--elev); }
.card > h2, .card > h3 { margin-bottom: 12px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack { display: grid; gap: 16px; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 900px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; min-width: 0; box-shadow: var(--elev); }
.tile.is-key { background: linear-gradient(140deg, var(--primary-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--primary) 28%, var(--line)); }
.tile-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; margin-bottom: 10px; background: var(--primary-soft); color: var(--primary); }
.tile-icon .icon { width: 18px; height: 18px; }
.tone-blue { background: var(--blue-soft); color: var(--blue); }
.tone-violet { background: var(--violet-soft); color: var(--violet); }
.tone-amber { background: var(--warn-soft); color: var(--warn); }
.tone-red { background: var(--bad-soft); color: var(--bad); }
.tile dt { color: var(--muted); font-size: 0.875rem; }
.tile dd { margin: 2px 0 0; font-size: 1.375rem; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.tile .note { display: block; font-size: 0.8125rem; font-weight: 400; color: var(--muted); letter-spacing: 0; }

.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; box-shadow: var(--elev); }
thead th { background: var(--surface-2); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: left; vertical-align: middle; }
th { font-size: 0.8125rem; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); white-space: nowrap; }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--ink); }
tbody tr + tr td { border-top: 1px solid var(--line); }
td.num, th.num { text-align: right; }
tr.is-link { cursor: pointer; }
tr.is-link:hover td { background: var(--surface-2); }
.row-title { font-weight: 600; }
.row-title a, a.row-link { color: inherit; text-decoration: none; }
.row-title a:hover { text-decoration: underline; }
.hide-sm { display: none; }
@media (min-width: 700px) { .hide-sm { display: table-cell; } }
@media (min-width: 700px) { .only-sm { display: none; } }
@media (max-width: 699px) { th, td { padding: 10px 8px; } th:first-child, td:first-child { padding-left: 12px; } th:last-child, td:last-child { padding-right: 12px; } }

.badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 0.8125rem; font-weight: 600; background: var(--surface-2); color: var(--ink); white-space: nowrap; }
.badge-good { background: var(--good-soft); color: var(--good); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.plus { color: var(--good); font-weight: 700; }
.minus { color: var(--bad); font-weight: 700; }

.avatar {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--primary);
  font-weight: 700; font-size: 0.875rem; object-fit: cover;
}
.hue-1 { background: var(--blue-soft); color: var(--blue); }
.hue-2 { background: var(--violet-soft); color: var(--violet); }
.hue-3 { background: var(--warn-soft); color: var(--warn); }
.hue-4 { background: var(--teal-soft); color: var(--teal); }
.hue-5 { background: var(--pink-soft); color: var(--pink); }
.with-avatar { display: flex; align-items: center; gap: 12px; min-width: 0; }

.empty { text-align: center; padding: 48px 16px; }
.empty h2 { margin-bottom: 6px; }
.empty p { color: var(--muted); max-width: 40ch; margin: 0 auto 16px; }
.empty .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.pager { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 0.875rem; }
.pager .count { margin-right: auto; }

.notice { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); border: 1px solid currentColor; }
.notice-bad { background: var(--bad-soft); color: var(--bad); }

/* Forms ------------------------------------------------------------------ */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label, .field > .label { font-weight: 600; }
.field .help { color: var(--muted); font-size: 0.875rem; }
.field .error, .errorlist { color: var(--bad); font-size: 0.875rem; font-weight: 600; list-style: none; margin: 0; padding: 0; }
.input, .field input[type="text"], .field input[type="tel"], .field input[type="email"], .field input[type="password"],
.field input[type="number"], .field input[type="search"], .field input[type="date"], .field input[type="file"], .field select, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
.input:focus, .field input:focus, .field select:focus { border-color: var(--primary); }
.field-row { display: grid; gap: 0 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); align-items: start; }
.search { position: relative; flex: 1; min-width: 200px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { width: 100%; min-height: 48px; padding: 10px 12px 10px 42px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar select { min-height: 48px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }

.switch { display: flex; align-items: center; gap: 12px; justify-content: space-between; margin-bottom: 16px; cursor: pointer; }
.switch .text { display: grid; }
.switch .text strong { font-weight: 600; }
.switch .text span { color: var(--muted); font-size: 0.875rem; }
.switch input { appearance: none; flex: none; width: 48px; height: 28px; border-radius: 14px; background: var(--muted); position: relative; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); transition: left 0.15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { left: 23px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 12px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

/* Dialogs: a side drawer on wide screens, a bottom sheet on phones -------- */
dialog { border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgb(10 14 26 / 0.55); }
.dialog-head { display: flex; align-items: center; gap: 8px; padding: 12px 12px 12px 20px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin-right: auto; font-size: 1.1875rem; }
.dialog-body { padding: 20px; overflow-y: auto; }
.dialog-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; }
.dialog-foot > * { flex: 1; }

.drawer { width: 100%; max-width: none; max-height: 92dvh; margin: auto 0 0; border-radius: 16px 16px 0 0; border-width: 1px 0 0; }
.drawer[open] { display: flex; flex-direction: column; }
.drawer form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.drawer .dialog-body { flex: 1; }
.modal { width: min(520px, calc(100vw - 24px)); max-height: 92dvh; border-radius: 14px; }
.modal[open] { display: flex; flex-direction: column; }
@media (min-width: 700px) {
  .drawer { width: 520px; height: 100dvh; max-height: none; margin: 0 0 0 auto; border-radius: 0; border-width: 0 0 0 1px; }
}
@media (prefers-reduced-motion: no-preference) {
  .drawer[open] { animation: slide-in 0.18s ease-out; }
  @keyframes slide-in { from { transform: translateY(24px); opacity: 0; } }
}

.toasts { position: fixed; left: 0; right: 0; bottom: 76px; z-index: 60; display: grid; justify-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
@media (min-width: 900px) { .toasts { bottom: 24px; } }
.toast { pointer-events: auto; padding: 12px 18px; border-radius: var(--radius-sm); background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: var(--shadow); }
.toast.error { background: var(--bad); color: var(--surface); }

/* Sign in ---------------------------------------------------------------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: radial-gradient(900px 480px at 50% -10%, var(--glow), transparent 70%), var(--bg); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 20px; }

/* Sell ------------------------------------------------------------------- */
.sell { display: grid; gap: 16px; }
.sell-items { min-width: 0; }
.item-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-top: 12px; }
.item-tile {
  display: grid; gap: 6px; align-content: start; text-align: left;
  min-height: 132px; padding: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  cursor: pointer; position: relative; box-shadow: var(--elev);
  transition: border-color 0.12s, transform 0.08s, box-shadow 0.12s;
}
.item-tile:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--line)); box-shadow: 0 6px 18px var(--glow); }
.item-tile:active { transform: scale(0.98); }
.item-tile.in-cart { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary); background: linear-gradient(160deg, var(--primary-soft), var(--surface) 55%); }
.item-tile .name { font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item-tile .meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 6px; margin-top: auto; }
.item-tile .price { font-weight: 700; white-space: nowrap; }
.item-tile .left { font-size: 0.8125rem; color: var(--muted); }
.item-tile .left.is-low { color: var(--warn); font-weight: 600; }
.item-tile .left.is-out { color: var(--bad); font-weight: 600; }
.item-tile .count {
  position: absolute; top: 8px; right: 8px; min-width: 26px; height: 26px; padding: 0 6px;
  display: grid; place-items: center; border-radius: 13px;
  background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 0.875rem;
}

.cart { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--elev); display: flex; flex-direction: column; min-height: 0; }
.cart-lines { flex: 1; overflow-y: auto; padding: 4px 16px; min-height: 120px; }
.cart-line { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(84px, auto); gap: 4px 10px; padding: 10px 0; align-items: center; }
.cart-line + .cart-line { border-top: 1px solid var(--line); }
.cart-line .name { font-weight: 600; overflow-wrap: anywhere; }
.cart-line .each { color: var(--muted); font-size: 0.875rem; }
.cart-line .line-total { font-weight: 700; text-align: right; }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.stepper button { width: 40px; height: 44px; border: 0; background: none; font-size: 1.25rem; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm); }
.stepper button:hover { background: var(--surface-2); }
.stepper input { width: 40px; height: 44px; padding: 0; border: 0; background: none; text-align: center; font-weight: 700; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { appearance: none; }
.cart-empty { display: grid; place-items: center; text-align: center; padding: 32px 16px; color: var(--muted); height: 100%; }
.cart-empty strong { color: var(--ink); display: block; }
.empty-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; background: var(--surface-2); color: var(--muted); }
.empty-icon .icon { width: 24px; height: 24px; }
.cart-foot { border-top: 1px solid var(--line); padding: 14px 16px 16px; display: grid; gap: 10px; background: var(--surface-2); border-radius: 0 0 14px 14px; }
.sum-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.sum-row.muted { font-size: 0.9375rem; }
.sum-total strong { font-size: 1.875rem; font-weight: 800; letter-spacing: -0.02em; }
.cart-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cart-actions .btn { padding: 8px 6px; }

.cart-bar { display: none; }
@media (min-width: 900px) { .cart-backdrop { display: none !important; } }
@media (max-width: 899px) {
  .sell .cart { display: none; }
  /* A sheet that rises from the bottom and is only as tall as it needs to
     be, so the items stay in view behind it. */
  .sell .cart.is-open {
    display: flex; position: fixed; inset: auto 0 0 0; z-index: 40; max-height: 82dvh;
    border-radius: 16px 16px 0 0; border-width: 1px 0 0; box-shadow: var(--shadow);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .sell .cart.is-open .cart-lines { min-height: 0; }
  .sell .cart.is-open .cart-foot { border-radius: 0; }
  .cart-backdrop { position: fixed; inset: 0; z-index: 39; background: rgb(10 14 26 / 0.55); }
  .cart-bar {
    display: flex; position: fixed; left: 12px; right: 12px; bottom: calc(68px + env(safe-area-inset-bottom)); z-index: 25;
    align-items: center; justify-content: space-between; gap: 12px;
    min-height: 56px; padding: 8px 18px; border: 0; border-radius: var(--radius);
    background: var(--primary); color: var(--primary-ink); font-weight: 700; font-size: 1.0625rem;
    box-shadow: var(--shadow); cursor: pointer;
  }
  .sell-items { padding-bottom: 72px; }
  .cart-close { display: flex !important; }
}
.cart-close { display: none; align-items: center; gap: 8px; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--line); }
.cart-close h2 { margin-right: auto; }
@media (min-width: 900px) {
  .sell { grid-template-columns: 1fr 360px; align-items: start; }
  .sell .cart { position: sticky; top: 28px; height: calc(100dvh - 56px); }
}

.change { text-align: center; font-size: 1.5rem; font-weight: 800; color: var(--good); margin: 8px 0 0; }
.done { text-align: center; display: grid; gap: 8px; justify-items: center; }
.done .tick { width: 56px; height: 56px; border-radius: 50%; background: var(--good-soft); color: var(--good); display: grid; place-items: center; }
.done .tick .icon { width: 30px; height: 30px; stroke-width: 2.5; }
.parked-list { display: grid; gap: 8px; }
.parked-row { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.parked-row .info { margin-right: auto; min-width: 0; }

/* Charts (drawn by the server, values always in text) --------------------- */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 180px; padding-top: 8px; background: repeating-linear-gradient(to top, transparent 0 39px, var(--line) 39px 40px) 0 -21px / 100% 100% no-repeat; }
.bars .bar-col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.bars .bar { width: 100%; max-width: 48px; background: linear-gradient(to top, color-mix(in srgb, var(--primary) 62%, transparent), var(--primary)); border-radius: 6px 6px 0 0; min-height: 2px; }
.bars .bar.is-zero { background: var(--line); }
.bars .bar-label { font-size: 0.6875rem; color: var(--muted); white-space: nowrap; height: 1rem; }
.hbar { display: grid; gap: 4px; margin-bottom: 12px; }
.hbar:last-child { margin-bottom: 0; }
.hbar .top { display: flex; justify-content: space-between; gap: 12px; }
.hbar .top .value { font-weight: 700; white-space: nowrap; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.hbar .fill { height: 100%; background: linear-gradient(to right, color-mix(in srgb, var(--primary) 65%, transparent), var(--primary)); border-radius: 4px; min-width: 2px; }

/* Receipt ---------------------------------------------------------------- */
.receipt { font-size: 0.9375rem; }
.receipt .center { text-align: center; }
.receipt .shop-name { font-weight: 800; font-size: 1.125rem; }
.receipt hr { border: 0; border-top: 1px dashed var(--muted); margin: 10px 0; }
.receipt .r-row { display: flex; justify-content: space-between; gap: 12px; }
.receipt .r-total { font-weight: 800; font-size: 1.125rem; }

.settings-list { display: grid; gap: 12px; }
@media (min-width: 700px) { .settings-list { grid-template-columns: 1fr 1fr; } }
.settings-link { display: flex; align-items: center; gap: 12px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: inherit; text-decoration: none; }
.settings-link { box-shadow: var(--elev); transition: border-color 0.12s, box-shadow 0.12s; }
.settings-link:hover { border-color: var(--primary); box-shadow: 0 6px 18px var(--glow); }
.settings-link .text { margin-right: auto; display: grid; }
.settings-link .text span { color: var(--muted); font-size: 0.875rem; }
.narrow { max-width: 640px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; text-decoration: none; font-weight: 600; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row .info { margin-right: auto; min-width: 0; display: grid; }

@media print {
  body { background: #fff; color: #000; }
  .shell { display: block; }
  .sidebar, .topbar, .bottomnav, .toasts, .no-print { display: none !important; }
  .main { padding: 0; }
  .print-receipt { width: 72mm; margin: 0 auto; font-size: 12px; }
  @page { margin: 4mm; }
}
