/* ===========================================================================
   Just The Numbers — design system
   Clean, light-first finance dashboard: white cards on a soft grey page, one
   blue accent (the logo's #0066FF), a multi-colour chart palette, Inter throughout.

   Light is the default (:root). Dark mode = :root[data-theme="dark"].
   Per-area styles live in dash.css (dashboards & charts), auth.css (sign-in,
   onboarding, client portal shell) and screens.css (other admin screens),
   all loaded after this file. Use the tokens below — never hard-code colours.
   =========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("/static/vendor/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---- Tokens: light (default) -------------------------------------------- */
:root {
  color-scheme: light;

  /* Brand accent (the logo's blue) */
  --accent: #0066FF;              /* links, icons, focus, selected states, chart-1 */
  --accent-hover: #0052CC;
  --accent-solid: #0066FF;        /* filled buttons / active nav — white text sits on it (4.8:1) */
  --accent-solid-hover: #0052CC;
  --accent-ink: #0052CC;          /* blue TEXT on the soft tint */
  --accent-tint: #EBF3FF;         /* active/selected backgrounds, count pills */
  --purple-tint: var(--accent-tint);
  --accent-rgb: 0, 102, 255;      /* for rgba(var(--accent-rgb), a) */
  --focus-ring-color: rgba(0, 102, 255, 0.25);
  --focus-ring: 0 0 0 4px var(--focus-ring-color);
  --on-accent: #FFFFFF;

  /* Surfaces */
  --bg: #F5F6FA;                  /* page */
  --surface: #FFFFFF;             /* cards, panels, menus */
  --surface-2: #F9FAFB;           /* table header, row hover, insets */
  --surface-3: #F2F4F7;           /* neutral chips, nav hover, pressed */
  --sidebar-bg: #FFFFFF;
  --topbar-bg: #FFFFFF;
  --input-bg: #FFFFFF;
  --suggest-bg: #FFFFFF;
  --overlay: rgba(16, 24, 40, 0.45);

  /* Text */
  --head: #1F2330;                /* headings, key figures */
  --ink: #344054;                 /* body */
  --ink-dim: #475467;             /* secondary body */
  --muted: #667085;               /* descriptions, labels (4.5:1+ on white and the page) */
  --faint: #98A2B3;               /* placeholders, decorative only — not for real text */

  /* Lines */
  --card-border: #ECEEF3;
  --line: #EAECF0;                /* row separators, dividers */
  --line-strong: #D0D5DD;         /* input + secondary-button borders */
  --input-border: #D0D5DD;

  /* Shape & depth */
  --radius: 16px;                 /* cards, modals */
  --radius-md: 12px;              /* tiles inside cards */
  --radius-sm: 10px;              /* buttons, inputs, nav items */
  --radius-xs: 8px;
  --radius-pill: 999px;
  --card-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 24px -4px rgba(16, 24, 40, 0.10), 0 4px 8px -2px rgba(16, 24, 40, 0.05);

  /* Status — hue (dots, bars, borders), -soft (backgrounds), -ink (text on white or soft) */
  --success: #16A34A;  --success-soft: #ECFDF3;  --success-ink: #067647;  --success-border: #ABEFC6;
  --danger:  #EF4444;  --danger-soft:  #FEF3F2;  --danger-ink:  #B42318;  --danger-border:  #FECDCA;
  --warning: #F59E0B;  --warning-soft: #FFFAEB;  --warning-ink: #B54708;  --warning-border: #FEDF89;
  --info:    #3B82F6;  --info-soft:    #EFF6FF;  --info-ink:    #175CD3;  --info-border:    #B2DDFF;

  /* Chart / category palette */
  --chart-1: #0066FF;  --chart-1-soft: #EBF3FF;   /* brand blue */
  --chart-2: #8B5CF6;  --chart-2-soft: #F5F3FF;   /* violet */
  --chart-3: #22C55E;  --chart-3-soft: #ECFDF3;   /* green */
  --chart-4: #F59E0B;  --chart-4-soft: #FFFAEB;   /* amber */
  --chart-5: #EC4899;  --chart-5-soft: #FDF2FA;   /* pink */
  --chart-6: #14B8A6;  --chart-6-soft: #F0FDFA;   /* teal */
  --chart-7: #F97316;  --chart-7-soft: #FFF4ED;   /* orange */
  --chart-grid: #F2F4F7;
  --chart-text: #667085;

  /* Type */
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;   /* code-like values only */

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 64px;
  --gap: 20px;
  --btn-h: 38px;

  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5l5 5 5-5' stroke='%23667085' stroke-width='1.67' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  /* Older names still used by app.js / charts.js — keep them pointing at the new tokens.
     --green/--red/--amber/--pink/--blue are TEXT-safe status colours. */
  --green: var(--success-ink);
  --red: var(--danger-ink);
  --amber: var(--warning-ink);
  --blue: var(--info-ink);
  --pink: #C11574;
  --bg-soft: var(--surface);      /* charts.js rings markers with it: must equal the card colour */
  --body-bg: var(--bg);
  --panel: var(--surface);
  --panel-2: var(--surface);
  --accent-dim: var(--accent-hover);
  --glow-rgb: var(--accent-rgb);
  --accent-glow: var(--focus-ring-color);
  --shadow: var(--card-shadow);
}

/* ---- Tokens: dark ------------------------------------------------------- */
:root[data-theme="dark"] {
  color-scheme: dark;

  --accent: #4D94FF;
  --accent-hover: #66A3FF;
  --accent-solid: #0066FF;        /* keeps white button text at 4.5:1 */
  --accent-solid-hover: #0052CC;
  --accent-ink: #8AB8FF;
  --accent-tint: rgba(77, 148, 255, 0.14);
  --accent-rgb: 77, 148, 255;
  --focus-ring-color: rgba(77, 148, 255, 0.35);

  --bg: #0F1117;
  --surface: #171A23;
  --surface-2: #1C2029;
  --surface-3: #232834;
  --sidebar-bg: #13161E;
  --topbar-bg: #13161E;
  --input-bg: #12151C;
  --suggest-bg: #1C2029;
  --overlay: rgba(0, 0, 0, 0.6);

  --head: #F2F4F7;
  --ink: #D0D5DD;
  --ink-dim: #B9C0CC;
  --muted: #98A2B3;
  --faint: #6B7385;

  --card-border: #262A36;
  --line: #262A36;
  --line-strong: #333846;
  --input-border: #333846;

  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.5);

  --success: #22C55E;  --success-soft: rgba(34, 197, 94, 0.14);   --success-ink: #4ADE80;  --success-border: rgba(34, 197, 94, 0.32);
  --danger:  #F87171;  --danger-soft:  rgba(248, 113, 113, 0.14); --danger-ink:  #FCA5A5;  --danger-border:  rgba(248, 113, 113, 0.32);
  --warning: #FBBF24;  --warning-soft: rgba(251, 191, 36, 0.14);  --warning-ink: #FCD34D;  --warning-border: rgba(251, 191, 36, 0.32);
  --info:    #60A5FA;  --info-soft:    rgba(96, 165, 250, 0.14);  --info-ink:    #93C5FD;  --info-border:    rgba(96, 165, 250, 0.32);

  --chart-1: #4D94FF;  --chart-1-soft: rgba(77, 148, 255, 0.16);
  --chart-2: #A78BFA;  --chart-2-soft: rgba(167, 139, 250, 0.16);
  --chart-3: #4ADE80;  --chart-3-soft: rgba(74, 222, 128, 0.16);
  --chart-4: #FBBF24;  --chart-4-soft: rgba(251, 191, 36, 0.16);
  --chart-5: #F472B6;  --chart-5-soft: rgba(244, 114, 182, 0.16);
  --chart-6: #2DD4BF;  --chart-6-soft: rgba(45, 212, 191, 0.16);
  --chart-7: #FB923C;  --chart-7-soft: rgba(251, 146, 60, 0.16);
  --chart-grid: #232834;
  --chart-text: #98A2B3;

  --select-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5l5 5 5-5' stroke='%2398A2B3' stroke-width='1.67' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");

  --pink: #F472B6;
}

/* ---- Base ---------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { min-height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(var(--accent-rgb), 0.2); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }
img, svg { max-width: 100%; }
code, kbd { font-family: var(--mono); font-size: 0.92em; }
ol, ul { color: var(--ink); }
hr { border: none; border-top: 1px solid var(--line); margin: 20px 0; }

/* Subtle scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--faint); }
::-webkit-scrollbar-track { background: transparent; }

/* Visible keyboard focus everywhere; mouse clicks stay clean. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ---- Layout shell -------------------------------------------------------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  display: flex; flex-direction: column;
  padding: 20px 16px 16px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--card-border);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 6px 10px 0; margin: 0 0 24px; }
/* The logo is the JTN mark (trimmed, transparent); the name sits beside it as text. */
.brand-logo, .topbar-logo-img, .welcome-logo { display: block; flex: none; width: auto; }
.brand-logo { height: 36px; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; color: var(--head); }
.brand-text { padding: 4px 4px 0; }
.brand-mark { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; line-height: 1; color: var(--accent); }
.brand-sub { margin-top: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--muted); }

#nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.nav-group { margin: 18px 12px 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.nav-group:first-child { margin-top: 0; }
#nav button {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 40px; padding: 0 12px;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  color: var(--ink-dim); font: 500 14px/1.2 var(--font); text-align: left;
  cursor: pointer; transition: background-color 0.15s, color 0.15s;
}
#nav button:hover { background: var(--surface-3); color: var(--head); }
#nav button.active { background: var(--accent-solid); color: var(--on-accent); box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
#nav button.nav-bottom { margin-top: auto; }
.nav-ic { width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.nav-ic svg { width: 100%; height: 100%; display: block; }

.sidebar-foot {
  margin-top: 16px; padding: 14px 8px 2px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  font-size: 12px; line-height: 1.5; color: var(--muted);
}
.draft {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 11.5px; font-weight: 600; color: var(--warning-ink); background: var(--warning-soft);
}

.mainwrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  min-height: var(--topbar-h); padding: 12px 28px;
  background: var(--topbar-bg); border-bottom: 1px solid var(--card-border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title {
  font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--head);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Compact logo: shown in the client portal and on phones (the sidebar has it on desktop). */
.topbar-logo {
  display: none; align-items: center; gap: 8px; padding: 2px 4px; flex: none;
  background: none; border: 0; border-radius: var(--radius-xs); cursor: pointer;
}
.topbar-logo:hover { background: var(--surface-3); }
.topbar-logo-img { height: 30px; }
.topbar-brand-name { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; color: var(--head); white-space: nowrap; }
.topbar-logo-text { font-size: 18px; font-weight: 800; letter-spacing: -0.02em; color: var(--accent); line-height: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }

.companyswitch { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cs-label { display: inline; margin: 0; font-size: 13px; font-weight: 500; color: var(--muted); white-space: nowrap; }
#companySel { width: auto; min-width: 170px; max-width: 240px; }
button.ghost.cs-add, button.ghost.cs-del, button.ghost.cs-bin {
  position: relative; width: var(--btn-h); padding: 0; flex: none;
  font-size: 18px; font-weight: 500;
}
.cs-del svg, .cs-bin svg { width: 18px; height: 18px; display: block; }
button.ghost.cs-del:hover:not(:disabled) { color: var(--danger-ink); border-color: var(--danger-border); background: var(--danger-soft); }
.cs-count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill); background: var(--accent-solid); color: var(--on-accent);
  font-size: 11px; font-weight: 600; line-height: 1; border: 2px solid var(--topbar-bg);
}

.themetoggle {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: var(--btn-h); height: var(--btn-h); padding: 0;
  background: var(--surface); color: var(--ink-dim);
  border: 1px solid var(--line-strong); border-radius: 50%;
  font-size: 16px; line-height: 1; cursor: pointer; transition: background-color 0.15s, color 0.15s;
}
.themetoggle:hover { background: var(--surface-3); color: var(--head); }
.themetoggle svg { width: 18px; height: 18px; display: block; }

.userchip {
  display: inline-flex; align-items: center; max-width: 260px; padding: 6px 12px;
  border-radius: var(--radius-pill); background: var(--surface-3); color: var(--head);
  font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

main { flex: 1; width: 100%; padding: 24px 28px 40px; }

footer {
  text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5;
  padding: 16px 28px 28px;
}
.foot-disclaimer { max-width: 720px; margin: 0 auto 8px; }
.foot-copy { margin-top: 8px; color: var(--muted); }

/* Legal links (footer + sign-in screen) */
.legal-links {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 2px 2px; margin: 4px auto; max-width: 720px;
}
.legal-link {
  background: none; border: none; padding: 4px 6px; cursor: pointer;
  color: var(--ink-dim); font: inherit; font-size: 12px; border-radius: 6px;
  transition: color 0.15s, background-color 0.15s;
}
.legal-link:hover { color: var(--accent-ink); background: var(--accent-tint); }
.legal-sep { color: var(--faint); font-size: 12px; }
.welcome-legal { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); width: 100%; }

/* ---- Cards (panels) and the title + description header ------------------- */
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: var(--gap);
  box-shadow: var(--card-shadow);
}
.panel > :last-child { margin-bottom: 0; }

/* Card header: title + ONE short description, optional action on the right.
   <div class="card-head">
     <div><h2 class="card-title">Revenue</h2><p class="card-desc">Money coming in each month.</p></div>
     <div class="card-actions"><button class="ghost sm">View report</button></div>
   </div> */
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.card-head > :first-child { min-width: 0; flex: 1 1 auto; }
.card-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.4; letter-spacing: -0.005em; color: var(--head); }
.card-desc { margin: 2px 0 0; font-size: 13px; line-height: 1.5; color: var(--muted); }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: none; }
.card-actions select { width: auto; }

/* Page header (optional, above a screen's cards) */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 0 0 20px; }
.page-title { margin: 0; font-size: 24px; font-weight: 600; line-height: 1.3; letter-spacing: -0.02em; color: var(--head); }
.page-desc { margin: 4px 0 0; font-size: 14px; color: var(--muted); }

/* Card layout grid — cards inside drop their bottom margin; one column on phones. */
.card-grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); margin-bottom: var(--gap); }
.card-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-grid > .panel { margin-bottom: 0; min-width: 0; }
.card-grid > .span-2 { grid-column: span 2; }
.card-grid > .span-all { grid-column: 1 / -1; }

/* ---- Typography ---------------------------------------------------------- */
h1 { font-size: 22px; line-height: 1.3; margin: 0 0 4px; font-weight: 600; letter-spacing: -0.015em; color: var(--head); }
h2 { font-size: 16px; line-height: 1.4; margin: 0 0 12px; font-weight: 600; letter-spacing: -0.005em; color: var(--head); }
h3 { font-size: 14px; line-height: 1.4; margin: 16px 0 8px; font-weight: 600; color: var(--head); }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
/* A description right under a heading sits tight to it. */
h2 + .sub, h2 + .help, h2 + p.help { margin-top: -8px; margin-bottom: 14px; }
.help { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
b, strong { font-weight: 600; }

label {
  display: block; margin: 14px 0 6px;
  font-size: 13px; font-weight: 500; color: var(--ink);
}

/* ---- Form controls ------------------------------------------------------- */
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="hidden"])),
select, textarea {
  width: 100%; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--input-border); border-radius: var(--radius-sm);
  background-color: var(--input-bg); color: var(--head);
  font: inherit; font-size: 14px; line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px; cursor: pointer;
  background-image: var(--select-chevron); background-repeat: no-repeat;
  background-position: right 10px center; background-size: 18px;
}
select option { background: var(--surface); color: var(--head); }
textarea { min-height: 110px; resize: vertical; font-family: var(--font); line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: 1; }
input:hover:not(:disabled):not(:focus), select:hover:not(:disabled):not(:focus), textarea:hover:not(:disabled):not(:focus) { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.6; cursor: not-allowed; background-color: var(--surface-2); }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); cursor: pointer; }
input[type="file"] { font: inherit; font-size: 13px; color: var(--ink); max-width: 100%; }
input[type="file"]::file-selector-button {
  margin-right: 12px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--head); font: inherit; font-weight: 600; cursor: pointer;
}

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

details > summary { cursor: pointer; color: var(--accent-ink); font-weight: 500; }
details > summary:hover { color: var(--accent-hover); }

/* ---- Buttons ------------------------------------------------------------- */
button { font: inherit; }
button.primary, button.ghost, button.danger, button.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--btn-h); padding: 8px 16px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 600; line-height: 1.2; text-align: center;
  cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}
button.primary {
  background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}
button.primary:hover:not(:disabled) { background: var(--accent-solid-hover); border-color: var(--accent-solid-hover); }
/* Secondary (the app calls it "ghost"): white with a grey border. */
button.ghost {
  background: var(--surface); border-color: var(--line-strong); color: var(--head);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
}
button.ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--head); }
/* Destructive: red text + border; add .solid for the final "yes, delete" confirm. */
button.danger, button.ghost.cs-del-txt { background: var(--surface); border-color: var(--danger-border); color: var(--danger-ink); }
button.danger:hover:not(:disabled), button.ghost.cs-del-txt:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); color: var(--danger-ink); }
button.danger.solid { background: #D92D20; border-color: #D92D20; color: #FFFFFF; }
button.danger.solid:hover:not(:disabled) { background: #B42318; border-color: #B42318; color: #FFFFFF; }
/* Small variant */
button.sm, button.small { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
/* Link-style button */
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; }
button.link:hover { color: var(--accent-hover); text-decoration: underline; }
/* Icon-only square button: <button class="ghost icon-btn" aria-label="…">svg</button> */
button.icon-btn { width: var(--btn-h); padding: 0; }
button.icon-btn svg { width: 18px; height: 18px; }
button:disabled, button[disabled] { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* Clickable suggestion chip (Lookup examples, filters) */
button.chip {
  --btn-h: 32px; padding: 4px 12px; border-radius: var(--radius-pill);
  background: var(--surface); border-color: var(--line-strong); color: var(--ink);
  font-size: 13px; font-weight: 500;
}
button.chip:hover:not(:disabled) { background: var(--accent-tint); border-color: transparent; color: var(--accent-ink); }
button.chip.active, button.chip[aria-pressed="true"] { background: var(--accent-tint); border-color: transparent; color: var(--accent-ink); }

/* ---- Tables -------------------------------------------------------------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th {
  background: var(--surface-2); color: var(--muted);
  font-size: 12px; font-weight: 500; line-height: 1.4; white-space: nowrap;
}
thead th:first-child { border-top-left-radius: var(--radius-xs); }
thead th:last-child { border-top-right-radius: var(--radius-xs); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
tfoot td { border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 600; color: var(--head); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { white-space: nowrap; color: var(--head); }
.num, .tabular { font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---- Financial statements ----------------------------------------------- */
.stmt { max-width: 560px; }
.stmt .line { display: flex; justify-content: space-between; gap: 16px; padding: 6px 0; font-variant-numeric: tabular-nums; }
.stmt .line span:last-child { white-space: nowrap; }
.stmt .line.total { border-top: 1px solid var(--line-strong); font-weight: 600; margin-top: 6px; padding-top: 10px; color: var(--head); }
.stmt .line.sub { color: var(--muted); margin: 0; font-size: inherit; }
.stmt .head { margin: 16px 0 4px; font-size: 13px; font-weight: 600; color: var(--head); }
.neg { color: var(--red); }

/* ---- Badges, pills, chips -------------------------------------------------
   <span class="badge success">Paid</span> · warning · danger · info · accent · neutral
   Month states from the app: .badge.CLOSED (green) · .badge.Medium / OPEN / SAVED (amber)
   Confidence: .badge.High (green) · .Medium (amber) · .Low (red) */
.badge {
  display: inline-flex; align-items: center; gap: 5px; vertical-align: middle;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-dim);
}
.badge.dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.success, .badge.green, .badge.CLOSED, .badge.High, .badge.PAID { background: var(--success-soft); color: var(--success-ink); }
.badge.warning, .badge.amber, .badge.Medium, .badge.OPEN, .badge.SAVED, .badge.DRAFT { background: var(--warning-soft); color: var(--warning-ink); }
.badge.danger, .badge.red, .badge.Low, .badge.OVERDUE { background: var(--danger-soft); color: var(--danger-ink); }
.badge.info, .badge.blue { background: var(--info-soft); color: var(--info-ink); }
.badge.accent, .badge.purple, .badge.count { background: var(--accent-tint); color: var(--accent-ink); }
.badge.neutral, .badge.gray { background: var(--surface-3); color: var(--ink-dim); }

/* Small annotation chip; a count next to a heading is blue. Empty pills vanish. */
.pill {
  display: inline-flex; align-items: center; vertical-align: middle;
  padding: 1px 8px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500; line-height: 18px;
  background: var(--surface-3); color: var(--ink-dim);
}
.pill:empty { display: none; }
h1 .pill, h2 .pill, summary .pill, .pill.count { background: var(--accent-tint); color: var(--accent-ink); margin-left: 4px; }

/* Colour helpers for charts, legends and icon bubbles: add .c1 … .c7 to set --c / --c-soft. */
.c1 { --c: var(--chart-1); --c-soft: var(--chart-1-soft); }
.c2 { --c: var(--chart-2); --c-soft: var(--chart-2-soft); }
.c3 { --c: var(--chart-3); --c-soft: var(--chart-3-soft); }
.c4 { --c: var(--chart-4); --c-soft: var(--chart-4-soft); }
.c5 { --c: var(--chart-5); --c-soft: var(--chart-5-soft); }
.c6 { --c: var(--chart-6); --c-soft: var(--chart-6-soft); }
.c7 { --c: var(--chart-7); --c-soft: var(--chart-7-soft); }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--accent)); vertical-align: middle; }
.swatch.round { border-radius: 50%; }
.icon-bubble {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 40px; height: 40px; border-radius: var(--radius-md);
  background: var(--c-soft, var(--accent-tint)); color: var(--c, var(--accent));
}
.icon-bubble svg { width: 20px; height: 20px; }

/* ---- Callouts ------------------------------------------------------------ */
.flag {
  padding: 10px 14px; border-radius: var(--radius-sm); margin: 8px 0; font-size: 13.5px;
  color: var(--ink); background: var(--surface-2); border: 1px solid var(--line);
}
.flag.warn { background: var(--warning-soft); border-color: var(--warning-border); }
.flag.crit { background: var(--danger-soft); border-color: var(--danger-border); }
.flag.ok { background: var(--accent-tint); border-color: transparent; }
.notice {
  padding: 10px 14px; border-radius: var(--radius-sm); margin: 8px 0; font-size: 13.5px;
  color: var(--ink); background: var(--info-soft); border: 1px solid var(--info-border);
}
.notice.success { background: var(--success-soft); border-color: var(--success-border); }
.notice.warning { background: var(--warning-soft); border-color: var(--warning-border); }
.notice.danger { background: var(--danger-soft); border-color: var(--danger-border); }
.error {
  color: var(--danger-ink); background: var(--danger-soft); border: 1px solid var(--danger-border);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px;
}
span.error { display: inline-block; padding: 6px 10px; }

/* Month-closed email status shown to the admin after closing */
.emailstatus { margin-bottom: 12px; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); }
.emailstatus.sent { color: var(--success-ink); border-color: var(--success-border); background: var(--success-soft); }
.emailstatus.skipped { color: var(--ink-dim); }
.emailstatus.error { color: var(--warning-ink); border-color: var(--warning-border); background: var(--warning-soft); }

/* ---- Stat tiles (KPI) ----------------------------------------------------
   <div class="kpis">
     <div class="kpi c1"><div class="kpi-k">Sales</div><div class="kpi-v">$12,340</div>
       <div class="kpi-delta up">▲ $1,200 vs Jan</div></div> …
   Each tile gets a coloured dot from the chart palette in order; add .c1–.c7 to pick one. */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.card, .kpi {
  position: relative; min-width: 0; container-type: inline-size;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius-md);
  padding: 16px 18px;
}
.cards > .card:nth-child(7n+2), .kpis > .kpi:nth-child(7n+2) { --auto-c: var(--chart-2); }
.cards > .card:nth-child(7n+3), .kpis > .kpi:nth-child(7n+3) { --auto-c: var(--chart-3); }
.cards > .card:nth-child(7n+4), .kpis > .kpi:nth-child(7n+4) { --auto-c: var(--chart-4); }
.cards > .card:nth-child(7n+5), .kpis > .kpi:nth-child(7n+5) { --auto-c: var(--chart-5); }
.cards > .card:nth-child(7n+6), .kpis > .kpi:nth-child(7n+6) { --auto-c: var(--chart-6); }
.cards > .card:nth-child(7n+7), .kpis > .kpi:nth-child(7n+7) { --auto-c: var(--chart-7); }
.card .k, .kpi-k {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.card .k::before, .kpi-k::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--auto-c, var(--chart-1))); }
/* Figures shrink with their tile (container units) rather than wrapping mid-number. */
.card .v, .kpi-v {
  margin-top: 8px; font-size: clamp(18px, 13cqi, 26px); font-weight: 700; line-height: 1.2; letter-spacing: -0.02em;
  color: var(--head); font-variant-numeric: tabular-nums; overflow-wrap: break-word;
}
.kpi-v { font-size: clamp(18px, 13.5cqi, 28px); }
.kpi-delta { margin-top: 6px; font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi-delta.up { color: var(--success-ink); }
.kpi-delta.down { color: var(--danger-ink); }
.statval { font-weight: 600; color: var(--head); font-size: 15px; font-variant-numeric: tabular-nums; }

/* ---- Months grid --------------------------------------------------------- */
.months-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.mcell {
  position: relative; padding: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.mcell:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.1); }
.mcell.closed { background: var(--surface); }
.mcell.reopened { background: var(--warning-soft); border-color: var(--warning-border); }
.mcell.empty { background: var(--surface-2); }
.mcell.empty .m { color: var(--ink-dim); }
.mcell .m { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; font-weight: 600; font-size: 14px; color: var(--head); }
.mcell .n { margin-top: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---- Editable transaction table ----------------------------------------- */
.editable td { padding: 4px 6px; }
.editable input, .editable select { min-height: 34px; padding: 6px 8px; font-size: 13px; border-color: transparent; background-color: transparent; }
.editable select { padding-right: 30px; }
.editable input:hover, .editable select:hover { border-color: var(--line-strong); }
.editable input:focus, .editable select:focus { border-color: var(--accent); background-color: var(--input-bg); }
#txtable td { padding: 4px 6px; vertical-align: middle; }
#txtable .txe { width: 100%; margin: 0; min-height: 34px; padding: 6px 8px; font-size: 13px; }
#txtable select.txe { min-width: 96px; padding-right: 30px; }
.txdel { line-height: 1; }
button.ghost.txdel { --btn-h: 32px; padding: 4px 10px; }
button.ghost.txdel:hover:not(:disabled) { color: var(--danger-ink); border-color: var(--danger-border); background: var(--danger-soft); }

/* General Ledger and other collapsible cards */
details.panel > summary.gl-top {
  display: flex; align-items: center; gap: 10px; list-style: none;
  font-size: 16px; font-weight: 600; color: var(--head); cursor: pointer;
}
details.panel > summary.gl-top::-webkit-details-marker { display: none; }
details.panel > summary.gl-top::before {
  content: ""; flex: none; width: 7px; height: 7px; margin: 0 4px 0 2px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg); transition: transform 0.15s ease;
}
details.panel[open] > summary.gl-top::before { transform: rotate(45deg); margin-top: -4px; }
details.panel > summary.gl-top:hover { color: var(--head); }
.glacct { border: 1px solid var(--card-border); border-radius: var(--radius-md); background: var(--surface); overflow: hidden; }
.glacct + .glacct { margin-top: 8px; }
.glacct > summary {
  cursor: pointer; list-style: none; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  font-weight: 600; font-size: 14px; color: var(--head);
}
.glacct > summary::-webkit-details-marker { display: none; }
.glacct > summary:hover { background: var(--surface-2); color: var(--head); }
.glacct[open] > summary { border-bottom: 1px solid var(--line); }
.glacct .scroll { padding: 8px 16px 14px; }

.retention-warn { border-color: var(--danger-border); background: var(--danger-soft); }
.retention-warn h2 { color: var(--danger-ink); }

/* ---- Drop zone + file list ---------------------------------------------- */
.dropzone {
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-md);
  background: var(--surface-2); padding: 32px 20px; text-align: center;
  cursor: pointer; transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-tint); }
.dropzone.over { border-color: var(--accent); background: var(--accent-tint); }
.dz-big { font-size: 15px; font-weight: 600; color: var(--head); }
.dz-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.dz-link { color: var(--accent); font-weight: 600; text-decoration: none; }
.filetable { width: 100%; margin-top: 12px; }
.filetable td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.filetable td:first-child { width: 100%; }
.filetable select { width: auto; min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 13px; }

/* ---- Address autocomplete + sales-tax estimate -------------------------- */
.suggest {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
  margin-top: 4px; background: var(--suggest-bg); border: 1px solid var(--card-border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); max-height: 260px; overflow-y: auto;
}
.sug-item { padding: 10px 12px; font-size: 13.5px; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--line); }
.sug-item:last-child { border-bottom: none; }
.sug-item:hover { background: var(--accent-tint); color: var(--accent-ink); }
.taxbox { background: var(--surface-2); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 16px 18px; }
.taxrate { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; color: var(--accent); line-height: 1.15; font-variant-numeric: tabular-nums; }
.taxlabel { font-size: 13px; font-weight: 500; color: var(--ink-dim); margin-top: 2px; }
.taxsub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.srctag { display: inline-flex; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-3); color: var(--ink-dim); }
.srctag.live { color: var(--success-ink); background: var(--success-soft); }
.srctag.est { color: var(--warning-ink); background: var(--warning-soft); }
.taxnotes { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); }
.taxnotes li { margin: 3px 0; }

/* ---- Loading ------------------------------------------------------------- */
.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: -3px;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading { color: var(--muted); padding: 44px; text-align: center; }

/* Indeterminate progress bar (reading documents) */
.proc { margin-top: 8px; max-width: 440px; width: 100%; }
.proc-bar { height: 8px; border-radius: var(--radius-pill); overflow: hidden; position: relative; background: var(--surface-3); }
.proc-bar span {
  position: absolute; top: 0; bottom: 0; left: -40%; width: 40%; border-radius: var(--radius-pill);
  background: var(--accent); animation: proc-slide 1.3s ease-in-out infinite;
}
@keyframes proc-slide { 0% { left: -40%; } 100% { left: 100%; } }
.proc-row { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 13px; color: var(--ink-dim); }
.proc-time { color: var(--muted); font-variant-numeric: tabular-nums; }
.proc-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Modals -------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--overlay); backdrop-filter: blur(2px);
  animation: fade-in 0.15s ease both;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
.modal {
  position: relative; width: 100%; max-width: 520px; max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow-lg); animation: modal-in 0.18s ease both;
}
.modal h2 { font-size: 18px; }
.emsteps { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; color: var(--ink); }
.emsteps .emnum {
  display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-right: 8px;
  border-radius: 50%; background: var(--accent-tint); color: var(--accent-ink); font-size: 12px; font-weight: 600;
}

/* Legal document modal */
.legal-modal { max-width: 680px; padding: 28px; text-align: left; }
.legal-close {
  position: absolute; top: 14px; right: 14px; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-xs);
  color: var(--ink-dim); font-size: 20px; line-height: 1; cursor: pointer; transition: background-color 0.15s;
}
.legal-close:hover { background: var(--surface-3); color: var(--head); }
.legal-doc { color: var(--ink); font-size: 14px; line-height: 1.65; }
.legal-title { color: var(--head); font-size: 22px; margin: 0 40px 4px 0; }
.legal-meta { color: var(--muted); font-size: 12.5px; margin: 0 0 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.legal-doc h3 { color: var(--head); font-size: 15px; margin: 22px 0 6px; }
.legal-doc p { margin: 0 0 10px; }
.legal-doc ul { margin: 0 0 12px; padding-left: 20px; }
.legal-doc li { margin: 0 0 6px; }
.legal-doc strong { color: var(--head); }

/* Temporary password reveal (admin sets a client login) */
.temppw { margin-top: 14px; padding: 16px; border-radius: var(--radius-md); background: var(--accent-tint); border: 1px solid transparent; }
.tp-title { font-weight: 600; color: var(--head); margin-bottom: 10px; font-size: 14px; }
.tp-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.tp-k { min-width: 140px; color: var(--muted); font-size: 13px; font-weight: 500; }
.tp-v {
  font-family: var(--mono); font-size: 15px; color: var(--head); background: var(--surface);
  padding: 4px 10px; border-radius: var(--radius-xs); border: 1px solid var(--line-strong); letter-spacing: 0.04em;
}
button.ghost.tp-copy { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
.tp-note { margin-top: 6px; color: var(--muted); font-size: 12.5px; line-height: 1.5; }

/* ---- Sign-in, welcome splash, client portal shell ----------------------- */
body.client-mode .sidebar { display: none; }
body.client-mode #companyswitch { display: none; }
body.client-mode .topbar-logo { display: inline-flex; }

.welcome-mode .sidebar,
.welcome-mode .topbar,
.welcome-mode footer { display: none; }
.welcome-mode .shell { display: block; }
.welcome-mode .mainwrap { min-height: 100vh; }
.welcome-mode main { padding: 0; }

.welcome {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 32px 16px; text-align: center; background: var(--bg);
}
.welcome-inner { display: flex; flex-direction: column; align-items: center; width: 100%; max-width: 520px; animation: welcome-rise 0.35s ease both; }
@keyframes welcome-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.welcome-logo { height: 72px; }
.welcome-mark { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; line-height: 1; color: var(--accent); }
.welcome-submark { font-size: 12px; font-weight: 600; letter-spacing: 0.12em; color: var(--muted); margin-top: 8px; }
.welcome-tag { color: var(--muted); font-size: 15px; line-height: 1.6; margin: 12px 0 24px; }
button.primary.welcome-btn { --btn-h: 44px; padding: 10px 28px; font-size: 15px; }
.welcome-foot { color: var(--muted); font-size: 12px; margin-top: 24px; }

.authcard {
  max-width: 420px; padding: 32px 28px;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 20px; box-shadow: var(--shadow-lg);
}
.authcard .welcome-logo { height: 56px; }
.authcard h1 { font-size: 22px; }
.authcard .welcome-tag { font-size: 14px; margin: 4px 0 0; }
.authform { display: flex; flex-direction: column; gap: 12px; width: 100%; margin-top: 22px; text-align: left; }
.authform input { width: 100%; min-height: 44px; }
.authform .welcome-btn { width: 100%; margin-top: 4px; }
.authform button.ghost { --btn-h: 44px; width: 100%; }
.authmsg { min-height: 18px; text-align: center; }
.authmsg:empty { display: none; }

/* ---- Client dashboard + business checkup -------------------------------- */
.dash-actions { justify-content: flex-end; }
.status-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line);
  font-size: 13.5px; color: var(--ink-dim);
}
.status-strip b { color: var(--head); }
.status-strip .dot { color: var(--faint); }
.ok-mark { color: var(--success-ink); }
.bad-mark { color: var(--danger-ink); }
.gate {
  padding: 12px 14px; border-radius: var(--radius-sm); margin-bottom: 12px; font-size: 13.5px;
  color: var(--warning-ink); background: var(--warning-soft); border: 1px solid var(--warning-border);
}

/* Findings (checkup cards): severity edge + chip, title, plain message, details */
.findings { display: flex; flex-direction: column; gap: 12px; }
.finding {
  padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid var(--card-border);
  border-left: 3px solid var(--line-strong); background: var(--surface); overflow-wrap: anywhere;
}
.finding.red { border-left-color: var(--danger); }
.finding.amber { border-left-color: var(--warning); }
.finding.green { border-left-color: var(--success); }
.finding.is-hidden { opacity: 0.65; border-style: dashed; }
.finding-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 6px; }
.sev {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-dim);
}
.sev.red { color: var(--danger-ink); background: var(--danger-soft); }
.sev.amber { color: var(--warning-ink); background: var(--warning-soft); }
.sev.green { color: var(--success-ink); background: var(--success-soft); }
.ftag { font-size: 12px; color: var(--ink-dim); background: var(--surface-3); border-radius: var(--radius-pill); padding: 1px 8px; }
.ftag.only-you { color: var(--accent-ink); background: var(--accent-tint); }
.ftag.hidden-tag { color: var(--muted); background: transparent; border: 1px dashed var(--line-strong); }
.finding-title { font-weight: 600; font-size: 15px; color: var(--head); }
.finding-msg { margin-top: 4px; font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.finding-next { margin-top: 6px; font-size: 13px; color: var(--ink-dim); }
.worked { margin-top: 8px; font-size: 13px; }
.worked > summary { font-size: 13px; }
.worked .help { margin-top: 6px; }
.fig-table { margin-top: 6px; max-width: 460px; }
.fig-table td { padding: 5px 8px; font-size: 13px; }
.fnote { margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-xs); font-size: 13px; background: var(--accent-tint); color: var(--ink); }
.finding-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.finding-actions button { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
.finding-none {
  padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  color: var(--success-ink); background: var(--success-soft); border: 1px solid var(--success-border);
}
.looking-good-admin { margin-top: 12px; }
.looking-good-admin > summary { margin-bottom: 10px; }

/* Charts (frontend/charts.js) and the tiles under them */
.dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--gap); align-items: start; }
.dash-grid > .panel { min-width: 0; }
.dash-grid.tiles { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.chart-card.wide { grid-column: 1 / -1; }
.chart-sub { margin: -8px 0 12px; }
.chart { margin: 0; min-width: 0; }
.chart + .chart { margin-top: 16px; }
.chart-svg { max-width: 100%; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 10px; font-size: 12.5px; color: var(--ink-dim); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.lg-key { display: inline-block; flex: none; }
.lg-bar { width: 10px; height: 10px; border-radius: 3px; }
.lg-line { width: 16px; height: 2px; border-radius: 1px; }
.lg-tick { width: 2px; height: 12px; border-radius: 1px; }
.chart-table { margin-top: 10px; font-size: 13px; }
.chart-table > summary { font-size: 12.5px; }
.chart-table table { margin-top: 6px; }
.chart-table th, .chart-table td { padding: 6px 8px; }
.chart-empty {
  padding: 28px 12px; text-align: center; font-size: 13px; color: var(--muted);
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
}
/* Chart.js canvases need a sized box: <div class="chart-box"><canvas></canvas></div> */
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box.sm { height: 200px; }
.chart-box.lg { height: 320px; }
.chart-box canvas { display: block; max-width: 100%; }
/* Centre label inside a doughnut: absolutely placed over the chart-box */
.chart-center {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; text-align: center;
}
.chart-center .v { font-size: 22px; font-weight: 700; color: var(--head); font-variant-numeric: tabular-nums; }
.chart-center .k { font-size: 12px; color: var(--muted); }
.tile-big { font-size: 26px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em; color: var(--head); font-variant-numeric: tabular-nums; }
.tile-text { margin: 6px 0 0; font-size: 13.5px; color: var(--ink-dim); }
.tile-list { list-style: none; padding: 0; margin: 10px 0 0; }
.tile-list li {
  display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; margin: 0;
  border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--ink);
}
.tile-list li:last-child { border-bottom: none; }
.tile-list li > span { min-width: 0; overflow-wrap: anywhere; }
.tile-list li b { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--head); }
.dash-empty p { color: var(--ink-dim); }
.dash-foot { margin: 8px 0 12px; text-align: center; font-size: 12px; color: var(--muted); }

/* Admin: all-clients overview + checkup controls */
.overview-table tr.ov-row { cursor: pointer; }
.overview-table tr.ov-row:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.overview-table tr.ov-row.active td { background: var(--accent-tint); }
.overview-table td { vertical-align: middle; }
.ck-industry { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.ck-industry label { margin: 0; }
.ck-industry select { width: auto; max-width: 100%; }
.preview-bar { border-color: var(--accent); background: var(--accent-tint); }

/* ---- Status page: backups ------------------------------------------------ */
.backups { font-size: 13.5px; }
.bk-head { color: var(--ink-dim); margin-bottom: 8px; }
.bkrow {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--card-border); border-radius: var(--radius-sm); background: var(--surface);
}
.bk-n { color: var(--head); font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.bk-s { color: var(--muted); margin-left: auto; font-size: 12.5px; white-space: nowrap; }
button.ghost.bk-dl { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }

/* ---- Subscription paywall (client) -------------------------------------- */
.plans { display: flex; gap: var(--gap); flex-wrap: wrap; justify-content: center; margin-top: 20px; }
.plan {
  flex: 1 1 260px; max-width: 320px; text-align: center;
  background: var(--surface); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 28px 24px; box-shadow: var(--card-shadow);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.plan:hover { border-color: var(--accent); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.plan-name { font-size: 15px; font-weight: 600; color: var(--accent-ink); }
.plan-price { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; color: var(--head); margin: 8px 0 2px; font-variant-numeric: tabular-nums; }
.plan-price span { font-size: 15px; font-weight: 500; letter-spacing: 0; color: var(--muted); }
.plan-blurb { color: var(--ink-dim); font-size: 14px; line-height: 1.5; min-height: 66px; margin-bottom: 16px; }
.plan-pick { width: 100%; }
.plan-feats { list-style: none; padding: 0; margin: 6px 0 18px; text-align: left; }
.plan-feats li { color: var(--ink); font-size: 13.5px; line-height: 1.5; padding: 5px 0 5px 26px; margin: 0; position: relative; }
.plan-feats li::before {
  content: "✓"; position: absolute; left: 0; top: 6px; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--success-soft); color: var(--success-ink); font-size: 11px; font-weight: 700;
}
.plan.featured { border: 2px solid var(--accent); padding: 27px 23px; }
.plan-tag {
  display: inline-block; margin-bottom: 8px; padding: 3px 12px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 600; color: var(--on-accent); background: var(--accent-solid);
}

/* Locked report section (client tier gating) */
.panel.locked { border-style: dashed; box-shadow: none; }
.lock-row { display: flex; align-items: center; gap: 14px; }
.lock-ic { font-size: 24px; }
.lock-title { font-weight: 600; color: var(--head); font-size: 16px; }

/* Subscription status pills (admin) */
.sub-pill {
  display: inline-flex; padding: 2px 10px; border-radius: var(--radius-pill); white-space: nowrap;
  font-size: 12px; font-weight: 500; line-height: 18px; background: var(--surface-3); color: var(--ink-dim);
}
.sub-pill.ok { color: var(--success-ink); background: var(--success-soft); }
.sub-pill.warn { color: var(--warning-ink); background: var(--warning-soft); }
.sub-pill.off { color: var(--muted); }

/* ---- Lookup (internal records search) ----------------------------------- */
.lookup-bar { display: flex; gap: 10px; margin: 14px 0 10px; }
.lookup-input { flex: 1; min-height: 44px; font-size: 15px; }
.lookup-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.lookup-filters select { width: auto; font-size: 13.5px; }
.lookup-examples { margin: 12px 0 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.lookup-summary { margin-top: 16px; padding: 16px 18px; border-radius: var(--radius-md); background: var(--accent-tint); }
.lk-interp { font-weight: 600; color: var(--head); margin-bottom: 6px; }
.lk-stats { display: flex; gap: 20px; flex-wrap: wrap; color: var(--ink-dim); font-size: 13.5px; }
.lk-stats b { color: var(--accent-ink); font-variant-numeric: tabular-nums; }
.lk-bycat { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.lk-cat {
  display: inline-flex; gap: 8px; align-items: baseline; padding: 5px 12px;
  border-radius: var(--radius-pill); background: var(--surface); border: 1px solid var(--card-border); font-size: 12.5px;
}
.lk-cat b { color: var(--head); font-variant-numeric: tabular-nums; }
.lk-docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.lk-doc {
  display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer; font: inherit;
  padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid var(--card-border);
  background: var(--surface); color: var(--ink); transition: border-color 0.15s, background-color 0.15s;
}
.lk-doc:hover { border-color: var(--accent); background: var(--accent-tint); }
.lk-doc-ic { font-size: 20px; line-height: 1; }
.lk-doc-meta { display: flex; flex-direction: column; min-width: 0; }
.lk-doc-name { font-size: 13.5px; font-weight: 600; color: var(--head); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lk-doc-month { font-size: 12px; color: var(--muted); }
table.lk-table { margin-top: 6px; }
table.lk-table td { vertical-align: top; }
.lk-empty {
  margin-top: 18px; padding: 24px; text-align: center; color: var(--ink-dim);
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-md);
}
.lk-didyoumean {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--warning-soft); border: 1px solid var(--warning-border); color: var(--ink); font-size: 13.5px;
}
.lk-didyoumean b { color: var(--head); }
.lk-didyoumean button { flex: none; --btn-h: 32px; padding: 4px 12px; font-size: 13px; }

/* ---- Client: bank & card accounts (read-only) --------------------------- */
.bank-items { display: flex; flex-direction: column; gap: 12px; margin-bottom: 12px; }
.bank-item {
  min-width: 0; padding: 14px 16px; border-radius: var(--radius-md); overflow-wrap: anywhere;
  border: 1px solid var(--card-border); border-left: 3px solid var(--success); background: var(--surface);
}
.bank-item.warn { border-left-color: var(--warning); background: var(--warning-soft); }
.bank-item.off { border-left-color: var(--line-strong); border-style: dashed; border-left-style: solid; }
.bank-item-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.bank-inst { min-width: 0; font-weight: 600; font-size: 15px; color: var(--head); }
.bank-chip, .sent-chip, .bl-tag {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-dim);
}
.bank-chip.ok, .sent-chip.added { color: var(--success-ink); background: var(--success-soft); }
.bank-chip.warn, .bl-tag { color: var(--warning-ink); background: var(--warning-soft); }
.bank-chip.off, .sent-chip.dismissed, .bl-tag.off { color: var(--muted); background: var(--surface-3); }
.sent-chip.received { color: var(--accent-ink); background: var(--accent-tint); }
.bank-accts { list-style: none; margin: 8px 0 0; padding: 0; }
.bank-acct {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px;
  padding: 8px 0; margin: 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.bank-acct:last-child { border-bottom: none; }
.bank-acct-name { min-width: 0; color: var(--ink); }
.bank-acct-bal { color: var(--ink-dim); font-variant-numeric: tabular-nums; }
.bank-acct-bal b { color: var(--head); }
.bank-note { margin-top: 6px; }
.bank-item-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.bank-item-actions button { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
.bank-actions { margin-top: 4px; }
.bank-actions .help { min-width: 0; }
.bank-trust { position: relative; margin: 12px 0 0; padding-left: 24px; font-size: 12.5px; line-height: 1.5; color: var(--ink-dim); }
.bank-trust::before { content: "🔒"; position: absolute; left: 0; top: 0; font-size: 13px; }
.bank-soon { margin: 0; font-size: 13.5px; color: var(--ink-dim); }

/* ---- Client: send your statements & bills ------------------------------- */
.send-intro { margin: -6px 0 4px; font-size: 13px; }
.send-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 0 16px; }
.send-drop { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 14px 16px; text-align: left; }
.send-drop .dz-sub { margin-top: 0; }
.picked-list { list-style: none; margin: 6px 0 0; padding: 0; }
.picked-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 0 10px;
  padding: 6px 0; margin: 0; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.picked-name { min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
button.ghost.picked-del { --btn-h: 30px; padding: 2px 10px; font-size: 12.5px; }
.send-note { min-height: 72px; font-size: 13.5px; }
.send-row { margin-top: 12px; }
.send-row .help { min-width: 0; }
.send-prog { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.send-bar { display: inline-block; width: 140px; max-width: 40vw; height: 8px; border-radius: var(--radius-pill); overflow: hidden; background: var(--surface-3); }
.send-bar span { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.sent-title, .bank-lines-head h3 { margin: 20px 0 8px; font-size: 14px; font-weight: 600; color: var(--head); }
.sent-list { list-style: none; margin: 0; padding: 0; }
.sent-item {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 2px 10px;
  padding: 10px 0; margin: 0; border-bottom: 1px solid var(--line);
}
.sent-name { grid-column: 1; min-width: 0; font-weight: 600; color: var(--head); overflow-wrap: anywhere; }
.sent-meta { grid-column: 1; grid-row: 2; }
.sent-chip { grid-column: 2; grid-row: 1 / span 2; }
.sent-acts { grid-column: 3; grid-row: 1 / span 2; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.sent-acts:empty { display: none; }
button.ghost.sent-del, button.ghost.sent-mv { --btn-h: 30px; padding: 2px 10px; font-size: 12.5px; }
.sent-lock, .sent-move { grid-column: 1 / -1; }
.sent-move:not([hidden]), .inbox-move:not([hidden]) { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding-top: 8px; }
.sent-move button, .inbox-move button, .md-move button { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }

/* Which month: a month list + a year list */
.my-pick { display: inline-flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.my-pick select { width: auto; max-width: 100%; min-height: 36px; font-size: 13.5px; }
.sent-more { margin-top: 8px; }
.sent-more > summary { font-size: 13px; }

/* ---- Admin: documents from the client + bank connections ---------------- */
.inbox-badge {
  display: inline-flex; align-items: center; margin-left: 6px; padding: 1px 8px; border-radius: var(--radius-pill); vertical-align: 1px;
  font-size: 12px; font-weight: 600; line-height: 18px; color: var(--on-accent); background: var(--accent-solid); white-space: nowrap;
}
.inbox-list { display: flex; flex-direction: column; gap: 12px; }
.inbox-item {
  display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px;
  padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent); background: var(--surface);
}
.inbox-main { flex: 1 1 240px; min-width: 0; overflow-wrap: anywhere; }
.inbox-name { font-weight: 600; color: var(--head); }
.inbox-note { margin-top: 6px; padding: 8px 12px; border-radius: var(--radius-xs); font-size: 13px; color: var(--ink); background: var(--surface-2); }
.inbox-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 100%; }
.inbox-actions select { width: auto; max-width: 100%; min-height: 36px; font-size: 13.5px; }
.inbox-actions button { --btn-h: 36px; padding: 6px 12px; font-size: 13px; }
.inbox-done { margin-top: 12px; }
.inbox-done > summary { font-size: 13px; }
.inbox-done-list { list-style: none; margin: 8px 0 0; padding: 0; }
.inbox-done-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 8px 0; margin: 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.inbox-done-list li > span:first-child { flex: 1 1 180px; min-width: 0; overflow-wrap: anywhere; }
button.ghost.inbox-dl-small { --btn-h: 30px; padding: 2px 10px; font-size: 12.5px; }
.inbox-done-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.inbox-move { flex-basis: 100%; }
#inboxMsg:not(:empty) { margin-top: 10px; }

.bank-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.bank-mfa-warn { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.bank-mfa-warn button { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
.bank-lines { margin-top: 16px; padding-top: 4px; border-top: 1px solid var(--line); }
.bank-lines-head { justify-content: space-between; margin: 12px 0 6px; }
.bank-lines-head h3 { margin: 0; }
.bank-lines-head select { width: auto; max-width: 100%; min-height: 36px; font-size: 13.5px; }
.bank-lines-table td { vertical-align: middle; }
.bank-lines-table td:first-child { white-space: nowrap; }
.bank-lines-table td:nth-child(2) { overflow-wrap: anywhere; }
.bank-lines-table tr.bl-removed td { opacity: 0.55; }
.bl-tag { margin-left: 4px; padding: 0 7px; font-size: 11.5px; vertical-align: 1px; }
.bl-in { color: var(--success-ink); }
.bl-out { color: var(--ink); }

/* ---- Monthly close: saved readings (drafts) ----------------------------- */
.mcell.draft { background: var(--surface); border-style: dashed; border-color: var(--line-strong); }
.draft-banner {
  display: flex; flex-direction: column; gap: 8px; margin-top: 14px; padding: 14px 16px;
  border-radius: var(--radius-md); font-size: 13.5px; color: var(--ink);
  background: var(--accent-tint); border: 1px solid transparent;
}
.draft-banner b { color: var(--head); }
.draft-banner button { align-self: flex-start; }
button[data-conflict-reload] { margin: 6px 0 0 8px; --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
.attached-docs {
  margin: 0 0 14px; padding: 12px 16px; border-radius: var(--radius-md); font-size: 13.5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--card-border); overflow-wrap: anywhere;
}
.attached-docs b { color: var(--head); }
.attached-docs ul { margin: 6px 0 0; padding-left: 18px; }
.md-table { margin-top: 8px; }
.md-acts { text-align: right; white-space: nowrap; }
.md-acts button { --btn-h: 30px; padding: 2px 10px; font-size: 12.5px; }
.md-move-in { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.md-msg:not(:empty) { margin-top: 8px; }

/* ---- Two-step sign-in (Status page) + backups encryption ---------------- */
.mfa-state { margin: 0 0 10px; font-size: 13.5px; line-height: 1.55; color: var(--ink-dim); }
.mfa-state b { color: var(--head); }
.mfa-state.on b { color: var(--success-ink); }
.mfa-row { margin-top: 8px; }
.mfa-row input { flex: 1 1 200px; width: auto; min-width: 0; max-width: 320px; }
.mfa-steps { margin: 0; padding-left: 20px; font-size: 13.5px; line-height: 1.55; }
.mfa-steps > li { margin-bottom: 14px; }
.mfa-keyrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; }
.mfa-key {
  font-family: var(--mono); font-size: 16px; letter-spacing: 0.06em; color: var(--head); overflow-wrap: anywhere;
  padding: 6px 12px; border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--line-strong);
}
.mfa-uri {
  display: block; margin-top: 4px; padding: 8px 10px; border-radius: var(--radius-xs); word-break: break-all;
  font-family: var(--mono); font-size: 11.5px; color: var(--ink-dim);
  background: var(--surface-2); border: 1px solid var(--line);
}
.mfa-codes p { margin: 0 0 10px; font-size: 13.5px; line-height: 1.55; }
.mfa-code-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 6px 14px; margin: 0 0 14px; padding-left: 24px; }
.mfa-code-list code { font-family: var(--mono); font-size: 14px; letter-spacing: 0.04em; color: var(--head); }
.bk-enc { margin: 0 0 10px; font-size: 13px; }
.bk-enc.ok { color: var(--success-ink); }
.rs-opt { font-weight: 400; color: var(--muted); }

/* ---- Review: notes for this month + the Paid column --------------------- */
.note-box { min-height: 72px; font-size: 13.5px; }
.saved-notes {
  margin: 14px 0 0; padding: 12px 16px; border-radius: var(--radius-md); font-size: 13.5px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--card-border); overflow-wrap: anywhere;
}
.saved-notes b { color: var(--head); }
.saved-notes ul { margin: 6px 0 0; padding-left: 18px; }
.note-list { display: flex; flex-direction: column; gap: 12px; }
.note-card {
  padding: 14px 16px; border-radius: var(--radius-md); border: 1px solid var(--card-border);
  border-left: 3px solid var(--accent); background: var(--surface); overflow-wrap: anywhere;
}
.note-card.ok { border-left-color: var(--success); }
.note-card.ask { border-left-color: var(--warning); }
.note-card.off { border-left-color: var(--line-strong); }
.note-card.off .note-text { color: var(--ink-dim); text-decoration: line-through; text-decoration-color: var(--faint); }
.note-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.note-text { min-width: 0; font-weight: 600; color: var(--head); }
.note-pill {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--radius-pill); vertical-align: 1px;
  font-size: 12px; font-weight: 500; line-height: 18px; white-space: nowrap;
  color: var(--accent-ink); background: var(--accent-tint);
}
.note-pill.ok { color: var(--success-ink); background: var(--success-soft); }
.note-pill.ask { color: var(--warning-ink); background: var(--warning-soft); }
.note-pill.off { color: var(--muted); background: var(--surface-3); }
h2 .note-pill { margin-left: 6px; }
td .note-pill { margin-top: 4px; font-size: 11.5px; }
.note-effect { margin-top: 6px; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.note-effect.ok { color: var(--head); }
.note-effect.info { color: var(--ink-dim); }
.note-effect.ask { color: var(--warning-ink); }
.note-instr { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.note-words { font-size: 12.5px; font-style: italic; color: var(--ink-dim); }
.note-cands { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
label.note-cand { display: flex; align-items: center; gap: 8px; margin: 0; cursor: pointer; font-size: 13.5px; font-weight: 400; color: var(--ink); }
.note-cand input { flex: none; }
.note-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.note-acts:empty { display: none; }
.note-acts button { --btn-h: 32px; padding: 4px 12px; font-size: 13px; }
.note-warn { font-size: 12.5px; font-weight: 600; color: var(--warning-ink); }
.rb-acts { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.paidcell { display: flex; flex-direction: column; gap: 4px; min-width: 150px; }
.paidcell select, .paidcell input { min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: 13px; }
.paid-st { font-size: 12px; color: var(--muted); }
.paid-st.ok { color: var(--success-ink); }
.paid-st.ask { color: var(--warning-ink); }
.paid-st.owe { color: var(--ink-dim); }
.paid-ask { font-size: 12px; line-height: 1.4; color: var(--warning-ink); max-width: 260px; }
.note-acts.note-ask { margin: 6px 0 4px; }

/* ---- Motion preferences --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .spinner { animation: spin 1.2s linear infinite !important; }
}

/* ---- Responsive -----------------------------------------------------------
   Breakpoints: 1100px (3-column grids → 2), 820px (tablets & phones: bottom nav,
   one column), 430px (small phones). */
@media (max-width: 1100px) {
  .card-grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Phones & tablets — the nav becomes a fixed bottom bar */
@media (max-width: 820px) {
  :root { --gap: 16px; }
  html, body { max-width: 100%; overflow-x: hidden; }   /* never let the page scroll sideways */
  .shell { flex-direction: column; max-width: 100%; }
  .mainwrap { min-width: 0; max-width: 100%; }
  /* The sidebar collapses; its logo moves to the top bar and its nav becomes the bottom bar. */
  .sidebar {
    flex: none; width: 100%; height: auto; position: static; overflow: visible;
    padding: 0; border-right: none; background: none;
  }
  .brand, .sidebar-foot { display: none; }
  .topbar-logo { display: inline-flex; }
  .topbar-logo-img { height: 28px; }
  .topbar-brand-name { display: none; }
  .cs-label { display: none; }

  /* Two tidy rows: [logo · title ……… theme · Sign out] then the client switcher, full width. */
  .topbar { padding: 10px 16px; flex-wrap: wrap; row-gap: 10px; column-gap: 8px; }
  .topbar-left { flex: 1 1 auto; min-width: 0; gap: 8px; order: 0; }
  .topbar-title { font-size: 17px; }
  .topbar-right { display: contents; }
  .themetoggle { order: 1; }
  #logoutBtn { order: 2; }
  .companyswitch { order: 3; flex: 1 1 100%; gap: 8px; min-width: 0; }
  .companyswitch:empty { display: none; }
  .userchip { order: 3; }
  #companySel { flex: 1 1 auto; min-width: 0; max-width: none; }

  #nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    flex-direction: row; gap: 0;
    padding: 6px 4px; padding-bottom: calc(6px + env(safe-area-inset-bottom));
    background: var(--topbar-bg);
    border-top: 1px solid var(--card-border); box-shadow: 0 -4px 16px rgba(16, 24, 40, 0.06);
  }
  .nav-group { display: none; }
  #nav button {
    flex: 1 1 auto; min-width: 0; width: auto; min-height: 52px;   /* longer labels get a little more room */
    flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    padding: 6px 2px; border-radius: var(--radius-sm);
    font-size: 10.5px; font-weight: 500; line-height: 1.15; letter-spacing: -0.01em; text-align: center; white-space: normal;
    color: var(--muted);
  }
  #nav button.nav-bottom { margin-top: 0; }
  #nav button:hover { background: transparent; color: var(--head); }
  #nav button.active { background: var(--accent-tint); color: var(--accent-ink); box-shadow: none; }
  .nav-ic { width: 22px; height: 22px; }

  /* Comfortable touch targets */
  :root { --btn-h: 44px; }
  button.sm, button.small, button.chip, .finding-actions button, .note-acts button, .bank-item-actions button,
  .inbox-actions button, .md-acts button, button.ghost.txdel, button.ghost.bk-dl, button.ghost.tp-copy,
  button.ghost.picked-del, button.ghost.sent-del, button.ghost.sent-mv, button.ghost.inbox-dl-small { --btn-h: 36px; }
  :where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"])), select { min-height: 44px; }
  .editable input, .editable select, #txtable .txe, .paidcell select, .paidcell input { min-height: 36px; }

  main { padding: 16px 16px 96px; }          /* clear the fixed bar; 16px side gutter */
  footer { padding: 12px 16px 96px; }
  .panel { padding: 18px 16px; border-radius: 14px; }
  .grid, .grid-3 { grid-template-columns: 1fr; }
  .card-grid, .card-grid.cols-2, .card-grid.cols-3 { grid-template-columns: 1fr; }
  .card-grid > .span-2 { grid-column: auto; }
  .userchip { max-width: 100%; }
  .dash-grid, .dash-grid.tiles { grid-template-columns: 1fr; }
  .dash-actions { justify-content: flex-start; }
  .send-grid { grid-template-columns: 1fr; }
  .months-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .mcell { padding: 12px; }
  .modal { padding: 20px 16px; }
  .legal-modal { padding: 22px 18px; }
}

/* Small phones */
@media (max-width: 430px) {
  .topbar-title { display: none; }            /* the bottom nav already labels the section */
  main { padding-left: 16px; padding-right: 16px; }
  .panel, .dash .panel, #checkupPanel, .overview-panel { padding: 16px 14px; }
  .card-head { flex-wrap: wrap; }
  .kpis, .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi, .card { padding: 12px 12px; }

  .tile-big { font-size: 22px; }
  .finding { padding: 12px 12px; }
  .dash-actions button { flex: 1 1 auto; }
  .authcard { padding: 24px 18px; }
  .bank-card, .send-card, #inboxPanel, #bankPanel, #mfaPanel { padding: 16px 14px; }
  .bank-item, .inbox-item { padding: 12px 12px; }
  .bank-item-actions button, .send-row button, .draft-banner button { flex: 1 1 auto; }
  .inbox-actions { width: 100%; }
  .inbox-actions select { flex: 1 1 100%; }
  .inbox-actions button { flex: 1 1 auto; }
  .sent-item { grid-template-columns: minmax(0, 1fr) auto; }
  .sent-acts { grid-column: 1 / -1; grid-row: auto; justify-content: flex-start; }
  .md-acts { white-space: normal; }
  .mfa-row input { flex-basis: 100%; max-width: none; }
  .mfa-key { font-size: 15px; }
  .bank-lines-table th:nth-child(3), .bank-lines-table td:nth-child(3) { display: none; }   /* account column */
  .bank-lines-table th, .bank-lines-table td { padding: 8px 6px; }
  .bank-lines-table td:first-child { font-size: 12px; }
  .bl-tag { white-space: normal; }
  button[data-conflict-reload] { margin-left: 0; }
  .note-card, .saved-notes { padding: 12px 12px; }
  .note-acts button, .rb-acts button { flex: 1 1 auto; }
  .rb-acts { width: 100%; }
  .note-pill { white-space: normal; }
  .paidcell { min-width: 132px; }
}

/* Very narrow phones: keep all eight bottom-bar labels apart. */
@media (max-width: 360px) {
  #nav { padding-left: 2px; padding-right: 2px; }
  #nav button { padding-left: 1px; padding-right: 1px; font-size: 9.5px; letter-spacing: -0.02em; }
}
