/* Reconciliation Service — admin UI.
   Server-rendered (Jinja2 + HTMX), plain CSS, no build step.
   Aesthetic: shadcn-grade neutral system — light bordered surfaces, restrained
   zinc palette, single green accent, soft shadows, consistent radius, ring-offset
   focus. IBM Plex stands in for Geist/Inter (vendored, on-prem). RTL-aware. */

/* --- Vendored fonts (local, on-prem) --- */
@font-face { font-family:"Plex"; src:url("/static/fonts/ibm-plex-sans-400.woff2") format("woff2"); font-weight:400; font-display:swap; }
@font-face { font-family:"Plex"; src:url("/static/fonts/ibm-plex-sans-500.woff2") format("woff2"); font-weight:500; font-display:swap; }
@font-face { font-family:"Plex"; src:url("/static/fonts/ibm-plex-sans-600.woff2") format("woff2"); font-weight:600; font-display:swap; }
@font-face { font-family:"PlexAr"; src:url("/static/fonts/ibm-plex-arabic-400.woff2") format("woff2"); font-weight:400; font-display:swap; }
@font-face { font-family:"PlexAr"; src:url("/static/fonts/ibm-plex-arabic-500.woff2") format("woff2"); font-weight:500; font-display:swap; }
@font-face { font-family:"PlexMono"; src:url("/static/fonts/ibm-plex-mono-400.woff2") format("woff2"); font-weight:400; font-display:swap; }
@font-face { font-family:"PlexMono"; src:url("/static/fonts/ibm-plex-mono-500.woff2") format("woff2"); font-weight:500; font-display:swap; }

:root {
  /* ===== Notion-style tokens — canonical source of truth =====
     See docs/superpowers/mockups/2026-08-07-notion-dashboard.html for the
     reference look. Everything below this block is legacy token NAMES kept
     because other rules in this file (and a few templates) still reference
     them — their VALUES now point at this light system so the whole app
     re-skins without any renaming. */
  --canvas:#ffffff; --sidebar:#e8e6e1; --panel:#efeee9;
  --text:#37352f; --text-2:#6b6a63; --text-3:#9b9a94;
  --line:rgba(15,15,14,.12); --line-2:rgba(15,15,14,.07);
  --accent:#0f7d59; --accent-2:#0b6347; --accent-soft:#eaf4ef;
  --hover:rgba(15,15,14,.045); --active:rgba(15,15,14,.06);
  --g:#1a7a48; --g-bg:#e9f4ec; --a:#8a6400; --a-bg:#f8f0dd; --r:#b3352c; --r-bg:#fbeae8; --b:#2a6fd0; --b-bg:#eaf1fb; --b-bd:#c7dbf5; --n:#605e57; --n-bg:#efefec;

  /* neutral (zinc) scale — legacy names, light values */
  --bg: #f3f1ec;              /* page canvas — warm light gray so white cards separate */
  --surface: #ffffff;         /* cards/surfaces — white, lifts off the gray canvas */
  --surface-2: var(--panel);  /* muted insets / table headers */
  --ink-strong: var(--text);  /* headings */
  --ink: var(--text);         /* body */
  --ink-2: var(--text-2);     /* muted-foreground */
  --ink-3: var(--text-3);     /* placeholder */
  /* --line / --line-2 set above */
  /* accent */
  --brand: var(--accent);
  --brand-ink: var(--accent-2);
  --brand-soft: var(--accent-soft);
  --ring: rgba(15,125,89,.32);
  /* sidebar — was dark, now the light Notion panel */
  --sidebar-bg: var(--sidebar);
  --sidebar-line: var(--line);
  --sidebar-ink: var(--text-2);
  --sidebar-ink-bright: var(--text);
  --sidebar-label: var(--text-3);
  --sidebar-hover: var(--hover);
  --sidebar-active: var(--active);
  --sidebar-scroll: rgba(15,15,14,.16);
  --sidebar-scroll-hover: rgba(15,15,14,.30);
  /* status (subtle tints) — unchanged; already read correctly on a white surface */
  --green:#137a44; --green-bg:#e7f6ec; --green-bd:#bfe6cd;
  --amber:#9a6700; --amber-bg:#fbf3df; --amber-bd:#ecd9a8;
  --red:#be2a23;   --red-bg:#fcebe9;   --red-bd:#f3c9c5;
  --grey:#52525b;  --grey-bg:#f1f1f3;  --grey-bd:#e0e0e4;
  /* solid action colours (vivid fills for coloured buttons) */
  --green-solid:#15924f; --green-solid-2:#0f7a40; --green-shadow:rgba(21,146,79,.30);
  --amber-solid:#c8810c; --amber-solid-2:#a86905; --amber-shadow:rgba(200,129,12,.30);
  --red-solid:#d63b34;   --red-solid-2:#b82b25;   --red-shadow:rgba(214,59,52,.30);
  /* layout */
  --sidebar-w: 248px;
  /* shape & depth */
  --radius: 6px;
  --radius-sm: 0.5rem;
  --radius-lg: 10px;
  --shadow-xs: 0 1px 2px rgba(15,15,14,.05);
  --shadow-sm: 0 1px 2px rgba(15,15,14,.04), 0 1px 3px rgba(15,15,14,.06);
  --shadow-md: 0 4px 14px rgba(15,15,14,.07), 0 2px 4px rgba(15,15,14,.04);

  /* ===== Dark palette — inert helper tokens (consumed by the dark remap
     selectors below). Values live here once; the remap just points the live
     tokens at these. Notion-grounded: page darkest, sidebar raised, cards
     lifted; accent brightened; status pills -> low-sat dark tints. ===== */
  --d-canvas:#242322; --d-sidebar:#1f1e1d; --d-panel:#201f1e;
  --d-bg:#191817; --d-surface:#242322;
  --d-text:#e8e7e4; --d-text-2:#9c9992; --d-text-3:#6e6b65;
  --d-line:rgba(255,255,255,.11); --d-line-2:rgba(255,255,255,.06);
  --d-accent:#35b07a; --d-accent-2:#5cc494; --d-accent-soft:rgba(53,176,122,.15);
  --d-ring:rgba(53,176,122,.45);
  --d-g:#63c791; --d-g-bg:rgba(53,176,122,.16); --d-a:#d8b25a; --d-a-bg:rgba(200,150,30,.16);
  --d-r:#e87c72; --d-r-bg:rgba(220,90,80,.16); --d-b:#6ea8f0; --d-b-bg:rgba(70,130,225,.16); --d-b-bd:rgba(70,130,225,.32);
  --d-n:#adaba5; --d-n-bg:rgba(255,255,255,.07);
  --d-green:#63c791; --d-green-bg:rgba(53,176,122,.15); --d-green-bd:rgba(53,176,122,.32);
  --d-amber:#d8b25a; --d-amber-bg:rgba(200,150,30,.15); --d-amber-bd:rgba(200,150,30,.32);
  --d-red:#e87c72; --d-red-bg:rgba(220,90,80,.15); --d-red-bd:rgba(220,90,80,.32);
  --d-grey:#adaba5; --d-grey-bg:rgba(255,255,255,.06); --d-grey-bd:rgba(255,255,255,.13);
  --d-hover:rgba(255,255,255,.055); --d-active:rgba(255,255,255,.085);
  --d-shadow-xs:0 1px 2px rgba(0,0,0,.35);
  --d-shadow-sm:0 1px 2px rgba(0,0,0,.35),0 1px 3px rgba(0,0,0,.4);
  --d-shadow-md:0 6px 18px rgba(0,0,0,.5),0 2px 6px rgba(0,0,0,.4);
  --d-sidebar-scroll:rgba(255,255,255,.18); --d-sidebar-scroll-hover:rgba(255,255,255,.32);
}

/* Base colour-scheme so native controls (selects, checkboxes, scrollbars)
   match the light theme by default. */
:root { color-scheme: light; }

/* Dark, when the OS prefers it AND the user has not explicitly forced light. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas:var(--d-canvas); --sidebar:var(--d-sidebar); --panel:var(--d-panel);
    --bg:var(--d-bg); --surface:var(--d-surface);
    --text:var(--d-text); --text-2:var(--d-text-2); --text-3:var(--d-text-3);
    --line:var(--d-line); --line-2:var(--d-line-2);
    --accent:var(--d-accent); --accent-2:var(--d-accent-2); --accent-soft:var(--d-accent-soft); --ring:var(--d-ring);
    --g:var(--d-g); --g-bg:var(--d-g-bg); --a:var(--d-a); --a-bg:var(--d-a-bg);
    --r:var(--d-r); --r-bg:var(--d-r-bg); --b:var(--d-b); --b-bg:var(--d-b-bg); --b-bd:var(--d-b-bd);
    --n:var(--d-n); --n-bg:var(--d-n-bg);
    --green:var(--d-green); --green-bg:var(--d-green-bg); --green-bd:var(--d-green-bd);
    --amber:var(--d-amber); --amber-bg:var(--d-amber-bg); --amber-bd:var(--d-amber-bd);
    --red:var(--d-red); --red-bg:var(--d-red-bg); --red-bd:var(--d-red-bd);
    --grey:var(--d-grey); --grey-bg:var(--d-grey-bg); --grey-bd:var(--d-grey-bd);
    --hover:var(--d-hover); --active:var(--d-active);
    --shadow-xs:var(--d-shadow-xs); --shadow-sm:var(--d-shadow-sm); --shadow-md:var(--d-shadow-md);
    --sidebar-scroll:var(--d-sidebar-scroll); --sidebar-scroll-hover:var(--d-sidebar-scroll-hover);
    color-scheme: dark;
  }
}

/* Dark, forced explicitly by the user (wins over any OS preference). */
:root[data-theme="dark"] {
  --canvas:var(--d-canvas); --sidebar:var(--d-sidebar); --panel:var(--d-panel);
  --bg:var(--d-bg); --surface:var(--d-surface);
  --text:var(--d-text); --text-2:var(--d-text-2); --text-3:var(--d-text-3);
  --line:var(--d-line); --line-2:var(--d-line-2);
  --accent:var(--d-accent); --accent-2:var(--d-accent-2); --accent-soft:var(--d-accent-soft); --ring:var(--d-ring);
  --g:var(--d-g); --g-bg:var(--d-g-bg); --a:var(--d-a); --a-bg:var(--d-a-bg);
  --r:var(--d-r); --r-bg:var(--d-r-bg); --b:var(--d-b); --b-bg:var(--d-b-bg); --b-bd:var(--d-b-bd);
  --n:var(--d-n); --n-bg:var(--d-n-bg);
  --green:var(--d-green); --green-bg:var(--d-green-bg); --green-bd:var(--d-green-bd);
  --amber:var(--d-amber); --amber-bg:var(--d-amber-bg); --amber-bd:var(--d-amber-bd);
  --red:var(--d-red); --red-bg:var(--d-red-bg); --red-bd:var(--d-red-bd);
  --grey:var(--d-grey); --grey-bg:var(--d-grey-bg); --grey-bd:var(--d-grey-bd);
  --hover:var(--d-hover); --active:var(--d-active);
  --shadow-xs:var(--d-shadow-xs); --shadow-sm:var(--d-shadow-sm); --shadow-md:var(--d-shadow-md);
  --sidebar-scroll:var(--d-sidebar-scroll); --sidebar-scroll-hover:var(--d-sidebar-scroll-hover);
  color-scheme: dark;
}

/* Explicit light forces the light scheme even on a dark OS. */
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Plex", "PlexAr", system-ui, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
:lang(ar), [dir="rtl"] { font-family: "PlexAr","Plex",system-ui,sans-serif; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { margin: 0; font-weight: 600; letter-spacing: -0.013em; color: var(--ink-strong); }
.mono, .amount, .num { font-family:"PlexMono",ui-monospace,monospace; font-variant-numeric: tabular-nums; }
::placeholder { color: var(--ink-3); }
input, select, textarea, button { font-family: inherit; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--ring);
}

/* ===== App shell ===== */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex: 0 0 248px; background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--sidebar-line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 11px; padding: 17px 18px 16px;
  color: var(--sidebar-ink-bright); font-weight: 600; font-size: 15px;
  border-bottom: 1px solid var(--sidebar-line);
}
.sidebar .brand .mark {
  width: 28px; height: 28px; border-radius: 7px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar .brand small { display:block; color: var(--sidebar-ink); font-weight:400; font-size:11px; letter-spacing:.01em; }
.nav { padding: 12px 12px; display: flex; flex-direction: column; gap: 1px; overflow-y:auto;
  scrollbar-width: thin; scrollbar-color: var(--sidebar-scroll) transparent; }
/* Thin, rounded scrollbar that suits the dark sidebar (WebKit/Chromium). The
   transparent border + padding-box clip render a slim pill inside a wider track. */
.nav::-webkit-scrollbar { width: 11px; }
.nav::-webkit-scrollbar-track { background: transparent; }
.nav::-webkit-scrollbar-thumb {
  background: var(--sidebar-scroll); border-radius: 999px;
  border: 3px solid transparent; background-clip: padding-box;
}
.nav::-webkit-scrollbar-thumb:hover { background: var(--sidebar-scroll-hover); background-clip: padding-box; }
.nav .label {
  font-size:11px; text-transform:uppercase; letter-spacing:.05em; color: var(--sidebar-label);
  padding:16px 10px 6px; font-weight:600;
}
.nav .label:first-child { padding-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px;
  border-radius: var(--radius-sm); color: var(--sidebar-ink); font-size: 13.5px; font-weight: 500;
  transition: background .12s, color .12s;
}
.nav a:hover { background: var(--sidebar-hover); color: var(--sidebar-ink-bright); text-decoration: none; }
.nav a.active { background: var(--sidebar-active); color: var(--sidebar-ink-bright); box-shadow: inset 2px 0 0 var(--brand); font-weight: 600; }
.nav a.active svg { opacity: 1; }
.nav a svg { width: 16px; height: 16px; opacity:.7; flex:0 0 auto; }
.sidebar .spacer { flex: 1; }
.sidebar .who {
  margin: 8px 12px 12px; padding: 10px 0 0; border-top:1px solid var(--sidebar-line);
  background: transparent; font-size: 13px;
}
.sidebar .who .name { color: var(--sidebar-ink-bright); font-weight: 500; }
.sidebar .who a { color: var(--sidebar-ink); font-size: 12px; }
.sidebar .who a:hover { color: var(--sidebar-ink-bright); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; background: var(--bg);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px; position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 15.5px; font-weight: 600; letter-spacing:-.015em; margin-inline-end:auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.topbar .crumb { color: var(--ink-3); font-weight: 400; }
.topbar .right { color: var(--ink-2); font-size: 13px; display:flex; gap:12px; align-items:center; flex:0 0 auto; }
.topbar .chip {
  background: var(--surface-2); color: var(--ink); font-weight:500;
  padding: 4px 11px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line);
  max-width: 240px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.topbar .who-mini { color: var(--ink-3); font-size:12.5px; }
.topbar .avatar {
  width: 30px; height: 30px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-ink);
  display: grid; place-items: center; font-weight: 600; font-size: 12.5px; border: 1px solid var(--green-bd);
}

/* ===== Theme toggle (top-bar sun/moon) ===== */
.theme-toggle {
  display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: 999px; background: transparent; border: 1px solid var(--line);
  color: var(--ink-2); cursor: pointer; flex: 0 0 auto;
  transition: background .12s, color .12s, border-color .12s;
}
.theme-toggle:hover { background: var(--hover); color: var(--ink); }
.theme-toggle:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }
.theme-toggle svg { width: 16px; height: 16px; }
/* Show the moon in light (click -> dark) and the sun in dark (click -> light),
   driven by the SAME cascade as the tokens so the icon is correct at first paint. */
.theme-toggle .ic-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .ic-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .ic-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .ic-moon { display: none; }
}
.content { padding: 30px 40px 56px; max-width: 1680px; margin-inline: auto; width: 100%; }
.lead { font-size: 14px; color: var(--ink-2); margin: 2px 0 26px; max-width: 720px; line-height:1.6; }
.lead strong { color: var(--ink-strong); font-weight: 600; }

/* ===== Buttons =====
   Neutral by default; colour carries meaning. Tinted action buttons fill with
   their solid colour on hover for a lively but professional feel. */
.btn {
  font: inherit; font-size: 13.5px; font-weight: 500; height: 36px; padding: 0 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none;
  background: var(--surface); color: var(--ink); display:inline-flex; align-items:center; justify-content:center; gap:7px;
  transition: background .14s, border-color .14s, box-shadow .14s, color .14s, transform .06s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex: 0 0 auto; }
.btn:hover { background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline:none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ring); }
.btn[disabled], .btn:disabled { opacity:.55; cursor:not-allowed; pointer-events:none; }

/* Primary commit — the brand action (Post to ledger) */
.btn-primary { background: var(--brand); color:#fff; border-color: var(--brand); font-weight: 500; box-shadow: none; }
.btn-primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }

/* Bulk approve — solid success green (Verify All) */
.btn-success { background: var(--green-solid); color:#fff; border-color: var(--green-solid); box-shadow: none; }
.btn-success:hover { background: var(--green-solid-2); border-color: var(--green-solid-2); }

/* Per-row approve — green tint, fills solid on hover (Confirm) */
.btn-confirm { background: var(--green-bg); border-color: var(--green-bd); color: var(--green); }
.btn-confirm:hover { background: var(--green-solid); border-color: var(--green-solid); color:#fff; box-shadow: none; }

/* Escalate — amber tint, fills solid on hover (Send for help) */
.btn-help { background: var(--amber-bg); border-color: var(--amber-bd); color: var(--amber); }
.btn-help:hover { background: var(--amber-solid); border-color: var(--amber-solid); color:#fff; box-shadow: none; }

/* Caution — red tint, fills solid on hover (Flag) */
.btn-flag { background: var(--red-bg); border-color: var(--red-bd); color: var(--red); }
.btn-flag:hover { background: var(--red-solid); border-color: var(--red-solid); color:#fff; box-shadow: none; }

.btn-save { height: 34px; font-size:12.5px; padding:0 13px; background: var(--brand-soft); border-color: var(--green-bd); color: var(--brand-ink); }
.btn-save:hover { background: var(--brand); border-color: var(--brand); color:#fff; box-shadow: none; }
.btn-sm { height: 32px; font-size:12.5px; padding:0 11px; }
.btn-lg { height: 40px; font-size:14px; padding:0 18px; }
.btn-block { width:100%; }

/* ===== Cards & grids ===== */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); margin-bottom: 18px;
}
.card:last-child { margin-bottom: 0; }
.card .card-h { padding: 18px 22px; border-bottom: 1px solid var(--line); display:flex; align-items:center; justify-content:space-between; gap:12px; }
.card .card-h h2 { font-size: 15px; display:flex; align-items:center; gap:9px; }
.card .card-h .count {
  font-family:"PlexMono",monospace; font-size:11px; font-weight:500;
  background: var(--surface-2); color: var(--ink-2); border-radius: 999px; padding: 2px 9px; border:1px solid var(--line);
}
.card .card-b { padding: 8px 0; }
.card-pad { padding: 26px 28px 28px; }   /* padded body for forms (not full-bleed tables) */
.stack { display: flex; flex-direction: column; gap: 22px; }
.stack .form-actions { margin-top: 4px; }
.card-desc { font-size: 12.5px; color: var(--ink-2); margin: 3px 0 0; font-weight: 400; }
.section-title { font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-3); margin: 4px 0 12px; font-weight:600; }

.stats { display:grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 12px; margin-bottom: 24px; }
.stat {
  background: var(--surface); border:1px solid var(--line); border-radius: var(--radius-lg);
  padding: 16px 18px; box-shadow: none; position: relative;
}
.stat .k { font-size:13px; color: var(--ink-2); display:flex; align-items:center; gap:7px; }
.stat .v { font-size: 27px; font-weight: 500; margin-top: 9px; font-family:"PlexMono",monospace; letter-spacing:-.01em; font-variant-numeric: tabular-nums; color: var(--ink-strong); }
.stat .dot { width:8px;height:8px;border-radius:50%; }
.stat.green .v{color:var(--green)} .stat.amber .v{color:var(--amber)} .stat.red .v{color:var(--red)}

/* ===== Segmented add / upload (shadcn Tabs: muted track, white active pill) ===== */
.seg-card { padding: 0; }
.seg-radio { position:absolute; width:1px; height:1px; opacity:0; pointer-events:none; }
.seg {
  display:inline-flex; gap:3px; background: var(--surface-2); padding:4px;
  border-radius: var(--radius-sm); margin: 18px 20px 2px; width: fit-content; max-width: calc(100% - 40px);
}
.seg-tab {
  font-size:13px; font-weight:500; padding:7px 14px; cursor:pointer; color:var(--ink-2);
  border-radius: calc(var(--radius-sm) - 3px); line-height:1.15; white-space:nowrap;
  transition: color .12s, background .12s, box-shadow .12s;
}
.seg-tab:hover { color:var(--ink-strong); }
.seg-radio:nth-of-type(1):checked ~ .seg .seg-tab:nth-of-type(1),
.seg-radio:nth-of-type(2):checked ~ .seg .seg-tab:nth-of-type(2) {
  background: var(--surface); color: var(--ink-strong); box-shadow: var(--shadow-xs); font-weight:600;
}
.seg-panels { padding: 26px 26px 28px; }
.seg-panel { display:none; }
/* display:block only (no entrance animation) — this rule also matches the
   panel that's already active on first page load (server sets `checked` via
   Jinja), so an entrance animation here would replay on every visit as a
   flash instead of only on an actual tab switch. */
.seg-radio:nth-of-type(1):checked ~ .seg-panels > .seg-panel:nth-of-type(1),
.seg-radio:nth-of-type(2):checked ~ .seg-panels > .seg-panel:nth-of-type(2) { display:block; }
@keyframes fade { from { opacity:0; transform: translateY(2px); } to { opacity:1; transform:none; } }

/* ===== Forms (field grid) ===== */
.field-grid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 22px 24px; max-width: 720px; }
.field { display:flex; flex-direction:column; gap:7px; min-width:0; }
.field.span-2 { grid-column: span 2; }
.field > label { font-size:12.5px; font-weight:500; color:var(--ink); }
.field .opt { color: var(--ink-3); font-weight:400; }
.field input, .field select {
  height: 38px; padding: 0 12px; font:inherit; font-size:13.5px; background:var(--surface);
  border:1px solid var(--line); border-radius:var(--radius); color:var(--ink); width:100%;
}
.field-static { margin:0; font-size:14px; font-weight:600; color:var(--ink-strong); }
.field.check { flex-direction:row; align-items:center; gap:9px; }
.field.check label { display:flex; align-items:center; gap:9px; font-size:13.5px; color:var(--ink); cursor:pointer; font-weight:500; }
.field.check input { width:17px; height:17px; accent-color: var(--brand); }
.form-actions { display:flex; gap:10px; margin-top: 22px; }

.uploader { display:flex; flex-direction:column; gap:10px; max-width: 600px; }
.uploader > label { font-size:12.5px; font-weight:500; color:var(--ink); }
.uploader input[type=file] {
  padding: 18px; border:1.5px dashed var(--line-2); border-radius: var(--radius);
  background: var(--surface-2); width:100%; font-size:13px; cursor:pointer; color: var(--ink-2);
  transition: border-color .12s, background .12s;
}
.uploader input[type=file]:hover { border-color: var(--brand); background: var(--brand-soft); }
.hint { font-size:12px; color:var(--ink-2); margin:0; line-height:1.55; }
.hint code { background:var(--surface-2); border:1px solid var(--line); border-radius:5px; padding:1px 6px; font-size:11.5px; color:var(--ink); font-family:"PlexMono",monospace; }

/* per-method SAP guidance panel (what this is + what you have to do) */
.sap-help { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 16px; margin: 0 0 16px; }
.sap-help h3 { font-size: 13.5px; margin: 0 0 6px; }
.sap-help p.hint { margin: 0 0 8px; }
.sap-help p.hint:last-child { margin-bottom: 0; }
.sap-help .steps { margin: 0; }
.sap-help .steps:last-child { padding-bottom: 0; }
.sap-help-more { margin: 8px 0 0; font-size: 12.5px; }
.sap-help-more:last-child { margin-bottom: 0; }
.sap-help-more a { font-weight: 600; }

/* ===== Tables (Notion database view) ===== */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: start; vertical-align: middle; }
table.data td { padding: 11px 16px; border-bottom: 1px solid var(--line-2); }
table.data thead th {
  color: var(--ink-3); font-weight: 500; font-size: 12px; padding: 9px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; white-space: nowrap;
}
table.data tbody tr { transition: background .1s; }
table.data tbody tr:hover { background: var(--hover); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.amount, table.data td.num { white-space: nowrap; }
table.data tr.is-inactive { opacity: .5; }
.col-actions { text-align: end; white-space: nowrap; }
.col-actions form { display:inline; margin:0; }
.col-actions .btn { margin-inline-start: 6px; }
.muted { color: var(--ink-2); }
.empty { padding: 48px 24px; color: var(--ink-3); text-align: center; font-size:13.5px; }

/* ===== Ledger (general-ledger view) ===== */
.data th.amt, .data td.amt { text-align: end; white-space: nowrap; }
.ledger td { vertical-align: top; }
.ledger tbody tr:hover { background: transparent; }     /* entries read as groups */
.ledger .le-start td { border-top: 2px solid var(--line-2); }
.le-ref { font-size: 12.5px; color: var(--ink); }
.le-meta { font-size: 11px; color: var(--ink-3); margin-top: 2px; text-transform: capitalize; }
.le-meta .pill { text-transform: none; margin-inline-start: 5px; }
.ledger tfoot .le-total td { font-weight: 600; border-top: 2px solid var(--ink-strong);
  background: var(--surface-2); color: var(--ink-strong); }
/* by-account view */
.ledger .le-acct td { font-weight: 600; color: var(--ink-strong); background: var(--surface-2);
  border-top: 2px solid var(--line-2); }
.ledger .le-subtotal td { font-weight: 500; color: var(--ink-2); border-top: 1px dashed var(--line-2); }
/* toolbar: view toggle (link-based segmented control) + date filter */
.ledger-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.seg-tab.is-active { background: var(--surface); color: var(--ink-strong); box-shadow: var(--shadow-xs); font-weight: 600; }
.ledger-filter { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; }
.ledger-filter label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.ledger-filter input { height: 34px; padding: 0 10px; font: inherit; font-size: 13px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); }

/* set-up checklist */
.steps { margin: 0; padding-inline-start: 20px; color: var(--ink-2); font-size:13.5px; }
.steps li { padding: 6px 0; }
.steps strong { color: var(--ink-strong); }

/* row tint by status */
.row-green { box-shadow: inset 3px 0 0 var(--green); }
.row-amber { box-shadow: inset 3px 0 0 var(--amber); }
.row-red   { box-shadow: inset 3px 0 0 var(--red); }
.row-grey  { box-shadow: inset 3px 0 0 var(--grey); }

/* ===== Badges / pills — Notion tag: soft-bg pastel pill + dot marker ===== */
.pill { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; font-weight:500; padding:2px 9px; border-radius:20px; border:1px solid transparent; text-transform:capitalize; line-height:1.3; }
.pill::before { content:""; width:6px; height:6px; border-radius:50%; background:currentColor; opacity:.85; flex:0 0 auto; }
.pill-green { background:var(--g-bg); color:var(--g); }
.pill-amber { background:var(--a-bg); color:var(--a); }
.pill-red   { background:var(--r-bg); color:var(--r); }
.pill-blue  { background:var(--b-bg); color:var(--b); }
.pill-grey  { background:var(--n-bg); color:var(--n); }

/* ===== Review toolbar (title + batch-level actions) ===== */
.review-tools {
  display:flex; align-items:flex-start; justify-content:space-between; gap:14px 18px;
  padding:16px 20px; border-bottom:1px solid var(--line); flex-wrap:wrap;
}
.review-tools .rt-title h2 { font-size:15px; display:flex; align-items:center; gap:9px; }
.review-tools .rt-sub { font-size:12.5px; color:var(--ink-2); margin-top:4px; max-width:52ch; line-height:1.5; }

/* ===== Action bar ===== */
.actionbar { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.actionbar .sep { width:1px; align-self:stretch; background:var(--line); margin:2px 2px; }

/* ===== Tabs (review) — Notion segmented control, horizontally scrollable ===== */
.tabs {
  display:inline-flex; gap:2px; margin: 12px 20px 14px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px;
  max-width: calc(100% - 40px); overflow-x:auto; scrollbar-width:none; -webkit-overflow-scrolling:touch;
}
.tabs::-webkit-scrollbar { display:none; }
.tab {
  font: inherit; font-size:13px; font-weight:500; padding:7px 14px; cursor:pointer; color:var(--ink-2);
  background:transparent; border:none; border-radius:6px;
  white-space:nowrap; display:inline-flex; align-items:center;
  transition: background .12s, color .12s, box-shadow .12s;
}
.tab:hover { color: var(--ink-strong); }
.tab.active { background: var(--surface); color: var(--ink-strong); font-weight:600; box-shadow: var(--shadow-xs); }
.tab .count { font-family:"PlexMono",monospace; font-size:11px; background:var(--surface); color:var(--ink-2); border-radius:999px; padding:1px 7px; margin-inline-start:6px; border:1px solid var(--line); }
.tab.active .count { background:var(--brand-soft); color:var(--brand-ink); border-color:var(--green-bd); }

/* Per-account filter above the review tabs (multi-account recon) */
.acct-bar { display:flex; align-items:center; gap:14px; flex-wrap:wrap; padding:14px 20px 0; }
.acct-filter { display:flex; align-items:center; gap:8px; margin:0; }
.acct-filter .k { font-size:11px; font-weight:600; color:var(--ink-2); text-transform:uppercase; letter-spacing:.04em; }
.acct-filter select {
  font:inherit; font-size:13px; height:34px; padding:0 10px; min-width:200px;
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); color:var(--ink);
}
.acct-hint { font-size:12px; color:var(--ink-2); }

/* Per-account TABS (segmented control) — one tab per bank statement in the recon.
   Deliberately distinct from the underline .tabs below so the two rows don't merge. */
.acct-lbl { font-size:11px; font-weight:600; color:var(--ink-2); text-transform:uppercase; letter-spacing:.04em; }
.acct-tabs { display:inline-flex; flex-wrap:wrap; gap:3px; background:var(--panel); border:1px solid var(--line); border-radius:8px; padding:3px; }
.acct-tab { appearance:none; border:0; background:none; font:inherit; font-size:13px; font-weight:500; color:var(--ink-2); cursor:pointer; padding:5px 12px; border-radius:6px; line-height:1.3; }
.acct-tab:hover { color:var(--ink-strong); }
.acct-tab.active { background:var(--surface); color:var(--ink-strong); font-weight:600; box-shadow:var(--shadow-xs); }
.acct-tab:focus-visible { outline:2px solid var(--ring); outline-offset:1px; }

/* ===== Match cards (review list) =====
   A card pairs a RECEIPT with its candidate BANK LINE. A status stripe runs
   down the inline-start edge; sections are separated by hairlines. */
.match-list { display: flex; flex-direction: column; gap: 14px; padding: 18px 20px; }
.match-card {
  position: relative; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--surface); box-shadow: var(--shadow-sm); overflow: hidden;
  transition: box-shadow .14s, border-color .14s;
}
.match-card:hover { box-shadow: var(--shadow-md); }
.match-card::before { content:""; position:absolute; inset-block:0; inset-inline-start:0; width:3px; background: var(--line-2); }
.match-card.row-green::before { background: var(--green); }
.match-card.row-amber::before { background: var(--amber); }
.match-card.row-red::before   { background: var(--red); }
.match-card.row-grey::before  { background: var(--grey); }

/* header: status + amount + primary action */
.mc-head { display: flex; align-items: center; gap: 10px 14px; padding: 13px 16px; flex-wrap: wrap; }
.mc-head-main { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; min-width: 0; }
.mc-amount { font-weight: 600; font-size: 17px; color: var(--ink-strong); font-family:"PlexMono",monospace; letter-spacing:-.01em; }
.mc-amount .cur { font-size: 12px; color: var(--ink-2); font-weight:500; margin-inline-start:3px; }
.mc-dir { font-size:11px; font-weight:500; color:var(--ink-2); background:var(--surface-2); border:1px solid var(--line); border-radius:6px; padding:2px 8px; }
.mc-actions { margin-inline-start: auto; display: flex; gap: 8px; align-items: center; }

/* pairing: receipt → bank line */
.mc-pair { display: grid; grid-template-columns: 1fr auto 1fr; border-top: 1px solid var(--line); }
.mc-side { padding: 12px 16px; min-width: 0; }
.mc-side .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; display:block; margin-bottom: 4px; }
.mc-side .v { font-size: 13.5px; color: var(--ink); overflow-wrap: anywhere; }
.mc-side .sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; overflow-wrap: anywhere; }
.mc-arrow { display: grid; place-items: center; padding: 0 4px; color: var(--ink-3); background: var(--surface-2); border-inline: 1px solid var(--line); }
.mc-arrow svg { width: 17px; height: 17px; }
.mc-side.is-empty .v { color: var(--ink-3); }

/* meta row: partner / match basis / journal */
.mc-meta { display: flex; flex-wrap: wrap; gap: 7px 18px; padding: 11px 16px; border-top: 1px solid var(--line); }
.mc-chip { display: inline-flex; align-items: baseline; gap: 6px; font-size: 12.5px; color: var(--ink-2); min-width:0; }
.mc-chip .k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight:600; }
.mc-chip b { color: var(--ink); font-weight: 500; overflow-wrap:anywhere; }
.mc-chip .je { color: var(--green); font-family: "PlexMono", monospace; font-size:12px; }

/* collapsibles (AI note + edit allocation) */
.mc-disc { padding: 0 16px; border-top: 1px solid var(--line); }
.mc-disc > summary { cursor: pointer; font-size: 12.5px; color: var(--brand-ink); padding: 10px 0; font-weight: 500; list-style: none; display: inline-flex; align-items:center; gap:6px; }
.mc-disc > summary::-webkit-details-marker { display:none; }
.mc-disc > summary::before { content:""; width:6px; height:6px; border-inline-end:1.6px solid currentColor; border-block-end:1.6px solid currentColor; transform: rotate(-45deg); transition: transform .15s; margin-inline-end:2px; }
.mc-disc[open] > summary::before { transform: rotate(45deg); }
.reason-body { padding: 2px 0 12px; font-size: 12.5px; color: var(--ink-2); max-width: 70ch; line-height:1.55; }

.mc-edit-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px 16px; margin: 2px 0 12px; padding: 14px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.mc-edit-grid label { display: block; font-size: 10.5px; text-transform:uppercase; letter-spacing:.05em; color: var(--ink-2); font-weight:600; }
.mc-edit-grid select { display: block; width: 100%; margin-top: 5px; font: inherit; font-size: 12.5px; height:36px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color:var(--ink); }
.mc-edit-actions { display: flex; gap: 8px; margin: 0 0 12px; flex-wrap:wrap; }

/* footer: secondary per-row actions */
.mc-foot { display: flex; align-items: center; gap: 8px; padding: 11px 16px; border-top: 1px solid var(--line); background: var(--surface-2); flex-wrap: wrap; }
.mc-help-link { font-size: 12px; margin-inline-start: auto; }
.confirmed-badge { display:inline-flex; align-items:center; gap:6px; color: var(--green); font-weight: 600; font-size: 13px; background:var(--green-bg); border:1px solid var(--green-bd); padding:5px 11px; border-radius: var(--radius-sm); }

/* ===== Notices (tinted callouts) ===== */
.notice { margin: 0 0 18px; padding: 13px 16px; border-radius: var(--radius); font-size:13px; border:1px solid; }
.notice-info { background:var(--b-bg); border-color:var(--b-bd); color:var(--b); }
.notice-ok { background:var(--green-bg); border-color:var(--green-bd); color:var(--green); }

/* ===== Forms (legacy config / login) ===== */
.form-card { max-width: 540px; }
.form-card label { display:block; margin:16px 0; font-size:13px; font-weight:500; color:var(--ink); }
.form-card input, .form-card select, .form-card textarea {
  display:block; width:100%; margin-top:6px; height:38px; padding:0 12px; font:inherit;
  font-weight:400; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface);
}
table.kv { width:100%; border-collapse:collapse; font-size:13px; }
table.kv th { text-align:start; width:130px; color:var(--ink-2); vertical-align:top; padding:5px 10px 5px 0; font-weight:400; }
table.kv td { padding:5px 0; }

/* ===== Standalone (login / help / public) ===== */
.center-wrap { min-height:100vh; display:grid; place-items:center; padding:24px; background:
  radial-gradient(1100px 460px at 50% -10%, #eef5f1, var(--bg)); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .center-wrap {
    background: radial-gradient(1100px 460px at 50% -10%, #16241d, var(--bg));
  }
}
:root[data-theme="dark"] .center-wrap {
  background: radial-gradient(1100px 460px at 50% -10%, #16241d, var(--bg));
}
.auth-card { width:100%; max-width:380px; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--radius-lg); box-shadow: var(--shadow-md); padding:28px 28px 26px; }
.auth-card .brand { display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.auth-card .brand .mark { width:32px;height:32px;border-radius:9px;background:var(--brand);display:grid;place-items:center;color:#fff;font-weight:700;box-shadow:0 2px 6px rgba(15,125,89,.32); }
.auth-card p.muted { margin: 2px 0 16px; }
.auth-card .notice { margin: 0 0 14px; }
.auth-card form label { display:block; font-size:13px; font-weight:500; color:var(--ink); margin:10px 0; }
.auth-card form input {
  display:block; width:100%; margin-top:5px; height:38px; padding:0 12px; font:inherit; font-size:13.5px;
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); color:var(--ink);
}
.auth-card .btn-primary { width:100%; justify-content:center; margin-top:8px; }

.help-wrap { max-width: 640px; margin: 0 auto; }
.help-wrap h1 { font-size:22px; margin-bottom:6px; }
.help-intro { margin: 6px 0 22px; font-size:14px; line-height:1.6; }
.help-card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:20px 22px; margin:14px 0; box-shadow:var(--shadow-sm); }
.help-card h2 { font-size:16px; margin-bottom:4px; }
.help-card label { display:block; font-size:13px; font-weight:500; color:var(--ink); margin:14px 0 0; }
.help-card label:first-of-type { margin-top:14px; }
.help-card > label:first-child { margin-top:0; }
.help-card input, .help-card select, .help-card textarea {
  display:block; width:100%; margin-top:6px; padding:0 12px; height:38px; font:inherit; font-size:13.5px;
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); color:var(--ink);
}
.help-card textarea { height:auto; min-height:72px; padding:10px 12px; line-height:1.5; resize:vertical; }
.help-card .btn { margin-top:16px; }
/* one payment's info + its "who is this for" picker, in a day's batch help form */
.help-item { padding:16px 0; border-top:1px solid var(--line-2); }
.help-item:first-of-type { border-top:none; padding-top:6px; }
.help-item-info { font-size:13.5px; margin-bottom:2px; }
.help-item-info .muted { font-size:12.5px; margin-top:2px; }

/* ===== Processing / progress (async /new) ===== */
.proc { display:flex; flex-direction:column; align-items:center; gap:16px; padding: 24px 0 8px; }
.spinner { width:36px; height:36px; border-radius:50%; border:3px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.proc-status { color: var(--ink-2); font-size:13.5px; margin:0; }
.proc-status.err { color: var(--red); max-width:460px; }

/* ===== Mobile nav drawer (pure CSS, no JS) =====
   A hidden checkbox toggles the off-canvas sidebar; the burger + scrim are
   <label>s pointing at it. Hidden on desktop; activated in the media query.
   State survives HTMX swaps (they never touch the sidebar) and resets to closed
   on full page navigation — exactly the desired behaviour. */
.nav-toggle { position:absolute; opacity:0; width:0; height:0; pointer-events:none; }
.burger {
  display:none; align-items:center; justify-content:center; width:38px; height:38px;
  border:1px solid var(--line-2); border-radius:var(--radius-sm); background:var(--surface);
  color:var(--ink); cursor:pointer; flex:0 0 auto; box-shadow:var(--shadow-xs);
}
.burger:hover { background:var(--surface-2); }
.burger svg { width:19px; height:19px; }
.nav-scrim { display:none; }
.nav-close { display:none; }

/* ===== Modal (confirm dialogs) ===== */
.modal-overlay { position: fixed; inset: 0; background: rgba(9,9,11,.45); display: grid; place-items: center; z-index: 60; padding: 20px; animation: fade .12s ease; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 22px 24px; max-width: 460px; width: 100%; }
.modal h3 { margin: 0 0 10px; font-size: 16px; }
.modal p { margin: 0 0 8px; color: var(--ink-2); font-size: 13.5px; line-height: 1.55; }
.modal p strong { color: var(--ink-strong); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ===== Responsive ===== */

/* Tablet: tighten the workspace gutters */
@media (max-width: 1024px) {
  .content { padding: 26px 24px 48px; }
  .topbar { padding: 0 24px; }
}

/* Phones + small tablets: sidebar becomes an off-canvas drawer */
@media (max-width: 860px) {
  .burger { display:inline-flex; }
  .topbar { padding: 0 16px; gap:10px; }
  .topbar h1 { font-size:15px; }
  .content { padding: 20px 16px 44px; }

  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60;
    width: 264px; flex-basis: 264px; height: 100dvh;
    transform: translateX(-100%); transition: transform .24s ease;
    box-shadow: 0 24px 60px rgba(15,15,14,.35);
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .nav-toggle:checked ~ .app .sidebar { transform: translateX(0); }
  .nav-toggle:checked ~ .app .nav-scrim {
    display:block; position:fixed; inset:0; z-index:50;
    background:rgba(15,15,14,.45); backdrop-filter:blur(2px); animation: fade .2s ease;
  }
  .nav-close {
    display:grid; place-items:center; position:absolute; inset-block-start:14px; inset-inline-end:12px;
    width:30px; height:30px; border-radius:var(--radius-sm); color:var(--sidebar-ink);
    background:var(--sidebar-hover); font-size:16px; cursor:pointer; z-index:1;
  }
  .nav-close:hover { color:var(--sidebar-ink-bright); }
  .main { width:100%; min-width:0; }

  /* review: amount + actions stack cleanly */
  .review-tools .actionbar { width:100%; }
}

/* Narrow phones: stack everything, hide secondary topbar chrome */
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: span 1; }
  .content { padding: 16px 12px 40px; }
  .topbar .chip, .topbar .who-mini { display:none; }
  .card .card-h { padding: 14px 16px; }
  .match-list { padding: 14px 12px; }
  .mc-pair { grid-template-columns: 1fr; }
  .mc-arrow { border-inline:none; border-block:1px solid var(--line); padding:5px; }
  .mc-arrow svg { transform: rotate(90deg); }
  [dir="rtl"] .mc-arrow svg { transform: rotate(90deg) scaleX(-1); }
  .mc-actions { margin-inline-start:0; width:100%; }
  .mc-actions .btn { flex:1; }
  .actionbar .btn { flex:1 1 auto; }
  table.data th, table.data td { padding: 11px 14px; }
}

/* ===== Chatbot — floating launcher + popover (pure-CSS toggle, like the nav drawer) ===== */
.chat-toggle { position:absolute; opacity:0; width:0; height:0; pointer-events:none; }
.chat-fab {
  position: fixed; inset-block-end: 22px; inset-inline-end: 22px; z-index: 40;
  width: 52px; height: 52px; border-radius: 999px; cursor: pointer;
  background: var(--brand); color: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(15,125,89,.36), var(--shadow-md);
  transition: background .14s, transform .08s;
}
.chat-fab:hover { background: var(--brand-ink); }
.chat-fab:active { transform: translateY(1px); }
.chat-fab svg { width: 24px; height: 24px; }
.chat-fab .ic-close { display: none; }
.chat-toggle:checked ~ .chat-fab .ic-open { display: none; }
.chat-toggle:checked ~ .chat-fab .ic-close { display: block; }

.chat-pop {
  position: fixed; inset-block-end: 86px; inset-inline-end: 22px; z-index: 40;
  width: 370px; max-width: calc(100vw - 44px);
  height: 480px; max-height: calc(100dvh - 130px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md); display: none; flex-direction: column; overflow: hidden;
}
.chat-toggle:checked ~ .chat-pop { display: flex; animation: fade .16s ease; }
.chat-pop-head { display:flex; align-items:center; justify-content:space-between; gap:10px;
  padding: 12px 15px; border-bottom: 1px solid var(--line); }
.chat-pop-head .t { font-weight: 600; color: var(--ink-strong); font-size: 13.5px; display:flex; align-items:center; gap:8px; }
.chat-pop-head .t svg { width:16px; height:16px; color: var(--brand); }
.chat-pop-x { cursor:pointer; color: var(--ink-3); width:26px; height:26px; display:grid; place-items:center; border-radius:6px; font-size:14px; }
.chat-pop-x:hover { background: var(--surface-2); color: var(--ink); }
.chat-pop-log { flex:1; overflow-y:auto; padding: 14px; display:flex; flex-direction:column; gap: 12px; }
.chat-hint { color: var(--ink-3); font-size: 12.5px; margin: 2px 0; }
.chat-pop-form { display:flex; gap:8px; padding: 10px; border-top: 1px solid var(--line); background: var(--surface); }
.chat-pop-form input { flex:1; height:38px; padding: 0 12px; font: inherit; font-size:13.5px;
  border:1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); }
.chat-pop-form button { flex:0 0 auto; width:38px; height:38px; border:none; border-radius: var(--radius-sm);
  background: var(--brand); color:#fff; cursor:pointer; font-size:17px; display:grid; place-items:center; }
.chat-pop-form button:hover { background: var(--brand-ink); }
.chat-pop-form button:disabled { opacity:.5; cursor:default; }

/* "thinking" indicator — htmx (hx-indicator) shows this only while a request is in flight */
.chat-thinking { display:none; align-items:center; gap:8px; padding: 2px 14px 10px; color: var(--ink-3); font-size: 12.5px; }
.chat-thinking.htmx-request { display:flex; }
.chat-thinking .dots { display:inline-flex; gap:4px; }
.chat-thinking .dots i { width:6px; height:6px; border-radius:50%; background: var(--brand); animation: chatdot 1s infinite ease-in-out; }
.chat-thinking .dots i:nth-child(2) { animation-delay:.15s; }
.chat-thinking .dots i:nth-child(3) { animation-delay:.3s; }
@keyframes chatdot { 0%,100% { opacity:.3; transform: translateY(0); } 40% { opacity:1; transform: translateY(-3px); } }

/* one Q/A turn (shared by the popover and the full /chat page) */
.chat-turn { display:flex; flex-direction:column; gap:6px; }
.chat-q, .chat-a { padding: 8px 11px; border-radius: var(--radius-sm); font-size: 13px; line-height:1.5; max-width: 92%; overflow-wrap: anywhere; }
.chat-q { align-self: flex-end; background: var(--brand-soft); color: var(--brand-ink); }
.chat-a { align-self: flex-start; background: var(--surface-2); color: var(--ink); }
.chat-a.error { background: var(--red-bg); color: var(--red); }
.chat-q .who, .chat-a .who { display:block; font-size: 9.5px; text-transform: uppercase; letter-spacing:.06em; color: var(--ink-3); margin-bottom: 3px; font-weight:600; }
.chat-table { align-self: flex-start; border-collapse: collapse; font-size: 12px; margin-top: 2px; }
.chat-table th, .chat-table td { border: 1px solid var(--line); padding: 3px 8px; text-align: start; }
.chat-table th { background: var(--surface-2); color: var(--ink-2); font-weight:500; }
.chat-sql { align-self: flex-start; max-width: 100%; }
.chat-sql > summary { cursor:pointer; font-size: 11.5px; color: var(--brand-ink); }
.chat-sql pre { margin: 6px 0 0; background: var(--surface-2); border:1px solid var(--line); border-radius: var(--radius-sm);
  padding: 9px 11px; overflow-x:auto; font-family:"PlexMono",monospace; font-size: 11.5px; color: var(--ink); }

/* full /chat page panel */
.card.chat { padding: 18px 20px; }
.card.chat .chat-log { display:flex; flex-direction:column; gap: 12px; margin: 14px 0; min-height: 80px; }
.card.chat .chat-form { display:flex; gap:10px; }
.card.chat .chat-form input { flex:1; height:40px; padding:0 13px; font:inherit; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); }
.card.chat .chat-form button { height:40px; padding:0 18px; border:none; border-radius:var(--radius-sm); background:var(--brand); color:#fff; cursor:pointer; font-weight:500; }
.card.chat .chat-form button:hover { background:var(--brand-ink); }

@media (max-width: 640px) {
  .chat-pop { inset-inline-start: 12px; inset-inline-end: 12px; width: auto; max-width: none; }
  .chat-fab { inset-block-end: 16px; inset-inline-end: 16px; }
}

/* ===== Batch cards (batches list) ===== */
.batch-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap:16px; }
.batch-card {
  position:relative; border:1px solid var(--line); border-radius:var(--radius-lg);
  background:var(--surface); box-shadow:var(--shadow-sm); overflow:hidden;
  transition: box-shadow .14s, border-color .14s;
}
.batch-card:hover { box-shadow:var(--shadow-md); }
.batch-card::before { content:""; position:absolute; inset-block:0; inset-inline-start:0; width:3px; background:var(--line-2); }
.batch-card.row-green::before { background:var(--green); }
.batch-card.row-amber::before { background:var(--amber); }
.batch-card.row-red::before   { background:var(--red); }
.batch-card.row-grey::before  { background:var(--grey); }
.bc-head { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:13px 16px 12px; border-bottom:1px solid var(--line); }
.bc-head .bc-no { font-weight:600; color:var(--ink-strong); font-size:14.5px; }
.bc-body { padding:14px 16px; display:grid; grid-template-columns:repeat(2, minmax(130px, 1fr)); gap:13px 16px; }
.bc-item { min-width:0; }
.bc-item.span-2 { grid-column:span 2; }
.bc-item .k { font-size:10.5px; text-transform:uppercase; letter-spacing:.05em; color:var(--ink-3); font-weight:600; display:block; margin-bottom:4px; }
.bc-item .v { font-size:13px; color:var(--ink); overflow-wrap:anywhere; }

/* ===== Setup guide (/guide) — curated docs rendered to readable HTML =====
   Docs layout: a readable content column + a sticky "On this page" rail (the
   app's own left nav already occupies the far left, so this is a second,
   lightweight in-page index — not another sidebar). Collapses to a
   horizontal, scrollable chip row above the content on narrow screens. */
.guide-head { max-width: 780px; margin: 0 0 26px; }
.guide-eyebrow {
  font-family:"PlexMono",monospace; font-size:11px; text-transform:uppercase;
  letter-spacing:.08em; color:var(--ink-3); font-weight:600; margin:0 0 8px;
}
.guide-head h1 { font-size:23px; line-height:1.25; }
.guide-head .lead { margin: 8px 0 0; max-width:none; }

.guide { display:grid; grid-template-columns: minmax(0,780px) 230px; gap:32px; align-items:start; }
.guide-docs { grid-column:1; grid-row:1; min-width:0; display:flex; flex-direction:column; gap:22px; }

.guide-index {
  grid-column:2; grid-row:1; position:sticky; top:78px; max-height:calc(100vh - 96px);
  overflow-y:auto; display:flex; flex-direction:column; gap:2px;
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface);
  box-shadow: var(--shadow-xs); padding:10px;
}
.guide-index-label { font-size:10.5px; text-transform:uppercase; letter-spacing:.06em; color:var(--ink-3); font-weight:600; padding:4px 8px 8px; }
.guide-rail-link {
  display:flex; flex-direction:column; gap:6px; padding:8px 9px; border-radius:var(--radius-sm);
  color:var(--ink); text-decoration:none; font-size:12.5px; font-weight:500; line-height:1.3;
  transition: background .12s;
}
.guide-rail-link:hover { background:var(--surface-2); text-decoration:none; }
.guide-rail-link.is-active { background:var(--brand-soft); box-shadow: inset 2px 0 0 var(--brand); }
.guide-rail-link.is-active .t { color:var(--brand-ink); font-weight:600; }
.guide-rail-link:focus-visible { outline:none; box-shadow: 0 0 0 3px var(--ring); background:var(--surface-2); }

/* Audience pills — the signature device: 3 hues only. Grey = general
   audience, brand green = admin/operator, amber = SAP Basis/ABAP. PlexMono,
   small, uppercase — same badge language as .pill, sized for inline use. */
.guide-pill {
  font-family:"PlexMono",monospace; font-size:10px; font-weight:600; text-transform:uppercase;
  letter-spacing:.04em; padding:3px 9px; border-radius:999px; border:1px solid; white-space:nowrap;
  line-height:1.4;
}
.guide-pill--grey  { background:var(--grey-bg);   color:var(--grey);     border-color:var(--grey-bd); }
.guide-pill--brand { background:var(--brand-soft); color:var(--brand-ink); border-color:var(--green-bd); }
.guide-pill--amber { background:var(--amber-bg);  color:var(--amber);    border-color:var(--amber-bd); }

.guide-card {
  border:1px solid var(--line); border-radius:var(--radius); background:var(--surface);
  box-shadow: var(--shadow-xs); overflow:hidden; scroll-margin-top:78px;
}
.guide-card-h {
  display:flex; align-items:center; justify-content:space-between; gap:14px; flex-wrap:wrap;
  padding:18px 26px; border-bottom:1px solid var(--line);
}
.guide-card-h h2 { font-size:16.5px; }

.guide-doc { padding:22px 26px 28px; color:var(--ink); line-height:1.65; font-size:14px; }
.guide-doc h1, .guide-doc h2, .guide-doc h3, .guide-doc h4 {
  color:var(--ink-strong); line-height:1.3; margin: 1.5em 0 .55em; font-weight:600;
}
.guide-doc h1:first-child, .guide-doc h2:first-child, .guide-doc h3:first-child { margin-top:0; }
.guide-doc h1 { font-size:19px; padding-bottom:10px; border-bottom:1px solid var(--line); }
.guide-doc h2 { font-size:16px; }
.guide-doc h3 { font-size:14px; }
.guide-doc h4 { font-size:13px; color:var(--ink-2); text-transform:uppercase; letter-spacing:.03em; }
.guide-doc p, .guide-doc ul, .guide-doc ol { margin: .7em 0; }
.guide-doc ul, .guide-doc ol { padding-inline-start: 1.5em; }
.guide-doc li { margin: .3em 0; }
.guide-doc a { color: var(--brand); text-decoration: underline; text-decoration-color: var(--line-2); }
.guide-doc a:hover { text-decoration-color: currentColor; }
.guide-doc strong { color: var(--ink-strong); font-weight:600; }
.guide-doc code {
  font-family:"PlexMono",monospace; font-size:12px; background:var(--grey-bg);
  border:1px solid var(--line); border-radius:var(--radius-sm); padding:1px 6px; color:var(--ink);
  overflow-wrap:anywhere;
}
.guide-doc pre {
  background:var(--grey-bg); border:1px solid var(--line); border-radius:var(--radius-sm);
  padding:14px 16px; overflow-x:auto; margin: 1em 0;
  white-space:pre-wrap; overflow-wrap:anywhere;
}
.guide-doc pre code { background:none; border:none; padding:0; font-size:12px; line-height:1.6; }
.guide-doc table { width:100%; border-collapse:collapse; font-size:12.5px; margin: 1em 0; }
.guide-doc th, .guide-doc td { border:1px solid var(--line); padding:8px 11px; text-align:start; vertical-align:top; overflow-wrap:anywhere; }
.guide-doc th { background:var(--surface-2); color:var(--ink-2); font-weight:600; }
.guide-doc hr { border:none; border-top:1px solid var(--line); margin: 1.6em 0; }
.guide-doc blockquote {
  margin: 1em 0; padding: 10px 16px; border-inline-start: 3px solid var(--brand);
  background: var(--brand-soft); border-radius: var(--radius-sm); color: var(--ink);
}
.guide-doc blockquote p { margin: .3em 0; }
.guide-doc blockquote strong { color: var(--brand-ink); }

@media (max-width: 900px) {
  .guide-head { max-width:none; }
  /* minmax(0,1fr), not a bare 1fr: a flexible track's implicit minimum is
     content-based, so without the 0 floor the nowrap chip row below would
     force this whole column (and the page) wider than the viewport. */
  .guide { grid-template-columns: minmax(0,1fr); gap:16px; }
  .guide-docs { grid-row:2; grid-column:1; }
  .guide-index {
    grid-row:1; grid-column:1; position:static; max-height:none; min-width:0;
    flex-direction:row; flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch;
    scrollbar-width:none; gap:8px;
  }
  .guide-index::-webkit-scrollbar { display:none; }
  .guide-index-label { display:none; }
  .guide-rail-link { flex:0 0 auto; flex-direction:row; align-items:center; gap:8px; white-space:nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  .guide-rail-link { transition:none; }
  html { scroll-behavior:auto; }
}
.bc-item .v .sub { display:block; font-size:11.5px; color:var(--ink-2); margin-top:2px; }
.bc-foot { display:flex; gap:8px; padding:11px 16px; border-top:1px solid var(--line); background:var(--surface-2); }

/* ===== Config setup journey (numbered steps on /config) ===== */
.card-h-title { display:flex; align-items:center; gap:11px; min-width:0; }
.step-badge {
  flex:0 0 auto; display:grid; place-items:center; width:26px; height:26px;
  border-radius:999px; background:var(--brand-soft); color:var(--brand-ink);
  border:1px solid var(--green-bd); font-family:"PlexMono",monospace;
  font-size:13px; font-weight:500; font-variant-numeric:tabular-nums;
}
.step-link {
  display:flex; align-items:center; gap:13px; margin-top:18px; padding:15px 18px;
  background:var(--surface); border:1px solid var(--line); border-radius:var(--radius-lg);
  box-shadow:var(--shadow-xs); color:var(--ink); text-decoration:none;
  transition:background .12s, border-color .12s;
}
.step-link:hover { background:var(--hover); text-decoration:none; }
.step-link:focus-visible { outline:none; box-shadow:0 0 0 3px var(--ring); }
.step-link-body { display:flex; flex-direction:column; gap:2px; min-width:0; flex:1; }
.step-link-title { font-weight:600; font-size:15px; color:var(--ink-strong); }
.step-link-desc { font-size:12.5px; color:var(--ink-2); line-height:1.5; }
.step-link-go { flex:0 0 auto; color:var(--brand-ink); font-size:13px; font-weight:500; }
/* per-field note under an input */
.fnote { margin:6px 0 0; font-size:12px; color:var(--ink-2); line-height:1.5; }
/* optional import sub-step nested inside the SAP step */
.substep { margin-top:20px; padding-top:18px; border-top:1px solid var(--line-2); }
.substep-h { font-size:13.5px; font-weight:600; color:var(--ink-strong); margin:0 0 4px; }
