/* App shell. Screen-specific styles are added as screens are built. */

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  /* surface, not bg: if a sub-pixel gap ever shows at a screen edge it matches
     the nav/bars rather than flashing a different colour */
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;           /* fixed frame; inner regions scroll, not the page */
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  overflow: hidden;
}

.statusrow, .screen-header, .bottomnav, .bottombar, .totalsbox { flex: none; }

/* The UI is chrome, not a document: no text selection or iOS long-press
   callout (copy / look up). Inputs opt back in below. */
#app {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
#app input, #app textarea, #app [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

/* --- status row ------------------------------------------------------------ */
.statusrow {
  display: flex;
  justify-content: space-between;
  padding: calc(7px + env(safe-area-inset-top, 0)) var(--gutter) 7px;
  background: var(--bg);
  font: 500 10px/1 var(--font-mono);
  color: var(--muted);
  letter-spacing: .04em;
}

/* --- add-to-home-screen nudge -------------------------------------------- */
/* Softer than the sync bar (surface, not accent-filled) — this is a
   suggestion, not a state that needs attention. */
.home-bar {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 9px var(--gutter);
  background: var(--surface);
  border-bottom: var(--rule-hairline) solid var(--hairline);
}
.home-bar-body {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; padding: 0;
  text-align: left; cursor: pointer;
}
.home-bar-body svg { flex: none; width: 15px; height: 15px; color: var(--accent); }
.home-bar-text {
  font: 500 11.5px/1.3 var(--font); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.home-bar-close {
  flex: none; border: 0; background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 2px 4px;
}

/* --- offline sync bar --------------------------------------------------- */
.sync-bar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px var(--gutter);
  background: var(--accent);
  color: #fff;
  font: 600 9.5px/1.3 var(--font);
  text-transform: uppercase; letter-spacing: .06em;
}
.sync-bar button {
  flex: none; border: 0; background: transparent; color: #fff;
  font-size: 14px; cursor: pointer; padding: 0 4px;
}

/* --- screen container ---------------------------------------------------- */
/* #screen is a fixed viewport that clips; the actual view is one .screen-page
   inside it (it's what scrolls). During a push/pop both the outgoing and the
   incoming page live here at once, stacked and animated by app.js (WAAPI). */
#screen {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.screen-page {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg);
}
/* While a transition (or an interactive edge-swipe) is running, every page in
   the container is absolutely positioned so they overlap; a leaving page is
   always taken out of flow. */
#screen.pg-clip > .screen-page,
.screen-page.pg-leaving {
  position: absolute;
  inset: 0;
}
/* Solid panel revealed behind the current page while it's dragged back. */
.pg-backdrop { position: absolute; inset: 0; background: var(--bg); z-index: 0; }

/* short fade + rise when the view changes (not on in-view updates) */
@keyframes screen-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: none; }
}
.screen-in { animation: screen-in .16s ease both; }
@media (prefers-reduced-motion: reduce) {
  .screen-in { animation: none; }
}

.screen-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Fixed height so the 2px rule doesn't shift between title-only screens
     (Add, Konto, Login) and screens with a right-aligned .btn--sm. */
  min-height: 53px;
  padding: 13px var(--gutter);
  border-bottom: var(--rule-major) solid var(--ink);
}

.screen-title {
  font: 700 17px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: .03em;
}

/* "2 / 7" position marker in the editor header while walking a queue */
.walk-count { font: 500 11px/1 var(--font-mono); color: var(--muted); letter-spacing: .08em; }

.screen-body { padding: 14px var(--gutter); }

/* --- buttons ------------------------------------------------------------ */
button {
  font-family: inherit;
  border-radius: 0;
  cursor: pointer;
  -webkit-appearance: none;   /* iOS clips dashed side-borders on native buttons */
  appearance: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  border: var(--rule-major) solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 10px 12px;
  font: 600 10.5px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: .07em;
  transition: background .12s ease, color .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:active { opacity: .6; }

.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--accent:active { background: var(--accent-pressed); border-color: var(--accent-pressed); }

.btn--block { width: 100%; }

.btn:disabled { opacity: .4; pointer-events: none; }
.btn.danger { border-color: var(--accent); color: var(--accent); background: transparent; }
.btn.danger:active { background: var(--accent); color: #fff; }
.btn.ai { border-color: var(--ai); color: var(--ai); background: transparent; }
.btn.ai:active { background: var(--ai); color: #fff; border-color: var(--ai); }
.btn.dashed { border: var(--rule-control) dashed var(--input-border); color: var(--muted); background: transparent; }

.btn--sm {
  border-width: var(--rule-control);
  padding: 6px 8px;
  font-size: 9.5px;
}

/* --- inputs ------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field > label {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  font: 600 9px/1.3 var(--font);
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}
.ai-flag {
  padding: 2px 5px;
  font: 500 9px/1 var(--font-mono);
  letter-spacing: .04em;
  color: var(--accent);
  border: var(--rule-control) solid var(--accent);
}
.field > input {
  border: var(--rule-control) solid var(--input-border);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  font: 500 13px/1.2 var(--font);
}

/* Read-only value + pen, shown for an already-verified or high-confidence field
   until the pen is tapped. Sized to match the text input so the layout is stable. */
.field-display {
  box-sizing: border-box;
  min-height: 42px;
  display: flex; align-items: center; justify-content: flex-start; gap: 5px;
  padding: 0 0 8px;
  border: var(--rule-control) solid transparent;
}
.field-value {
  flex: 0 1 auto; min-width: 0;
  font: 500 15px/1.2 var(--font); color: var(--ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.field-edit {
  flex: none;
  border: 0; background: none; cursor: pointer;
  padding: 6px; margin: -6px 0;
  color: var(--muted);
  display: flex; align-items: center;
}
.field-edit svg { width: 15px; height: 15px; }
.field-edit:active { color: var(--ink); }

/* amount input + ± sign flip (iOS decimal keypad has no minus key) */
.amount-input { display: flex; min-width: 0; }
.amount-input > input {
  flex: 1; min-width: 0;
  border: var(--rule-control) solid var(--input-border);
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  font: 500 13px/1.2 var(--font);
}
.sign-flip {
  flex: none; width: 38px;
  border: var(--rule-control) solid var(--input-border); border-left: 0;
  background: var(--surface); color: var(--ink);
  font: 600 15px/1 var(--font);
  cursor: pointer;
}
.sign-flip:active { background: var(--hairline); }

/* Normalise every text-ish input to one box model, so the date and amount
   fields in a two-up grid are the same size (iOS renders <input type=date>
   taller and centre-aligned otherwise). */
#app input:not([type="checkbox"]):not([type="radio"]) {
  box-sizing: border-box;
  height: 42px;
  border-radius: 0;
  font-size: 13px;
  line-height: 1.2;
  -webkit-appearance: none;
  appearance: none;
  text-align: left;
}
/* iOS still shows its localised, picker-backed date UI on tap even with
   appearance:none — this just makes the box model identical to the text fields
   so the two-up date/amount grid lines up exactly. */
#app input[type="date"] { padding-block: 0; }
#app input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
#app input[type="date"]::-webkit-calendar-picker-indicator { margin-left: auto; }

/* --- bottom nav ------------------------------------------------------- */
.bottomnav {
  display: flex;
  border-top: var(--rule-major) solid var(--ink);
  background: var(--surface);
}
.bottomnav button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;     /* places the icon+label group within the cell */
  border: 0;
  background: transparent;
  color: var(--muted);
  /* the safe-area inset lives on the cells, so the accent Add cell fills it too */
  padding: 10px 4px calc(9px + env(safe-area-inset-bottom, 0));
  cursor: pointer;
}
.nav-inner {
  display: flex;
  flex-direction: column;
  align-items: center;         /* icon always centred over its label */
  gap: 4px;
  font: 600 8.5px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.bottomnav button.is-active { color: var(--ink); }
.bottomnav button[data-nav="add"] {
  flex: 1.15;
  background: var(--accent);
  color: #fff;
}
.bottomnav svg { width: 24px; height: 24px; }

/* Installed / home-screen only: shift the two edge cells' groups toward the
   centre, clear of the phone's rounded corners. In a browser tab there's no
   corner clipping and the page sits above the browser chrome, so the cells stay
   evenly spaced (the default). */
html.standalone .bottomnav button:first-child { justify-content: flex-end; }
html.standalone .bottomnav button:last-child { justify-content: flex-start; }

/* --- list rows -------------------------------------------------------- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--gutter);
  border-bottom: var(--rule-hairline) solid var(--hairline);
  cursor: pointer;
  text-align: left;
  width: 100%;
  background: transparent;
  border-left: 0; border-right: 0; border-top: 0;
  color: inherit;
}
.row__main { flex: 1; min-width: 0; }
.row__name { font: 600 14px/1.2 var(--font); }
.row__meta { font: 400 10px/1.4 var(--font); color: var(--muted); margin-top: 2px; margin-left: 6px; }
.row__total { font: 600 13px/1 var(--font); }
.badge {
  border: var(--rule-control) solid var(--hairline);
  padding: 4px 5px;
  font: 500 9px/1 var(--font-mono);
  color: var(--muted);
  transition: color .2s ease, border-color .2s ease;
}
.badge--accent { color: var(--accent); border-color: var(--accent); }

.muted-para {
  font: 400 12px/1.6 var(--font);
  color: var(--muted);
  padding: 14px var(--gutter);
  border-bottom: var(--rule-hairline) solid var(--hairline);
}

.form-error {
  font: 500 11px/1.5 var(--font);
  color: var(--accent);
  margin: 0 0 12px;
}
.muted-hint {
  font: 400 10px/1.5 var(--font);
  color: var(--muted);
}

/* --- add receipt --- */
.add-actions { display: flex; flex-direction: column; gap: 10px; }
.big-btn { padding: 22px 14px; font-size: 12px; }
.add-assign { margin-top: auto; padding: 14px var(--gutter); border-top: var(--rule-major) solid var(--ink); display: flex; flex-direction: column; gap: 14px; }
.chips-block { display: flex; flex-direction: column; gap: 8px; }
.chips-block > label { font: 600 9px/1 var(--font); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }

.chiprow { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.chip {
  flex: none;
  border: var(--rule-control) solid var(--hairline);
  background: var(--surface);
  color: var(--ink);
  padding: 7px 11px;
  font: 500 11px/1 var(--font);
  white-space: nowrap;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.chip:active { transform: scale(.96); }
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
/* Dashed outline drawn as four gradient strips rather than `border-style: dashed`
   — iOS Safari clips the left/right dashes of a 1.5px dashed border (fine on
   desktop). Gradients render identically everywhere and still theme via var(). */
.chip.dashed {
  border-color: transparent;
  background-color: transparent;
  background-image:
    repeating-linear-gradient(90deg, var(--input-border) 0 4px, transparent 4px 7px),
    repeating-linear-gradient(90deg, var(--input-border) 0 4px, transparent 4px 7px),
    repeating-linear-gradient(0deg,  var(--input-border) 0 4px, transparent 4px 7px),
    repeating-linear-gradient(0deg,  var(--input-border) 0 4px, transparent 4px 7px);
  background-size: 100% 1.5px, 100% 1.5px, 1.5px 100%, 1.5px 100%;
  background-position: 0 0, 0 100%, 0 0, 100% 0;
  background-repeat: no-repeat;
}
.chip--system { color: var(--accent); border-color: var(--accent); order: -1; }

/* --- processing overlay --- */
.overlay {
  position: absolute; inset: 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  font: 500 11px/1.4 var(--font); color: var(--muted); text-align: center; padding: 0 32px;
  z-index: 10;
}
.spinner {
  width: 44px; height: 44px;
  border: 3px solid var(--hairline);
  border-top-color: var(--accent);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- image box --- */
.imagebox {
  position: relative;
  flex: none;              /* the image is position:absolute, so nothing holds
                              the box open against the page's flex-shrink */
  height: 232px;
  background: var(--placeholder);
  border-bottom: var(--rule-hairline) solid var(--hairline);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
/* Fill the box width at the image's natural aspect, anchored to the top — a tall
   receipt overflows the box downwards and the pinch/pan handler scrolls through
   it (even at scale 1); tap → fullscreen. transform is driven live by that
   handler — no transition on it. opacity: hidden until fully decoded (see
   fadeInImage), then a quick fade. */
.imagebox > img {
  position: absolute; top: 0; left: 0;
  width: 100%; height: auto;
  transform-origin: top center; cursor: zoom-in;
}
.pdf-holder img {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
.imagebox img {
  opacity: 0; transition: opacity .22s ease;
}
.imagebox img.is-loaded { opacity: 1; }
.pdf-holder { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.pdf-holder.is-missing::after {
  content: attr(data-label);
  font: 500 11px/1 var(--font-mono);
  letter-spacing: .14em;
  color: var(--placeholder-dash);
}

/* --- fullscreen image viewer --- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  background: #000;
  display: flex; align-items: center; justify-content: center;
  animation: screen-in .16s ease;
}
.lightbox-stage {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  touch-action: none;
}
.lightbox-stage img {
  max-width: 100%; max-height: 100%;
  transform-origin: center;
  -webkit-user-select: none; user-select: none; -webkit-user-drag: none;
  will-change: transform;
  opacity: 0; transition: opacity .2s ease;
}
.lightbox-stage img.is-loaded { opacity: 1; }
.lightbox-close {
  position: absolute; z-index: 1;
  top: calc(10px + env(safe-area-inset-top, 0)); right: 12px;
  width: 42px; height: 42px;
  border: 0; background: rgba(255, 255, 255, .16); color: #fff;
  font-size: 18px; line-height: 1; cursor: pointer;
}

/* --- generic full-screen info lightbox (privacy policy, add-to-home-screen) --- */
.info-lightbox {
  position: fixed; inset: 0; z-index: 210;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: screen-in .16s ease;
}
.info-header {
  display: flex; align-items: center; justify-content: space-between;
  flex: none;
  min-height: 53px;
  padding: calc(13px + env(safe-area-inset-top, 0)) var(--gutter) 13px;
  border-bottom: var(--rule-major) solid var(--ink);
}
.info-close {
  border: 0; background: transparent; color: var(--ink);
  font-size: 18px; line-height: 1; cursor: pointer; padding: 4px;
}
.info-body {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px var(--gutter) calc(32px + env(safe-area-inset-bottom, 0));
}
.info-body p { font: 400 13px/1.65 var(--font); color: var(--ink); margin: 0 0 14px; }
.info-body ul, .info-body ol { margin: 0 0 14px; padding-left: 18px; }
.info-body li { font: 400 13px/1.65 var(--font); color: var(--ink); margin-bottom: 6px; }
.info-body strong { font-weight: 600; }
.info-body a { color: var(--accent); }
.info-h {
  font: 700 10px/1.3 var(--font);
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--muted);
  margin: 22px 0 8px;
  padding-top: 16px;
  border-top: var(--rule-hairline) solid var(--hairline);
}
.info-h:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.info-footer {
  margin-top: 8px; padding-top: 14px;
  border-top: var(--rule-hairline) solid var(--hairline);
}
.info-footer p { font: 400 11px/1.6 var(--font); color: var(--muted); margin: 0; }

.a2hs-steps { counter-reset: a2hs; }
.a2hs-steps li { list-style: none; padding-left: 26px; position: relative; }
.a2hs-steps li::before {
  counter-increment: a2hs; content: counter(a2hs);
  position: absolute; left: 0; top: 0;
  width: 18px; height: 18px;
  border: var(--rule-control) solid var(--accent); color: var(--accent);
  font: 700 10px/16px var(--font); text-align: center;
}

/* Subtle link-styled button, used for the privacy-policy link under the
   login/signup forms — deliberately not a .btn, shouldn't compete with the
   primary action. */
.footer-link {
  display: block;
  margin: 16px auto 0;
  background: none; border: 0; padding: 4px;
  font: 500 10px/1.4 var(--font);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: end; }
.grid2 .field { margin-bottom: 0; min-width: 0; }

/* receipt screen: fields sit directly under .screen-page, so they need the gutter */
.screen-page > .field, .screen-page > .grid2 { padding-left: var(--gutter); padding-right: var(--gutter); margin-top: 14px; }

.vat-block { border-top: var(--rule-hairline) solid var(--hairline); border-bottom: var(--rule-hairline) solid var(--hairline); padding: 12px var(--gutter); }
.vat-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.vat-rate { font: 600 11px/1 var(--font); width: 44px; }
.vat-amount { flex: 1; border: var(--rule-control) solid var(--input-border); background: var(--surface); color: var(--ink); padding: 8px; font: 500 13px/1 var(--font); }
.vat-x { border: 0; background: transparent; color: var(--muted); font-size: 13px; }
.vat-excl { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0 4px; margin-bottom: 8px; border-top: var(--rule-hairline) solid var(--hairline); font: 500 13px/1.3 var(--font); }
.vat-excl > span:last-child { font-weight: 600; white-space: nowrap; }
.vat-adders { display: flex; gap: 6px; margin: 6px 0; }

.screen-page > .btn--block { margin: 14px var(--gutter); width: calc(100% - 2 * var(--gutter)); }

.bottombar {
  position: sticky; bottom: 0;
  border-top: var(--rule-major) solid var(--ink);
  background: var(--surface);
  padding: 12px var(--gutter);
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
  display: flex; gap: 6px;
}
/* the screen's primary action(s) — taller, a bit heavier than inline buttons */
.bottombar .btn {
  flex: 1;
  justify-content: space-between;
  padding: 16px 14px;
  font-size: 12px;
  letter-spacing: .07em;
}
/* Secondary action hugs its label; the primary one fills the rest. */
.bottombar .bar-secondary { flex: none; justify-content: center; padding-inline: 13px; }

/* --- all receipts / project view --- */
.btn--sm.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.list-cats { padding: 10px var(--gutter); border-bottom: var(--rule-hairline) solid var(--hairline); }
.list-body { flex: 1; min-height: 0; overflow-y: auto; }

.section-head {
  display: flex; justify-content: space-between;
  padding: 8px var(--gutter) 6px;
  background: var(--surface);
  border-top: var(--rule-hairline) solid var(--hairline);
  border-bottom: var(--rule-hairline) solid var(--hairline);
  font: 700 9.5px/1.2 var(--font);
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted);
}

.swipe-wrap {
  position: relative;
  overflow: hidden;
  background: var(--accent);   /* revealed behind the row on swipe-left */
}
.swipe-del {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 88px;
  border: 0; background: var(--accent); color: #fff;
  font: 600 10px/1 var(--font); text-transform: uppercase; letter-spacing: .06em;
  cursor: pointer;
}
.receipt-row {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 13px var(--gutter);
  border-bottom: var(--rule-hairline) solid var(--hairline);
  background: var(--bg);
  cursor: pointer;
  transition: transform .2s ease;
  touch-action: pan-y;
}
.receipt-row { transition: transform .2s ease, background .12s ease; }
.receipt-row.is-checked { background: var(--surface); }
.receipt-row:active { background: var(--surface); }

/* checkbox is always in the DOM; it collapses to zero width until selection
   mode, then slides in */
.checkbox {
  width: 0; height: 16px; flex: none;
  border: var(--rule-control) solid var(--input-border);
  opacity: 0;
  margin-right: -11px;   /* eat the row gap while hidden */
  transition: width .16s ease, opacity .16s ease, margin-right .16s ease;
}
.list-body.is-selecting .checkbox { width: 16px; opacity: 1; margin-right: 0; }
.receipt-row.is-checked .checkbox { background: var(--ink); border-color: var(--ink); }
.ai-badge {
  flex: none;
  font: 700 9px/1 var(--font-mono);
  padding: 4px 5px;
  border: var(--rule-control) solid var(--accent);
  color: var(--accent);
}

.totalsbox {
  /* the bottom nav sits directly below and already reserves the safe area —
     no env() padding here or it's just dead space above the nav */
  flex: none;
  border-top: var(--rule-major) solid var(--ink);
  background: var(--surface);
  padding: 11px var(--gutter);
  display: flex; flex-direction: column; gap: 9px;
}
.totals-main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.totals-label { font: 600 9px/1.25 var(--font); text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.totals-figures { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 6px 12px; }
.totals-breakdown { display: flex; gap: 16px; min-width: 0; }
.totals-fig { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.totals-fig i {
  font: 600 8px/1 var(--font-mono); font-style: normal;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap;
}
.totals-fig b { font: 700 15px/1 var(--font); letter-spacing: -.02em; white-space: nowrap; }
.totals-fig--vat b { color: var(--muted); }
.totals-fig--incl { align-items: flex-end; text-align: right; flex: none; }
.totals-fig--incl b { font-size: 19px; }
.totals-foreign { font: 500 12px/1 var(--font); color: var(--muted); }
.totals-actions { display: flex; justify-content: flex-end; gap: 8px; }
.totals-actions .btn { flex: none; padding: 9px 12px; }

/* duplicate-receipt hint on the editor — informational, dismissible */
.dupe-banner {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 12px var(--gutter) 0;
  padding: 10px 12px;
  border: var(--rule-control) solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.dupe-body { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.dupe-title {
  font: 600 9px/1.3 var(--font); text-transform: uppercase; letter-spacing: .08em; color: var(--accent);
}
.dupe-link {
  align-self: flex-start;
  border: 0; background: transparent; color: var(--ink);
  padding: 0; font: 500 11.5px/1.3 var(--font); text-align: left;
  text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer;
}
.dupe-x {
  flex: none; border: 0; background: transparent; color: var(--muted);
  font-size: 12px; cursor: pointer; padding: 2px;
}

.editor-actions { display: flex; gap: 8px; padding: 14px var(--gutter); }
.editor-actions .btn { flex: 1; justify-content: center; }

.filter-strip {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px var(--gutter);
  background: var(--surface);
  border-bottom: var(--rule-hairline) solid var(--hairline);
  font: 600 9.5px/1.3 var(--font);
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--accent);
}
.filter-strip button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; text-decoration: underline; cursor: pointer;
}

/* --- search --- */
.search-body { flex: 1; min-height: 0; overflow-y: auto; }

/* "Sök" flows below the filters (no docked bottombar / thick divider). */
.search-go { padding: 16px var(--gutter) 24px; }
.search-go .btn {
  width: 100%;
  justify-content: space-between;
  padding: 15px 14px;
  font-size: 12px;
  letter-spacing: .07em;
}
.search-block {
  display: flex; flex-direction: column; gap: 8px;
  padding: 13px var(--gutter);
  border-bottom: var(--rule-hairline) solid var(--hairline);
}
.search-block label {
  font: 600 9px/1 var(--font); text-transform: uppercase; letter-spacing: .09em; color: var(--muted);
}
.filter-head { display: flex; justify-content: space-between; align-items: center; }
.filter-pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: var(--rule-control) solid var(--hairline);
  background: transparent; color: var(--muted);
  padding: 4px 7px 4px 5px;
  font: 600 8.5px/1 var(--font); text-transform: uppercase; letter-spacing: .06em;
  cursor: pointer;
}
.filter-pill .dot {
  width: 8px; height: 8px; flex: none;
  border: var(--rule-control) solid var(--muted); background: transparent;
}
.toggleable:not(.is-off) .filter-pill { color: var(--ink); border-color: var(--ink); }
.toggleable:not(.is-off) .filter-pill .dot { background: var(--accent); border-color: var(--accent); }
.toggleable.is-off .seg,
.toggleable.is-off > input,
.toggleable.is-off .grid2-inline { opacity: .4; }
.search-block input,
.search-block select {
  border: var(--rule-control) solid var(--input-border);
  background: var(--surface); color: var(--ink);
  padding: 10px; font: 500 13px/1 var(--font); width: 100%;
  border-radius: 0; height: 42px;
}
.search-block input:disabled { opacity: .45; }
.chiprow.wrap { flex-wrap: wrap; overflow: visible; }
.grid2-inline { display: flex; gap: 8px; }
.grid2-inline input { flex: 1; min-width: 0; }

/* Settings disclosure panels — the start-screen project picker and the
   change-password fields slide open (grid-rows 0fr→1fr = animatable height).
   .slide-wrap holds the trigger + panel with no flex gap so a closed panel
   leaves no phantom space. */
.slide-wrap { display: flex; flex-direction: column; }
.slide-panel {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows .2s ease, opacity .2s ease;
}
.slide-panel.open { grid-template-rows: 1fr; opacity: 1; }
.slide-panel > div { overflow: hidden; min-height: 0; }
.start-picker select { margin-top: 8px; }

.disclosure {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 0; border: 0; background: none; cursor: pointer;
  font: 600 9px/1 var(--font); text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted);
}
.disclosure-caret { font-size: 14px; line-height: 1; transition: transform .2s ease; }
.disclosure[aria-expanded="true"] .disclosure-caret { transform: rotate(90deg); }
.disclosure-fields { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  border: var(--rule-control) solid var(--hairline);
  background: var(--surface); color: var(--ink);
  padding: 8px 6px;
  font: 600 9.5px/1 var(--font); text-transform: uppercase; letter-spacing: .05em;
  cursor: pointer;
}
.seg button.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* --- export option rows --- */
.opt-row {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%;
  border: var(--rule-control) solid var(--hairline);
  background: var(--surface); color: var(--ink);
  padding: 12px; margin-top: 6px;
  font: 500 12.5px/1 var(--font);
  text-align: left; cursor: pointer;
}
.opt-row:first-of-type { margin-top: 0; }
.opt-row.is-active { border-color: var(--ink); }
.opt-row:disabled { opacity: .4; pointer-events: none; }
.opt-check { width: 16px; height: 16px; border: var(--rule-control) solid var(--input-border); flex: none; }
.opt-check.on { background: var(--ink); border-color: var(--ink); }

/* --- scoped list edit row --- */
.scope-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px var(--gutter);
  border-bottom: var(--rule-hairline) solid var(--hairline);
}
.scope-row p { margin: 0; font: 400 11.5px/1.5 var(--font); color: var(--muted); }
.scope-row .btn { flex: none; }

/* --- edit project --- */
.cat-edit-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.cat-edit-row input {
  flex: 1; min-width: 0;
  border: var(--rule-control) solid var(--input-border);
  background: var(--surface); color: var(--ink);
  padding: 9px 10px; font: 500 12.5px/1 var(--font);
}
.member-row {
  display: flex; justify-content: space-between; align-items: center;
  border: var(--rule-control) solid var(--input-border);
  background: var(--surface);
  padding: 10px; margin-bottom: 6px;
  font: 500 12.5px/1.3 var(--font);
}
.member-owner { font: 600 9px/1 var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.member-remove {
  border: 0; background: transparent; color: var(--accent);
  font: 600 9px/1 var(--font); text-transform: uppercase; letter-spacing: .06em; cursor: pointer;
}

/* --- invite code --- */
.invite-code {
  border: var(--rule-major) solid var(--ink);
  background: var(--surface);
  padding: 14px 12px;
  font: 600 24px/1 var(--font-mono);
  letter-spacing: .18em;
  text-align: center;
  color: var(--ink);
  user-select: all; -webkit-user-select: all;
  -webkit-touch-callout: default;
}

/* --- API token (long string, must wrap) --- */
.token-fresh { margin-bottom: 10px; display: flex; flex-direction: column; gap: 8px; }
.token-fresh .invite-code {
  font: 600 12px/1.5 var(--font-mono);
  letter-spacing: .04em;
  text-align: left;
  word-break: break-all;
}
.token-fresh .btn { align-self: flex-start; }

/* --- embed "done" screen (the iOS Shortcut's web view, nothing left to do) --- */
.embed-done {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
  padding: 0 40px;
  text-align: center;
}
.embed-done-check {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border: var(--rule-major) solid var(--ink);
  color: var(--ink);
  font: 700 26px/1 var(--font);
}
.embed-done-title { font: 700 17px/1.3 var(--font); text-transform: uppercase; letter-spacing: .02em; }

/* --- batch queue --- */
.batch-row {
  display: flex; align-items: center; gap: 11px;
  padding: 12px var(--gutter);
  border-bottom: var(--rule-hairline) solid var(--hairline);
}
.batch-thumb { width: 28px; height: 36px; background: var(--placeholder); flex: none; }
.batch-row .row__main { display: flex; flex-direction: column; gap: 6px; }
.progress { display: block; height: 6px; background: var(--hairline); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
/* "uploading" covers the upload + the inline OCR call, which can sit here for
   several seconds with no real progress to report — moving stripes read as
   "still working" instead of a stalled bar. */
.progress.uploading > i {
  width: 55%;
  background-color: var(--accent);
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(255, 255, 255, .3) 0 8px,
    transparent 8px 16px
  );
  background-size: 32px 100%;
  animation: progress-stripes 1s linear infinite;
}
@keyframes progress-stripes {
  from { background-position: 0 0; }
  to   { background-position: 32px 0; }
}
@media (prefers-reduced-motion: reduce) {
  .progress.uploading > i { animation: none; background-image: none; }
}
.progress.done > i { width: 100%; }
.progress.error > i { width: 100%; background: var(--muted); }
/* Right-hand status marker on each batch row — all boxed the same way. */
.batch-tag {
  flex: none;
  font: 700 9px/1 var(--font-mono);
  padding: 4px 5px;
  border: var(--rule-control) solid var(--muted);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.batch-tag.done,
.batch-tag.error { border-color: var(--accent); color: var(--accent); }
.batch-tag.is-reviewed { border-color: var(--ink); color: var(--ink); }
.batch-row.is-deleted { opacity: .5; }
.batch-row.is-deleted .row__name { text-decoration: line-through; }

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 86px;
  background: var(--ink);
  color: var(--bg);
  padding: 12px 16px;
  font: 600 10.5px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: .06em;
  animation: toast-in .18s ease;
}
.toast.out { animation: toast-out .22s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 6px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toast-out { to { opacity: 0; transform: translate(-50%, 6px); } }

[hidden] { display: none !important; }
