/* GroDino: neutral surfaces, one accent, thin lines. Color carries meaning (good / warning / data), not decoration. */

:root {
  /* Each token is light-dark(light theme, dark theme). `color-scheme` picks one: the system setting
     by default, or the header's theme toggle (data-theme on <html>, see theme.js). */
  color-scheme: light dark;
  --bg: light-dark(#f7f7f8, #0c0c0e);
  --card: light-dark(#ffffff, #141417);
  --text: light-dark(#18181b, #ededef);
  --muted: light-dark(#71717a, #9b9ba4);
  --faint: light-dark(#a1a1aa, #6b6b74);
  --border: light-dark(#e4e4e7, #26262b);
  --subtle: light-dark(#f4f4f5, #1b1b1f);
  --hover: light-dark(#f4f4f5, #1d1d22);
  --accent: light-dark(#4f46e5, #818cf8);
  --accent-soft: light-dark(#eef2ff, #1e1b3a);
  --on-accent: light-dark(#ffffff, #0c0c0e);
  --good: light-dark(#047857, #34d399);
  --good-soft: light-dark(#ecfdf5, #0b2a20);
  --warn: light-dark(#b45309, #fbbf24);
  --warn-soft: light-dark(#fef6e7, #2a2108);
  --bad: light-dark(#dc2626, #f87171);
  --bad-soft: light-dark(#fef2f2, #2a1215);
  --low: light-dark(#fef3c7, #3b2f0b);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px light-dark(rgb(24 24 27 / 4%), transparent);
  --shadow-pop: 0 12px 32px light-dark(rgb(24 24 27 / 14%), rgb(0 0 0 / 50%)), 0 2px 6px light-dark(rgb(24 24 27 / 6%), transparent);
  --chart-bar: light-dark(#4f46e5, #6366f1); /* each validated against its theme's card surface */
  /* Donut slices (supermarkets, categories): the reference categorical palette's first five slots, validated in both themes
     (adjacent pairs, including the donut's wraparound). "Other" is neutral gray. */
  --slice-1: light-dark(#2a78d6, #3987e5);
  --slice-2: light-dark(#eb6834, #d95926); /* orange: reserved for Meat */
  --slice-3: light-dark(#1baf7a, #199e70);
  --slice-4: light-dark(#eda100, #c98500);
  --slice-5: light-dark(#e87ba4, #d55181);
  --slice-other: light-dark(#a1a1aa, #6b6b74);
  --content: 1120px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* also over .field, .progress etc., which set display */
body { margin: 0; min-height: 100vh; }
h1, h2, h3 { font-weight: 600; letter-spacing: -.015em; }
a { color: var(--accent); text-underline-offset: 3px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--content); margin: 0 auto; height: 60px;
  padding: 0 clamp(16px, 4vw, 32px);
  display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; }
.logo { width: 24px; height: 24px; color: var(--accent); }
.wordmark { font-weight: 650; font-size: 1.05rem; letter-spacing: -.02em; }

.theme-toggle {
  display: grid; place-items: center; flex: none; margin-left: auto; /* pushes it and the account to the right */
  width: 34px; height: 34px; padding: 0; border-color: transparent; border-radius: 10px;
  background: transparent; color: var(--muted);
}
.theme-toggle:hover:not(:disabled) { color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; }
/* Show the theme a click switches to: a moon in light mode, a sun in dark mode. */
.theme-toggle .sun { display: none; }
.theme-toggle[data-current="dark"] .sun { display: block; }
.theme-toggle[data-current="dark"] .moon { display: none; }

.main-nav { display: flex; gap: 4px; height: 100%; }
.nav-item {
  display: flex; align-items: center; padding: 0 10px;
  color: var(--muted); text-decoration: none; font-size: .92rem; font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.nav-item:hover { color: var(--text); }
.nav-item[aria-current="page"] { color: var(--text); border-bottom-color: var(--text); }
.nav-item:focus-visible { outline-offset: -4px; border-radius: 6px; }

/* ---------- Layout ---------- */
main {
  max-width: var(--content); margin: 0 auto;
  padding: 32px clamp(16px, 4vw, 32px) 64px;
}
.page { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; } /* never wider than the screen */
.intro { display: grid; gap: 4px; margin-bottom: 4px; }
.page-title { margin: 0; font-size: 1.6rem; letter-spacing: -.025em; }
.intro p { margin: 0; max-width: 62ch; }
.section-title { margin: 0 0 14px; font-size: .95rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ---------- Controls ---------- */
button, select, input {
  font: inherit; font-size: .92rem; color: inherit;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  padding: 8px 14px; background: var(--card);
}
input, select { transition: border-color .15s, box-shadow .15s; }
input:hover, select:hover { border-color: var(--faint); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--faint); }
button { cursor: pointer; font-weight: 500; transition: background .15s, border-color .15s, color .15s, opacity .15s; }
button:hover:not(:disabled) { background: var(--hover); }
button.primary { background: var(--text); border-color: var(--text); color: var(--bg); padding: 8px 18px; }
button.primary:hover:not(:disabled) { background: var(--text); opacity: .86; }
button.ghost { background: transparent; }
button.small { padding: 5px 11px; font-size: .84rem; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.link { border: 0; padding: 0; background: none; color: var(--accent); font-weight: 500; }
button.link:hover:not(:disabled) { background: none; text-decoration: underline; }

.field { display: grid; gap: 6px; font-size: .8rem; font-weight: 500; color: var(--muted); }
.controls { display: flex; gap: 12px; align-items: flex-end; margin-top: 20px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content;
  padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 500; white-space: nowrap;
  background: var(--subtle); color: var(--muted);
}
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { color: var(--bad); }
.chip.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Upload ---------- */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 168px; padding: 24px;
  border: 1.5px dashed var(--border); border-radius: var(--radius-sm);
  background: var(--subtle);
  cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { font-weight: 600; }
.dropzone .muted { font-size: .88rem; }
.drop-icon {
  display: grid; place-items: center;
  width: 40px; height: 40px; margin-bottom: 10px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.drop-icon svg { width: 20px; height: 20px; }

.capture-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.capture-row .muted { font-size: .85rem; }
.capture-row button { display: inline-flex; align-items: center; gap: 8px; }
.capture-row svg { width: 18px; height: 18px; }

.thumbs {
  list-style: none; margin: 20px 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px;
}
.thumb {
  position: relative; overflow: hidden;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--card);
}
.thumb img { display: block; width: 100%; height: 140px; object-fit: cover; object-position: top; background: var(--subtle); }
/* Receipts loaded from an account have no photo: photos are never uploaded. */
.no-photo {
  display: grid; place-items: center; text-align: center;
  background: var(--subtle); color: var(--faint); font-size: .72rem;
}
.thumb .no-photo { height: 140px; }
.thumb .meta { padding: 8px 10px; font-size: .78rem; display: grid; gap: 6px; }
.thumb .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thumb .remove {
  position: absolute; top: 6px; right: 6px;
  width: 24px; height: 24px; padding: 0; border-radius: 50%; border: 0;
  background: rgb(24 24 27 / 60%); color: #fff; font-size: 14px; line-height: 1;
  opacity: 0; transition: opacity .15s, background .15s;
}
.thumb:hover .remove, .thumb .remove:focus-visible { opacity: 1; }
@media (hover: none) { .thumb .remove { opacity: 1; } }
.thumb .remove:hover:not(:disabled) { background: var(--bad); }
.thumb .mini-bar { height: 3px; background: var(--subtle); border-radius: 2px; overflow: hidden; }
.thumb .mini-bar > div { height: 100%; background: var(--accent); transition: width .2s; }

.progress { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.progress .bar { flex: 1; height: 4px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.progress #bar { height: 100%; width: 0; background: var(--accent); transition: width .25s; }
.progress span { color: var(--muted); font-size: .85rem; min-width: min(240px, 40%); }

/* ---------- Results ---------- */
#results { padding-top: 6px; }
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 18px;
  overflow-x: auto; scrollbar-width: none; /* many receipts scroll sideways rather than wrap */
}
.tabs::-webkit-scrollbar { display: none; }
.tab { white-space: nowrap; flex: none; }
.tab {
  border: 0; border-radius: 0; background: transparent;
  padding: 12px 10px 11px; margin-bottom: -1px;
  color: var(--muted); border-bottom: 2px solid transparent;
}
.tab:hover:not(:disabled) { background: transparent; color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }
/* A receipt's views: a small segmented control. */
.subtabs {
  width: fit-content; gap: 2px; padding: 3px; margin: 0;
  border: 0; border-radius: var(--radius-sm); background: var(--subtle);
}
.subtabs .tab { padding: 5px 12px; margin: 0; border: 0; border-radius: 7px; font-size: .86rem; }
.subtabs .tab.active { background: var(--card); box-shadow: 0 1px 2px rgb(24 24 27 / 8%); }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-note { font-size: .88rem; max-width: 72ch; flex: 1 1 300px; min-width: 0; } /* the buttons keep one row */
/* On a receipt's tab the note holds the receipt's header (photo, supermarket, date) instead. */
.toolbar > .spacer { display: none; } /* the note grows to push the buttons right */
.toolbar:has(.receipt-head) { align-items: flex-end; }
.toolbar-note:has(.receipt-head) { max-width: none; color: var(--text); font-size: inherit; }
.toolbar:has(.receipt-head) > button { margin-bottom: 1px; }
.scan-note { margin: 10px 0 0; font-size: .84rem; }
.toolbar button { font-size: .86rem; padding: 6px 12px; }

.view { overflow: auto; }
.view > * + * { margin-top: 24px; }
.view h2 { font-size: .95rem; margin: 0 0 12px; }

/* Stat tiles: the hero leads by size, not color. */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.stat {
  display: grid; gap: 4px; align-content: start;
  padding: 16px 18px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--border);
}
.view .stat { background: var(--subtle); border-color: transparent; }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.5rem; font-weight: 600; letter-spacing: -.025em; font-variant-numeric: tabular-nums; }
.stat.hero .value { font-size: 2.1rem; }
.stat .chip { margin-top: 4px; }
/* A receipt's tile on Summary is a button to its items. */
.stat-link {
  position: relative; font: inherit; color: inherit; text-align: left; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.view .stat-link:hover:not(:disabled) { background: var(--hover); border-color: var(--border); }
.stat-link > .label:first-child { padding-right: 22px; }
.stat-go {
  position: absolute; top: 14px; right: 16px;
  font-size: .95rem; color: var(--faint); transition: color .15s, transform .15s;
}
.stat-link:hover .stat-go, .stat-link:focus-visible .stat-go { color: var(--accent); transform: translateX(2px); }

.insights { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.insights li {
  position: relative; padding: 10px 14px 10px 32px; border-radius: var(--radius-sm);
  background: var(--subtle); font-size: .92rem;
}
.insights li::before {
  content: ""; position: absolute; left: 14px; top: 1.05em;
  width: 7px; height: 7px; border-radius: 50%; background: var(--good);
}
.insights li.even::before { background: var(--faint); }
.insights + .table-wrap, .insights + .donut-chart { margin-top: 14px; }

/* ---------- Tables ---------- */
.table-wrap { border: 1px solid var(--border); border-radius: 12px; overflow: auto; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 10px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--card); color: var(--muted);
  font-size: .76rem; font-weight: 500;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: var(--hover); }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 600; border-top: 1px solid var(--border); border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.best { color: var(--good); font-weight: 600; }
td[contenteditable] { border-radius: 6px; }
td[contenteditable]:hover { box-shadow: inset 0 0 0 1px var(--border); }
td[contenteditable]:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); background: var(--card); }
td.low { background: var(--low); }
td.idx { color: var(--faint); width: 1%; white-space: nowrap; }

pre {
  white-space: pre-wrap; margin: 0; font-size: .85rem; line-height: 1.6;
  background: var(--subtle); border-radius: 12px; padding: 16px;
}
.error { color: var(--bad); }
.empty { color: var(--muted); padding: 32px 16px; text-align: center; margin: 0; }

/* ---------- A receipt ---------- */
.receipt-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.receipt-head img, .receipt-head .no-photo {
  width: 52px; height: 68px; object-fit: cover; object-position: top;
  border-radius: 8px; border: 1px solid var(--border);
}
.receipt-head input { font-weight: 500; width: 190px; }
.receipt-head input[type="date"] { width: 160px; }
.receipt-head .chip { margin-bottom: 9px; }
.receipt-photo { display: block; line-height: 0; flex: none; }
.icon-button {
  display: grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0; border-radius: 10px;
  background: transparent; color: var(--muted);
}
.icon-button svg { width: 18px; height: 18px; }
.icon-button:hover:not(:disabled) { color: var(--text); }
.icon-button[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.receipt-head #scanDetails { margin-bottom: 1px; }
.scan-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 12px; background: var(--subtle);
}
.scan-bar strong { font-weight: 600; font-size: .9rem; }
.scan-bar .subtabs { background: var(--card); }
.scan-bar .subtabs .tab.active { background: var(--subtle); box-shadow: none; }
.scan-bar .link { font-size: .86rem; }

/* ---------- Categories (All items, a receipt's items, months) ---------- */
.category-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.category-bar button { border-color: transparent; color: var(--muted); }
.category-bar button:hover:not(:disabled) { color: var(--text); }
.legend { display: flex; gap: 6px 16px; flex-wrap: wrap; font-size: .78rem; color: var(--muted); flex: 1 1 0; min-width: 240px; }
.category-bar > .spacer { display: none; }
.category-bar button { white-space: nowrap; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

.categories { display: grid; gap: 8px; }
.category { border: 1px solid var(--border); border-radius: 12px; background: var(--card); overflow: hidden; }
.category > summary {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px;
  cursor: pointer; user-select: none; list-style: none;
  transition: background .15s;
}
.category > summary::-webkit-details-marker { display: none; }
.category > summary:hover { background: var(--hover); }
.category > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 12px; }
.category[open] > summary { border-bottom: 1px solid var(--border); }
.chevron { width: 16px; height: 16px; display: grid; place-items: center; flex: none; transition: transform .2s; }
.chevron::before {
  content: ""; width: 6px; height: 6px; margin-left: -2px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
}
.category[open] .chevron { transform: rotate(90deg); }
.cat-icon { font-size: 1.1rem; }
.cat-name { font-weight: 500; }
.cat-total { font-weight: 600; font-variant-numeric: tabular-nums; }
.category table th { position: static; }
/* Same column widths in every category, so the numbers line up from one table to the next. */
.category table { table-layout: fixed; }
.category th:first-child { width: 40%; }
.category th.actions { width: 48px; }
.category td:first-child, .category th:first-child { padding-left: 16px; }
/* A receipt's items: one plain table. */
/* Editing: hovering a row shows its cells as fields; a focused cell gets a clear ring. */
.edit-note { margin: 10px 0 -12px; font-size: .84rem; color: var(--warn); }
.edit-note:empty { display: none; }
.items-table td[contenteditable], .items-table .editable { cursor: text; }
.items-table tbody tr:hover td[contenteditable],
.items-table tbody tr:hover .editable { box-shadow: inset 0 0 0 1px var(--border); background: var(--card); }
@media (hover: none) {
  .items-table td[contenteditable], .items-table .editable { box-shadow: inset 0 0 0 1px var(--border); }
}
.items-table td[contenteditable]:focus,
.items-table .editable:focus { box-shadow: inset 0 0 0 2px var(--accent); background: var(--card); }
.items-table td[contenteditable]:empty::before { content: "—"; color: var(--faint); }
.items-table .editable:empty::before { content: "Item name"; color: var(--faint); }
.items-table tr.saved { animation: row-saved 1.2s ease-out; }
@keyframes row-saved { from { background: var(--good-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .items-table tr.saved { animation: none; } }
.items-table { table-layout: fixed; }
.items-table th:first-child { width: 46%; }
.items-table th.actions { width: 48px; }

.grand-total {
  display: flex; justify-content: space-between;
  padding: 14px 16px; border-top: 1px solid var(--border);
  font-weight: 600; font-variant-numeric: tabular-nums;
}
.view > .grand-total { margin-top: 8px; }

/* ---------- Diet markers ---------- */
.item-name { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.dot.veg { background: #16a34a; }
.dot.nonveg { background: #dc2626; }
.tags { display: inline-flex; gap: 3px; }
.tags:empty { display: none; }
.tag {
  position: relative; display: inline-grid; place-items: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--subtle); font-size: .7rem;
  cursor: help;
}
/* "free" tags (gluten-free, lactose-free, sugar-free) are crossed out. */
.tag.free::after {
  content: ""; position: absolute; width: 1.5px; height: 22px;
  background: #dc2626; transform: rotate(45deg); border-radius: 1px;
}
.item-name .editable { min-width: 4ch; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; }
.item-name .editable:hover { box-shadow: inset 0 0 0 1px var(--border); }
.item-name .editable:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent); background: var(--card); }

/* ---------- Editing a receipt's items ---------- */
td.actions { padding: 4px 8px; text-align: center; }
.row-remove {
  width: 26px; height: 26px; padding: 0; line-height: 1; border: 0;
  border-radius: 8px; background: transparent; color: var(--faint);
  opacity: 0;
}
tr:hover .row-remove, .row-remove:focus-visible { opacity: 1; }
@media (hover: none) { .row-remove { opacity: 1; } }
.row-remove:hover:not(:disabled) { color: var(--bad); background: var(--subtle); }
.add-item {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 16px; border-radius: 12px; background: var(--subtle);
}
.add-item input { width: 130px; background: var(--card); }
.add-item .field:first-child { flex: 1; min-width: 200px; }
.add-item .field:first-child input { width: 100%; }

/* ---------- Account ---------- */
.account { display: flex; gap: 8px; align-items: center; }
.account button { padding: 6px 14px; font-size: .88rem; white-space: nowrap; }
.account .who { display: grid; font-size: .84rem; line-height: 1.25; }
.account .who strong { font-weight: 500; }
.account .who .muted { font-size: .76rem; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none; object-fit: cover;
  display: grid; place-items: center; font-size: .8rem; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
.sync { font-size: .78rem; margin-right: 4px; }
@media (max-width: 720px) {
  .account .who, .sync { display: none; }
  .topbar-inner { gap: 14px; }
  .wordmark { display: none; }
}
@media (max-width: 480px) {
  .topbar-inner { gap: 8px; padding: 0 12px; }
  .theme-toggle { width: 30px; }
  .nav-item { padding: 0 6px; font-size: .88rem; }
  .account [data-open="signin"] { display: none; } /* the sign-up dialog links to "Sign in" */
  .account button { padding: 6px 12px; }
  main { padding-top: 24px; }
  .card { padding: 16px; }
  .page-title { font-size: 1.4rem; }
  .controls #extract { flex: 1; }
}

.auth-dialog {
  width: min(400px, calc(100vw - 32px)); padding: 32px;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow-pop);
}
.auth-dialog::backdrop { background: rgb(12 12 14 / 40%); backdrop-filter: blur(4px); }
.auth-dialog h2 { margin: 0 0 6px; font-size: 1.3rem; letter-spacing: -.02em; }
.auth-dialog > p { margin: 0 0 22px; font-size: .9rem; }
.auth-dialog .close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; font-size: 1.2rem; color: var(--muted);
}
.providers { display: grid; gap: 8px; }
.provider { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 10px 14px; }
.provider svg { width: 18px; height: 18px; flex: none; }
.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--faint); font-size: .78rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-form { display: grid; gap: 14px; }
.auth-form input { width: 100%; }
.auth-form .primary { margin-top: 4px; padding: 10px 18px; }
.auth-form .link { justify-self: start; font-size: .85rem; }
.auth-dialog .error, .auth-dialog .notice { margin: 14px 0 0; font-size: .88rem; }
.auth-dialog .notice { color: var(--good); }
.auth-dialog .switch { margin: 20px 0 0; text-align: center; font-size: .88rem; color: var(--muted); }

/* ---------- Monthly spending page ---------- */
.page-months .stats { margin: 0; }
.month-chart { margin: 0; }
.month-chart .plot { position: relative; height: 220px; margin: 20px 0 0 44px; }
.gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border); }
.gridline span {
  position: absolute; right: calc(100% + 10px); top: -.65em;
  font-size: .72rem; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap;
}
.month-chart .cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, 1fr); }
/* The whole column is the hover / click target, much bigger than the bar. */
.col {
  position: relative; height: 100%; padding: 0; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer;
}
.col:hover:not(:disabled), .col:focus-visible { background: var(--hover); }
.col:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.col .bar {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(24px, 64%); min-height: 2px;
  background: var(--chart-bar); border-radius: 4px 4px 0 0;
}
.col .val {
  position: absolute; left: 50%; transform: translate(-50%, -6px);
  font-size: .72rem; font-weight: 600; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.col .tip {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); z-index: 2;
  display: grid; gap: 2px; padding: 8px 12px; border-radius: 10px;
  background: var(--card); border: 1px solid var(--border); box-shadow: var(--shadow-pop);
  font-size: .76rem; color: var(--muted); white-space: nowrap; text-align: left;
  opacity: 0; pointer-events: none; transition: opacity .12s;
}
.col .tip strong { color: var(--text); font-size: .95rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.col:hover .tip, .col:focus .tip { opacity: 1; }
.month-chart .x-labels {
  display: grid; grid-template-columns: repeat(12, 1fr); margin: 8px 0 0 44px;
  font-size: .72rem; color: var(--faint); text-align: center;
}
.month-chart .x-labels .now { color: var(--text); font-weight: 600; }

.month-body { padding: 16px; display: grid; gap: 12px; }
.month-body p { margin: 0; font-size: .9rem; }
.month-body h3 { margin: 4px 0 0; font-size: .78rem; font-weight: 500; color: var(--muted); }
.month-body table { table-layout: auto; }
.month-body th { position: static; }

/* ---------- Camera ---------- */
.camera-dialog {
  width: min(760px, calc(100vw - 32px)); padding: 20px;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow-pop);
}
.camera-dialog::backdrop { background: rgb(12 12 14 / 55%); backdrop-filter: blur(4px); }
.camera-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.camera-head h2 { margin: 0; font-size: 1.1rem; }
.camera-head .close {
  width: 30px; height: 30px; padding: 0; border: 0; border-radius: 8px; font-size: 1.2rem; color: var(--muted);
}
.camera-view {
  position: relative; overflow: hidden; border-radius: 12px;
  background: #000; aspect-ratio: 4 / 3; max-height: 65vh;
}
.camera-view video { display: block; width: 100%; height: 100%; object-fit: contain; }
.camera-message {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px;
  padding: 24px; text-align: center; color: #e4e4e7; font-size: .92rem;
}
.camera-message p { margin: 0; max-width: 40ch; }
.camera-message button { color: #fff; border-color: rgb(255 255 255 / 30%); }
.camera-message button:hover:not(:disabled) { background: rgb(255 255 255 / 10%); }
.camera-tip { margin: 12px 0 0; font-size: .85rem; }
.camera-actions { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.camera-actions .primary { padding: 9px 22px; }

/* By supermarket: donut + legend table */
.section-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-head .section-title { margin: 0; flex: 1; }
.section-head select { padding: 6px 10px; font-size: .86rem; }
.donut-chart { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 28px; align-items: center; }
@media (max-width: 640px) { .donut-chart { grid-template-columns: minmax(0, 1fr); justify-items: center; } .donut-chart .table-wrap { width: 100%; } }
.donut { position: relative; margin: 0; width: 220px; height: 220px; }
.donut svg { display: block; width: 100%; height: 100%; }
.slice { fill: none; stroke-width: 22; transition: opacity .15s; cursor: default; }
.slice.dim { opacity: .3; }
.donut-center {
  position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px;
  pointer-events: none;
}
.donut-center strong { font-size: 1.35rem; font-weight: 600; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.donut-center span { font-size: .78rem; color: var(--muted); max-width: 130px; }
.donut-chart tr[data-slice] { cursor: default; }
.donut-chart tr[data-slice].on { background: var(--hover); }
.donut-chart tr[data-slice]:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 10px; vertical-align: -1px; }

/* By supermarket: month stepper, and a compact table beside the donut. */
.month-stepper {
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border-radius: 12px; background: var(--subtle);
}
.month-stepper .icon-button { width: 32px; height: 32px; border: 0; border-radius: 9px; color: var(--text); }
.month-stepper .icon-button:hover:not(:disabled) { background: var(--card); }
.month-stepper .icon-button:disabled { opacity: .3; }
.month-stepper select {
  appearance: none; -webkit-appearance: none;
  min-width: 150px; padding: 6px 28px 6px 12px; border: 0; border-radius: 9px;
  background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m7 10 5 5 5-5' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 8px center / 14px;
  box-shadow: 0 1px 2px rgb(24 24 27 / 8%);
  font-weight: 600; font-size: .95rem; text-align: center; cursor: pointer;
}
#storeSection .donut-chart { grid-template-columns: 200px minmax(0, 440px); justify-content: center; gap: 36px; }
#storeSection .donut { width: 200px; height: 200px; }
#storeSection .donut-chart table { font-size: .84rem; }
#storeSection .donut-chart th, #storeSection .donut-chart td { padding: 7px 12px; }
#storeSection .donut-chart th { font-size: .72rem; }
@media (max-width: 640px) { #storeSection .donut-chart { grid-template-columns: minmax(0, 1fr); } }

/* The month shown in By supermarket, marked in the 12-month chart. */
.col.selected { background: var(--accent-soft); }
.col.selected:hover:not(:disabled) { background: var(--accent-soft); }

/* ---------- Deleting a receipt ---------- */
button.danger, button.with-icon { display: inline-flex; align-items: center; gap: 6px; }
button.danger { color: var(--bad); }
button.with-icon svg { width: 16px; height: 16px; }
button.danger svg { width: 16px; height: 16px; }
button.danger:hover:not(:disabled) { background: var(--bad-soft); border-color: var(--bad-soft); }
button.danger-solid { background: #dc2626; border-color: #dc2626; color: #fff; }
button.danger-solid:hover:not(:disabled) { background: #b91c1c; border-color: #b91c1c; }

.confirm-dialog {
  width: min(400px, calc(100vw - 32px)); padding: 28px;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow-pop);
}
.confirm-dialog::backdrop { background: rgb(12 12 14 / 45%); backdrop-filter: blur(3px); }
.confirm-icon {
  display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: 14px;
  border-radius: 12px; background: var(--bad-soft); color: var(--bad);
}
.confirm-icon svg { width: 22px; height: 22px; }
.confirm-icon.restore { background: var(--accent-soft); color: var(--accent); }
.confirm-dialog h2 { margin: 0 0 16px; font-size: 1.2rem; }
.confirm-summary {
  display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 0;
  padding: 14px 16px; border-radius: 12px; background: var(--subtle); font-size: .9rem;
}
.confirm-summary dt { color: var(--muted); }
.confirm-summary dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.confirm-dialog > p { margin: 14px 0 0; font-size: .86rem; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; }
