/* ==========================================================================
   Wryght · Project Expenses: design system
   Loaded last. Every control in the app follows these rules; screens may lay
   components out, but must not invent new sizes, weights or corners.
   See /components.html for every component side by side.
   ==========================================================================

   TYPE (5 sizes, 4 weights)          SIZES FOR THINGS YOU TAP (3 only)
   12  caption   (500/600)            36  small  · inline text actions (+ Page, Add item)
   14  secondary (500/600)            44  medium · secondary buttons, choices, compact fields, icon buttons
   16  body      (400/600/700)        56  large  · main actions, form fields
   20  heading   (700)                64  hero   · the one big amount field
   30  display   (800)
                                      CORNERS
   SPACING 4 · 8 · 12 · 16 · 24 · 32   8 small parts · 12 buttons & fields · 16 cards & sheets · round = choices & icons
*/
:root {
  --h-sm: 36px; --h-md: 44px; --h-lg: 56px; --h-hero: 64px;
  --w-regular: 400; --w-medium: 500; --w-semi: 600; --w-bold: 700; --w-display: 800;
  --r-control: var(--r-md);   /* 12: buttons, fields, tiles */
  --r-container: var(--r-lg); /* 16: cards, sheets, panels */
}

/* ---------- Buttons: 4 styles × 3 sizes ---------- */
.btn { height: var(--h-md); padding: 0 var(--s4); border-radius: var(--r-control); font-size: var(--t-md); font-weight: var(--w-semi); gap: var(--s2); }
.btn svg.i { width: 20px; height: 20px; }
.btn-big { height: var(--h-lg); font-size: var(--t-md); font-weight: var(--w-bold); border-radius: var(--r-control); }
.btn-sm { height: var(--h-sm); padding: 0 var(--s3); font-size: var(--t-sm); }
.btn-sm svg.i { width: 16px; height: 16px; }
.btn-ink { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }        /* Main */
.btn-soft { background: var(--surface); border-color: var(--line); color: var(--text); }   /* Secondary */
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }  /* Quiet */
.btn-bad { background: transparent; border-color: var(--line); color: var(--bad); }       /* Danger */
.btn-bad-solid { background: var(--bad); border-color: var(--bad); color: var(--on-ink); }
.btn-square { width: var(--h-md); height: var(--h-md); padding: 0; }
.btn-square svg.i { width: 20px; height: 20px; }
.btn[disabled] { opacity: .45; }
.btn-tall { height: var(--h-lg); }

/* Round icon button (close, back): medium */
.circle-btn { width: var(--h-md); height: var(--h-md); }
.circle-btn svg.i { width: 20px; height: 20px; }

/* Inline text action (+ Add item, + Page): small */
.add-link, .thumb-page { height: var(--h-sm); font-size: var(--t-sm); font-weight: var(--w-bold); border-radius: var(--r-sm); }
.add-link svg.i, .thumb-page svg.i { width: 16px; height: 16px; }

/* ---------- Choices (pills / chips): medium, round ---------- */
.chip, .pill-btn, .it-cat .pill-btn, .period-grid .pill-btn {
  height: var(--h-md); padding: 0 var(--s4); border-radius: var(--r-full);
  font-size: var(--t-sm); font-weight: var(--w-semi); gap: var(--s2);
}
.chip svg.i, .pill-btn svg.i { width: 16px; height: 16px; }
.chip[aria-pressed="true"], .pill-btn[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); font-weight: var(--w-semi); }

/* ---------- Fields: large; compact (inside the item card): medium; hero: the amount ---------- */
.input, .pickbox, .select { height: var(--h-lg); border-radius: var(--r-control); font-size: var(--t-md); }
.select-lg { height: var(--h-lg); font-size: var(--t-md); font-weight: var(--w-semi); }
.input-amount { height: var(--h-hero); font-size: var(--t-xl); font-weight: var(--w-bold); }
.it-f .input, .it-f .unit-btn, .it-name { height: var(--h-md); min-height: var(--h-md); }
.label { font-size: var(--t-sm); font-weight: var(--w-semi); color: var(--text-2); }
.it-f span { font-size: var(--t-xs); font-weight: var(--w-semi); }

/* ---------- Tiles (Upload receipt / Camera / Gallery): large ---------- */
.source-c { height: var(--h-lg); border-radius: var(--r-control); font-size: var(--t-md); font-weight: var(--w-semi); }
.source-c svg.i { width: 20px; height: 20px; }
.pa { border-radius: var(--r-control); font-size: var(--t-xs); font-weight: var(--w-semi); }

/* ---------- Containers: 16px corners ---------- */
.card, .proj-card, .spend, .items-card, .group, .sheet, .pending-card { border-radius: var(--r-container); }
/* Slide-up cards sit on the bottom edge: only the top corners are rounded */
.sheet { border-radius: var(--r-container) var(--r-container) 0 0; }
.banner, .resume, .notice, .notice-mini, .cat-bar { border-radius: var(--r-control); font-size: var(--t-sm); }
.fin-card { border-radius: var(--r-container); min-height: var(--h-lg); font-size: var(--t-md); font-weight: var(--w-semi); }
.new-proj { min-height: var(--h-lg); border-radius: var(--r-container); font-size: var(--t-md); font-weight: var(--w-semi); }

/* ---------- Headings ---------- */
.page-title, .page-title-sm { font-size: var(--t-xl); font-weight: var(--w-display); letter-spacing: -.02em; }
.sheet h2, .section-head h2 { font-size: var(--t-lg); font-weight: var(--w-bold); }

/* ---------- Status lines and messages ---------- */
.status { font-size: var(--t-sm); font-weight: var(--w-semi); }
.toast { font-size: var(--t-sm); font-weight: var(--w-semi); border-radius: var(--r-control); }

/* ==========================================================================
   Components added with the system
   ========================================================================== */
/* Brand header (Projects page): logo icon + company name, left-aligned as one unit */
.brand-top { display: flex; align-items: center; gap: var(--s3); min-height: var(--h-lg); }
.brand-icon { width: 32px; height: 36px; object-fit: contain; }
.brand-name { font-size: var(--t-md); font-weight: var(--w-bold); letter-spacing: .01em; }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .brand-icon { filter: invert(1); } }
html[data-theme="dark"] .brand-icon { filter: invert(1); }
.greeting { margin: 0 0 var(--s1); font-size: var(--t-md); font-weight: var(--w-medium); color: var(--text-2); }
.test-link { display: block; margin: var(--s6) auto var(--s4); height: var(--h-sm); padding: 0 var(--s3); border: 0; background: none; color: var(--text-3); font-size: var(--t-xs); font-weight: var(--w-semi); }

/* "New" sits on its own line above the latest expense, so names stay aligned */
.new-tag { display: block; margin-bottom: 2px; font-size: var(--t-xs); font-weight: var(--w-bold); letter-spacing: .04em; text-transform: uppercase; color: var(--text-2); }
.pill-new { display: none; }

/* Item name suggestions float over the card below the name box: nothing underneath moves */
.it-row { position: relative; }
.it-suggest { position: absolute; z-index: 5; left: var(--s4); right: var(--s4); top: calc(var(--s4) + var(--h-md) + 4px); display: grid; gap: 0; padding: var(--s1); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); box-shadow: 0 8px 24px color-mix(in srgb, var(--g11) 14%, transparent); }
.it-suggest:empty { display: none; }
.sug { display: flex; align-items: center; min-height: var(--h-md); padding: 0 var(--s3); border: 0; border-radius: var(--r-sm); background: transparent; text-align: left; font-size: var(--t-md); font-weight: var(--w-medium); color: var(--text); }
.sug:active, .sug:hover { background: var(--surface-2); }
.sug span:first-of-type { font-weight: var(--w-medium); }

/* Category sheet */
.cat-sheet-head { display: flex; align-items: center; gap: var(--s3); }
.cat-sheet-head .num { font-size: var(--t-lg); font-weight: var(--w-bold); }
.cat-sheet-list { max-height: 50vh; overflow: auto; border-radius: var(--r-control); }

/* Finish prompt: only appears when the project is probably done */
.finish-card { display: grid; gap: var(--s3); padding: var(--s4); border-radius: var(--r-container); background: var(--surface); box-shadow: var(--shadow); border: 1.5px solid var(--ink); }
.fc-text { display: flex; gap: var(--s3); align-items: flex-start; font-size: var(--t-sm); }
.fc-text strong { font-size: var(--t-md); }
.fc-text svg.i { width: 20px; height: 20px; flex: none; margin-top: 2px; }

/* Receipt viewer: Check (full width) above Delete | Back */
.rv-bottom .rv-check { grid-column: 1 / -1; background: #fff; color: #111113; border: 0; }
.rv-back { background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, .35); }

/* ==========================================================================
   A4 report pages: 794 × 1123 px = 210 × 297 mm; 15 mm margins. Shrunk to fit on screen.
   Report type: 10pt body (13px), 8pt notes (11px), 16pt title (21px): print sizes, not app sizes.
   ========================================================================== */
.pdf-scroll { padding: var(--s3) 12px var(--s5); background: var(--g4); overflow: auto; }
.a4-stack { display: grid; justify-content: center; gap: 16px; zoom: var(--a4-zoom, .5); }
.a4 { width: 794px; height: 1123px; box-sizing: border-box; padding: 57px 57px 40px; display: grid; grid-template-rows: auto 1fr auto;
  background: #fff; color: #111113; box-shadow: 0 2px 12px rgba(0, 0, 0, .18); font-size: 13px; line-height: 1.4; }
.a4-head { display: grid; grid-template-columns: 52px 1fr auto; gap: 16px; align-items: center; padding-bottom: 16px; border-bottom: 2px solid #111113; }
.a4-logo { width: 52px; height: 59px; object-fit: contain; }
.a4-title { display: grid; gap: 2px; }
.a4-co { font-size: 11px; font-weight: 700; letter-spacing: .14em; color: #63636a; }
.a4-title strong { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.a4-title span:last-child { font-size: 13px; font-weight: 600; }
.a4-meta { margin: 0; display: grid; grid-template-columns: auto auto; gap: 2px 10px; font-size: 11px; text-align: right; }
.a4-meta dt { color: #63636a; } .a4-meta dd { margin: 0; font-weight: 600; }
.a4-head-sm { grid-template-columns: 36px 1fr auto; padding-bottom: 10px; }
.a4-head-sm .a4-logo { width: 36px; height: 41px; }
.a4-head-sm .a4-title strong { font-size: 15px; }
.a4-body { overflow: hidden; padding-top: 20px; min-height: 0; }
.a4-sum { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; margin-bottom: 24px; }
.a4 table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.a4 th { text-align: left; font-size: 11px; font-weight: 700; color: #63636a; text-transform: uppercase; letter-spacing: .06em; padding: 6px 8px; border-bottom: 1px solid #111113; }
.a4 td { padding: 7px 8px; border-bottom: 1px solid #e0e0e3; vertical-align: top; }
.a4 .r { text-align: right; white-space: nowrap; }
.a4-tot td { font-weight: 800; border-top: 2px solid #111113; border-bottom: 0; }
.a4-budget { display: grid; gap: 8px; align-content: start; }
.a4-budget div { display: grid; padding: 10px 12px; background: #f6f6f7; border-radius: 6px; }
.a4-budget span { font-size: 11px; color: #63636a; } .a4-budget strong { font-size: 16px; }
.a4-tbl .c-date { width: 96px; white-space: nowrap; } .a4-tbl .c-cat { width: 110px; } .a4-tbl .c-amt { width: 96px; }
.a4-sup { display: block; font-size: 11px; color: #63636a; }
.a4-foot { display: flex; justify-content: space-between; padding-top: 10px; border-top: 1px solid #e0e0e3; font-size: 11px; color: #63636a; }
.a4-h3 { margin: 0 0 12px; font-size: 15px; }
.a4-photos { display: grid; gap: 16px; }
.a4-photo { margin: 0; display: grid; gap: 6px; }
.a4-ph { height: 400px; display: grid; place-content: center; justify-items: center; gap: 8px; border: 1px dashed #a6a6ac; border-radius: 6px; color: #82828a; font-size: 13px; }
.a4-ph svg.i { width: 32px; height: 32px; }
.a4-photo figcaption { font-size: 11px; color: #63636a; }

@media print {
  @page { size: A4; margin: 0; }
  html, body { background: #fff !important; }
  body > *:not(#overlay), .pdf-bar, .pdf-actions { display: none !important; }
  .pdf-view { position: static !important; display: block !important; background: #fff !important; }
  .pdf-scroll { padding: 0 !important; overflow: visible !important; background: #fff !important; }
  .a4-stack { zoom: 1 !important; display: block !important; }
  .a4 { box-shadow: none; break-after: page; }
}
/* Danger must never look like Secondary: grey fill instead of white (greyscale until colour is approved) */
.btn-bad { background: var(--surface-2); border-color: transparent; color: var(--bad); font-weight: var(--w-bold); }

/* Project page: tighter spending card so the Expenses heading and first expense show without scrolling */
.spend { padding: var(--s4); }
.spend .sum-pair { margin-top: var(--s3); }
.spend .spend-list { margin-top: var(--s3); }
.cat-row { min-height: var(--h-lg); padding: var(--s2) 0; }
.see-all { display: flex; align-items: center; justify-content: center; gap: var(--s1); width: 100%; height: var(--h-md); margin-top: var(--s2); border: 0; border-radius: var(--r-control); background: none; color: var(--text); font: inherit; font-size: var(--t-sm); font-weight: var(--w-bold); }
.see-all svg.i { width: 16px; height: 16px; }
.see-all:active { background: var(--surface-2); }

/* Bottom bar total: always in view while filling in a receipt */
.sb-total { display: flex; align-items: center; gap: var(--s3); min-height: 28px; margin-bottom: var(--s2); font-size: var(--t-sm); color: var(--text-2); }
.sb-total strong { font-size: var(--t-md); color: var(--text); font-weight: var(--w-bold); }
.sb-total .sb-ok, .sb-total .sb-warn { display: inline-flex; align-items: center; gap: var(--s1); font-weight: var(--w-semi); }
.sb-total .sb-warn { color: var(--text); }
.sb-total svg.i { width: 14px; height: 14px; }
.sb-total .faint { margin-left: auto; }

/* Photo viewer: photo centred, tap to zoom, Close at the bottom */
.pviewer { position: fixed; inset: 0; z-index: 40; display: grid; grid-template-rows: 1fr auto; background: #111113; color: #fff; }
.pv-stage { overflow: auto; display: grid; place-items: center; padding: var(--s4); touch-action: pan-x pan-y pinch-zoom; }
.pv-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: var(--r-sm); cursor: zoom-in; }
.pv-stage.zoomed { place-items: start; }
.pv-stage.zoomed img { max-width: none; max-height: none; width: 250%; cursor: zoom-out; }
.pv-bottom { display: grid; gap: var(--s3); justify-items: center; padding: var(--s3) var(--s4) calc(var(--s4) + env(safe-area-inset-bottom, 0px)); }
.pv-bottom .faint { color: rgba(255, 255, 255, .55); font-size: var(--t-xs); }
.pv-close { width: 100%; background: #fff; color: #111113; border: 0; }
@media (min-width: 520px) { .pviewer { left: var(--side); right: var(--side); } }

/* PDF: expense row, then its items underneath */
.a4-tbl .c-qty { width: 72px; } .a4-tbl .c-up { width: 92px; }
.a4-exp td { padding-top: 12px; border-bottom: 1px solid #cbcbcf; background: #f6f6f7; }
.a4-exp .a4-sup { display: inline; margin-left: 6px; }
.a4-item td { padding: 4px 8px; border-bottom: 1px solid #ededef; font-size: 12px; }
.a4-item td:nth-child(2) { padding-left: 14px; }

/* Skeleton loading: grey shapes of the coming screen, softly pulsing */
.skeleton { display: grid; gap: var(--s3); padding: var(--s4) 0; }
.sk { background: var(--surface-2); border-radius: var(--r-control); animation: sk-pulse 1.2s ease-in-out infinite; }
.sk-title { height: 34px; width: 70%; }
.sk-line { height: 20px; width: 45%; } .sk-short { width: 35%; }
.sk-card { height: 132px; border-radius: var(--r-container); }
.sk-tall { height: 300px; }
.sk-btn { height: var(--h-lg); }
.sk-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s2); }
.sk-tile { height: 76px; }
.sk-row-item { height: 64px; }
@keyframes sk-pulse { 50% { opacity: .5; } }
@media (prefers-reduced-motion: reduce) { .sk { animation: none; } }

/* Projects: "+ New" next to the title, always in reach however many projects there are */
.ph-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.new-top { border-radius: var(--r-full); padding: 0 var(--s4); }
.to-top { white-space: nowrap; } /* "See all 126 expenses" stays on one line */
/* Bottom bar with a total: solid background and a hairline, so the total never floats over the list */
.savebar:has(.sb-total) { background: var(--bg); border-top: 1px solid var(--line); padding-top: var(--s3); box-shadow: 0 -8px 16px color-mix(in srgb, var(--bg) 85%, transparent); }

/* Bottom bar total: tap (pencil) to change it */
.sb-edit { display: inline-flex; align-items: center; gap: var(--s2); height: var(--h-sm); margin-left: calc(-1 * var(--s2)); padding: 0 var(--s2); border: 0; border-radius: var(--r-sm); background: none; color: var(--text-2); font: inherit; font-size: var(--t-sm); }
.sb-edit strong { font-size: var(--t-md); color: var(--text); }
.sb-edit svg.i { width: 16px; height: 16px; color: var(--text); }
.sb-edit:active { background: var(--surface-2); }
.sb-total .sb-pos { margin-left: auto; }
.sb-total .faint:not(.sb-pos) { margin-left: 0; }

/* Full-screen layers: centred when they fit, scroll from the top when they don't; contents swap without a flash */
.overlay { align-items: start; }
.overlay .overlay-in { margin-block: auto; }
.overlay-in.swap-in { animation: swap-in .22s ease-out; }
@keyframes swap-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .overlay-in.swap-in { animation: none; } }

/* Saved screen: a warm line under the amount */
.cheer { margin: calc(-1 * var(--s3)) 0 0; font-size: var(--t-md); font-weight: var(--w-medium); color: var(--text-2); text-wrap: balance; }

/* A layer replacing another appears instantly (no fade from transparent), so nothing flashes through */
#overlay > .no-fade { animation: none !important; }

/* Welcome screen (only when the app opens): logo, greeting, one calm line; fades away */
.welcome { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: var(--s6); background: var(--bg); transition: opacity .35s ease; }
.welcome.out { opacity: 0; pointer-events: none; }
.welcome-in { display: grid; justify-items: center; gap: var(--s3); text-align: center; animation: welcome-in .5s ease-out; }
.welcome-in img { width: 48px; height: 54px; object-fit: contain; margin-bottom: var(--s3); }
.welcome-in h1 { margin: 0; font-size: var(--t-xl); font-weight: var(--w-display); letter-spacing: -.02em; }
.welcome-in p { margin: 0; font-size: var(--t-md); color: var(--text-2); }
@keyframes welcome-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .welcome-in { animation: none; } .welcome { transition: none; } }
@media (prefers-color-scheme: dark) { html:not([data-theme="light"]) .welcome-in img { filter: invert(1); } }
html[data-theme="dark"] .welcome-in img { filter: invert(1); }
@media (min-width: 520px) { .welcome { left: var(--side); right: var(--side); } }
/* Top bar "+" (new project): quiet, always in the same place */
.brand-top .circle-btn { margin-left: auto; }
.greeting, .ph-row, .new-top { display: none; }

/* ==========================================================================
   Attention colour: the ONE colour in the app, used only for "please check this".
   Everything else stays greyscale until the full palette is approved.
   ========================================================================== */
:root { --attn: #c0362c; --attn-bg: #fdf1f0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --attn: #ff8a80; --attn-bg: #3a2120; } }
:root[data-theme="dark"] { --attn: #ff8a80; --attn-bg: #3a2120; }

/* Fields to check: solid red outline + light tint (no tags, no dashes, nothing moves) */
.unsure .pickbox, .unsure .input, .unsure .select { border: 2px solid var(--attn); background: var(--attn-bg); }
.unsure .items-card { box-shadow: 0 0 0 2px var(--attn); }
.unsure .it-row { border: 0; }
.unsure-tag { display: none; }
.attn-line { display: flex; align-items: center; gap: var(--s2); margin-top: calc(-1 * var(--s1)); font-size: var(--t-sm); font-weight: var(--w-semi); color: var(--attn); }
.attn-line svg.i { width: 16px; height: 16px; flex: none; }
.attn-ok { height: var(--h-sm); padding: 0 var(--s3); border: 1.5px solid var(--attn); border-radius: var(--r-full); background: transparent; color: var(--attn); font: inherit; font-size: var(--t-sm); font-weight: var(--w-bold); white-space: nowrap; }
.sb-attn { display: inline-flex; align-items: center; gap: var(--s1); color: var(--attn); font-weight: var(--w-semi); }
.sb-attn svg.i { width: 14px; height: 14px; }

/* Supplier | Date: same height labels, more room between the two boxes */
.pair-row { gap: var(--s4); align-items: end; }
.pair-row .label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-height: 20px; }

/* Checks with answers */
.warns { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.warn-card { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) var(--s4); border-radius: var(--r-control); background: var(--surface-2); font-size: var(--t-sm); }
.warn-card > svg.i { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.warn-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s2); }

/* Just-saved expense: a soft highlight that fades away (no "New" label) */
.new-tag { display: none; }
.item.is-new { animation: just-saved 2.6s ease-out forwards; }
@keyframes just-saved { 0%, 35% { background: var(--surface-2); } 100% { background: var(--surface); } }

/* New project: round button bottom right, where the thumb is */
.fab { position: fixed; right: max(16px, calc(var(--side, 0px) + 16px)); bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px)); z-index: 7;
  width: var(--h-lg); height: var(--h-lg); border: 0; border-radius: 50%; display: grid; place-items: center;
  background: var(--ink); color: var(--on-ink); box-shadow: 0 6px 20px color-mix(in srgb, var(--g11) 28%, transparent); }
.fab svg.i { width: 24px; height: 24px; stroke-width: 2.5; }
.fab:active { transform: scale(.94); }
.app:has(.fab) { padding-bottom: 96px; }

/* Page frozen while a card or full-screen layer is open; scrolling inside the card never reaches the page */
html.locked, html.locked body { overflow: hidden; overscroll-behavior: none; }
.sheet, .scrim, .overlay, .pdf-scroll, .rv-pages, .pv-stage, .cat-sheet-list { overscroll-behavior: contain; }
.proj-title.title-long { font-size: var(--t-lg); line-height: 1.3; } /* long project names stay readable without filling the screen */
/* Bottom bar never cramps: the total stays on one line, the note shortens */
.sb-edit, .sb-edit span { white-space: nowrap; }
.sb-total > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sb-total { flex-wrap: nowrap; }

/* PDF expenses: one-item receipts on one line; multi-item receipts = header + indented items joined by a line */
.a4-one td { padding-top: 9px; padding-bottom: 9px; border-bottom: 1px solid #e0e0e3; }
.a4-one .a4-sup, .a4-exp .a4-sup { display: block; margin: 1px 0 0; }
.a4-exp td { background: transparent; border-bottom: 0; padding-top: 10px; padding-bottom: 2px; }
.a4-item td { border-bottom: 0; color: #313136; }
.a4-item.a4-last td { border-bottom: 1px solid #e0e0e3; padding-bottom: 9px; }
.a4-indent { display: block; padding-left: 12px; border-left: 2px solid #cbcbcf; }
/* PDF: a small dot marks each item of the receipt above (a vertical line could be read as a "1") */
.a4-indent { border-left: 0; padding-left: 14px; position: relative; }
.a4-dot { position: absolute; left: 3px; top: .62em; width: 4px; height: 4px; border-radius: 50%; background: #82828a; }
/* No scrollbars: phones don't show them, so the test version shouldn't either (scrolling still works) */
html, body, * { scrollbar-width: none; }
::-webkit-scrollbar { display: none; width: 0; height: 0; }
.a4-dot { display: none; } /* indent alone shows the items belong to the receipt above */

/* Welcome: the building rises from the ground (revealed bottom → top), then the greeting and the day's line fade in */
.welcome-in { animation: none; }
.welcome-in img { clip-path: inset(100% 0 0 0); animation: rise .7s cubic-bezier(.2, .8, .2, 1) .1s forwards; }
.welcome-in h1, .welcome-in p { opacity: 0; animation: welcome-text .45s ease-out forwards; }
.welcome-in h1 { animation-delay: .55s; }
.welcome-in p { animation-delay: .7s; }
@keyframes rise { to { clip-path: inset(0 0 0 0); } }
@keyframes welcome-text { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .welcome-in img { clip-path: none; animation: none; }
  .welcome-in h1, .welcome-in p { opacity: 1; animation: none; }
}

/* Cards (sheets): slide up from the bottom edge, background dims in step; slide back down to close */
.scrim { animation: scrim-in .24s ease-out; }
.scrim .sheet { animation: sheet-in .32s cubic-bezier(.2, .85, .25, 1); will-change: transform; }
.scrim.closing { animation: scrim-out .2s ease-in forwards; pointer-events: none; }
.scrim.closing .sheet { animation: sheet-out .2s ease-in forwards; }
@keyframes scrim-in { from { background-color: transparent; } }
@keyframes scrim-out { to { background-color: transparent; } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .scrim, .scrim .sheet, .scrim.closing, .scrim.closing .sheet { animation: none; } }

/* Waiting for signal (outbox) and photos from the Telegram bot */
.waiting-note { display: flex; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); border-radius: var(--r-control); background: var(--surface-2); font-size: var(--t-sm); }
.waiting-note svg.i { width: 20px; height: 20px; flex: none; }
.bigtick-wait { background: var(--surface-2); color: var(--text); }
.inbox-card { display: flex; align-items: center; gap: var(--s3); width: 100%; margin-bottom: var(--s4); padding: var(--s4); border: 0; border-radius: var(--r-container); background: var(--ink); color: var(--on-ink); font: inherit; font-size: var(--t-sm); text-align: left; }
.inbox-card strong { font-size: var(--t-md); }
.inbox-card .muted { color: color-mix(in srgb, var(--on-ink) 70%, transparent); }
.inbox-card svg.i { width: 20px; height: 20px; flex: none; }
.offline-note { display: flex; align-items: center; justify-content: center; gap: var(--s2); margin: 0 0 var(--s3); padding: var(--s2) var(--s3); border-radius: var(--r-full); background: var(--surface-2); color: var(--text-2); font-size: var(--t-xs); font-weight: var(--w-semi); }
.offline-note svg.i { width: 14px; height: 14px; }

/* Unit picker: the units that fit the item first (large), the rest behind "More units" */
.unit-hint { font-size: var(--t-sm); font-weight: var(--w-semi); color: var(--text-2); margin-bottom: var(--s2); }
.unit-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.unit-opt { height: var(--h-lg); border-radius: var(--r-control); font-size: var(--t-md); font-weight: var(--w-semi); }
.unit-own { grid-column: 1 / -1; }
.unit-more { display: flex; align-items: center; justify-content: center; gap: var(--s1); width: 100%; height: var(--h-md); margin-top: var(--s2); border: 0; background: none; color: var(--text-2); font: inherit; font-size: var(--t-sm); font-weight: var(--w-bold); }
.unit-more svg.i { width: 16px; height: 16px; }

/* Item card (slide-up): the item form lives here, so the list never changes shape */
#sheet .it-row { padding: 0; border: 0; background: none; box-shadow: none; }
#sheet .it-row.is-open { padding: 0; border: 0; background: none; }
#sheet .it-x { display: none; }
#sheet .it-suggest { left: 0; right: 0; top: calc(var(--h-md) + 4px); }
.item-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.sheet-head { display: flex; align-items: center; gap: var(--s2); }
.sheet-head .btn-square { margin-left: calc(-1 * var(--s3)); }
.item-first { display: flex; align-items: center; justify-content: center; width: 100%; min-height: var(--h-lg); padding: var(--s4); border-top: 1px solid var(--line); background: var(--surface); color: var(--text-3); font-size: var(--t-sm); font-weight: var(--w-medium); } /* empty state: says there's nothing yet; the one action is "+ Add item" above */
.item-first svg.i { width: 20px; height: 20px; }

/* Project actions: the two everyday ones stay pinned under the bar; Sheet and PDF are quieter and scroll away */
.proj-actions { grid-auto-columns: 1fr; gap: var(--s2); padding-top: var(--s2); padding-bottom: var(--s3); }
.proj-actions .btn { min-width: 0; padding-inline: var(--s3); white-space: nowrap; }
.proj-links { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin-top: calc(-1 * var(--s2)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-control); overflow: hidden; }
.pl { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--h-md); padding: 0 var(--s3); border: 0; background: transparent; color: var(--text); font: inherit; font-size: var(--t-sm); font-weight: var(--w-semi); text-decoration: none; }
.pl + .pl { border-left: 1px solid var(--line); }
.pl:active { background: var(--surface-2); }
.pl svg.i { width: 18px; height: 18px; color: var(--text-2); }
.pl svg.i:last-child:not(:first-child) { width: 14px; height: 14px; margin-left: -4px; color: var(--text-3); }
.link-btn { padding: 0; border: 0; background: none; font: inherit; font-weight: var(--w-semi); color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
/* Check step: "+" to add a receipt, after the last one; pinned to the right edge when the row is full */
.rstrip { align-items: stretch; padding-right: 0; }
.rs-add { position: sticky; right: 0; flex: none; width: 52px; height: 64px; display: grid; place-items: center; padding: 0; border: 1.5px dashed var(--line-strong, var(--g4)); border-radius: var(--r-sm); background: var(--surface); color: var(--text); box-shadow: -12px 0 12px -4px var(--bg); }
.rs-add svg.i { width: 22px; height: 22px; }
.rs-add:active { background: var(--surface-2); }
/* Photo that couldn't be read: a light red wash over the whole photo, and the lower part says what happened and what a tap does */
.thumb-bad::after { content: ""; position: absolute; inset: 0; background: color-mix(in srgb, var(--attn) 22%, transparent); pointer-events: none; }
.st-fix { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; display: grid; justify-items: start; gap: 2px; padding: var(--s3); border: 0; background: color-mix(in srgb, #c0362c 90%, transparent); color: #fff; /* same deep red in dark mode, so white text always reads */ font: inherit; text-align: left; cursor: pointer; }
.st-fix strong { font-size: var(--t-sm); font-weight: var(--w-bold); line-height: 1.25; }
.st-fix span { font-size: var(--t-xs); line-height: 1.3; opacity: .9; }
.st-fix:active { background: #a82e25; }
/* Over budget: one solid red fill (red = "please look"), and a line with the amount and "Change budget" */
.bar .over { background: var(--attn); }
.sp.is-over small { color: var(--text-3); } /* label stays grey like the others */
.sp.is-over strong { color: var(--attn); } /* the only red here: the amount over */
.over-note { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s1) var(--s3); margin: 0; font-size: var(--t-sm); font-weight: var(--w-semi); }
.over-note > span { color: var(--attn); }
.over-note .link-btn { color: var(--text); font-size: var(--t-sm); text-decoration-thickness: 1px; }
.spend .over-note { margin: var(--s3) 0 0; }
.spend .over-note > span { color: var(--text-2); font-weight: var(--w-medium); }
/* Saved screen: the bar moves from the old total to the new one */
.bar-move i { animation: none; transition: width .9s cubic-bezier(.2, .7, .2, 1) .2s; }
@media (prefers-reduced-motion: reduce) { .bar-move i { transition: none; } }
/* Saved screen budget card: total, bar, one status line, then the four categories in a tidy grid */
.result-total { gap: var(--s2); }
.rt-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); }
.rt-k { font-size: var(--t-sm); color: var(--text-2); font-weight: var(--w-medium); }
.rt-head strong { font-size: var(--t-lg); font-weight: var(--w-bold); }
.rt-head .faint { font-size: var(--t-sm); }
.result-total .bar { margin: 0; }
.rt-left { margin: 0; font-size: var(--t-sm); color: var(--text-2); }
.rt-cats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2) var(--s3); padding-top: var(--s3); margin-top: var(--s1); border-top: 1px solid var(--line); font-size: var(--t-sm); color: var(--text-2); }
.rt-cats span { display: inline-flex; align-items: center; gap: var(--s2); }
.rt-cats svg.i { width: 16px; height: 16px; color: var(--text-3); }
/* Saved: a party popper in the same line style as every other icon, plus a quick burst of confetti */
.bigtick.bigtick-party { width: 104px; height: 104px; background: none; color: var(--ink); border-radius: 0; }
.bigtick-party svg.i { width: 96px; height: 96px; stroke-width: 1.6; }
.bigtick-party svg.i path { stroke-dasharray: none; stroke-dashoffset: 0; animation: none; }
.bigtick-party { animation: party-pop .5s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes party-pop { 0% { transform: scale(.6) rotate(-12deg); } 70% { transform: scale(1.06) rotate(4deg); } 100% { transform: none; } }
.confetti { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; width: var(--w); height: var(--h); margin: calc(var(--h) / -2) 0 0 calc(var(--w) / -2); border-radius: 1px; opacity: 0;
  animation: confetti-fly var(--d) cubic-bezier(.15, .7, .3, 1) forwards; }
@keyframes confetti-fly {
  0% { opacity: 1; transform: translate(0, 0) rotate(0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), calc(var(--y) + 140px)) rotate(var(--r)); }
}
@media (prefers-reduced-motion: reduce) { .bigtick-party { animation: none; } }
/* Expense rows: the line under the name stays on one line; if it's too long it fades out before the amount, and the receipt icon always shows */
.item .m { display: flex; align-items: center; gap: var(--s2); white-space: nowrap; overflow: visible; }
.item .m-t { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: clip; }
.item .m-ico { flex: none; display: inline-grid; color: var(--text-3); }
.item .t { text-overflow: clip; }
.item .is-cut { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 28px), transparent); }
/* Expense rows, calmer: a long name wraps onto a second line (then "…"); only the small grey line underneath fades, softly, with clear space before the amount */
.item .amt { margin-left: var(--s1); }
.item .t { white-space: normal; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; text-overflow: ellipsis; line-height: 1.3; }
.item .is-cut { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); }
/* Bars grow once when a screen opens; a redraw of the same screen (fresh numbers arriving) leaves them still */
.bar.still i { animation: none; }
.to-top.no-anim { transition: none !important; }
/* Floating pills hand over cleanly: the old one simply fades out where it is, then the new one rises in */
.to-top { transition: opacity .14s ease, transform 0s linear .14s; }
.to-top.show { transition: opacity .2s ease .14s, transform .24s cubic-bezier(.2, .8, .2, 1) .14s; }
/* Google Sheet / PDF report before there's anything in them: greyed out, not tappable */
.pl.is-off { color: var(--text-3); pointer-events: none; }
.pl.is-off svg.i { color: var(--text-3); opacity: .7; }
