:root {
  --bg: #f2f4ef;
  --panel: #fffefa;
  --ink: #1d2924;
  --muted: #6b7770;
  --line: #dce2d8;
  --accent: #2f6b52;
  --accent-strong: #22503d;
  --accent-soft: #e0efe6;
  --danger: #a33b32;
  --danger-soft: #f7e2df;
  --warn: #8a5a14;
  --warn-soft: #f7ead0;
  --shadow: 0 1px 2px rgba(29, 41, 36, 0.06), 0 10px 28px rgba(29, 41, 36, 0.05);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { background: var(--bg); max-width: 100%; }
body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(1100px 550px at 8% -10%, #fbf8ef 0, transparent 55%),
    radial-gradient(900px 480px at 112% 0%, #e6efe8 0, transparent 50%),
    var(--bg);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(25px, 3.5vw, 38px); letter-spacing: -0.04em; line-height: 1.08; }
h2 { font-size: 17px; letter-spacing: -0.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 11px;
  font-weight: 750;
  color: var(--accent);
}

/* Login */
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: clamp(26px, 5vw, 44px);
}
.login-card h1 { margin: 8px 0 10px; }
.login-card form { display: grid; gap: 10px; }
.login-card label { font-weight: 650; font-size: 13px; }

/* Shell */
#app-view { width: 100%; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(242, 244, 239, 0.9);
  border-bottom: 1px solid rgba(220, 226, 216, 0.85);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: max-content; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px;
  border-radius: 11px; background: var(--ink); color: #fffefa;
  font-weight: 800; letter-spacing: -0.04em;
}
.brand strong { display: block; line-height: 1.1; }
.tabs { display: flex; align-items: center; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  border: 0; background: transparent; color: var(--muted);
  padding: 8px 12px; border-radius: 999px; white-space: nowrap;
  font-weight: 650; font-size: 13.5px;
}
.tab:hover { background: rgba(255, 254, 250, 0.85); color: var(--ink); }
.tab.active { background: var(--ink); color: #fffefa; }
.tab:disabled { opacity: 0.38; cursor: not-allowed; }
.tab:disabled:hover { background: transparent; color: var(--muted); }

.page { width: min(1320px, 100%); margin: 0 auto; padding: clamp(16px, 3.5vw, 32px); min-width: 0; }
.view { display: grid; gap: 16px; min-width: 0; animation: rise 160ms ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.panel {
  min-width: 0; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.panel-head h2 { margin-bottom: 2px; }

/* Buttons and fields */
button.primary, button.quiet, .chip, .tab, .link, button.danger {
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
button.primary {
  border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 9px; padding: 9px 14px; font-weight: 700; white-space: nowrap;
}
button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.primary:disabled { opacity: 0.45; cursor: not-allowed; }
button.quiet {
  border: 1px solid #cbd3c9; background: transparent; color: var(--ink);
  border-radius: 9px; padding: 8px 12px; font-weight: 600; white-space: nowrap;
}
button.quiet:hover { background: #f2f5ee; }
button.quiet.danger, button.danger { color: var(--danger); border-color: #e0b9b4; }
button.quiet.danger:hover, button.danger:hover { background: var(--danger-soft); }
button.small { padding: 5px 9px; font-size: 12px; }
button.link { border: 0; background: none; color: var(--accent); font-weight: 700; padding: 2px; font-size: 12px; }
button.link.danger { color: var(--danger); }
input, select, textarea {
  width: 100%; min-width: 0; max-width: 100%;
  border: 1px solid #cbd3c9; background: #fffefa; border-radius: 9px;
  padding: 9px 10px; color: var(--ink); min-height: 40px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid rgba(47, 107, 82, 0.22); outline-offset: 1px; border-color: var(--accent);
}
input[type="checkbox"] { width: 16px; height: 16px; min-height: 0; accent-color: var(--accent); }
.check-label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-bottom: 12px; }
.inline-form label, .range-fields label { display: grid; gap: 4px; font-size: 12.5px; font-weight: 650; color: var(--muted); flex: 1 1 150px; }
.inline-form button { flex: none; }
.inline-select { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 650; }
.inline-select select { width: auto; min-height: 32px; padding: 4px 8px; }

/* Lists layout */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; min-width: 0; }
.lists-panel { padding: 16px; position: sticky; top: 80px; }
.lists-body { display: grid; gap: 5px; min-width: 0; }
.list-row {
  display: flex; align-items: center; gap: 2px; width: 100%; min-width: 0;
  padding: 0; border: 1px solid transparent; border-radius: 10px;
  background: transparent; text-align: left;
}
.list-row:hover { background: #f3f6ef; }
.list-row.active { background: var(--accent-soft); border-color: #c8ddce; }
.list-open {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  padding: 10px 4px 10px 11px; border: 0; background: transparent;
  color: inherit; text-align: left; border-radius: 10px 0 0 10px;
}
.list-delete {
  flex: none; display: grid; place-items: center; width: 34px; height: 34px;
  margin-right: 5px; padding: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--muted);
}
.list-delete svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.list-delete:hover, .list-delete:focus-visible { color: var(--danger); background: var(--danger-soft); }
.list-row .list-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.list-row .list-count {
  flex: none; font-size: 12px; font-weight: 700; color: var(--muted);
  background: #eef2ea; border-radius: 999px; padding: 3px 8px; font-variant-numeric: tabular-nums;
}
.list-row.done .list-count { color: var(--accent-strong); background: var(--accent-soft); }
.list-row .list-meta { display: block; font-size: 11.5px; color: var(--muted); font-weight: 400; margin-top: 1px; }

.list-pane { position: relative; padding: clamp(16px, 3vw, 26px); min-height: 300px; }
.list-pane.list-zoom-in { animation: list-zoom-in 420ms cubic-bezier(.2, .8, .2, 1); transform-origin: center top; }
.list-pane.list-zoom-out { animation: list-zoom-out 200ms cubic-bezier(.4, 0, .8, 1) forwards; transform-origin: center top; pointer-events: none; }
.lists-panel.list-select-in { animation: list-select-in 260ms cubic-bezier(.2, .8, .2, 1); transform-origin: center top; }
@keyframes list-zoom-in {
  from { opacity: 0; transform: scale(.94); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes list-zoom-out {
  from { opacity: 1; transform: scale(1); }
  to { opacity: 0; transform: scale(.94); }
}
@keyframes list-select-in {
  from { opacity: .7; transform: scale(1.04); }
  to { opacity: 1; transform: scale(1); }
}
.no-list { display: grid; place-items: center; min-height: 240px; }
.list-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; padding-right: 0; }
.list-title-wrap { flex: 1; min-width: 0; }
.list-head > * { min-width: 0; }
.list-actions { min-width: 0; }
.list-title-wrap h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-presence { margin-top: 2px; font-size: 12px; color: var(--accent-strong); }
.list-total-wrap { flex: none; text-align: right; margin-left: auto; padding: 2px 0 0; border: 0; background: transparent; color: inherit; font: inherit; cursor: pointer; }
.list-total-label { display: block; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
#list-total { color: var(--accent-strong); font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
body.list-simple .topbar,
body.list-simple #list-summary,
body.list-simple .item .item-meta { display: none !important; }
body.list-simple .back-mobile { display: inline-grid; }
body.list-simple .lists-panel { visibility: hidden; pointer-events: none; }
body.list-simple .list-head { margin-bottom: 10px; }
body.list-simple .page { padding-top: max(12px, env(safe-area-inset-top)); }
.back { display: inline-grid; place-items: center; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid #cbd3c9; background: var(--panel); border-radius: 9px; color: var(--ink); }
.back svg { display: block; width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.back:hover { border-color: var(--accent); color: var(--accent); }
.back-mobile { display: none; }
button.icon-action { width: 38px; height: 38px; padding: 0; display: inline-grid; place-items: center; }
.icon-action svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-action .symbol { font-size: 23px; font-weight: 600; line-height: 1; }
#delete-items-button[aria-pressed="true"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.conflict-banner {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 10px;
  background: var(--warn-soft); border: 1px solid #e6cfa2; color: var(--warn); font-size: 13px;
}

/* Items */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.items { padding: 4px 0; }
.item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 13px; border-bottom: 1px solid #edf0e9; min-width: 0;
}
.item:last-child { border-bottom: 0; }
.item .select-box {
  flex: none; width: 27px; height: 27px; border-radius: 8px;
  border: 2px solid #c8d0c6; background: var(--panel); color: transparent;
  display: grid; place-items: center; font-size: 13px; font-weight: 800; padding: 0;
}
.item .select-box.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.item .item-main { flex: 1; min-width: 0; cursor: pointer; border-radius: 8px; outline-offset: 4px; }
.item .item-meta { min-width: 0; overflow-wrap: anywhere; }
.item .item-name-row { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.item .item-name { font-weight: 650; overflow-wrap: anywhere; }
.item.checked .item-name { color: var(--muted); text-decoration: line-through; }
.item.checked.needs-price .item-name { color: var(--danger); }
.item .item-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.item .item-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.item .item-meta .price { color: var(--accent-strong); font-weight: 650; }
.item .item-meta .estimated { color: var(--warn); }
.item.delete-mode { background: #fffaf9; }
.item.delete-mode .item-main { cursor: default; }
.item .item-delete { flex: none; padding: 5px 7px; border-radius: 8px; }
.item .item-delete svg { display: block; width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.item .item-delete:hover { background: var(--danger-soft); }
.done-section { margin-top: 16px; }
.done-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.done-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.mini-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.form-panel { padding: clamp(16px, 3vw, 26px); }
.type-search { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; min-width: 0; }
.type-search input { flex: 1; min-width: 0; font-size: 16px; }
.type-search button { flex: none; }
#type-search-add {
  width: 48px; min-width: 48px; padding: 0;
  font-size: 26px; line-height: 1;
}
#logout-button {
  min-width: 44px; padding: 6px 9px;
  font-size: 22px; line-height: 1;
}
.type-results { margin-top: 4px; }
.table-panel { padding: clamp(16px, 3vw, 24px); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid #edf0e9; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--accent-soft); color: var(--accent-strong); }
.badge.archived { background: var(--warn-soft); color: var(--warn); }
.empty { padding: 30px 14px; color: var(--muted); text-align: center; }

/* Range and KPIs */
.rangebar {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px;
  padding: 13px; background: rgba(255, 254, 250, 0.75); border: 1px solid var(--line); border-radius: var(--radius);
}
.range-fields, .presets { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; min-width: 0; }
.range-fields input { width: 150px; }
.chip {
  border: 1px solid #cbd3c9; background: #fffefa; color: var(--ink);
  border-radius: 999px; padding: 7px 11px; font-size: 12.5px; font-weight: 650;
}
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.active:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
/* Search overlay */
.search-overlay, .scan-overlay, .modal-overlay {
  position: fixed; inset: 0; z-index: 40; background: rgba(29, 41, 36, 0.42);
  display: grid; place-items: stretch; padding: 0;
}
.search-overlay, .scan-overlay {
  top: var(--visual-viewport-top, 0px);
  bottom: auto;
  height: var(--visual-viewport-height, 100dvh);
}
.search-shell {
  background: var(--bg); min-height: 100%; height: 100%; padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; overflow: auto;
}
.search-head { display: flex; align-items: center; gap: 9px; }
.search-head input { flex: 1; font-size: 18px; min-height: 48px; }
.search-head button { flex: none; }
.search-context { padding-left: 4px; }
.search-results { display: grid; gap: 6px; align-content: start; }
.search-result {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 11px;
  text-align: left; width: 100%;
}
.search-result:hover { border-color: var(--accent); background: #f7faf5; }
.search-result .result-main { min-width: 0; overflow-wrap: anywhere; }
.search-result .result-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-result .result-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.search-result .result-price { flex: none; color: var(--accent-strong); font-weight: 700; font-variant-numeric: tabular-nums; }
.search-result.create { border-style: dashed; color: var(--accent); font-weight: 650; }
.search-result-row { display: flex; align-items: stretch; gap: 6px; }
.search-result-row .search-result { flex: 1; min-width: 0; }
.search-result-edit {
  flex: none; width: 44px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 11px;
  background: var(--panel); color: var(--muted);
}
.search-result-edit:hover { border-color: var(--accent); color: var(--accent); background: #f7faf5; }
.search-result-edit svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.search-notice { margin-top: auto; padding: 10px 12px; border-radius: 10px; font-size: 13px; min-height: 0; }
.search-notice.ok { background: var(--accent-soft); color: var(--accent-strong); }
.search-notice.err { background: var(--danger-soft); color: var(--danger); }
.search-notice:empty { display: none; }

/* Modal */
.modal-overlay {
  place-items: center; padding: 20px; z-index: 50;
  top: var(--visual-viewport-top, 0px);
  bottom: auto;
  height: var(--visual-viewport-height, 100dvh);
}
.modal {
  width: min(560px, 100%);
  max-height: min(calc(var(--visual-viewport-height, 100dvh) - 48px), 760px);
  overflow: auto; padding: 20px;
}
.modal h2 { margin-bottom: 4px; }
.modal .modal-sub { margin-bottom: 14px; }
.modal form { display: grid; gap: 12px; }
.modal label, .modal .form-field { display: grid; gap: 4px; font-size: 12.5px; font-weight: 650; color: var(--muted); }
.modal .form-field label { font: inherit; color: inherit; }
.modal .form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.autocomplete { display: grid; gap: 4px; }
.autocomplete-suggestions {
  display: grid; gap: 2px; padding: 4px;
  border: 1px solid var(--line); border-radius: 9px; background: #fffefa;
  max-height: 178px; overflow-y: auto;
}
.autocomplete-suggestion {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  width: 100%; border: 0; border-radius: 6px; background: transparent;
  padding: 7px 8px; text-align: left; color: var(--ink);
}
.autocomplete-suggestion:hover, .autocomplete-suggestion.active { background: var(--accent-soft); }
.autocomplete-suggestion.is-matched { color: var(--muted); }
.autocomplete-section {
  margin-top: 3px; padding: 5px 8px 2px;
  color: var(--muted); font-size: 9.5px; font-weight: 750;
  letter-spacing: 0.06em; text-transform: uppercase;
}
.autocomplete-suggestion-value { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.autocomplete-suggestion-meta { overflow: hidden; color: var(--muted); font-size: 11px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.item-details { display: grid; gap: 2px; }
.modal-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.confirm-form h2 { color: var(--danger); }
.confirm-form .modal-sub { margin-bottom: 2px; }
.confirm-form .confirm-details { display: grid; gap: 4px; margin: 10px 0 14px; padding-left: 18px; color: var(--muted); font-size: 0.9rem; }
button.primary.danger-solid { background: var(--danger); border-color: var(--danger); }
button.primary.danger-solid:hover { background: #8c2f28; border-color: #8c2f28; }
/* Scan */
.scan-overlay { padding: 0; }
.scan-shell {
  background: var(--bg); min-height: 100%; height: 100%; padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  overflow: auto;
}
.scan-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.scan-head h1 { font-size: clamp(24px, 4vw, 34px); }
.scan-controls { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.scan-progress {
  margin: 12px 0 4px; padding: 15px 16px;
  border: 1px solid #c8ddce; border-radius: 14px;
  background: linear-gradient(115deg, #f7fbf7 0%, #eef6ef 55%, #f8fbf7 100%);
  overflow: hidden;
}
.scan-progress-copy { min-width: 0; }
.scan-progress-title-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.scan-progress-title-row strong { font-size: 14px; }
.scan-progress-elapsed { flex: none; color: var(--accent-strong); font-size: 12px; font-weight: 750; font-variant-numeric: tabular-nums; }
.scan-progress-copy p { margin: 3px 0 9px; }
.scan-progress-tracks { display: grid; gap: 5px; }
.scan-progress-track {
  display: grid; grid-template-columns: repeat(20, minmax(0, 1fr)); gap: 3px;
  height: 6px;
}
.scan-progress-track span {
  display: block; height: 100%; border-radius: 2px; background: #dce8dd;
  transition: background-color 120ms ease;
}
.scan-progress-track span.filled { background: var(--accent); }
@media (prefers-reduced-motion: reduce) {
  .scan-progress-track span { transition: none; }
}
.file-label { display: grid; gap: 5px; font-size: 12.5px; font-weight: 650; color: var(--muted); min-width: min(100%, 330px); }
.file-label input { padding: 10px; background: #f7f9f4; }
.scan-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 14px 0 8px; }
.scan-checksum { margin: 0 0 9px; font-size: 12.5px; color: var(--muted); }
.scan-checksum.ok { color: var(--accent-strong); }
.scan-checksum.warn { color: var(--warn); }
.scan-checksum:empty { display: none; }
#scan-draft-wrap { padding-bottom: calc(116px + env(safe-area-inset-bottom)); }
.scan-actions {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin: 0;
  padding: 10px max(18px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  background: var(--bg); border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(29, 41, 36, 0.08);
}
.scan-action-status { flex: 1 1 100%; order: -1; margin: 0; color: var(--warn); font-size: 12.5px; }
.scan-actions button { padding-left: 9px; padding-right: 9px; }
.scan-list { display: grid; gap: 6px; }
.scan-row {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: inherit; text-align: left; cursor: pointer;
  font: inherit;
}
.scan-row:hover { border-color: var(--accent); }
.scan-row:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scan-row-text { display: grid; gap: 2px; min-width: 0; flex: 1; }
.scan-row-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-row-meta { color: var(--muted); font-size: 12px; }
.scan-row-meta.missing { color: var(--danger); }
.scan-row-total { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.scan-row-chevron { color: var(--muted); font-size: 19px; line-height: 1; }
.scan-modal-state { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.scan-modal-total { margin: 0; }
.scan-modal-status { margin: 0; color: var(--warn); font-size: 12.5px; }
.scan-modal-status:empty { display: none; }
.scan-approve { display: flex; align-items: center; gap: 7px; margin-top: 0; font-size: 12.5px; }
.scan-approve[hidden] { display: none; }
.scan-modal-actions .danger { margin-right: auto; }
.badge.new { background: var(--warn-soft); color: var(--warn); }
.badge.on { background: var(--accent-soft); color: var(--accent-strong); }
.badge.known { background: #eeeae1; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  background: var(--ink); color: #fffefa; border-radius: 10px; padding: 10px 16px;
  box-shadow: var(--shadow); z-index: 60; max-width: min(90vw, 620px); font-size: 13px;
}
.error { color: var(--danger); font-size: 13px; min-height: 1.2em; }

@media (prefers-reduced-motion: reduce) {
  .list-pane.list-zoom-in,
  .list-pane.list-zoom-out,
  .lists-panel.list-select-in { animation: none; }
}

/* Responsive */
@media (max-width: 980px) {
  .charts { grid-template-columns: 1fr; }
  .layout { grid-template-columns: 230px minmax(0, 1fr); }
  .list-actions { max-width: 260px; }
}

@media (max-width: 720px) {
  .login-shell { min-height: var(--visual-viewport-height, 100dvh); padding: max(18px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); }
  .login-card { border-radius: 18px; }
  .topbar {
    gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 10px;
    backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--bg);
  }
  .brand-mark { width: 32px; height: 32px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    gap: 2px; padding: 5px 5px calc(5px + env(safe-area-inset-bottom));
    background: var(--panel); border-top: 1px solid var(--line);
    box-shadow: 0 -6px 20px rgba(29, 41, 36, 0.06);
  }
  .tab { flex: 1 1 0; min-height: 50px; padding: 6px 2px; border-radius: 10px; font-size: 11.5px; display: grid; place-items: center; }
  .tab.active { background: var(--accent); color: #fff; }
  .page { padding: 12px 12px calc(86px + env(safe-area-inset-bottom)); }
  body.list-simple .page { padding-bottom: max(18px, env(safe-area-inset-bottom)); }
  .view { gap: 12px; }
  .layout { display: block; }
  .lists-panel { position: static; }
  .list-pane { display: none; }
  body.list-detail-open .lists-panel { display: none; }
  body.list-detail-open .list-pane { display: block; }
  .back-mobile { display: inline-grid; }
  .list-head { flex-wrap: wrap; padding-right: 0; }
  .list-title-wrap { padding-right: 38px; }
  .list-actions { width: 100%; justify-content: flex-start; max-width: none; }
  .list-actions #delete-items-button { margin-left: auto; }
  .item { padding: 9px 10px; }
  .inline-form { display: grid; grid-template-columns: 1fr 1fr; align-items: end; }
  .inline-form label { min-width: 0; }
  .inline-form label:first-child { grid-column: 1 / -1; }
  .inline-form button { grid-column: 1 / -1; width: 100%; }
  input, select, textarea { font-size: 16px; }
  button.primary, button.quiet { min-height: 42px; }
  .back, button.icon-action { width: 42px; height: 42px; min-height: 42px; }
  .modal { padding: 16px; }
  .modal .form-row { grid-template-columns: 1fr; }
  .toast { bottom: calc(74px + env(safe-area-inset-bottom)); width: calc(100% - 24px); text-align: center; }
  .scan-progress { padding: 12px; }
  .scan-row { padding: 10px; gap: 8px; }
  .scan-row-name { white-space: normal; }
  .scan-row-total { font-size: 13px; }
}

.scan-adjustments {
  margin-top: 14px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
.scan-adjust-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.scan-adjustment-list { display: grid; gap: 6px; margin-top: 8px; }
.scan-adjustment-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 132px 88px auto;
  align-items: center;
  gap: 6px;
}
.scan-adjustment-row input,
.scan-adjustment-row select { min-height: 36px; padding: 7px 9px; }
.scan-adjustment-row input[aria-invalid="true"] { border-color: var(--danger); }
.scan-adjustment-empty { margin: 0; }
@media (max-width: 720px) {
  .scan-adjustment-row { grid-template-columns: minmax(0, 1fr) 88px; }
  .scan-adjustment-row select { grid-column: 1 / -1; }
  .scan-adjustment-row input:nth-of-type(2) { grid-column: 2; }
  .scan-adjustment-row button { grid-column: 1 / -1; justify-self: start; }
}

.scan-toolbar-tools { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; }
.scan-select-label { display: grid; gap: 3px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.scan-select-label select { min-height: 34px; padding: 5px 8px; font-size: 12.5px; text-transform: none; letter-spacing: normal; }
.scan-row-discount { color: var(--danger); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.scan-filter-empty { margin: 10px 0; }

.type-expand, .type-expand-spacer {
  flex: none; width: 28px; min-height: 38px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  color: var(--muted); font-size: 16px; line-height: 1; padding: 0;
}
.type-expand:hover { border-color: var(--accent); color: var(--accent); background: #f7faf5; }
.type-expand-spacer { border-color: transparent; background: transparent; }
.type-indent { flex: none; width: 0; }
.item-price { flex: none; color: var(--accent-strong); font-size: 11.5px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.checked .item-price { color: var(--muted); }

.prices-hidden .item-price, .prices-hidden .list-total-label { display: none; }
.scan-group-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 12px 2px 2px; padding-top: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 11px; font-weight: 750;
  letter-spacing: 0.05em; text-transform: uppercase;
}
.scan-group-head:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.scan-group-count { font-variant-numeric: tabular-nums; }
.scan-row.in { box-shadow: inset 3px 0 var(--accent); }
.scan-row.not { box-shadow: inset 3px 0 var(--warn); }

/* A tapped Hide button should not leave a harsh focus rectangle in the
   compact done header. Keyboard focus still gets a clear, softer cue. */
#toggle-done:focus-visible {
  outline: none;
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}
