/* ============================================================================
   Receipt Ledger — visual system
   Order: tokens · base · layout · components · states · utilities · print
   No external assets. System fonts only. Light + dark.
   ========================================================================== */

/* ---------- 1. Tokens ------------------------------------------------------ */

:root {
  color-scheme: light;

  /* Brand — deep blue carries the trust */
  --brand:        #0f4c81;
  --brand-strong: #0a3a63;
  --brand-soft:   #e7eef6;
  --brand-ink:    #0b3a63;
  --on-brand:     #ffffff;

  /* Sky — Matheo's blue. Tints and surfaces only; never a fill under white text. */
  --sky:       #6aa6dd;
  --sky-soft:  #e3eefb;
  --sky-line:  #c8ddf2;
  --sky-ink:   #235d92;
  --sky-bar:   #dcebfa;

  /* Surfaces — soft blue daylight */
  --bg:         #eef4fb;
  --surface:    #ffffff;
  --surface-2:  #f7fafd;
  --surface-3:  #e6eef7;

  /* Ink */
  --ink:    #1b2127;
  --ink-2:  #4e5762;
  --ink-3:  #626b76;

  /* Lines */
  --line:        #dce6f0;
  --line-strong: #c4d3e3;

  /* Semantic */
  --danger:       #b23b32;
  --danger-soft:  #fbeae7;
  --danger-ink:   #8e2f27;
  --ok:           #2f6b4f;
  --ok-soft:      #e7efe9;
  --ok-ink:       #245740;
  --warn-soft:    #fbf0dc;
  --warn-ink:     #75510f;
  --info-soft:    var(--brand-soft);
  --info-ink:     var(--brand-ink);

  --focus: #1f6fb2;

  /* Elevation — hairline first, shadow second */
  --shadow-1: 0 1px 2px rgba(24, 28, 34, .05);
  --shadow-2: 0 1px 3px rgba(24, 28, 34, .07), 0 6px 18px rgba(24, 28, 34, .06);
  --shadow-bar: 0 1px 0 rgba(24, 28, 34, .06);

  /* Radii — nursery-soft, never bubbly */
  --r-sm: 10px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 26px;

  /* Space — 4pt base */
  --s1: 4px;  --s2: 8px;  --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s7: 32px; --s8: 40px;

  /* Type */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-num: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Roboto,
              "Helvetica Neue", Arial, sans-serif;

  --page: 1120px;
  --tap: 44px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --brand:        #4c93d4;   /* accents + fills carry dark ink labels */
  --brand-strong: #6aa8e0;
  --brand-soft:   #1a2b3b;
  --brand-ink:    #a8cbec;
  --on-brand:     #08192a;

  --sky:       #6aa6dd;
  --sky-soft:  #1b2937;
  --sky-line:  #2c3f52;
  --sky-ink:   #9cc6ea;
  --sky-bar:   #171b20;

  --bg:         #131619;
  --surface:    #1a1e23;
  --surface-2:  #20252b;
  --surface-3:  #262c33;

  --ink:    #e9e6e0;
  --ink-2:  #b0b7bf;
  --ink-3:  #949ba3;

  --line:        #2b3138;
  --line-strong: #3a424b;

  --danger:       #e8756b;
  --danger-soft:  #33201e;
  --danger-ink:   #f0a49c;
  --ok:           #6fbb92;
  --ok-soft:      #1a2a22;
  --ok-ink:       #93d0ad;
  --warn-soft:    #2e2618;
  --warn-ink:     #e0bd7c;
  --info-soft:    var(--brand-soft);
  --info-ink:     var(--brand-ink);

  --focus: #7fb6e8;

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .32);
  --shadow-bar: 0 1px 0 rgba(0, 0, 0, .35);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --brand: #4c93d4;  --brand-strong: #6aa8e0; --brand-soft: #1a2b3b;
    --brand-ink: #a8cbec; --on-brand: #08192a;
    --sky: #6aa6dd; --sky-soft: #1b2937; --sky-line: #2c3f52; --sky-ink: #9cc6ea; --sky-bar: #171b20;
    --bg: #131619; --surface: #1a1e23; --surface-2: #20252b; --surface-3: #262c33;
    --ink: #e9e6e0; --ink-2: #b0b7bf; --ink-3: #949ba3;
    --line: #2b3138; --line-strong: #3a424b;
    --danger: #e8756b; --danger-soft: #33201e; --danger-ink: #f0a49c;
    --ok: #6fbb92; --ok-soft: #1a2a22; --ok-ink: #93d0ad;
    --warn-soft: #2e2618; --warn-ink: #e0bd7c;
    --focus: #7fb6e8;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 1px 3px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .32);
    --shadow-bar: 0 1px 0 rgba(0, 0, 0, .35);
  }
}

/* ---------- 2. Base -------------------------------------------------------- */

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

h1, h2, h3, p, figure { margin: 0; }

h1 {
  font-size: 1.375rem;
  line-height: 1.2;
  letter-spacing: -0.012em;
  font-weight: 650;
}

h2 {
  font-size: 0.75rem;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--ink-3);
  margin: var(--s6) 0 var(--s2);
}

a { color: var(--brand-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--brand); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
:focus:not(:focus-visible) { outline: none; }

::selection { background: var(--brand-soft); color: var(--brand-ink); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

/* ---------- 3. App shell --------------------------------------------------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s2);
  background: var(--sky-bar);
  color: var(--brand-ink);
  border-bottom: 1px solid var(--sky-line);
  padding: calc(var(--s3) + env(safe-area-inset-top)) max(var(--s4), env(safe-area-inset-right))
           var(--s3) max(var(--s4), env(safe-area-inset-left));
}

[data-theme="dark"] #topbar { background: #171b20; border-bottom-color: var(--line); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #topbar { background: #171b20; border-bottom-color: var(--line); }
}

#brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  min-width: 0;
  flex: 0 1 auto;
  color: var(--brand-ink);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  min-height: var(--tap);
}
#brand:hover { color: var(--brand-ink); }
#brand .mark { width: 28px; height: 28px; flex: none; display: block; border-radius: 8px; }
#brand .wordmark { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#brand .wordmark-long { display: none; }

#nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: none;
}

#nav a,
#nav .linklike {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 var(--s2);
  border-radius: var(--r);
  color: var(--brand-ink);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}
#nav a:hover,
#nav .linklike:hover { background: rgba(15, 76, 129, .1); color: var(--brand-ink); }
#nav a.btn.primary {
  background: var(--brand);
  border: 1px solid var(--brand);
  color: var(--on-brand);
  padding: 0 var(--s3);
  font-size: 0.9375rem;
  font-weight: 650;
  white-space: nowrap;
  box-shadow: var(--shadow-1);
}
#nav a.btn.primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
  color: var(--on-brand);
}
#nav .add-long { display: none; }
[data-theme="dark"] #nav a,
[data-theme="dark"] #nav .linklike { color: var(--sky-ink); }
[data-theme="dark"] #nav a:hover,
[data-theme="dark"] #nav .linklike:hover { background: rgba(255, 255, 255, .1); color: var(--ink); }
[data-theme="dark"] #nav a.btn.primary { color: var(--on-brand); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) #nav a,
  :root:not([data-theme="light"]) #nav .linklike { color: var(--sky-ink); }
  :root:not([data-theme="light"]) #nav a:hover,
  :root:not([data-theme="light"]) #nav .linklike:hover { background: rgba(255, 255, 255, .1); color: var(--ink); }
  :root:not([data-theme="light"]) #nav a.btn.primary { color: var(--on-brand); }
}

#app {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--s5) max(var(--s4), env(safe-area-inset-left))
           calc(96px + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-right));
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s4);
  margin-bottom: var(--s4);
}
.page-head .sub { color: var(--ink-2); font-size: 0.875rem; margin-top: 2px; }

/* ---------- 4. Surfaces ---------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  margin-bottom: var(--s3);
  box-shadow: var(--shadow-1);
}
.card > :last-child { margin-bottom: 0; }
.card-title { font-weight: 650; font-size: 1rem; letter-spacing: -0.005em; }

.stack { display: flex; flex-direction: column; gap: var(--s3); }
.stack.tight { gap: var(--s2); }

/* ---------- 5. Buttons ----------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .15s ease, border-color .15s ease, transform .06s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); color: var(--on-brand); }

.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger-ink);
}
.btn.danger:hover { background: var(--danger-soft); color: var(--danger-ink); }

.btn.ghost { background: transparent; border-color: transparent; color: var(--brand-ink); }
.btn.ghost:hover { background: var(--brand-soft); }

.btn.small { min-height: 40px; padding: 0 var(--s3); font-size: 0.875rem; }
.btn.block { display: flex; width: 100%; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn .ic { width: 18px; height: 18px; flex: none; }

.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 0.875rem;
  color: var(--brand-ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.linklike.quiet { color: var(--ink-3); }
.linklike.destructive { color: var(--danger-ink); }

.actions {
  display: flex;
  gap: var(--s2);
  margin-top: var(--s5);
}
.actions .btn { flex: 1; }

/* Fixed thumb-reach bar for the primary action (mobile) */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 15;
  display: flex;
  gap: var(--s2);
  padding: var(--s3) max(var(--s4), env(safe-area-inset-left))
           calc(var(--s3) + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-top: 1px solid var(--line);
}
.actionbar .btn { flex: 1; min-height: 50px; font-size: 1rem; }
.actionbar .btn.hold { flex: 0 0 auto; padding: 0 var(--s4); }

/* ---------- 6. Forms ------------------------------------------------------- */

.field { margin-bottom: var(--s4); }
.field:last-child { margin-bottom: 0; }

label,
.label {
  display: flex;
  align-items: center;
  gap: var(--s2);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
  margin: 0 0 var(--s1);
}
.label-hint { font-weight: 500; color: var(--ink-3); }

input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px var(--s3);
  font: inherit;
  font-size: 1rem;          /* 16px — prevents iOS zoom on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}
textarea { min-height: 84px; resize: vertical; line-height: 1.45; }

input[type="number"], .num-input { font-variant-numeric: tabular-nums; }

select {
  appearance: none;
  padding-right: var(--s7);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'><path d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23626b76' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right var(--s3) center;
  background-size: 12px 8px;
  text-transform: capitalize;
}

.row { display: flex; gap: var(--s3); }
.row > * { flex: 1; min-width: 0; }
.row .narrow { flex: 0 0 34%; }

.amount-field input { font-size: 1.125rem; font-weight: 650; font-variant-numeric: tabular-nums; }

/* Marks a value Claude filled in, so it reads as "please check me" */
.field.ai-filled > label::after {
  content: "auto-filled";
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-ink);
  background: var(--brand-soft);
  padding: 2px 7px;
  border-radius: 999px;
}

/* ---------- 7. Totals ------------------------------------------------------ */

.totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: var(--s2);
  margin-bottom: var(--s4);
}

.total-box {
  background: var(--brand);
  color: var(--on-brand);
  border: 1px solid var(--brand);
  border-radius: var(--r-xl);
  padding: var(--s3) var(--s4) var(--s4);
  box-shadow: var(--shadow-1);
}
.total-box .label {
  color: inherit;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: .92;
}
.total-box .value {
  font-family: var(--font-num);
  font-size: 1.5rem;
  line-height: 1.15;
  font-weight: 680;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: var(--s1);
}
.total-box .foot { font-size: 0.75rem; opacity: .88; margin-top: 2px; color: inherit; }

.total-box.alt {
  background: var(--sky-soft);
  color: var(--ink);
  border-color: var(--sky-line);
}
.total-box.alt .label { color: var(--sky-ink); opacity: 1; }
.total-box.alt .foot { color: var(--sky-ink); opacity: 1; }

/* ---------- 7b. Hero — who this ledger is for ------------------------------ */

.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: var(--s3);
  background: var(--sky-soft);
  border: 1px solid var(--sky-line);
  border-radius: var(--r-lg);
  padding: var(--s4);
  margin-bottom: var(--s3);
}
.hero .hero-mark {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--sky-line);
  display: grid; place-items: center;
  color: var(--sky-ink);
}
.hero .hero-mark .ic { width: 26px; height: 26px; }
.hero-text { min-width: 0; }
.hero-title { font-weight: 650; font-size: 0.9375rem; letter-spacing: -0.005em; color: var(--ink); }
.hero-sub { font-size: 0.8125rem; color: var(--sky-ink); margin-top: 1px; }
.hero .stars {
  position: absolute;
  right: var(--s2); top: 0; bottom: 0;
  width: 118px;
  color: var(--sky);
  opacity: .34;
  pointer-events: none;
}

/* Clouds by day, moon at night */
.stars .moon { display: none; }
[data-theme="dark"] .stars .moon { display: block; }
[data-theme="dark"] .stars .cloud { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .stars .moon { display: block; }
  :root:not([data-theme="light"]) .stars .cloud { display: none; }
}

/* ---------- 8. Entry list -------------------------------------------------- */

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  margin: var(--s6) 0 var(--s2);
}
.list-head h2 { margin: 0; }

.seg {
  display: none;                      /* density switch is a desktop affordance */
  padding: 3px;
  gap: 2px;
  background: var(--surface-3);
  border-radius: 999px;
}
.seg button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 var(--s3);
  border: none;
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}
.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.list { display: grid; gap: var(--s2); }

.entry-card {
  display: block;
  color: inherit;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--s3) var(--s4);
  box-shadow: var(--shadow-1);
  transition: border-color .15s ease, background-color .15s ease;
}
.entry-card:hover { border-color: var(--line-strong); background: var(--surface-2); color: inherit; }
.entry-card:active { background: var(--surface-3); }

.entry-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s3);
}
.entry-merchant {
  font-weight: 650;
  font-size: 1rem;
  letter-spacing: -0.008em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-amount {
  font-family: var(--font-num);
  font-weight: 680;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.entry-sub {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s3);
  margin-top: var(--s1);
  color: var(--ink-3);
  font-size: 0.8125rem;
}
.entry-meta { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
.entry-nok { font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry-desc {
  margin-top: var(--s2);
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.4;
  text-wrap: pretty;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.clip .ic { width: 13px; height: 13px; }

/* Category badge — hue-tinted, low chroma */
.badge {
  --h: 250; --c: .02;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  background: #eceae5;
  color: #575e66;
  background: oklch(94.5% var(--c) var(--h));
  color: oklch(40% calc(var(--c) * 3.2) var(--h));
}
.badge .ic { width: 12px; height: 12px; flex: none; }
.badge[data-cat="accommodation"] { --h: 245; --c: .035; }
.badge[data-cat="food"]          { --h: 75;  --c: .05; }
.badge[data-cat="baby"]          { --h: 320; --c: .035; }
.badge[data-cat="medical"]       { --h: 25;  --c: .045; }
.badge[data-cat="transport"]     { --h: 200; --c: .04; }
.badge[data-cat="clothing"]      { --h: 45;  --c: .04; }
.badge[data-cat="household"]     { --h: 150; --c: .035; }
.badge[data-cat="other"]         { --h: 250; --c: .015; }

[data-theme="dark"] .badge,
.badge { }
[data-theme="dark"] .badge {
  background: oklch(28% calc(var(--c) * 1.4) var(--h));
  color: oklch(84% calc(var(--c) * 2.2) var(--h));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge {
    background: oklch(28% calc(var(--c) * 1.4) var(--h));
    color: oklch(84% calc(var(--c) * 2.2) var(--h));
  }
}

/* Dense "statement" rows — desktop density switch */
.list.rows { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-1); }
.list.rows .entry-card {
  display: flex;
  align-items: center;
  gap: var(--s4);
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  padding: var(--s3) var(--s4);
}
.list.rows .entry-card:first-child { border-top: none; }
/* Flatten the two rows into one line; order below re-sequences the parts. */
.list.rows .entry-head,
.list.rows .entry-sub,
.list.rows .entry-meta { display: contents; }
.list.rows .entry-date {
  order: 1; flex: 0 0 84px;
  color: var(--ink-2); font-size: 0.875rem; font-variant-numeric: tabular-nums;
}
.list.rows .entry-merchant { order: 2; flex: 1 1 auto; min-width: 0; font-size: 0.9375rem; }
.list.rows .badge { order: 3; flex: 0 0 auto; }
.list.rows .clip { order: 4; flex: 0 0 auto; width: 34px; justify-content: flex-end; }
.list.rows .entry-amount { order: 5; flex: 0 0 132px; text-align: right; margin-left: auto; }
.list.rows .entry-nok {
  order: 6; flex: 0 0 118px; text-align: right;
  color: var(--ink-3); font-size: 0.8125rem;
}
.list.rows .entry-desc { display: none; }

/* ---------- 9. Notices, empty, skeletons ----------------------------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--s2);
  padding: var(--s3) var(--s4);
  border-radius: var(--r);
  font-size: 0.9rem;
  line-height: 1.4;
  margin: var(--s3) 0;
  text-wrap: pretty;
}
.notice::before {
  content: "";
  flex: none;
  width: 8px; height: 8px;
  margin-top: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: .55;
}
.notice.info { background: var(--info-soft); color: var(--info-ink); }
.notice.warn { background: var(--warn-soft); color: var(--warn-ink); }
.notice.ok   { background: var(--ok-soft);   color: var(--ok-ink); }
.notice.error { background: var(--danger-soft); color: var(--danger-ink); }
.notice small { display: block; opacity: .85; margin-top: 2px; }
.notice .notice-body { flex: 1; min-width: 0; }
.notice .btn { margin-top: var(--s2); }
.notice:has(.spinner)::before { display: none; }

.empty {
  text-align: center;
  padding: var(--s8) var(--s5);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}
.empty .empty-mark {
  width: 56px; height: 56px;
  margin: 0 auto var(--s3);
  border-radius: 50%;
  background: var(--sky-soft);
  border: 1px solid var(--sky-line);
  color: var(--sky-ink);
  display: grid; place-items: center;
}
.empty .empty-mark .ic { width: 26px; height: 26px; }
.empty h3 { font-size: 1rem; font-weight: 650; margin-bottom: var(--s1); }
.empty p { color: var(--ink-2); font-size: 0.9rem; max-width: 34ch; margin: 0 auto; text-wrap: pretty; }
.empty .btn { margin-top: var(--s4); }

.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  flex: none;
  border: 2px solid color-mix(in srgb, currentColor 28%, transparent);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: currentColor; opacity: .8; }
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: var(--surface-3);
  border-radius: 6px;
  color: transparent;
}
.skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 70%, transparent), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s ease-in-out infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .skeleton::after { animation: none; } }

.sk-row { display: flex; justify-content: space-between; gap: var(--s4); }
.sk-line { height: 12px; }
.sk-line.w40 { width: 40%; } .sk-line.w25 { width: 25%; }
.sk-line.w60 { width: 60%; } .sk-line.w90 { width: 90%; }
.sk-line.tall { height: 16px; }

/* ---------- 10. Receipt capture -------------------------------------------- */

.dropzone {
  display: block;
  width: 100%;
  border: 1.5px dashed var(--sky-line);
  border-radius: var(--r-xl);
  background: var(--sky-soft);
  padding: var(--s6) var(--s4);
  text-align: center;
  color: var(--ink-2);
  transition: border-color .15s ease, background-color .15s ease;
}
.dropzone.is-over { border-color: var(--focus); background: var(--brand-soft); }
.dropzone .dz-mark {
  width: 52px; height: 52px;
  margin: 0 auto var(--s3);
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--sky-line);
  color: var(--sky-ink);
  display: grid;
  place-items: center;
}
.dropzone .dz-mark .ic { width: 24px; height: 24px; }
.dropzone strong { display: block; color: var(--ink); font-size: 1rem; font-weight: 650; }
.dropzone .dz-hint { font-size: 0.875rem; color: var(--ink-3); margin-top: 2px; }
.dropzone .dz-actions { display: flex; gap: var(--s2); justify-content: center; margin-top: var(--s4); flex-wrap: wrap; }
.dropzone .dz-actions .btn { flex: 1 1 150px; max-width: 240px; }

/* Progress card: upload → read → review */
.progress-card {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--r-lg);
  padding: var(--s4);
}
.progress-card .pc-head { display: flex; align-items: center; gap: var(--s2); font-weight: 600; color: var(--ink); }
.progress-card .pc-sub { color: var(--ink-3); font-size: 0.8125rem; margin-top: 2px; padding-left: 24px; }
.progress-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: var(--s3);
}
.progress-track span {
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: var(--brand);
  animation: slide 1.5s ease-in-out infinite;
}
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress-track span { animation: none; width: 60%; margin-left: 0; } }

.steps { display: flex; gap: var(--s4); margin-top: var(--s3); font-size: 0.78rem; color: var(--ink-3); }
.steps li { display: flex; align-items: center; gap: 6px; list-style: none; }
.steps { padding: 0; }
.steps li::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--line-strong);
}
.steps li[data-state="done"] { color: var(--ok-ink); }
.steps li[data-state="done"]::before { background: var(--ok); }
.steps li[data-state="active"] { color: var(--ink); font-weight: 600; }
.steps li[data-state="active"]::before { background: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); }

.thumbs { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }
.thumb { position: relative; }
.thumb:nth-child(odd)  { transform: rotate(-1.4deg); }
.thumb:nth-child(even) { transform: rotate(1.1deg); }
.thumbs img,
.thumbs .pdf {
  width: 88px; height: 88px;
  object-fit: cover;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface);
  display: block;
}
.thumbs .pdf {
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.thumb .thumb-remove {
  position: absolute;
  top: -6px; right: -6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow-1);
  padding: 0;
  line-height: 1;
}

/* ---------- 11. Line items ------------------------------------------------- */

.items { border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.item-row {
  padding: var(--s3);
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.item-row:first-child { border-top: none; }
.item-row + .item-row { background: var(--surface); }
.item-main { display: flex; gap: var(--s2); }
.item-main > :first-child { flex: 1; min-width: 0; }
.item-main .narrow { flex: 0 0 108px; }
.item-row .item-desc-input { margin-top: var(--s2); }
.item-orig { color: var(--ink-3); font-size: 0.75rem; margin-top: var(--s1); }
.item-foot { display: flex; justify-content: flex-end; margin-top: var(--s1); }
.items-empty { padding: var(--s4); color: var(--ink-3); font-size: 0.875rem; text-align: center; background: var(--surface); }

/* Read-only item list (used in the review summary) */
.item-line { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-top: 1px dotted var(--line); }
.item-line:first-child { border-top: none; }
.item-name { font-weight: 600; font-size: 0.9375rem; }
.item-desc { color: var(--ink-2); font-size: 0.8125rem; }
.item-price { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- 12. Export ----------------------------------------------------- */

.export-grid { display: grid; gap: var(--s3); }
.export-card { display: flex; flex-direction: column; gap: var(--s2); }
.export-card .ec-head { display: flex; align-items: center; gap: var(--s3); }
.export-card .ec-mark {
  width: 40px; height: 40px; flex: none;
  border-radius: var(--r);
  background: var(--sky-soft);
  border: 1px solid var(--sky-line);
  color: var(--sky-ink);
  display: grid; place-items: center;
}
.export-card .ec-mark .ic { width: 20px; height: 20px; }
.export-card h3 { font-size: 0.9375rem; font-weight: 650; }
.export-card p { color: var(--ink-2); font-size: 0.875rem; text-wrap: pretty; }
.export-card .btn { margin-top: auto; }

/* ---------- 13. Login ------------------------------------------------------ */

.login-wrap {
  min-height: calc(100dvh - 200px);
  display: grid;
  place-items: center;
  padding: var(--s6) 0;
}
.login-card { width: 100%; max-width: 380px; margin: 0; padding: var(--s6); }
.login-mark { width: 56px; height: 56px; margin-bottom: var(--s4); display: block; }
.login-sky {
  position: relative;
  height: 74px;
  margin: calc(var(--s6) * -1) calc(var(--s6) * -1) var(--s5);
  background: var(--sky-soft);
  border-bottom: 1px solid var(--sky-line);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  overflow: hidden;
  color: var(--sky);
}
.login-sky svg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .5; }
.login-card .login-mark { margin-top: -46px; position: relative; }
.login-card h1 { margin-bottom: var(--s1); }
.login-card .sub { color: var(--ink-2); font-size: 0.9rem; margin-bottom: var(--s5); text-wrap: pretty; }
.login-foot { text-align: center; color: var(--ink-3); font-size: 0.8125rem; margin-top: var(--s4); }

/* ---------- 14. Utilities -------------------------------------------------- */

.muted { color: var(--ink-2); font-size: 0.9rem; }
.tiny { font-size: 0.8125rem; color: var(--ink-3); }
.center { text-align: center; }
.mt { margin-top: var(--s4); }
.nowrap { white-space: nowrap; }
.tabular { font-variant-numeric: tabular-nums; }
.only-desktop { display: none; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.divider { height: 1px; background: var(--line); margin: var(--s5) 0; border: 0; }

/* ---------- 15. Desktop ---------------------------------------------------- */

@media (min-width: 430px) {
  #brand .wordmark-long { display: inline; }
}

@media (min-width: 700px) {
  .totals { gap: var(--s3); }
  .total-box .value { font-size: 1.75rem; }
  .export-grid { grid-template-columns: repeat(3, 1fr); }
  .list { grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
  .list.rows { grid-template-columns: 1fr; }
}

@media (min-width: 900px) {
  #app { padding-top: var(--s7); padding-bottom: var(--s8); }
  h1 { font-size: 1.75rem; }
  .only-desktop { display: inline-flex; }
  #nav .add-long { display: inline; }
  #brand { font-size: 1rem; }
  #nav { gap: var(--s1); }
  #nav a, #nav .linklike { padding: 0 var(--s3); }
  #nav a.btn.primary { padding: 0 var(--s4); }
  .seg { display: inline-flex; }

  /* The primary action lives in the page head; no thumb bar needed */
  .actionbar.mobile-only { display: none; }
  .actionbar:not(.mobile-only) {
    position: static;
    padding: 0;
    background: none;
    backdrop-filter: none;
    border: none;
    justify-content: flex-end;
    margin-top: var(--s5);
  }
  .actionbar:not(.mobile-only) .btn { flex: 0 0 auto; min-width: 160px; min-height: var(--tap); }

  /* Entry screen: receipt on the left, form on the right */
  .entry-layout {
    display: grid;
    grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
    gap: var(--s5);
    align-items: start;
  }
  .entry-layout .receipt-panel { position: sticky; top: calc(72px + var(--s5)); }
  .login-wrap { min-height: calc(100dvh - 240px); }
}

@media (min-width: 1180px) {
  .list:not(.rows) { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- 16. Print (app screens) ---------------------------------------- */

@media print {
  #topbar, .actionbar, .seg, .btn { display: none !important; }
  #app { max-width: none; padding: 0; }
  .card, .entry-card { box-shadow: none; break-inside: avoid; }
}

/* ---------- 8. Post-design features (added after the redesign handoff) -----
   Review badge, claim exclusion, email evidence tiles. Uses handoff tokens. */

.badge.review { background: var(--warn-soft); color: var(--warn-ink); }

.item-row.excluded .item-main input,
.item-row.excluded .item-desc-input { text-decoration: line-through; opacity: 0.55; }

.item-exclude {
  display: inline-flex; align-items: center; gap: var(--s2);
  margin-right: auto;
  font-size: 0.8125rem; font-weight: 600; color: var(--ink-2);
  min-height: var(--tap); cursor: pointer;
}
.item-exclude input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand); }

.flag-hint {
  background: var(--warn-soft); color: var(--warn-ink);
  border-radius: var(--r-sm); padding: var(--s1) var(--s3);
  font-size: 0.8125rem; margin-top: var(--s2);
}

a.thumb { text-decoration: none; }
.thumbs .pdf .ic { width: 16px; height: 16px; margin-right: 4px; }

/* Inbox — email arrivals staged for review, visually apart from the ledger */
.inbox-card { border-style: dashed; border-color: var(--sky-line); background: var(--sky-soft); }
.inbox-card .entry-nok { color: var(--sky-ink); font-size: 0.8125rem; font-style: italic; }
