/* ==========================================================================
   Suru Accounting — design system
   --------------------------------------------------------------------------
   One stylesheet, no build step, no framework. Written mobile-first: the
   layout starts as a single column with a bottom bar, and widens into a
   sidebar at 900px. Money is always tabular-figure so columns align.
   ========================================================================== */

:root {
  /* Brand */
  --teal-900: #06312e;
  --teal-800: #083f3b;
  --teal-700: #0a544f;
  --teal-600: #0f7a73;
  --teal-500: #159089;
  --teal-300: #7fd6cd;
  --teal-100: #d8efec;
  --teal-050: #eef8f6;

  --gold-600: #c98a24;
  --gold-500: #e9a93c;
  --gold-300: #f6d79c;
  --gold-100: #fdf3e0;

  --ink-900: #0c2523;
  --ink-800: #16332f;
  --ink-700: #2b4a45;
  --ink-500: #55706b;
  --ink-400: #7b918d;
  --ink-300: #a8bab6;
  --ink-200: #ccd9d6;
  --ink-100: #e4edeb;
  --ink-050: #f2f7f6;

  --red-600: #b3261e;
  --red-500: #d64545;
  --red-100: #fbe6e4;
  --amber-600: #a8620a;
  --amber-500: #e08a17;
  --amber-100: #fdf0da;
  --green-600: #146c43;
  --green-500: #1d9159;
  --green-100: #e3f4ea;
  --blue-600: #1d4ed8;
  --blue-100: #e5edfd;

  /* Semantic — light */
  --bg: #fafaf7;
  --bg-sunken: #f2f4f2;
  --surface: #ffffff;
  --surface-2: #f7faf9;
  --surface-inset: #f2f7f6;
  --border: #e2e9e7;
  --border-strong: #ccd9d6;
  --text: var(--ink-900);
  --text-muted: var(--ink-500);
  --text-subtle: var(--ink-400);
  --accent: var(--teal-600);
  --accent-hover: var(--teal-700);
  --accent-contrast: #ffffff;
  --accent-soft: var(--teal-050);
  --focus: #0f7a73;

  --positive: var(--green-600);
  --negative: var(--red-600);
  --warning: var(--amber-600);

  /* Shape and depth */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;
  --shadow-sm: 0 1px 2px rgba(12, 37, 35, 0.06), 0 1px 3px rgba(12, 37, 35, 0.04);
  --shadow: 0 2px 4px rgba(12, 37, 35, 0.05), 0 8px 24px rgba(12, 37, 35, 0.07);
  --shadow-lg: 0 12px 40px rgba(12, 37, 35, 0.14);

  /* Type */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --step--2: 0.75rem;
  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.0625rem;
  --step-2: 1.25rem;
  --step-3: 1.5rem;
  --step-4: 1.9375rem;
  --step-5: 2.5rem;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  --nav-height: 60px;
  --sidebar-width: 250px;
  --content-max: 1180px;
}

:root[data-theme="dark"] {
  --bg: #0b1a19;
  --bg-sunken: #071110;
  --surface: #112523;
  --surface-2: #16302d;
  --surface-inset: #0e201e;
  --border: #23413d;
  --border-strong: #305a54;
  --text: #e8f2f0;
  --text-muted: #9db4b0;
  --text-subtle: #7d9591;
  --accent: #2ba79c;
  --accent-hover: #38bdb1;
  --accent-contrast: #04211f;
  --accent-soft: #123330;
  --focus: #4fd3c5;

  --positive: #4ec98a;
  --negative: #f28b82;
  --warning: #f0b458;

  --red-100: #3a1c1a;
  --amber-100: #3a2c14;
  --green-100: #12331f;
  --blue-100: #16224a;
  --teal-100: #123330;
  --gold-100: #33260f;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1a19;
    --bg-sunken: #071110;
    --surface: #112523;
    --surface-2: #16302d;
    --surface-inset: #0e201e;
    --border: #23413d;
    --border-strong: #305a54;
    --text: #e8f2f0;
    --text-muted: #9db4b0;
    --text-subtle: #7d9591;
    --accent: #2ba79c;
    --accent-hover: #38bdb1;
    --accent-contrast: #04211f;
    --accent-soft: #123330;
    --focus: #4fd3c5;
    --positive: #4ec98a;
    --negative: #f28b82;
    --warning: #f0b458;
    --red-100: #3a1c1a;
    --amber-100: #3a2c14;
    --green-100: #12331f;
    --blue-100: #16224a;
    --teal-100: #123330;
    --gold-100: #33260f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

body {
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

h1, h2, h3, h4 { line-height: 1.2; font-weight: 640; letter-spacing: -0.014em; }
h1 { font-size: var(--step-4); }
h2 { font-size: var(--step-2); }
h3 { font-size: var(--step-1); }
h4 { font-size: var(--step-0); }

/* ---------- layout ---------- */
.app { display: flex; min-height: 100dvh; }

.sidebar {
  display: none;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-4);
  position: sticky;
  top: 0;
  height: 100dvh;
  overflow-y: auto;
}

.main {
  flex: 1;
  min-width: 0;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + var(--space-5));
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4);
}

@media (min-width: 900px) {
  .sidebar { display: block; }
  .main { padding-bottom: var(--space-6); }
  .content { padding: var(--space-6); }
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar > * { min-width: 0; }
.topbar .brand { display: flex; align-items: center; gap: var(--space-2); font-weight: 660; letter-spacing: -0.02em; flex: none; }
.topbar .brand img { width: 26px; height: 26px; border-radius: 7px; }
.topbar .spacer { flex: 1; }

/* On a phone the bar has to hold a company name and two controls inside 100vw,
   so the wordmark steps aside and the switcher takes what is left. */
@media (max-width: 480px) {
  .topbar { gap: var(--space-2); padding-left: var(--space-3); padding-right: var(--space-3); }
  .topbar .brand span { display: none; }
  .switcher summary { max-width: 52vw; }
}

/* ---------- company switcher ---------- */
.switcher { position: relative; }
.switcher summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  font-weight: 560;
  font-size: var(--step--1);
  max-width: 62vw;
}
.switcher summary::-webkit-details-marker { display: none; }
.switcher summary .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.switcher summary .caret { color: var(--text-subtle); font-size: 10px; }
.switcher[open] summary { border-color: var(--accent); }
.switcher .menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 280px;
  max-width: 92vw;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: 60;
  max-height: 70vh;
  overflow-y: auto;
}
.switcher .menu a {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: 9px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
}
.switcher .menu a:hover { background: var(--surface-inset); }
.switcher .menu a[aria-current="true"] { background: var(--accent-soft); color: var(--accent-hover); font-weight: 600; }
.switcher .menu .divider { height: 1px; background: var(--border); margin: var(--space-2) 0; }

/* ---------- sidebar nav ---------- */
.nav-group { margin-bottom: var(--space-5); }
.nav-group h5 {
  font-size: var(--step--2); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-subtle); font-weight: 620; margin-bottom: var(--space-2); padding-left: 10px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text-muted); text-decoration: none; font-weight: 520; font-size: var(--step-0);
}
.nav-item:hover { background: var(--surface-inset); color: var(--text); text-decoration: none; }
.nav-item[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); font-weight: 620; }
.nav-item .count {
  margin-left: auto; font-size: var(--step--2); font-weight: 640;
  background: var(--surface-inset); color: var(--text-muted);
  padding: 1px 7px; border-radius: var(--radius-full);
}
.nav-item .count.alert { background: var(--red-100); color: var(--negative); }

/* ---------- bottom nav (mobile) ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  align-items: end;
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 4px 8px; color: var(--text-subtle); text-decoration: none;
  font-size: 10.5px; font-weight: 560; letter-spacing: 0.01em;
}
.bottom-nav a[aria-current="page"] { color: var(--accent); }
.bottom-nav svg { width: 22px; height: 22px; }
.bottom-nav .add {
  position: relative;
}
.bottom-nav .add span.fab {
  display: grid; place-items: center;
  width: 50px; height: 50px; margin-top: -18px;
  border-radius: var(--radius-full);
  background: var(--accent); color: var(--accent-contrast);
  box-shadow: 0 6px 18px rgba(15, 122, 115, 0.4);
  font-size: 26px; font-weight: 400; line-height: 1;
}

/*
 * Desktop hides the mobile chrome. This block has to come after the rules it
 * overrides: a media query carries no extra specificity, so `display: grid` on
 * .bottom-nav further down the file would otherwise win over `display: none`
 * declared earlier — the tab bar would sit across the middle of a wide window.
 */
@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .topbar-mobile-only { display: none; }
}

/* ---------- reconciliation ---------- */
/* A card whose number is the thing standing between the person and a finished
   reconciliation gets an edge, so it reads as unfinished at a glance. */
.card.warn-edge { border-color: color-mix(in srgb, var(--negative) 45%, var(--border)); }
tr.is-cleared { background: color-mix(in srgb, var(--positive) 7%, transparent); }
tr.is-cleared td { color: var(--text-muted); }

/* ---------- cards and surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card.tight { padding: var(--space-4); }
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3);
  margin-bottom: var(--space-4);
}
.card-head h2, .card-head h3 { margin: 0; }
.card-head .action { font-size: var(--step--1); font-weight: 560; }

.grid { display: grid; gap: var(--space-4); }
.grid.cols-2 { grid-template-columns: 1fr; }
.grid.cols-3 { grid-template-columns: 1fr; }
.grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 640px) {
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 900px) {
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- stats ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .label {
  font-size: var(--step--1); color: var(--text-muted); font-weight: 540;
  display: flex; align-items: center; gap: 6px;
}
.stat .value {
  font-size: var(--step-3); font-weight: 660; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.stat .value.sm { font-size: var(--step-2); }
.stat .sub { font-size: var(--step--1); color: var(--text-subtle); }
.stat .value.positive { color: var(--positive); }
.stat .value.negative { color: var(--negative); }

.money { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; white-space: nowrap; }
.money.negative { color: var(--negative); }
.money.positive { color: var(--positive); }

/* ---------- health ring ---------- */
.health { display: flex; align-items: center; gap: var(--space-5); flex-wrap: wrap; }
.health-ring { position: relative; width: 116px; height: 116px; flex-shrink: 0; }
.health-ring svg { transform: rotate(-90deg); }
.health-ring .track { stroke: var(--surface-inset); }
.health-ring .fill { stroke: var(--accent); transition: stroke-dasharray 600ms ease; }
.health-ring.grade-good .fill { stroke: var(--positive); }
.health-ring.grade-excellent .fill { stroke: var(--positive); }
.health-ring.grade-needs_work .fill { stroke: var(--warning); }
.health-ring.grade-at_risk .fill { stroke: var(--negative); }
.health-ring .center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.health-ring .center strong { font-size: var(--step-3); font-weight: 680; letter-spacing: -0.03em; }
.health-ring .center small { font-size: var(--step--2); color: var(--text-subtle); display: block; }
.health-list { flex: 1; min-width: 240px; display: flex; flex-direction: column; gap: 10px; }
.health-item { display: flex; align-items: flex-start; gap: 10px; font-size: var(--step--1); }
.health-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 7px; flex-shrink: 0; }
.health-item .dot.ok { background: var(--positive); }
.health-item .dot.warn { background: var(--warning); }
.health-item .dot.bad { background: var(--negative); }
.health-item .body strong { display: block; font-weight: 600; }
.health-item .body span { color: var(--text-muted); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 15px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--surface-inset); color: var(--text);
  font-weight: 580; font-size: var(--step-0); cursor: pointer; text-decoration: none;
  transition: background 120ms ease, border-color 120ms ease, transform 60ms ease;
  min-height: 40px;
}
.btn:hover { text-decoration: none; background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-contrast); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-inset); }
.btn.danger { background: var(--red-100); color: var(--negative); }
.btn.danger:hover { background: color-mix(in srgb, var(--red-100) 70%, var(--negative) 12%); }
.btn.sm { padding: 5px 11px; font-size: var(--step--1); min-height: 32px; }
.btn.lg { padding: 13px 22px; font-size: var(--step-1); min-height: 48px; }
.btn.block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; pointer-events: none; }

.btn-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: var(--space-4); }
.field > label { font-weight: 580; font-size: var(--step--1); }
.field .hint { font-size: var(--step--1); color: var(--text-muted); }
.field .error { font-size: var(--step--1); color: var(--negative); font-weight: 540; }

/*
 * Every text-like field, chosen by exclusion rather than by listing types. An
 * enumerated list silently misses `type="time"`, `type="url"` and — the common
 * case — an <input> with no type attribute at all, which then renders in the
 * browser's own colours and looks broken in dark mode.
 */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="submit"]):not([type="button"]):not([type="reset"]):not([type="image"]):not([type="color"]):not([type="hidden"]),
select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  min-height: 42px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
textarea { min-height: 84px; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--negative); }

.input-money { font-variant-numeric: tabular-nums; font-size: var(--step-2); font-weight: 620; }

.field-row { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
@media (min-width: 560px) { .field-row.two { grid-template-columns: 1fr 1fr; } }

/* Segmented control — used for "what happened?" */
.segmented { display: grid; gap: var(--space-2); grid-template-columns: repeat(2, 1fr); }
@media (min-width: 560px) { .segmented { grid-template-columns: repeat(3, 1fr); } }
.segmented label {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  cursor: pointer; background: var(--surface); transition: all 120ms ease;
}
.segmented label:hover { border-color: var(--accent); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label strong { font-weight: 600; font-size: var(--step-0); }
.segmented label span { font-size: var(--step--1); color: var(--text-muted); }
.segmented input:checked + strong { color: var(--accent-hover); }
.segmented label:has(input:checked) {
  border-color: var(--accent); background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--step-0); }
table.data th {
  text-align: left; font-weight: 600; font-size: var(--step--1); color: var(--text-muted);
  padding: 10px var(--space-4); border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; background: var(--surface); z-index: 1;
}
table.data td { padding: 11px var(--space-4); border-bottom: 1px solid var(--border); vertical-align: top; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .shrink { width: 1%; white-space: nowrap; }
table.data tfoot td { font-weight: 640; border-top: 2px solid var(--border-strong); }
table.data tr.total td { font-weight: 660; background: var(--surface-inset); }
table.data tr.subtotal td { font-weight: 600; border-top: 1px solid var(--border-strong); }
table.data .indent-1 { padding-left: calc(var(--space-4) + 18px); }

/* ---------- list rows (mobile-friendly alternative to tables) ---------- */
.rows { display: flex; flex-direction: column; }
.row-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  color: var(--text); text-decoration: none;
}
.row-item:last-child { border-bottom: none; }
.row-item:hover { background: var(--surface-2); text-decoration: none; }
.row-item .avatar {
  width: 36px; height: 36px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: grid; place-items: center; font-weight: 640; font-size: var(--step--1);
  background: var(--surface-inset); color: var(--text-muted);
}
.row-item .body { flex: 1; min-width: 0; }
.row-item .body strong { display: block; font-weight: 570; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-item .body span { font-size: var(--step--1); color: var(--text-muted); }
.row-item .trail { text-align: right; flex-shrink: 0; }
.row-item .trail .money { font-weight: 600; }
.row-item .trail small { display: block; font-size: var(--step--2); color: var(--text-subtle); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: var(--radius-full);
  font-size: var(--step--2); font-weight: 620; letter-spacing: 0.01em;
  background: var(--surface-inset); color: var(--text-muted);
  white-space: nowrap;
}
.badge.ok { background: var(--green-100); color: var(--positive); }
.badge.warn { background: var(--amber-100); color: var(--warning); }
.badge.bad { background: var(--red-100); color: var(--negative); }
.badge.info { background: var(--blue-100); color: var(--blue-600); }
.badge.accent { background: var(--accent-soft); color: var(--accent-hover); }
.badge.demo { background: var(--gold-100); color: var(--gold-600); }

/* ---------- callouts ---------- */
.callout {
  display: flex; gap: var(--space-3);
  padding: var(--space-4); border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--step-0);
}
.callout .icon { flex-shrink: 0; font-size: var(--step-1); line-height: 1.3; }
.callout strong { display: block; margin-bottom: 2px; }
.callout p { color: var(--text-muted); }
.callout.ok { background: var(--green-100); border-color: color-mix(in srgb, var(--positive) 25%, transparent); }
.callout.warn { background: var(--amber-100); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.callout.bad { background: var(--red-100); border-color: color-mix(in srgb, var(--negative) 25%, transparent); }
.callout.accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }

/* ---------- explain box: the "why" Suru always shows ---------- */
.explain {
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  padding: var(--space-3) var(--space-4);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--step--1);
  color: var(--text-muted);
}
.explain strong { color: var(--text); }

/* ---------- upload dropzone ---------- */
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  background: var(--surface-2);
  transition: all 160ms ease;
  cursor: pointer;
}
.dropzone:hover, .dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone h3 { margin-bottom: 6px; }
.dropzone p { color: var(--text-muted); font-size: var(--step--1); }
.dropzone .formats { margin-top: var(--space-4); font-size: var(--step--2); color: var(--text-subtle); }

/* ---------- receipt review ---------- */
/* The photograph and the form it produced, side by side on anything wide
   enough. The image is capped rather than shown at its natural size: a phone
   camera produces something four times taller than a screen, and a person
   confirming an amount needs the form in front of them, not below the fold. */
.receipt-review { display: grid; gap: 20px; align-items: start; }
.receipt-image img {
  max-height: 62vh;
  object-fit: contain;
  object-position: top center;
  background: var(--surface-sunk, #f2f4f3);
}
@media (min-width: 900px) {
  .receipt-review { grid-template-columns: minmax(0, 5fr) minmax(340px, 6fr); }
  .receipt-image { position: sticky; top: 16px; }
}
@media (max-width: 899px) {
  /* Stacked: show enough of the receipt to recognise it, then get out of the
     way. Tapping the image opens it full size. */
  .receipt-image img { max-height: 42vh; }
}

/* ---------- progress ---------- */
.bar { height: 6px; border-radius: var(--radius-full); background: var(--surface-inset); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.bar.ok > span { background: var(--positive); }
.bar.warn > span { background: var(--warning); }
.bar.bad > span { background: var(--negative); }

/* ---------- pipeline stepper ---------- */
.stepper { display: flex; flex-wrap: wrap; gap: 6px; font-size: var(--step--2); }
.stepper .step {
  padding: 3px 9px; border-radius: var(--radius-full);
  background: var(--surface-inset); color: var(--text-subtle); font-weight: 600;
}
.stepper .step.done { background: var(--green-100); color: var(--positive); }
.stepper .step.current { background: var(--accent); color: var(--accent-contrast); }
.stepper .step.blocked { background: var(--red-100); color: var(--negative); }

/* ---------- charts ---------- */
.chart { width: 100%; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.6; }
.chart .label { fill: var(--text-subtle); font-size: 10px; font-family: var(--font-sans); }
.chart .bar-in { fill: var(--accent); }
.chart .bar-out { fill: var(--gold-500); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent); opacity: 0.1; }
.legend { display: flex; gap: var(--space-4); font-size: var(--step--1); color: var(--text-muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- misc ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.page-head .titles p { color: var(--text-muted); font-size: var(--step-0); margin-top: 2px; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); }
.small { font-size: var(--step--1); }
.tiny { font-size: var(--step--2); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.stack { display: flex; flex-direction: column; }
.stack.gap-2 { gap: var(--space-2); }
.stack.gap-3 { gap: var(--space-3); }
.stack.gap-4 { gap: var(--space-4); }
.stack.gap-5 { gap: var(--space-5); }
.row { display: flex; align-items: center; gap: var(--space-3); }
.row.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
.center { text-align: center; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }

.empty { text-align: center; padding: var(--space-7) var(--space-4); color: var(--text-muted); }
.empty .mark { width: 44px; height: 44px; margin: 0 auto var(--space-3); opacity: 0.5; }
.empty h3 { color: var(--text); margin-bottom: 4px; }

.tooltip { border-bottom: 1px dotted var(--text-subtle); cursor: help; }

.filters { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.filters a {
  padding: 5px 11px; border-radius: var(--radius-full); font-size: var(--step--1);
  font-weight: 560; background: var(--surface); border: 1px solid var(--border);
  color: var(--text-muted); text-decoration: none;
}
.filters a[aria-current="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.filters a:hover { text-decoration: none; border-color: var(--accent); }

.flash { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-height) + 16px); z-index: 80; width: min(560px, calc(100vw - 32px)); }
@media (min-width: 900px) { .flash { bottom: 24px; } }
.flash .msg {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); margin-bottom: var(--space-2);
  background: var(--ink-900); color: #fff; font-size: var(--step-0); font-weight: 540;
}
.flash .msg.error { background: var(--red-600); }
.flash .msg.success { background: var(--green-600); }
.flash .msg.warning { background: var(--amber-600); }

/* Auth pages */
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-4); background: var(--bg-sunken); }
.auth-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-6); box-shadow: var(--shadow); }
.auth-card .brand { display: flex; align-items: center; gap: 10px; margin-bottom: var(--space-5); }
.auth-card .brand img { width: 34px; height: 34px; border-radius: 9px; }
.auth-card .brand strong { font-size: var(--step-1); letter-spacing: -0.02em; }
.auth-card h1 { font-size: var(--step-2); margin-bottom: 4px; }
.auth-card > p.lede { color: var(--text-muted); margin-bottom: var(--space-5); }
.auth-foot { text-align: center; margin-top: var(--space-4); font-size: var(--step--1); color: var(--text-muted); }

.qr-panel { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); padding: var(--space-4); background: #fff; border-radius: var(--radius); border: 1px solid var(--border); }
.qr-panel svg { width: min(220px, 60vw); height: auto; }
.secret-code { font-family: var(--font-mono); font-size: var(--step-0); letter-spacing: 0.06em; background: var(--surface-inset); padding: 8px 12px; border-radius: var(--radius-sm); word-break: break-all; text-align: center; color: var(--text); }
.recovery-codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-2); font-family: var(--font-mono); font-size: var(--step-0); }
.recovery-codes span { background: var(--surface-inset); padding: 7px 10px; border-radius: var(--radius-sm); text-align: center; letter-spacing: 0.04em; }

.otp-input { font-family: var(--font-mono); font-size: var(--step-3); letter-spacing: 0.4em; text-align: center; padding: 12px; }

/* Print — reports must print cleanly for an accountant */
@media print {
  .sidebar, .bottom-nav, .topbar, .btn, .filters, .flash { display: none !important; }
  body { background: #fff; color: #000; font-size: 10pt; }
  .card { border: none; box-shadow: none; padding: 0; }
  .content { padding: 0; max-width: none; }
  table.data th { position: static; }
  a { color: #000; text-decoration: none; }
}
