/* Ticket Malin — "the receipt, made better".
   Thermal-paper cream, near-black ink, three accents: tomato for spending and rises,
   basil for savings, mustard for markers. Fraunces for voice and big figures, Figtree
   for reading, IBM Plex Mono for everything a receipt would print.
   Fonts are served by the site (SIL OFL, see static/vendor/fonts/). */

@font-face { font-family: "Fraunces"; src: url("vendor/fonts/fraunces.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("vendor/fonts/fraunces-italic.woff2") format("woff2"); font-weight: 100 900; font-style: italic; font-display: swap; }
@font-face { font-family: "Figtree"; src: url("vendor/fonts/figtree.woff2") format("woff2"); font-weight: 300 900; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("vendor/fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("vendor/fonts/ibm-plex-mono-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  --paper: #f6f1e7;
  --paper-deep: #ece4d4;
  --surface: #fffdf8;
  --ink: #1d1a16;
  --ink-soft: #4a443b;
  --muted: #7a7266;
  --rule: #e2d9c8;
  --tomato: #e0533a;
  --tomato-soft: #fbe1da;
  --basil: #2e7d57;
  --basil-soft: #dcefe3;
  --mustard: #f0b43c;
  --mustard-soft: #fbedc8;
  --sky: #3f7fbf;
  --receipt: #fffefa;
  --receipt-ink: #26231f;
  --shadow: 0 1px 0 rgba(29, 26, 22, 0.04), 0 12px 32px -18px rgba(29, 26, 22, 0.28);
  --radius: 22px;
  --display: "Fraunces", ui-serif, Georgia, serif;
  --body: "Figtree", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;

  /* One color per product category, used by the ring and its legend. */
  --c-savory_grocery: #d9822b;
  --c-sweet_grocery: #e2688f;
  --c-dairy: #7db4e3;
  --c-meat_fish: #c8553d;
  --c-fruit_vegetables: #5fa86b;
  --c-frozen: #62c1c8;
  --c-drinks: #f0b43c;
  --c-hygiene: #9b7fd4;
  --c-household: #4f6d7a;
  --c-pets: #a0785a;
  --c-other: #b8b0a2;
  color-scheme: light;
}

/* Dark theme: the system preference, unless the visitor picked light with the toggle;
   or the visitor's explicit choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15130f;
    --paper-deep: #1d1a15;
    --surface: #211e18;
    --ink: #f3ecdf;
    --ink-soft: #d4cabb;
    --muted: #a39a8b;
    --rule: #37322a;
    --tomato: #ff7a5e;
    --tomato-soft: #45241d;
    --basil: #5fcf94;
    --basil-soft: #1f3a2b;
    --mustard: #f7c65f;
    --mustard-soft: #3d321a;
    --sky: #7fb3ea;
    --receipt: #f1ead9;
    --receipt-ink: #26231f;
    --shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #15130f;
  --paper-deep: #1d1a15;
  --surface: #211e18;
  --ink: #f3ecdf;
  --ink-soft: #d4cabb;
  --muted: #a39a8b;
  --rule: #37322a;
  --tomato: #ff7a5e;
  --tomato-soft: #45241d;
  --basil: #5fcf94;
  --basil-soft: #1f3a2b;
  --mustard: #f7c65f;
  --mustard-soft: #3d321a;
  --sky: #7fb3ea;
  --receipt: #f1ead9;
  --receipt-ink: #26231f;
  --shadow: 0 16px 40px -20px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

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

body {
  margin: 0;
  font: 16.5px/1.55 var(--body);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration-color: var(--mustard); text-decoration-thickness: 2px; text-underline-offset: 3px; }
/* A label that reads as a link: it focuses its field. */
label.link, .validate label.link { display: inline; cursor: pointer; text-decoration: underline; text-decoration-color: var(--mustard); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--tomato); }
:focus-visible { outline: 3px solid var(--mustard); outline-offset: 2px; border-radius: 6px; }

h1, h2, h3 { font-family: var(--display); font-weight: 600; line-height: 1.08; letter-spacing: -0.01em; margin: 0 0 0.4em; font-variation-settings: "SOFT" 60, "WONK" 1; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); font-weight: 700; }
h2 { font-size: clamp(1.35rem, 2.6vw, 1.7rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.9em; }
small { color: var(--muted); }

/* Marker highlight, as if circled on the receipt. */
mark, .hl { background: linear-gradient(transparent 58%, var(--mustard-soft) 58% 92%, transparent 92%); color: inherit; padding: 0 0.1em; }

/* ---------- Header ---------- */

/* Anchors land below the sticky header (its height is measured in base.html). */
html { scroll-padding-top: calc(var(--header-height, 4.5rem) + 1rem); }

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px dashed var(--rule);
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 1.3rem; letter-spacing: -0.02em; }
.brand em { font-style: italic; font-weight: 500; color: var(--tomato); }
.brand svg { width: 30px; height: 34px; flex: none; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 0.25rem; align-items: center; }
.site-header nav a { text-decoration: none; padding: 0.35rem 0.8rem; border-radius: 999px; font-weight: 600; font-size: 0.95rem; color: var(--ink-soft); }
.site-header nav a:hover { background: var(--paper-deep); color: var(--ink); }
.site-header nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.site-header nav a.user { color: var(--muted); font-weight: 500; }
.site-header nav a.user[aria-current="page"] { color: var(--paper); }
/* Whose tickets the pages analyse: the user alone, or the household. */
.view-switch { display: inline-flex; margin: 0 0.25rem; padding: 2px; border: 1.5px solid var(--rule); border-radius: 999px; }
.view-switch button { padding: 0.2rem 0.75rem; border: 0; background: transparent; color: var(--ink-soft); font-size: 0.88rem; }
.view-switch button:hover { transform: none; box-shadow: none; color: var(--ink); }
.view-switch button[aria-pressed="true"] { background: var(--basil); color: #fff; }

.content { max-width: 76rem; margin: 0 auto; padding: clamp(1.25rem, 3vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) 4rem; }

/* ---------- Buttons and fields ---------- */

button, .button {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font: 600 0.98rem var(--body);
  padding: 0.62rem 1.1rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
button:hover, .button:hover { transform: translateY(-1px); box-shadow: 0 3px 0 var(--mustard); }
button.secondary, .button.secondary { background: transparent; color: var(--ink); }
button.danger { background: var(--tomato); border-color: var(--tomato); color: #fff; }
button:disabled { opacity: 0.55; cursor: wait; transform: none; box-shadow: none; }

input, select {
  font: inherit; color: inherit;
  padding: 0.42rem 0.6rem;
  border: 1.5px solid var(--rule);
  border-radius: 10px;
  background: var(--surface);
  min-width: 0; width: 100%;
}
input:focus, select:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px var(--mustard-soft); }
input:disabled { background: transparent; border-color: transparent; color: inherit; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; margin: 0 0.5rem 0 0; vertical-align: -0.2rem; accent-color: var(--basil); }
fieldset { min-width: 0; }

/* ---------- Generic blocks ---------- */

.lede { color: var(--ink-soft); font-size: 1.05rem; max-width: 62ch; }
.lede b { color: var(--ink); }
.note { color: var(--muted); font-size: 0.9rem; margin-top: 0.75rem; }
.insufficient { color: var(--muted); font-style: italic; }
.error { color: var(--tomato); font-weight: 600; }
.notice, .queue { background: var(--basil-soft); padding: 0.6rem 0.9rem; border-radius: 12px; }
.queue { background: var(--mustard-soft); }
.badge { font: 600 0.75rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; padding: 0.2rem 0.6rem; border-radius: 999px; background: var(--mustard-soft); color: var(--ink); vertical-align: middle; }
.up { color: var(--tomato); font-weight: 700; }
.down { color: var(--basil); font-weight: 700; }
.check-ok { color: var(--basil); font-weight: 600; }
.check-failed { color: var(--tomato); font-weight: 600; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-top: 1rem; }
.actions form { margin: 0; }
.scroll { overflow-x: auto; }

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: clamp(1.1rem, 2.4vw, 1.6rem);
  box-shadow: var(--shadow);
  margin: 0 0 1.25rem;
  min-width: 0;
}
.panel.danger { border-color: var(--tomato-soft); }
.panel h2 { margin-top: 0; }
.card--pending { padding-block: 0.7rem; box-shadow: none; border-style: dashed; }
.card--pending .eyebrow { display: none; }
.card--pending h2 { font-size: 0.9rem; font-weight: 600; margin-block: 0 0.2rem; color: var(--muted); }
.card--pending .insufficient { margin-block: 0; }

.eyebrow { font: 600 0.78rem var(--mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); margin: 0 0 0.5rem; }

/* ---------- Tables ---------- */

table.data, .history, .items { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data th, .history th, .items th { text-align: left; font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0.5rem; border-bottom: 1.5px solid var(--ink); }
table.data td, .history td, .items td { padding: 0.5rem; border-bottom: 1px dashed var(--rule); }
table.data .n, .history .amount { text-align: right; white-space: nowrap; font-family: var(--mono); font-size: 0.88rem; }
table.data tr.current td { font-weight: 700; background: var(--mustard-soft); }
.spend { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; }
.spend i { display: block; height: 0.45rem; background: var(--mustard); border-radius: 99px; }

/* ---------- Charts: horizontal bars ---------- */

.bars { display: grid; gap: 0.55rem; }
.bar { display: grid; grid-template-columns: 5rem 1fr 6.2rem; gap: 0.7rem; align-items: center; font-size: 0.92rem; }
.bar .track { height: 1.9rem; background: var(--basil-soft); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; min-width: 2rem; background: var(--basil); border-radius: 999px; color: #fff; font: 600 0.8rem var(--mono); display: flex; align-items: center; padding-left: 0.7rem; }
.bar.small .track { background: var(--tomato-soft); }
.bar.small .fill { background: var(--tomato); }
.bar .v { text-align: right; font-family: var(--mono); font-size: 0.85rem; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Charts: columns ---------- */

.months { display: grid; grid-template-columns: repeat(var(--count), minmax(0, 1fr)); gap: 0.35rem; height: 13rem; align-items: end; }
.month, .weekday { display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.month .plot, .weekday .plot { flex: 1; width: 100%; display: flex; align-items: flex-end; padding-top: 1.3rem; }
.month .column, .weekday .column { position: relative; width: 100%; min-height: 4px; background: var(--ink); border-radius: 10px 10px 3px 3px; }
.month:last-child .column { background: var(--tomato); }
.month .column b, .weekday .column b { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 0.15rem; font: 600 0.72rem var(--mono); white-space: nowrap; }
.month span, .weekday span { font: 0.72rem var(--mono); color: var(--muted); margin-top: 0.35rem; white-space: nowrap; }
.weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; height: 7.5rem; }
.weekday .column { background: var(--mustard); }

/* ---------- Dashboard: bento ---------- */

.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 1.25rem; align-items: start; }
.bento > .card { align-self: stretch; }
.bento > .hero, .bento > .receipt { align-self: center; }
.bento > * { grid-column: span 12; margin: 0; }
@media (min-width: 62rem) {
  .span-4 { grid-column: span 4; }
  .span-5 { grid-column: span 5; }
  .span-6 { grid-column: span 6; }
  .span-7 { grid-column: span 7; }
  .span-8 { grid-column: span 8; }
}

.hero { background: transparent; border: 0; box-shadow: none; padding: 0.5rem 0; display: flex; flex-direction: column; justify-content: center; }
.hero h1 { font-size: clamp(2.2rem, 5.2vw, 3.9rem); line-height: 1.02; margin-bottom: 0.35em; }
.hero h1 .amount { color: var(--tomato); font-style: italic; white-space: nowrap; }
.facts { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.6rem; }
.fact { background: var(--surface); border: 1px solid var(--rule); border-radius: 999px; padding: 0.4rem 0.95rem; display: flex; gap: 0.45rem; align-items: baseline; }
.fact b { font: 600 0.95rem var(--mono); }
.fact span { color: var(--muted); font-size: 0.88rem; }
.fact.good b { color: var(--basil); }

/* The receipt: thermal paper, monospace, torn zigzag edge, a slight tilt. */
.receipt {
  position: relative;
  align-self: center;
  justify-self: center;
  width: min(100%, 23rem);
  background: var(--receipt);
  color: var(--receipt-ink);
  font: 0.86rem/1.6 var(--mono);
  padding: 1.6rem 1.5rem 3.6rem;
  transform: rotate(1.4deg);
  filter: drop-shadow(0 18px 22px rgba(29, 26, 22, 0.22));
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
    radial-gradient(circle 7px at 50% 100%, transparent 97%, #000) bottom / 16px 10px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
    radial-gradient(circle 7px at 50% 100%, transparent 97%, #000) bottom / 16px 10px repeat-x;
}
.receipt .head { text-align: center; text-transform: uppercase; letter-spacing: 0.08em; }
.receipt .head b { display: block; font-size: 1rem; }
.receipt hr { border: 0; border-top: 1.5px dashed #a59d8f; margin: 0.7rem 0; }
.receipt .line { display: flex; justify-content: space-between; gap: 1rem; }
.receipt .line span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt .more { color: #857d70; }
.receipt .total { font-weight: 600; font-size: 1.05rem; }
.receipt .saved { color: #2e7d57; }
.receipt .stamp {
  position: absolute; right: 1.1rem; bottom: 1.3rem;
  font: 700 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--tomato); border: 2px solid var(--tomato); border-radius: 6px;
  padding: 0.2rem 0.45rem; transform: rotate(-9deg); opacity: 0.85;
}
@media (prefers-reduced-motion: no-preference) {
  .receipt { animation: print 1s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  @keyframes print {
    from { clip-path: inset(0 0 100% 0); transform: rotate(1.4deg) translateY(-18px); }
    to { clip-path: inset(0 0 0 0); transform: rotate(1.4deg); }
  }
}

/* Where to get money back: always dark ink, in both themes, so the figures pop. */
.money { --on: #f6f1e7; background: #1d1a16; color: var(--on); border-color: #1d1a16; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .money { background: #0d0c0a; border-color: #3a3328; } }
:root[data-theme="dark"] .money { background: #0d0c0a; border-color: #3a3328; }
.money h2 { color: var(--on); }
.money .eyebrow { color: var(--on); opacity: 0.6; }
.money .lede { color: color-mix(in srgb, var(--on) 75%, transparent); }
.money .total { font: 700 clamp(2.4rem, 6vw, 3.6rem)/1 var(--display); color: #f7c65f; font-style: italic; }
.levers { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.9rem; margin-top: 1.2rem; }
.lever { background: rgba(246, 241, 231, 0.06); border: 1px solid rgba(246, 241, 231, 0.16); border-radius: 16px; padding: 1rem 1.1rem; }
.lever .amount { font: 700 1.7rem/1 var(--display); color: #8fe0b4; margin-bottom: 0.45rem; }
.lever.maybe .amount { color: #f7c65f; }
.lever h3 { font: 700 1rem/1.3 var(--body); margin-bottom: 0.35rem; color: var(--on); }
.lever p { font-size: 0.9rem; margin: 0; color: rgba(246, 241, 231, 0.72); }

/* Category ring, drawn with a conic gradient. */
.ring-wrap { display: grid; grid-template-columns: minmax(9rem, 13rem) 1fr; gap: 1.5rem; align-items: center; }
.ring { aspect-ratio: 1; border-radius: 50%; position: relative; }
.ring::after { content: ""; position: absolute; inset: 22%; border-radius: 50%; background: var(--surface); }
.ring .center { position: absolute; inset: 0; z-index: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.ring .center b { font: 700 1.5rem/1 var(--display); }
.ring .center span { font-size: 0.78rem; color: var(--muted); max-width: 6rem; }
.legend { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; font-size: 0.92rem; }
.legend li { display: grid; grid-template-columns: 0.8rem 1fr auto auto; gap: 0.6rem; align-items: center; }
.legend i { width: 0.8rem; height: 0.8rem; border-radius: 4px; }
.legend .share { font: 600 0.8rem var(--mono); }
.legend .v { font: 0.8rem var(--mono); color: var(--muted); min-width: 5.2rem; text-align: right; }

/* Shopping list */
.shopping { list-style: none; padding: 0; margin: 0; }
.shopping h3, .shop h3 { font: 600 0.72rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin: 1rem 0 0.3rem; }
.shopping li { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.4rem 0; border-bottom: 1px dashed var(--rule); }
.shopping label { flex: 1; cursor: pointer; }
.shopping input:checked + span { text-decoration: line-through; color: var(--muted); }
.shopping .when { margin-left: auto; font: 0.78rem var(--mono); color: var(--muted); white-space: nowrap; }
.shopping .late { color: var(--tomato); }
.shops { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 26rem), 1fr)); gap: 1.25rem; align-items: start; }
.shop { margin: 0; }
.shop-head { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; align-items: baseline; justify-content: space-between; padding-bottom: 0.6rem; border-bottom: 1.5px solid var(--ink); }
.shop-head h2 { margin: 0; }
.shop-sum { font: 0.85rem var(--mono); color: var(--muted); }
.shop-sum b { color: var(--ink); }
.shopping .price { font: 0.8rem var(--mono); color: var(--ink-soft); white-space: nowrap; }
.shopping .also { display: block; font-size: 0.78rem; margin-left: 1.65rem; }
.share-status { color: var(--basil); font-size: 0.9rem; }

/* Deleting several tickets: a bar floating at the bottom of the screen once one is
   ticked, so that the table does not move under the cursor. */
.bulk-delete { display: none; flex-wrap: wrap; gap: 0.5rem 1.25rem; align-items: center; position: fixed; bottom: clamp(1rem, 3vw, 2rem); left: 50%; transform: translateX(-50%); z-index: 20; width: max-content; max-width: calc(100vw - 2rem - 4rem); padding: 0.75rem 1rem; border: 1.5px solid var(--tomato); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.bulk-delete.active { display: flex; }
.bulk-delete label { margin: 0; font-size: 0.92rem; }
.bulk-delete button:disabled { cursor: not-allowed; }
.delete-ticket { display: grid; gap: 0.75rem; margin-top: 1rem; padding: 1rem; }
.delete-ticket label { margin: 0; font-size: 0.9rem; }
.delete-ticket button { justify-content: center; }
.delete-ticket button:disabled { cursor: not-allowed; }
.history .pick { width: 2rem; }
.history .pick input { margin: 0; }

/* Printed shopping list: one compact sheet, two columns per shop, only what is left to buy. */
@media print {
  @page { margin: 12mm; }
  .shopping-page { font-size: 9.5pt; line-height: 1.3; color: #000; }
  .shopping-page .eyebrow, .shopping-page .lede, .shopping-page .note,
  .site-footer, .shopping .when, .shopping .also, .shopping .price { display: none !important; }
  .shopping-page h1 { font-size: 15pt; margin: 0 0 4mm; }
  .shopping-page .shops { display: block; }
  .shopping-page .shop { padding: 0; margin: 0 0 5mm; columns: 2; column-gap: 8mm; background: none; }
  .shopping-page .shop-head { column-span: all; padding-bottom: 1mm; margin-bottom: 1mm; }
  .shopping-page .shop-head h2 { font-size: 11.5pt; }
  .shopping-page .shop-head a { text-decoration: none; }
  .shopping-page .shop-sum { font-size: 8.5pt; }
  .shopping-page h3 { font-size: 7.5pt; margin: 2mm 0 0.5mm; break-after: avoid; }
  .shopping-page .shopping li { padding: 0.4mm 0; border: 0; break-inside: avoid; }
  .shopping-page .shopping li.done { display: none; }
  .shopping-page .shopping input { width: 3mm; height: 3mm; margin-right: 1.5mm; }
  .shopping-page .qty { font-size: 7.5pt; background: none; padding: 0; }
}

.qty { font: 600 0.8rem var(--mono); background: var(--mustard-soft); border-radius: 6px; padding: 0.05rem 0.35rem; margin-right: 0.3rem; }
.horizons { display: inline-flex; gap: 0.3rem; background: var(--paper-deep); padding: 0.25rem; border-radius: 999px; }
.horizons a { text-decoration: none; padding: 0.3rem 0.8rem; border-radius: 999px; font-weight: 600; font-size: 0.9rem; }
.horizons a[aria-current="true"] { background: var(--ink); color: var(--paper); }

.kinds { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.5rem; }
.kinds li { display: flex; gap: 0.8rem; align-items: baseline; }
.kinds b { font: 700 1.25rem var(--display); color: var(--basil); min-width: 6rem; }
.big-figure { font: 700 clamp(2rem, 4vw, 2.8rem)/1 var(--display); color: var(--basil); margin: 0.2rem 0 0.6rem; }

/* ---------- Home ---------- */

.welcome { display: grid; gap: 2.5rem; align-items: center; padding: 2rem 0; }
@media (min-width: 56rem) { .welcome { grid-template-columns: 1.2fr 0.8fr; } }
.welcome h1 { font-size: clamp(2.6rem, 6.5vw, 4.8rem); line-height: 0.98; }
.welcome h1 em { color: var(--tomato); }
.welcome .lede { font-size: 1.2rem; }
.promises { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1rem; margin-top: 1rem; }
.promises div { border-top: 2px solid var(--ink); padding-top: 0.7rem; }
.promises b { font-family: var(--display); font-size: 1.15rem; display: block; margin-bottom: 0.2rem; }

/* ---------- Import ---------- */

.drop-zone {
  display: block;
  padding: 2.4rem 1rem;
  border: 2px dashed var(--ink-soft);
  border-radius: var(--radius);
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  font-family: var(--display);
  font-size: 1.2rem;
  transition: background 0.15s, border-color 0.15s;
}
.drop-zone.dragging { border-color: var(--basil); background: var(--basil-soft); }
.drop-zone input { display: block; margin: 1rem auto 0; max-width: 100%; width: auto; font: 0.9rem var(--body); }
#file-list { font-family: var(--mono); font-size: 0.88rem; }
#status { font-weight: 600; }
#status.error { color: var(--tomato); }
.chunks table { width: 100%; border-collapse: collapse; font: 0.85rem var(--mono); }
.chunks td { padding: 0.15rem 0.4rem; border-bottom: 1px dashed var(--rule); overflow-wrap: anywhere; }
.chunks td.price { text-align: right; white-space: nowrap; }
.chunks tr.truncated { color: var(--muted); text-decoration: line-through; }

/* ---------- Ticket review: the draft printed on thermal paper, checks beside it ---------- */

.review-head { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.5rem; }
.review-head h1 { margin: 0; }
.queue-progress { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; align-items: center; min-width: min(100%, 16rem); }
.queue-count { font: 0.95rem var(--mono); color: var(--muted); }
.queue-count b { font: 700 1.9rem/1 var(--display); color: var(--ink); }
.queue-progress ol { list-style: none; display: flex; gap: 0.3rem; padding: 0; margin: 0; }
.queue-progress li { flex: 1; height: 0.4rem; min-width: 0.7rem; border-radius: 99px; background: var(--rule); }
.queue-progress li.done { background: var(--basil); }
.queue-progress li.current { background: var(--mustard); }
.queue-progress small { grid-column: 2; font-size: 0.82rem; }

.review { display: grid; gap: 1.75rem; align-items: start; }
@media (min-width: 62rem) { .review { grid-template-columns: minmax(0, 1fr) 20rem; } }
.review-side { position: sticky; top: 5rem; display: grid; gap: 0.5rem; }
.review-side .panel { margin: 0; }

/* The sheet reuses the dashboard receipt: same paper, ink, font and torn edge, without the tilt. */
.sheet {
  position: relative;
  background: var(--receipt);
  color: var(--receipt-ink);
  font: 0.9rem/1.5 var(--mono);
  padding: clamp(1.1rem, 3vw, 2rem) clamp(0.8rem, 3vw, 2rem) 3.5rem;
  filter: drop-shadow(0 18px 22px rgba(29, 26, 22, 0.18));
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
    radial-gradient(circle 7px at 50% 100%, transparent 97%, #000) bottom / 16px 10px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 10px) no-repeat,
    radial-gradient(circle 7px at 50% 100%, transparent 97%, #000) bottom / 16px 10px repeat-x;
  color-scheme: light; /* the paper stays light in the dark theme, so do the date picker icons */
}
.sheet fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
/* Fields look printed; they only reveal themselves on hover and focus. */
.sheet input, .sheet select {
  font: inherit; color: inherit;
  background: transparent;
  border: 0; border-bottom: 1.5px dotted transparent; border-radius: 0;
  padding: 0.2rem 0.1rem;
  transition: border-color 0.12s, background 0.12s;
}
.sheet input:hover:not(:disabled), .sheet select:hover { border-bottom-color: #b3aa9a; }
.sheet input:focus, .sheet select:focus { border-bottom-color: var(--receipt-ink); background: #fbeecb; box-shadow: none; }
.sheet input:disabled { background: transparent; }

.sheet .sheet-head { display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 1rem; text-align: center; padding-bottom: 0.9rem; border-bottom: 1.5px dashed #a59d8f; margin-bottom: 0.4rem; }
.sheet-retailer { grid-column: 1 / -1; }
.sheet-head .sheet-retailer input { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.14em; }
.sheet-head label, .sheet-foot label { display: flex; flex-direction: column; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.12em; color: #857d70; }
.sheet-head input { text-align: center; font-size: 0.95rem; color: var(--receipt-ink); text-transform: uppercase; }
.sheet-head input[aria-invalid="true"] { color: var(--tomato); box-shadow: inset 0 -2px 0 var(--tomato); }

.sheet .items { font-size: 0.9rem; }
.sheet .items th { color: #857d70; border-bottom: 1.5px dashed #a59d8f; padding: 0.55rem 0.25rem; }
.sheet .items th.n { text-align: right; }
.sheet .items td { padding: 0.3rem 0.25rem; border-bottom: 1px dotted #e3dccd; vertical-align: top; }
.items td.label input { font-weight: 600; }
.items td.quantity { width: 3.5rem; }
.items td.unit_price, .items td.amount { width: 5.8rem; }
.items td.quantity input, .items td.unit_price input, .items td.amount input { text-align: right; }
.items td.amount input { font-weight: 600; }
.items td.remove { width: 2rem; text-align: right; }

/* Category: a small tag with the ring's color, under the label. */
.tag { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0.1rem 0 0.15rem 0.1rem; }
.tag::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 3px; background: var(--dot); flex: none; }
.sheet .tag select { width: auto; font: 0.74rem var(--body); color: #6d665a; padding: 0 1rem 0 0; cursor: pointer; appearance: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23857d70' fill='none' stroke-width='1.5'/%3E%3C/svg%3E") right center / 0.55rem no-repeat; }
.join-note { font: 600 0.68rem var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: #a0660f; margin-left: 0.6rem; }
.items tr.suspicious td { background: linear-gradient(transparent 8%, #fbedc8 8% 92%, transparent 92%); }

.items td.remove button { width: 1.7rem; height: 1.7rem; padding: 0; justify-content: center; font: 1.1rem/1 var(--body); background: transparent; color: #a59d8f; border: 0; opacity: 0.45; }
.items tr:hover td.remove button, .items td.remove button:focus-visible { opacity: 1; }
.items td.remove button:hover { color: #fff; background: var(--tomato); box-shadow: none; transform: none; }
.add-line { margin-top: 0.6rem; background: transparent; color: #6d665a; border: 1.5px dashed #b3aa9a; border-radius: 8px; font: 600 0.82rem var(--mono); padding: 0.4rem 0.8rem; }
.add-line:hover { color: var(--receipt-ink); border-color: var(--receipt-ink); box-shadow: none; }

.sheet .sheet-foot { display: grid; grid-template-columns: 1fr 1.2fr; gap: 1rem; margin-top: 1rem; padding-top: 0.8rem; border-top: 1.5px dashed #a59d8f; align-items: end; }
.sheet-foot input { font-size: 1rem; color: var(--receipt-ink); }
.sheet-foot .total input { text-align: right; }
.sheet-foot .total { text-align: right; color: var(--receipt-ink); font-weight: 600; font-size: 0.8rem; }
.sheet-foot .total input { font: 700 clamp(1.5rem, 3vw, 1.9rem)/1.1 var(--mono); }
.payments { list-style: none; padding: 0.6rem 0 0; margin: 0.8rem 0 0; border-top: 1.5px dashed #a59d8f; font-size: 0.85rem; color: #6d665a; }
.payments li { display: flex; justify-content: space-between; gap: 1rem; text-transform: uppercase; }

.sheet .stamp {
  position: absolute; left: clamp(1rem, 3vw, 2rem); bottom: 1.4rem;
  font: 700 0.78rem var(--mono); text-transform: uppercase; letter-spacing: 0.12em;
  border: 2px solid; border-radius: 6px; padding: 0.2rem 0.5rem;
  transform: rotate(-6deg); opacity: 0.85;
}
.sheet .stamp.ok { color: #2e7d57; }
.sheet .stamp.ko { color: #d2442c; }

.verdict-title { font: 700 1.45rem/1.15 var(--display); margin: 0 0 0.8rem; }
.verdict-title.ok { color: var(--basil); }
.verdict-title.ko { color: var(--tomato); }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.55rem; }
.checks li { display: grid; grid-template-columns: 1.4rem 1fr; column-gap: 0.4rem; font-size: 0.92rem; line-height: 1.35; }
.checks li::before { grid-row: span 2; width: 1.3rem; height: 1.3rem; border-radius: 50%; display: grid; place-items: center; font: 700 0.75rem var(--body); color: #fff; }
.checks .passed::before { content: "✓"; background: var(--basil); }
.checks .failed::before { content: "!"; background: var(--tomato); }
.checks small { font: 0.78rem var(--mono); }
.checks .failed small { color: var(--tomato); }
.validate { margin: 1.3rem 0 0; padding-top: 1rem; border-top: 1px dashed var(--rule); display: grid; gap: 0.7rem; }
.validate label { font-size: 0.88rem; color: var(--ink-soft); }
.validate button[type="submit"]:first-of-type { justify-content: center; }
.link-danger { background: transparent; border: 0; color: var(--muted); padding: 0.2rem; justify-self: center; font-size: 0.88rem; text-decoration: underline; text-decoration-color: var(--tomato-soft); text-underline-offset: 3px; }
.link-danger:hover { color: var(--tomato); box-shadow: none; transform: none; }
.back { margin-top: 2rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
  .bar { grid-template-columns: 4.2rem 1fr 5rem; font-size: 0.85rem; }
  .month b { font-size: 0.6rem; }
  .month span { font-size: 0.6rem; height: 2.8rem; writing-mode: vertical-rl; transform: rotate(180deg); }
  .ring-wrap { grid-template-columns: 1fr; }
  .ring { width: min(13rem, 70%); margin: 0 auto; }
  table.data .optional { display: none; }
  table.data td:first-child { overflow-wrap: anywhere; }
  table.data td, table.data th { padding: 0.45rem 0.3rem; }
  .spend i { display: none; }
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 0.2rem; padding: 0.45rem 0; border-bottom: 1px dotted #e3dccd; }
  .sheet .items td { border: 0; width: auto !important; padding: 0; }
  .items td.label { grid-column: 1 / -1; }
  .items td.remove button { opacity: 1; }
  .review-side { position: static; order: -1; } /* the verdict first, not after 60 lines */
  .receipt { transform: none; }
}

@media print {
  .site-header, .no-print { display: none !important; }
  body { background: #fff; }
  .panel, .card { box-shadow: none; border: 0; }
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  width: 2.4rem; height: 2.4rem; padding: 0; justify-content: center;
  border: 1.5px solid var(--rule); background: var(--surface); color: var(--ink);
  margin-left: 0.25rem;
}
.theme-toggle:hover { box-shadow: 0 3px 0 var(--mustard); }
.theme-toggle svg { width: 1.3rem; height: 1.3rem; overflow: visible; }
/* Sun by default; in the dark theme the rays retract, the disc grows and a shadow bites
   into it to make the moon. */
.theme-toggle .disc { transition: r 0.5s cubic-bezier(0.5, 1.6, 0.4, 0.9); r: 5px; }
.theme-toggle .bite { transition: cx 0.5s ease, cy 0.5s ease; cx: 26px; cy: 2px; }
.theme-toggle .rays { transform-origin: 12px 12px; transition: transform 0.5s cubic-bezier(0.5, 1.6, 0.4, 0.9), opacity 0.3s; }
:root[data-theme="dark"] .theme-toggle .disc { r: 9px; }
:root[data-theme="dark"] .theme-toggle .bite { cx: 17px; cy: 7px; }
:root[data-theme="dark"] .theme-toggle .rays { transform: rotate(90deg) scale(0.4); opacity: 0; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .disc { r: 9px; }
  :root:not([data-theme="light"]) .theme-toggle .bite { cx: 17px; cy: 7px; }
  :root:not([data-theme="light"]) .theme-toggle .rays { transform: rotate(90deg) scale(0.4); opacity: 0; }
}

/* The new theme spreads in a circle from the toggle (View Transitions). */
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }
::view-transition-old(root) { z-index: 1; }

/* ---------- Footer, account, consent, privacy ---------- */

.site-footer { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; align-items: center; max-width: 76rem; margin: 0 auto; padding: 1.5rem clamp(1rem, 4vw, 2.5rem) 2.5rem; border-top: 1px dashed var(--rule); font-size: 0.9rem; color: var(--muted); }
.site-footer em { color: var(--tomato); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 1rem; }
.site-footer .made-in { font-family: var(--display); font-style: italic; color: inherit; text-decoration: none; }
.site-footer .made-in:hover { color: var(--tomato); }

.about .creators { list-style: none; padding: 0; margin: 1.2rem 0; display: grid; gap: 0.8rem; max-width: 62ch; }
.about .creators li { border-left: 3px solid var(--basil); padding-left: 0.9rem; font-family: var(--display); font-size: 1.15rem; }

.account-head { margin-bottom: 1.5rem; }
.account-head h1 { margin-bottom: 0.2em; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 1.25rem; align-items: stretch; }
.account-grid > * { margin: 0; display: flex; flex-direction: column; }
.account-grid > * .actions, .account-grid > * .validate { margin-top: auto; }
.danger-zone { margin-top: 2.5rem; color: var(--tomato); }
.panel.danger h2 { color: var(--tomato); }

.consent .pledges { list-style: none; padding: 0; margin: 1.2rem 0; display: grid; gap: 0.8rem; max-width: 62ch; }
.consent .pledges li { border-left: 3px solid var(--basil); padding-left: 0.9rem; }
.consent .pledges b { display: block; font-family: var(--display); font-size: 1.1rem; }
.consent .validate { max-width: 62ch; }

.privacy { max-width: 46rem; }
.privacy section { border-top: 1.5px solid var(--ink); padding-top: 0.9rem; margin-top: 1.8rem; }
.privacy ul { padding-left: 1.2rem; display: grid; gap: 0.45rem; }

/* ---------- Import: the reading stage ---------- */

.stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: start; margin: 1.5rem 0 2rem; padding: clamp(1.2rem, 3vw, 2rem); background: var(--paper-deep); border-radius: var(--radius); overflow: hidden; }
.stage[hidden] { display: none; }
.stage-caption { grid-column: 1 / -1; margin: 0; text-align: center; font: italic 600 1.15rem var(--display); color: var(--ink-soft); }

/* The deck: the top card is scanned, the others wait underneath, slightly askew. */
.deck-wrap { display: flex; flex-direction: column; align-items: center; gap: 0.8rem; }
.deck { position: relative; width: min(100%, 15rem); aspect-ratio: 3 / 4.2; }
.deck-count { margin: 0; font: 600 0.85rem var(--mono); color: var(--muted); }
.ticket-card {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  background: var(--receipt); color: var(--receipt-ink);
  border-radius: 14px; padding: 0.7rem;
  box-shadow: 0 14px 30px -16px rgba(29, 26, 22, 0.45);
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.45s;
}
.ticket-card[data-depth="0"] { transform: none; }
.ticket-card[data-depth="1"] { transform: translate(6px, 8px) rotate(3deg) scale(0.97); }
.ticket-card[data-depth="2"] { transform: translate(-6px, 14px) rotate(-3deg) scale(0.94); }
.ticket-card[data-depth="3"] { transform: translate(4px, 20px) rotate(1.5deg) scale(0.91); }
.ticket-card[data-depth="4"], .ticket-card[data-depth="gone"] { opacity: 0; pointer-events: none; }
.ticket-card[data-depth="gone"] { transition: none; }
.ticket-card .preview { position: relative; flex: 1; overflow: hidden; border-radius: 8px; background: repeating-linear-gradient(transparent 0 14px, #eee6d6 14px 15px); }
.ticket-card canvas { display: block; width: 100%; height: auto; }
.ticket-card .name { margin: 0.5rem 0 0; font: 600 0.75rem var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-card .laser { position: absolute; left: 0; right: 0; top: 0; height: 3px; background: var(--tomato); box-shadow: 0 0 12px 3px rgba(224, 83, 58, 0.55); opacity: 0; }
.ticket-card.scanning .laser { opacity: 1; animation: scan 1.6s ease-in-out infinite alternate; }
@keyframes scan { from { top: 0; } to { top: calc(100% - 3px); } }

/* Verdict stamp, then the swipe. */
.ticket-card .verdict {
  position: absolute; top: 1.4rem; padding: 0.25rem 0.6rem;
  font: 800 1.1rem var(--mono); text-transform: uppercase; letter-spacing: 0.1em;
  border: 3px solid; border-radius: 8px; background: rgba(255, 254, 250, 0.85);
  opacity: 0; transform: scale(1.6);
  transition: opacity 0.2s, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.ticket-card.is-ok .verdict { left: 1rem; color: #2e7d57; transform: rotate(-14deg); opacity: 1; }
.ticket-card.is-check .verdict { right: 1rem; color: #b27a0c; transform: rotate(12deg); opacity: 1; }
.ticket-card.is-error .verdict { right: 1rem; color: #d2442c; transform: rotate(12deg); opacity: 1; }
.ticket-card.swipe-right { transform: translate(140%, -10%) rotate(24deg) !important; opacity: 0; }
.ticket-card.swipe-left { transform: translate(-140%, -10%) rotate(-24deg) !important; opacity: 0; }

/* The printer: rows come out of the slot, the oldest fall off the top. */
.printer { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.printer-body { position: relative; z-index: 1; width: min(100%, 19rem); height: 3.2rem; border-radius: 16px 16px 10px 10px; background: var(--ink); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 0.7rem; }
.printer-body .slot { width: 82%; height: 5px; border-radius: 3px; background: #000; }
.printer-body .led { position: absolute; top: 0.7rem; right: 1rem; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--basil); box-shadow: 0 0 8px var(--basil); }
.stage:not(.done) .printer-body .led { animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.paper {
  width: min(78%, 15rem); min-height: 8rem; margin-top: -0.8rem; padding: 1.3rem 0.8rem 1.4rem;
  background: var(--receipt); color: var(--receipt-ink); font: 0.72rem/1.55 var(--mono);
  filter: drop-shadow(0 10px 14px rgba(29, 26, 22, 0.2));
  -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, radial-gradient(circle 5px at 50% 100%, transparent 97%, #000) bottom / 12px 8px repeat-x;
  mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, radial-gradient(circle 5px at 50% 100%, transparent 97%, #000) bottom / 12px 8px repeat-x;
}
.paper ol { list-style: none; margin: 0; padding: 0; }
.paper li { display: flex; justify-content: space-between; gap: 0.6rem; animation: feed 0.25s ease-out both; }
.paper li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.paper li.truncated { color: #a59d8f; text-decoration: line-through; }
.paper li.rule { border-top: 1.5px dashed #a59d8f; margin: 0.35rem 0; }
.paper li.total { font-weight: 600; font-size: 0.85rem; }
@keyframes feed { from { opacity: 0; transform: translateY(-6px); clip-path: inset(0 0 100% 0); } to { opacity: 1; transform: none; clip-path: inset(0); } }

@media (max-width: 40rem) {
  .stage { grid-template-columns: 1fr; }
  .deck { width: min(70%, 12rem); }
}
@media (prefers-reduced-motion: reduce) {
  .ticket-card, .ticket-card .verdict { transition: opacity 0.2s; }
  .ticket-card.scanning .laser { animation: none; top: 50%; }
  .ticket-card.swipe-right, .ticket-card.swipe-left { transform: none !important; }
  .paper li, .stage:not(.done) .printer-body .led { animation: none; }
}
.deck::after { content: "Pile terminée"; position: absolute; inset: 0; display: grid; place-items: center; border: 2px dashed var(--rule); border-radius: 14px; font: 600 0.85rem var(--mono); color: var(--muted); opacity: 0; transition: opacity 0.4s 0.2s; }
.stage.done .deck::after { opacity: 1; }

/* The stage becomes the results panel: same view-transition name, never both shown. */
.stage, .results { view-transition-name: import-result; }
::view-transition-group(import-result) { animation-duration: 0.6s; animation-timing-function: cubic-bezier(0.2, 0.8, 0.2, 1); }
::view-transition-old(import-result) { animation: 0.3s ease-in both fade-out; }
::view-transition-new(import-result) { animation: 0.4s 0.2s ease-out both fade-in; }
@keyframes fade-out { to { opacity: 0; } }
@keyframes fade-in { from { opacity: 0; } }
.results #outcomes tr { animation: feed 0.3s ease-out both; animation-delay: calc(var(--i, 0) * 70ms + 0.5s); }
@media (prefers-reduced-motion: reduce) { .results #outcomes tr { animation: none; } }
.drop-zone.busy { opacity: 0.5; cursor: not-allowed; }

.leave-dialog { max-width: min(26rem, calc(100% - 2rem)); border: 1px solid var(--rule); border-radius: var(--radius); padding: 1.5rem; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.leave-dialog::backdrop { background: rgba(29, 26, 22, 0.45); backdrop-filter: blur(3px); }
.leave-dialog h2 { margin-top: 0; }
@media (prefers-reduced-motion: no-preference) {
  .leave-dialog[open] { animation: pop 0.2s cubic-bezier(0.3, 1.4, 0.5, 1); }
  @keyframes pop { from { opacity: 0; transform: scale(0.94) translateY(8px); } }
}

/* ---------- Price history ---------- */

.price-filter input { width: min(22rem, 100%); border-radius: 999px; padding: 0.5rem 1rem; }
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 19rem), 1fr)); gap: 1.25rem; margin-top: 1.25rem; }
.price-card { margin: 0; display: flex; flex-direction: column; gap: 0.3rem; }
.price-card[hidden] { display: none; }
.price-card:target { outline: 3px solid var(--mustard); }
.price-card h2 { font-size: 1.05rem; margin: 0; }
.price-sum { margin: 0; font: 0.9rem var(--mono); display: flex; gap: 0.4rem; align-items: baseline; flex-wrap: wrap; }
.price-sum .flat { color: var(--muted); }
.price-chart { width: 100%; height: auto; overflow: visible; }
.price-chart .grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 3 4; }
.price-chart .line { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; }
.price-chart .dot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; }
.price-chart .high .dot { fill: var(--tomato); }
.price-chart .low .dot { fill: var(--basil); }
.price-chart .hit { fill: transparent; }
.price-chart .point:hover .dot { r: 6; }
.price-chart .value { font: 600 11px var(--mono); fill: var(--ink-soft); }
.price-foot { display: flex; justify-content: space-between; gap: 0.5rem; margin: 0; font: 0.72rem var(--mono); color: var(--muted); }
.price-table summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.price-table table { margin-top: 0.4rem; }

/* A long batch: the file list scrolls inside a bounded box, and folds while reading. */
.file-summary { margin: 0.8rem 0 0.3rem; font: 600 0.9rem var(--mono); }
.file-list { max-height: 11rem; overflow-y: auto; margin: 0 0 0.8rem; padding: 0.4rem 0.8rem 0.4rem 2.2rem; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; }
.reading .drop-zone, .reading .file-list { display: none; }

/* Editable payments at the foot of the ticket. */
.sheet .payments li:has(input) { display: grid; grid-template-columns: minmax(0, 1fr) auto 6rem 1.7rem; gap: 0.4rem; align-items: center; text-transform: none; }
.sheet .payments li input[name="label"] { text-transform: uppercase; }
.sheet .payments li input[name="amount"] { text-align: right; }
.discount-box { display: inline-flex; align-items: center; font: 0.7rem var(--mono); color: #857d70; cursor: pointer; white-space: nowrap; }
.sheet .discount-box input[type="checkbox"] { width: 0.95rem; height: 0.95rem; margin: 0 0.3rem 0 0; }
.remove-payment { width: 1.7rem; height: 1.7rem; padding: 0; justify-content: center; font: 1.1rem/1 var(--body); background: transparent; color: #a59d8f; border: 0; opacity: 0.45; }
.payments li:hover .remove-payment, .remove-payment:focus-visible { opacity: 1; }
.remove-payment:hover { color: #fff; background: var(--tomato); box-shadow: none; transform: none; }
@media (max-width: 40rem) { .sheet .payments li:has(input) { grid-template-columns: minmax(0, 1fr) 5rem 1.7rem; } .discount-box { grid-column: 1; grid-row: 2; } .remove-payment { opacity: 1; } }
.sheet:has(.stamp) { padding-bottom: 4.4rem; }

/* The editor is swapped whole after each change: without this, Chrome's scroll anchoring
   jumps to the bottom of the ticket. */
#editor, .review { overflow-anchor: none; }

/* A long review queue: one continuous bar instead of a dot per draft. */
.queue-bar { grid-column: 2; height: 0.4rem; border-radius: 99px; background: var(--rule); overflow: hidden; }
.queue-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--basil) calc(100% - 0.7rem), var(--mustard) 0); border-radius: 99px; }
.queue-progress { max-width: 100%; }
.queue-progress ol { flex-wrap: wrap; }

/* Lines to check, from the verdict panel. */
.to-check { margin: 0.9rem 0 0; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--mustard-soft); font-size: 0.88rem; }
.to-check b { display: block; margin-bottom: 0.2rem; }
.to-check ul { margin: 0; padding-left: 1.1rem; }
.to-check a { overflow-wrap: anywhere; }
.items tr:target td { background: var(--mustard-soft); }

/* Undo toast after a deletion. */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; z-index: 20; transform: translateX(-50%);
  display: flex; gap: 1rem; align-items: center; max-width: calc(100% - 2rem);
  padding: 0.6rem 0.7rem 0.6rem 1.1rem; border-radius: 999px;
  background: var(--ink); color: var(--paper); box-shadow: var(--shadow); font-size: 0.92rem;
  animation: toast-in 0.25s ease-out, toast-out 0.4s ease-in 9.6s forwards;
}
.toast span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast button { background: var(--mustard); border-color: var(--mustard); color: #1d1a16; padding: 0.35rem 0.9rem; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 1rem); } }
@keyframes toast-out { to { opacity: 0; visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .toast { animation: toast-out 0s 10s forwards; } }

/* Permanent progress of the import, at the top of the stage. */
.stage-progress { grid-column: 1 / -1; display: grid; gap: 0.45rem; }
.progress-track { height: 0.7rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--rule); overflow: hidden; }
.progress-track span { display: block; height: 100%; width: 0; background: var(--basil); border-radius: 99px; transition: width 0.4s ease; }
.stage.done .progress-track span { background: var(--basil); }
.progress-text { margin: 0; font-size: 1rem; }
.progress-count { font: 700 1.05rem var(--mono); }
.progress-eta { color: var(--ink-soft); }
@media (prefers-reduced-motion: reduce) { .progress-track span { transition: none; } }

.price-period { display: flex; flex-wrap: wrap; gap: 0.8rem 1.2rem; align-items: center; margin: 1rem 0 1.25rem; }
.price-period label { display: flex; gap: 0.5rem; align-items: center; font-weight: 600; }
.price-period input[type="date"] { width: auto; }
.price-summary { margin-bottom: 0.5rem; }
.big-figure.up { color: var(--tomato); }
.big-figure.down { color: var(--basil); }
.promo-watch { margin-top: 1.25rem; }
.confidence { font: 0.72rem var(--mono); color: var(--muted); margin-left: 0.4rem; white-space: nowrap; }
.confidence.steady { color: var(--basil); }
.price-curves-title { margin-top: 2rem; }
.price-chart .promo .dot { fill: var(--mustard); }

/* A shop name that opens Google Maps: a small pin before it. */
.place { text-decoration-style: dotted; }
.place::before {
  content: ""; display: inline-block; width: 0.62em; height: 0.62em; margin-right: 0.3em;
  border-radius: 50% 50% 50% 0; background: var(--tomato); transform: rotate(-45deg) translateY(-0.05em);
}
/* Under the store name, in the first column of the sheet head. */
.sheet-place { grid-column: 1; margin: -0.2rem 0 0; line-height: 1.2; text-align: center; font-size: 0.72rem; }
.sheet .sheet-head:has(.sheet-place) { padding-bottom: 0.55rem; }
.sheet .place { color: #6d665a; }
.basket-band { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.3rem 1.5rem; align-items: center; }
.basket-band .eyebrow { grid-column: 1 / -1; margin: 0; }
.basket-band .big-figure, .basket-band p { margin: 0; }
.basket-band > p:last-child { max-width: 60ch; }
@media (max-width: 40rem) { .basket-band { grid-template-columns: 1fr; } }

.to-top { position: fixed; right: clamp(1rem, 3vw, 2rem); bottom: clamp(1rem, 3vw, 2rem); z-index: 15; width: 3rem; height: 3rem; display: grid; place-items: center; border-radius: 50%; background: var(--ink); color: var(--paper); box-shadow: var(--shadow); transition: transform 0.15s ease, box-shadow 0.15s ease; }
.to-top[hidden] { display: none; }
.to-top:hover { transform: translateY(-2px); box-shadow: 0 4px 0 var(--mustard); }
.to-top svg { width: 1.3rem; height: 1.3rem; }
@media print { .to-top { display: none !important; } }

/* Category legend entries lead to the category page. */
.legend a { display: grid; grid-template-columns: 0.8rem 1fr auto auto; gap: 0.6rem; align-items: center; text-decoration: none; border-radius: 8px; padding: 0.15rem 0.3rem; margin: 0 -0.3rem; }
.legend li { display: block; }
.legend a:hover { background: var(--paper-deep); }
.legend a span:nth-child(2) { text-decoration: underline; text-decoration-color: var(--mustard); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.category-title { display: flex; align-items: center; gap: 0.8rem; }
.category-title i { width: 0.8em; height: 0.8em; border-radius: 0.2em; flex: none; }
.category-products select { min-width: 11rem; }
.category-products tr.moved td { background: var(--basil-soft); }
.category-products tr.moved td { display: table-cell; }
.moved-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.8rem; }
.moved-text { flex: 1 1 20rem; }
.category-products tr.moved button { flex: none; padding: 0.25rem 0.8rem; font-size: 0.85rem; white-space: nowrap; }
table.data th.n { font: 600 0.72rem var(--mono); text-align: right; }
.category-products { margin-top: 1rem; }
.price-filter { display: block; }
.price-filter input { margin: 0; }

/* Discreet link from a ticket line to its price curve: no underline until hovered. */
.price-link { display: inline-flex; align-items: center; gap: 0.25rem; margin-left: 0.7rem; font: 0.7rem var(--mono); color: #857d70; text-decoration: none; }
.price-link svg { width: 0.95rem; height: 0.6rem; }
.price-link:hover { color: var(--receipt-ink); text-decoration: underline; text-decoration-color: var(--mustard); }
.moved-check { flex: none; display: grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; background: var(--basil); color: #fff; font: 700 0.75rem var(--body); }

/* Autosave feedback in the verdict panel. */
.saved-state { margin: 1rem 0 0; font: 600 0.8rem var(--mono); color: var(--muted); }
.saved-state.just-saved { color: var(--basil); }
@media (prefers-reduced-motion: no-preference) {
  .saved-state.just-saved { animation: saved 1.6s ease-out; }
  @keyframes saved { 0% { transform: scale(1.08); } 20% { transform: none; } }
}

/* Unfolding a card lists its price levels; the neighbours keep their own height. */
.price-grid { align-items: start; }
.price-steps summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); }
.steps-shop { margin: 0.5rem 0 0.2rem; font-size: 0.82rem; color: var(--muted); }
.price-steps ol { list-style: none; margin: 0.4rem 0 0; padding: 0 0.2rem 0 0; max-height: 16rem; overflow-y: auto; }
.price-steps li { display: grid; grid-template-columns: 4.6rem 3.6rem 1fr; gap: 0.1rem 0.5rem; align-items: baseline; padding: 0.4rem 0; border-bottom: 1px dashed var(--rule); font-size: 0.85rem; }
.step-price { font: 600 0.9rem var(--mono); }
.step-change { font: 600 0.75rem var(--mono); }
.step-promo { grid-column: 2; grid-row: 2; justify-self: start; font: 600 0.65rem var(--mono); text-transform: uppercase; letter-spacing: 0.06em; background: var(--mustard-soft); border-radius: 4px; padding: 0 0.3rem; }
.step-when { grid-column: 3; grid-row: 1 / span 2; color: var(--ink-soft); }
.step-when a { font-family: var(--mono); font-size: 0.8rem; }
/* The basket figure counts from one period to the next: a fixed width and even digits
   keep the text beside it still. */
.basket-band .big-figure { font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.step-dates { display: block; white-space: nowrap; }
.step-when small { display: block; color: var(--muted); }

/* Dashboard price rises: three columns that fit the card, dates under the prices. */
table.rises td.n { white-space: nowrap; }
table.rises td.n small { display: block; font-size: 0.72rem; }
table.rises td:first-child { overflow-wrap: anywhere; }

/* ---------- Household ---------- */

.household-members { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.6rem; }
.household-members li { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; align-items: center; justify-content: space-between; border-left: 3px solid var(--basil); padding-left: 0.8rem; }
.household-members b { font-family: var(--display); font-size: 1.1rem; }
.household-members small { color: var(--muted); }
.household-members form { margin: 0; }
/* A field and its button side by side, same height, wrapping below on a phone. */
.household-form, .invite-link { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: stretch; margin-top: 1rem; }
.household-form input, .invite-link input { flex: 1 1 14rem; width: auto; padding: 0.55rem 0.9rem; border-radius: 999px; }
.invite-link input { font: 0.85rem var(--mono); background: var(--receipt); }
.household-form button, .invite-link button { flex: none; }
.pending-title { margin: 1.5rem 0 0.25rem; }
.consent form.validate { margin-top: 1.25rem; }
.share-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 0.2rem 0.5rem; margin: 0 0 1rem; }
.share-toggle .note { flex-basis: 100%; margin: 0; }
.share-toggle label { margin: 0; }
