/* Diamond Hands Consortium — General Ledger workspace.
   A clean, professional accounting UI: deep-navy sidebar, cool paper workspace,
   the brand's blues for accents. Refined, data-dense, restrained motion. */

:root {
  /* surfaces */
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #eff3f8;

  /* brand blues (from the consortium mark) */
  --navy: #133a5e;
  --navy-deep: #0f2c47;
  --blue: #2c79ad;
  --blue-bright: #3b8fc9;
  --sky: #7fb2d8;
  --sky-soft: #cfe2f0;

  /* ink */
  --ink: #14222e;
  --ink-soft: #4a5b6b;
  --ink-faint: #8395a4;
  --line: #e1e8f0;
  --line-strong: #cdd8e4;

  /* accounting semantics */
  --debit: #1f4e74;     /* debit-normal, brand navy */
  --credit: #1c7d6b;    /* credit-normal, teal */
  --pos: #1c7d6b;
  --neg: #b4453a;
  --gold: #b0772f;

  --shadow-sm: 0 1px 2px rgba(20, 40, 60, 0.06), 0 1px 3px rgba(20, 40, 60, 0.05);
  --shadow: 0 6px 24px -12px rgba(19, 58, 94, 0.28);

  --sans: "Hanken Grotesk", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --display: "Fraunces", Georgia, serif;

  --r: 12px;
  --r-sm: 8px;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over element `display` rules. Author rules
   (e.g. `.gate`/`.app { display: grid }`) otherwise out-rank the UA stylesheet's
   `[hidden] { display: none }`, leaving the seed gate stuck on screen even after
   the books are opened. */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
em { font-style: italic; color: var(--blue); }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── buttons ─────────────────────────────────────────────── */
.btn {
  font-family: var(--sans);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.14s ease, background 0.16s, box-shadow 0.16s, border-color 0.16s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }
.btn.primary:hover { background: var(--navy-deep); box-shadow: 0 8px 20px -10px rgba(15, 44, 71, 0.6); }
.btn.ghost { background: var(--surface); color: var(--navy); border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--blue); color: var(--blue); }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.btn.lg { padding: 13px 26px; font-size: 16px; }

/* ── seed gate ───────────────────────────────────────────── */
.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(127, 178, 216, 0.25), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(44, 121, 173, 0.18), transparent 55%),
    var(--bg);
  z-index: 50;
}
.gate-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 48px 44px;
  max-width: 460px;
  text-align: center;
}
.gate-logo { width: 76px; height: 76px; object-fit: contain; border-radius: 14px; }
.gate-card h1 { font-family: var(--display); font-weight: 600; font-size: 30px; margin: 18px 0 2px; letter-spacing: -0.01em; }
.gate-sub { font-family: var(--mono); font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--blue); margin: 0 0 20px; }
.gate-body { color: var(--ink-soft); font-size: 15px; margin: 0 0 28px; }

/* ── app shell ───────────────────────────────────────────── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  color: #d7e3ef;
  padding: 22px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 9px; background: #fff; padding: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -0.01em; }
.brand-text span { font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--sky); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: #c2d4e4;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--r-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.nav-item.active { background: rgba(127, 178, 216, 0.18); color: #fff; box-shadow: inset 3px 0 0 var(--sky); }
.nav-item.active svg { opacity: 1; color: var(--sky); }

.sidebar-foot { margin-top: auto; padding-top: 18px; }
.nav-health {
  font-size: 12px;
  font-weight: 600;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.nav-health::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.nav-health.ok { background: rgba(28, 125, 107, 0.16); color: #8fe3cf; }
.nav-health.ok::before { background: #38d6b3; }
.nav-health.bad { background: rgba(180, 69, 58, 0.18); color: #f2b3ab; }
.nav-health.bad::before { background: #e9685a; }
.sidebar-meta { font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em; color: rgba(193, 212, 228, 0.5); padding: 0 4px; }

/* ── main column ─────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(18px, 3vw, 36px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumbs { display: flex; align-items: baseline; gap: 10px; font-size: 14px; min-width: 0; }
.crumb-co { color: var(--ink-faint); font-weight: 500; }
.crumb-sep { color: var(--line-strong); }
.crumb-view { font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.top-right { display: flex; align-items: center; gap: 14px; }
.period-chip {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
}
.period-chip b { color: var(--credit); }

.workspace { padding: clamp(18px, 3vw, 32px); }
.view { animation: fade 0.22s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── cards ───────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
  margin-bottom: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.card-head h3 { font-family: var(--display); font-weight: 600; font-size: 19px; margin: 0; letter-spacing: -0.01em; }
.card-sub { font-size: 13px; color: var(--ink-faint); }
/* report export buttons sit at the top-right of each report card head */
.report-actions { display: flex; gap: 8px; flex-shrink: 0; }
.hint { font-size: 13.5px; color: var(--ink-soft); margin: -6px 0 18px; line-height: 1.5; }

/* ── KPIs ────────────────────────────────────────────────── */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--sky); }
.kpi.k-pos::before { background: var(--pos); }
.kpi.k-neg::before { background: var(--neg); }
.kpi.k-navy::before { background: var(--navy); }
.k-label { font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-faint); }
.k-val { font-family: var(--mono); font-weight: 500; font-size: 27px; margin-top: 8px; color: var(--ink); letter-spacing: -0.01em; }
.k-val.pos { color: var(--pos); }
.k-val.neg { color: var(--neg); }
.k-tie { font-size: 12px; font-weight: 600; margin-top: 6px; display: inline-flex; align-items: center; gap: 5px; }
.k-tie.yes { color: var(--pos); }
.k-tie.no { color: var(--neg); }

/* ── dashboard ───────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.qa-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.qa {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  font-family: var(--sans); font-size: 14px; font-weight: 600; color: var(--navy);
  cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.14s;
}
.qa:hover { background: var(--surface-3); border-color: var(--blue); transform: translateY(-1px); }
.qa-ic { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; background: var(--sky-soft); color: var(--navy); font-size: 15px; }

.summary { display: flex; flex-direction: column; }
.sum-row { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.sum-row:last-child { border-bottom: 0; }
.sum-row .lbl { color: var(--ink-soft); }
.sum-row .val { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; }

.recent { display: flex; flex-direction: column; }
.recent-row { display: grid; grid-template-columns: 86px 1fr auto; gap: 14px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: 0; }
.recent-row .rd { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); }
.recent-row .rdesc { font-size: 14px; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .ramt { font-family: var(--mono); font-weight: 500; color: var(--debit); }
.tag-rev { font-size: 11px; color: var(--neg); font-weight: 600; }

/* ── chart of accounts ───────────────────────────────────── */
.inline-form {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap;
  padding: 16px; margin-bottom: 18px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.inline-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; min-width: 0; }
.inline-form label.grow { flex: 1; min-width: 160px; }
.inline-form input, .inline-form select { font-family: var(--sans); font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink); padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); width: 100%; }
.inline-form input:focus, .inline-form select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 121, 173, 0.14); }

.coa-group { margin-bottom: 22px; }
.coa-group:last-child { margin-bottom: 0; }
.coa-group-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 0 8px; border-bottom: 2px solid var(--line-strong); margin-bottom: 4px; }
.coa-group-head h4 { font-family: var(--display); font-weight: 600; font-size: 15px; margin: 0; }
.coa-group-head .gtot { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.coa-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.coa-row:last-child { border-bottom: 0; }
.coa-row .code { font-family: var(--mono); font-size: 13px; color: var(--ink-faint); }
.coa-row .nm { font-size: 14px; }
.coa-row .nm .inactive-pill { font-size: 10px; color: var(--neg); border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; margin-left: 8px; text-transform: uppercase; letter-spacing: 0.06em; }
.coa-row .bal { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; }
.bal.debit { color: var(--debit); }
.bal.credit { color: var(--credit); }
.bal.zero { color: var(--ink-faint); }

/* ── split layout (form + list) ──────────────────────────── */
.split { display: grid; grid-template-columns: 380px 1fr; gap: 20px; align-items: start; }
.form-card { position: sticky; top: 84px; }
.stack { display: flex; flex-direction: column; gap: 13px; }
.stack label, .two label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; }
.opt { text-transform: none; font-weight: 400; color: var(--line-strong); }
.stack input, .stack select, .two input, .two select {
  font-family: var(--sans); font-size: 15px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--ink);
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.stack input:focus, .stack select:focus, .two input:focus, .two select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 121, 173, 0.14); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
/* Let the 1fr tracks shrink below the inputs' intrinsic (size-attribute) width
   so a two-input row always splits the card's inner width and neither input
   overflows the card outline. */
.two label { min-width: 0; }
.stack .btn.primary { margin-top: 4px; }

/* journal lines */
.jhead { display: grid; grid-template-columns: 1fr 110px 32px; gap: 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); padding: 4px 0 0; }
.jhead span:nth-child(2) { text-align: right; }
.jlines { display: flex; flex-direction: column; gap: 8px; }
.jline { display: grid; grid-template-columns: 1fr 110px 32px; gap: 8px; align-items: center; }
.jline select { padding: 8px; font-size: 13px; font-family: var(--sans); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-width: 0; }
.jline input { padding: 8px 10px; text-align: right; font-family: var(--mono); border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-width: 0; }
.jline select:focus, .jline input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 121, 173, 0.14); }
.jline .rm { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; color: var(--ink-faint); height: 36px; font-size: 16px; }
.jline .rm:hover { color: var(--neg); border-color: var(--neg); }
.jline-foot { display: flex; align-items: center; justify-content: space-between; }
.jbalance { font-family: var(--mono); font-size: 14px; font-weight: 500; color: var(--ink-faint); }
.jbalance.good { color: var(--pos); }
.jbalance.bad { color: var(--neg); }

/* ── document lists (invoices / bills) ───────────────────── */
.doc-list { display: flex; flex-direction: column; }
.doc-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 14px; align-items: center; padding: 13px 0; border-bottom: 1px solid var(--line); }
.doc-row:last-child { border-bottom: 0; }
.doc-num { font-family: var(--mono); font-size: 13px; font-weight: 500; color: var(--navy); }
.doc-meta { min-width: 0; }
.doc-meta .party { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-meta .dt { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }
.doc-amt { font-family: var(--mono); font-weight: 500; font-size: 14px; text-align: right; }
.doc-amt.reversed { text-decoration: line-through; color: var(--ink-faint); }
.pill { font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; }
.pill.posted { background: rgba(28, 125, 107, 0.12); color: var(--credit); }
.pill.reversed { background: rgba(180, 69, 58, 0.12); color: var(--neg); }

/* ── entry feed ──────────────────────────────────────────── */
.entries { display: flex; flex-direction: column; gap: 12px; }
.entry { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px 16px; background: var(--surface-2); }
.entry.reversed { opacity: 0.62; }
.entry-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.entry-desc { font-weight: 600; font-size: 14px; }
.entry-date { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.entry-lines { display: flex; flex-direction: column; gap: 4px; }
.entry-line { display: grid; grid-template-columns: 1fr auto; font-size: 13px; font-family: var(--mono); color: var(--ink-soft); }
.entry-line .amt.debit { color: var(--debit); }
.entry-line .amt.credit { color: var(--credit); }
.entry-line .lkey { color: var(--gold); font-size: 11px; }
.entry-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 11px; padding-top: 10px; border-top: 1px dashed var(--line-strong); }
.estatus { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.estatus.posted { color: var(--credit); }
.estatus.reversed { color: var(--neg); }
.revbtn { font-size: 12px; font-weight: 600; padding: 5px 11px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; color: var(--ink-soft); }
.revbtn:hover { border-color: var(--neg); color: var(--neg); }

/* ── reports ─────────────────────────────────────────────── */
.subtabs { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.subtab { font-family: var(--sans); font-size: 13.5px; font-weight: 600; padding: 8px 16px; border: none; background: transparent; color: var(--ink-soft); border-radius: 999px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.subtab:hover { color: var(--navy); }
.subtab.active { background: var(--navy); color: #fff; }

.ledger-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ledger-table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); padding: 0 12px 10px 0; border-bottom: 1px solid var(--line-strong); }
.ledger-table th.r, .ledger-table td.r { text-align: right; }
.ledger-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line); }
.ledger-table tr:last-child td { border-bottom: 0; }
.ledger-table .code { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); width: 56px; }
.ledger-table .amt { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ledger-table .amt.debit { color: var(--debit); }
.ledger-table .amt.credit { color: var(--credit); }
.ledger-table tr.total td { border-top: 2px solid var(--ink); border-bottom: 0; padding-top: 11px; font-weight: 700; }
.ledger-table tr.subhead td { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--navy); padding-top: 16px; }
.ledger-table tr.balanced td { color: var(--pos); font-weight: 700; }
.ledger-table tr.imbalanced td { color: var(--neg); font-weight: 700; }

.stmt-card { max-width: 620px; }
.stmt-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.stmt-row .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.stmt-row.sub { color: var(--ink-soft); padding-left: 14px; }
.stmt-row.head { font-family: var(--display); font-weight: 600; color: var(--navy); border-bottom: 2px solid var(--line-strong); }
.stmt-row.total { border-top: 2px solid var(--ink); border-bottom: 0; margin-top: 4px; padding-top: 11px; font-weight: 700; font-size: 15px; }
.stmt-row.total .v.pos { color: var(--pos); }
.stmt-row.total .v.neg { color: var(--neg); }
.tie-banner { margin-top: 16px; padding: 12px 16px; border-radius: var(--r-sm); font-size: 13.5px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.tie-banner.ok { background: rgba(28, 125, 107, 0.1); color: var(--credit); }
.tie-banner.bad { background: rgba(180, 69, 58, 0.1); color: var(--neg); }

.sub-group { margin-bottom: 20px; }
.sub-group:last-child { margin-bottom: 0; }
.sub-group h4 { font-family: var(--display); font-weight: 600; font-size: 15px; margin: 0 0 6px; }
.sub-group .ctrl { font-family: var(--mono); font-size: 12px; color: var(--ink-faint); font-weight: 400; }
.sub-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.sub-row .k { color: var(--gold); font-family: var(--mono); font-size: 13px; }
.sub-row .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ── periods ─────────────────────────────────────────────── */
.periods { display: flex; flex-direction: column; }
.period-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--line); }
.period-row:last-child { border-bottom: 0; }
.period-row .plabel { font-family: var(--mono); font-weight: 500; font-size: 15px; }
.period-row .prange { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }
.badge { font-size: 10px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; padding: 4px 11px; border-radius: 999px; }
.badge.open { background: rgba(28, 125, 107, 0.13); color: var(--credit); }
.badge.locked { background: rgba(180, 69, 58, 0.12); color: var(--neg); }
.period-row .pactions { display: flex; gap: 8px; align-items: center; }
.unlock-reason { display: flex; gap: 8px; align-items: center; grid-column: 1 / -1; }
.unlock-reason input { flex: 1; }
.period-manage .two { margin-bottom: 0; }
.period-preview { margin: 4px 0 12px; min-height: 1.5em; }
.period-preview.warn, .period-hint.warn { color: var(--gold); }
.period-preview.err, .period-hint.err { color: var(--neg); }
.period-preview.ok, .period-hint.ok { color: var(--credit); }
.period-hint { margin: 0 0 6px; }
.backfill-form { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.period-events { display: flex; flex-direction: column; }
.period-event { display: grid; grid-template-columns: 90px 1fr auto; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.period-event:last-child { border-bottom: 0; }
.period-event .pe-label { font-family: var(--mono); font-weight: 500; }
.period-event .pe-when { font-family: var(--mono); font-size: 11.5px; color: var(--ink-faint); }
.period-event .pe-why { color: var(--ink-soft); font-style: italic; }

/* ── about / prose ───────────────────────────────────────── */
.prose { max-width: 920px; padding: 32px 36px; }
.kicker { font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--blue); }
.prose h2 { font-family: var(--display); font-weight: 600; font-size: 30px; margin: 12px 0 14px; letter-spacing: -0.015em; }
.prose h3.sub { font-family: var(--display); font-weight: 600; font-size: 21px; margin: 38px 0 16px; }
.prose > p { color: var(--ink-soft); font-size: 16px; max-width: 70ch; }
.layers { display: grid; grid-template-columns: 1fr 130px 1fr; align-items: stretch; margin: 26px 0 8px; }
.layer { border: 1px solid var(--line-strong); background: var(--surface-2); padding: 24px; border-radius: var(--r); }
.layer.engine { border-color: var(--navy); }
.layer .tag { font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; padding: 4px 10px; border-radius: 5px; background: var(--surface-3); color: var(--ink-soft); }
.layer.engine .tag { background: var(--navy); color: #fff; }
.layer h3 { font-family: var(--display); font-weight: 600; font-size: 20px; margin: 12px 0 14px; }
.layer ul { list-style: none; padding: 0; margin: 0 0 18px; }
.layer li { position: relative; padding: 9px 0 9px 20px; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--ink-soft); }
.layer li::before { content: "—"; position: absolute; left: 0; color: var(--blue); }
.layer.engine li::before { color: var(--credit); }
.endpoint { display: inline-block; font-family: var(--mono); font-size: 12px; padding: 7px 12px; background: var(--surface-3); border: 1px dashed var(--line-strong); border-radius: 6px; }
.seam { display: grid; place-items: center; position: relative; }
.seam::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: repeating-linear-gradient(to bottom, var(--line-strong) 0 6px, transparent 6px 12px); }
.seam span { position: relative; background: var(--surface); font-family: var(--mono); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); padding: 8px 6px; text-align: center; }
.types { width: 100%; border-collapse: collapse; font-size: 14px; }
.types th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); padding: 0 14px 10px 0; border-bottom: 1px solid var(--line-strong); }
.types td { padding: 11px 14px 11px 0; border-bottom: 1px solid var(--line); }
.types tr td:first-child { font-family: var(--display); font-weight: 600; font-size: 15px; }
.aside { color: var(--ink-soft); font-size: 14.5px; max-width: 76ch; margin-top: 16px; }
.principles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.principles article { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 18px 18px; }
.principles h4 { font-family: var(--display); font-weight: 600; font-size: 16px; margin: 0 0 8px; }
.principles p { color: var(--ink-soft); font-size: 13.5px; margin: 0; }
.docs-note { margin-top: 26px; color: var(--ink-faint); font-size: 14px; }
.prose code { font-family: var(--mono); font-size: 13px; background: var(--surface-3); padding: 1px 6px; border-radius: 4px; }

/* ── toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; z-index: 80; left: 50%; bottom: 28px; transform: translate(-50%, 24px);
  background: var(--navy-deep); color: #fff; font-size: 14px; font-weight: 500;
  padding: 13px 20px; border-radius: var(--r-sm); box-shadow: 0 18px 40px -16px rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity 0.22s, transform 0.22s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--neg); }
.toast.ok { background: var(--credit); }

.empty { color: var(--ink-faint); font-style: italic; padding: 26px 0; text-align: center; font-size: 14px; }

/* ── responsive ──────────────────────────────────────────── */
@media (max-width: 1080px) {
  .dash-grid { grid-template-columns: 1fr; }
  .split { grid-template-columns: 1fr; }
  .form-card { position: static; }
}
@media (max-width: 880px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .principles { grid-template-columns: 1fr; }
  .layers { grid-template-columns: 1fr; gap: 14px; }
  .seam { height: 48px; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px; }
  .brand { width: 100%; padding: 0 4px 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .nav-item span { display: none; }
  .nav-item { padding: 10px; }
  .nav-item.active { box-shadow: none; }
  .sidebar-foot { display: none; }
  .qa-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── integrations: recurring invoices (Stripe) & bank (Plaid) ───────────── */

/* pill variants reused across both tabs */
.pill.ok { background: rgba(28, 125, 107, 0.12); color: var(--credit); }
.pill.err { background: rgba(180, 69, 58, 0.12); color: var(--neg); }
.pill.pending { background: rgba(176, 119, 47, 0.14); color: var(--gold); }
.pill.muted { background: var(--surface-3); color: var(--ink-faint); }

/* configuration notice banner (info, not error) */
.intg-banner {
  background: rgba(44, 121, 173, 0.08);
  border: 1px solid var(--sky-soft);
  color: var(--ink-soft);
  border-radius: var(--r-sm);
  padding: 11px 15px;
  font-size: 13.5px;
  margin-bottom: 16px;
}
.intg-banner b { color: var(--navy); }

/* action bar above a list */
.rec-actions, .bank-action-btns { display: flex; align-items: center; gap: 14px; }
.rec-actions { justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; }
.rec-actions-text h3 { margin: 0 0 2px; font-size: 17px; }
.bank-action-btns { flex-wrap: wrap; }

.check { flex-direction: row !important; align-items: center; gap: 8px !important;
  text-transform: none !important; letter-spacing: 0 !important; font-weight: 500 !important;
  color: var(--ink-soft) !important; font-size: 13.5px !important; }
.check input { width: auto; }

/* schedule cards */
.rec-list { display: flex; flex-direction: column; gap: 12px; }
.rec-card { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 14px; background: var(--surface-2); }
.rec-card.canceled { opacity: 0.6; }
.rec-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.rec-top > div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rec-cust { font-weight: 700; color: var(--ink); }
.rec-freq { font-size: 12px; color: var(--ink-faint); }
.rec-amt { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--debit); }
.rec-meta { display: flex; align-items: center; gap: 12px; margin-top: 9px; font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; }
.rec-next b { color: var(--ink); }
.rec-runs { color: var(--ink-faint); }
.run-list { margin-top: 11px; border-top: 1px dashed var(--line-strong); padding-top: 9px; display: flex; flex-direction: column; gap: 5px; }
.run-row { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; align-items: center; font-size: 12.5px; }
.run-num { font-family: var(--mono); color: var(--ink-soft); }
.run-dt { color: var(--ink-faint); }
.run-amt { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.rec-controls { display: flex; gap: 8px; margin-top: 11px; }
.btn.danger { color: var(--neg); }
.btn.danger:hover { background: rgba(180, 69, 58, 0.08); }

/* saved payment methods */
.pm-list { display: flex; flex-direction: column; gap: 7px; margin-top: 12px; }
.pm-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.pm-cust { font-weight: 600; }
.pm-card { font-family: var(--mono); font-size: 12.5px; color: var(--ink-soft); }

/* bank connections + transactions */
.bank-conns { display: flex; flex-direction: column; gap: 9px; }
.conn-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.conn-name { font-weight: 600; display: flex; align-items: center; gap: 8px; }
.conn-meta { font-size: 12px; color: var(--ink-faint); font-family: var(--mono); }
.bank-table td { vertical-align: middle; }
.bank-table .acct-mask { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); }
.txn-actions, .txn-matched { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.btn.match { color: var(--blue); }
.match-to { font-size: 12px; color: var(--ink-soft); }
.muted-note { font-size: 12px; color: var(--ink-faint); font-style: italic; }

/* ── partner investments ── */
.partner-breakdown .partner-total { border-top: 2px solid var(--line-strong); border-bottom: none; margin-top: 4px; padding-top: 11px; }
.partner-breakdown .partner-total .k { color: var(--navy); }
.stmt-row.partner-sub { border-bottom: 1px dashed var(--line); }
.stmt-row.partner-sub span:first-child { padding-left: 18px; color: var(--ink-soft); font-size: 13px; font-family: var(--mono); }
.stmt-row.partner-sub .v { color: var(--ink-soft); }

/* ── Loans (small-business lending) ─────────────────────────────────────── */
.badge.overdue { background: rgba(176, 119, 47, 0.15); color: var(--gold); }

/* New-loan form extras */
.fees-fs { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px 4px; margin: 2px 0 4px; }
.fees-fs legend { font-size: 12px; font-weight: 600; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; padding: 0 6px; }
.stack textarea {
  font-family: var(--sans); font-size: 14px; color: var(--ink); resize: vertical;
  padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--r-sm); background: var(--surface);
  width: 100%;
}
.stack textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 121, 173, 0.14); }

.loan-calc { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; }
.calc-row { display: flex; justify-content: space-between; font-size: 13px; padding: 5px 0; color: var(--ink-soft); }
.calc-row span:last-child { font-family: var(--mono); }
.calc-row.total { border-top: 1px solid var(--line-strong); margin-top: 4px; padding-top: 9px; font-weight: 700; color: var(--ink); }
.calc-hint { font-size: 13px; color: var(--ink-faint); font-style: italic; }

/* Member contributions (loan funding) */
.contrib-fs .contrib-hint { margin: 0 0 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); }
.contrib-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.contrib-row { display: grid; grid-template-columns: 1fr 130px 32px; gap: 8px; align-items: center; }
.contrib-row input {
  padding: 8px 10px; font-size: 13px; border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-width: 0; width: 100%;
}
.contrib-row .c-amount { text-align: right; font-family: var(--mono); }
.contrib-row input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(44, 121, 173, 0.14); }
.contrib-row .rm { border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--r-sm); cursor: pointer; color: var(--ink-faint); height: 34px; font-size: 16px; }
.contrib-row .rm:hover { color: var(--neg); border-color: var(--neg); }

/* Funding split preview inside the loan calculator */
.calc-split { border-top: 1px dashed var(--line-strong); margin-top: 8px; padding-top: 6px; }
.calc-row.head { font-weight: 700; color: var(--navy); text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
.calc-row.sub { padding-left: 12px; color: var(--ink-faint); font-size: 12.5px; }
.calc-row .pos { color: var(--pos); }
.calc-split.over { background: rgba(178, 58, 72, 0.05); border-radius: var(--r-sm); }
.calc-warn { margin-top: 6px; font-size: 12px; color: var(--neg); font-weight: 600; }
.loan-fund-pill {
  display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px;
  background: rgba(46, 125, 91, 0.12); color: var(--pos); font-family: var(--sans);
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em; text-transform: none;
}

/* DHC Joint Pot & member exit (partner investments tab) */
.dhc-pot-line {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 12px; margin-bottom: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--r-sm); font-weight: 600; color: var(--ink);
}
.dhc-pot-line .v { font-family: var(--mono); font-size: 18px; }
.dhc-pot-line .v.pos { color: var(--pos); }
.exit-table { margin-top: 4px; }
.exit-table td.pos, .exit-table .amt.pos { color: var(--pos); }
.exit-note { margin: 10px 2px 0; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }

/* Member exit form: the live locked-payout preview */
.exit-preview {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 10px 12px; font-size: 13px;
}
.exit-preview-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 4px 0; color: var(--ink);
}
.exit-preview-row b { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.exit-preview-row b.pos { color: var(--pos); }
.exit-preview-row.total {
  margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--line-strong);
  font-weight: 700;
}
.exit-preview-row.total b { font-size: 16px; }

/* Departed members roll */
.departed-list { display: flex; flex-direction: column; gap: 10px; }
.departed-row {
  border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 13px; background: var(--surface-2);
}
.departed-head { display: flex; justify-content: space-between; align-items: center; }
.departed-head .k { color: var(--gold); font-family: var(--mono); font-size: 13.5px; font-weight: 600; }
.departed-meta { font-size: 12px; color: var(--ink-faint); margin: 3px 0 8px; }
.departed-figs {
  display: flex; flex-wrap: wrap; gap: 4px 18px; font-size: 12.5px; color: var(--ink-faint);
  padding-top: 5px;
}
.departed-figs b { color: var(--ink); font-family: var(--mono); font-variant-numeric: tabular-nums; margin-left: 4px; }
.departed-figs b.pos { color: var(--pos); }
.departed-figs b.neg { color: var(--neg); }
.settle-form { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.settle-form h4 { margin: 0; font-size: 13.5px; }


/* Loan list (portfolio) */
.loan-list { display: flex; flex-direction: column; }
.loan-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center;
  width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid var(--line);
  padding: 14px 4px; cursor: pointer; font-family: inherit; transition: background 0.12s;
}
.loan-row:last-child { border-bottom: 0; }
.loan-row:hover { background: var(--surface-2); }
.loan-borrower { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 14.5px; color: var(--navy); }
.loan-key { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--gold); }
.loan-figs { display: flex; gap: 22px; }
.loan-fig { display: flex; flex-direction: column; gap: 2px; }
.loan-fig .lf-l { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.loan-fig .lf-v { font-family: var(--mono); font-size: 13px; color: var(--ink); }

/* Loan detail */
.loan-detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.lstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 20px; margin: 4px 0 8px; }
.lstat { display: flex; flex-direction: column; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.ls-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.ls-v { font-family: var(--mono); font-size: 17px; color: var(--ink); }
.ls-v.pos { color: var(--pos); }
.ls-v.neg { color: var(--neg); }
.loan-terms { margin-top: 14px; }
.loan-terms .lt-h { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); font-weight: 600; }
.loan-terms p { margin: 5px 0 0; font-size: 14px; color: var(--ink-soft); line-height: 1.55; }

@media (max-width: 920px) {
  .loan-row { grid-template-columns: 1fr auto; }
  .loan-figs { display: none; }
  .lstats { grid-template-columns: repeat(2, 1fr); }
}

/* ══════════════════════════════════════════════════════════════
   AUTH · ROLES · MEMBER PORTAL
   ══════════════════════════════════════════════════════════════ */

/* Sign-in gate ─ demo picker */
.clerk-mount { min-height: 40px; margin-top: 8px; }
.demo-signin { text-align: left; }
.demo-users { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.demo-user {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 12px 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
  font-family: var(--sans); text-align: left;
}
.demo-user:hover { border-color: var(--blue); box-shadow: var(--shadow-sm); }
.demo-user:active { transform: translateY(1px); }
.demo-user-main { display: flex; flex-direction: column; gap: 3px; }
.demo-user-main b { color: var(--ink); font-size: 14px; }
.demo-key { font-family: var(--mono); font-size: 11.5px; color: var(--gold); }
.auth-status { margin-top: 8px; }
.auth-status .gate-body { margin-bottom: 18px; }
.auth-error {
  margin-top: 14px; padding: 10px 12px; border-radius: var(--r-sm);
  background: rgba(180, 69, 58, 0.1); color: var(--neg); font-size: 13px; text-align: left;
}

/* Role pills (header chip + demo picker + users list) */
.pill.role-admin { background: rgba(19, 58, 94, 0.13); color: var(--navy); }
.pill.role-accountant { background: rgba(28, 125, 107, 0.13); color: var(--credit); }
.pill.role-member { background: rgba(176, 119, 47, 0.15); color: var(--gold); }
.pill.role-viewer { background: var(--surface-3); color: var(--ink-soft); }

/* Header user chip */
.user-chip { display: flex; align-items: center; gap: 12px; padding-left: 12px; border-left: 1px solid var(--line); }
.user-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; line-height: 1.2; }
.user-email { font-size: 12.5px; color: var(--ink-soft); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Users & Access list */
.users-list { display: flex; flex-direction: column; }
.user-row {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
  padding: 13px 0; border-bottom: 1px solid var(--line);
}
.user-row.inactive { opacity: 0.55; }
.user-row-main { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.user-row-main b { color: var(--ink); }
.user-sub { font-size: 12px; color: var(--ink-faint); }
.user-row-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-role-select { padding: 6px 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: var(--surface); font-family: var(--sans); font-size: 13px; }
.user-key-row { display: flex; gap: 8px; margin-top: 5px; }
.user-key-input { padding: 6px 10px; border-radius: var(--r-sm); border: 1px solid var(--line-strong); font-family: var(--mono); font-size: 12.5px; width: 190px; }

/* Member portal */
.portal { display: flex; flex-direction: column; gap: 20px; }
.portal-head h2 { font-family: var(--display); font-size: 26px; margin: 0; color: var(--navy); }
.portal-sub { color: var(--ink-soft); margin: 4px 0 0; font-size: 14px; }
.portal-sub code { font-family: var(--mono); font-size: 12.5px; color: var(--gold); }
.portal-kpis { margin: 0; }
.portal-foot { color: var(--ink-faint); font-size: 12.5px; margin: 4px 2px 0; line-height: 1.5; }

/* ── role-scoped chrome ──────────────────────────────────────
   Server-side authorization is the real gate; these rules keep the UI honest
   so a viewer isn't shown controls that would only 403, and a member gets a
   clean portal instead of the full workspace. */
body[data-role="viewer"] .form-card,
body[data-role="viewer"] #newInvoiceBtn,
body[data-role="viewer"] .quick-actions,
body[data-role="viewer"] #toggleAcctForm,
body[data-role="viewer"] #krustyKrabBtn,
body[data-role="viewer"] #sampleLoanBtn,
body[data-role="viewer"] #runDueBtn,
body[data-role="viewer"] .bank-action-btns,
body[data-role="viewer"] [data-quick],
body[data-role="viewer"] [data-lock],
body[data-role="viewer"] [data-unlock],
body[data-role="viewer"] #periodManage,
body[data-role="member"] #periodManage,
body[data-role="viewer"] .revbtn { display: none !important; }

body[data-role="member"] .inv-write,
body[data-role="member"] #loanPortfolio,
body[data-role="member"] #loanDetail,
body[data-role="member"] #newInvoiceBtn,
body[data-role="member"] #periodChip { display: none !important; }

@media (max-width: 720px) {
  .user-email { max-width: 120px; }
  .user-row { flex-direction: column; }
  .user-key-input { width: 100%; }
}

/* ══════════════════════════════════════════════════════════════
   INVESTMENTS
   ══════════════════════════════════════════════════════════════ */
.inv-pane { display: flex; flex-direction: column; gap: 20px; }

/* chart range toggle */
.range-tabs { display: inline-flex; gap: 2px; background: var(--surface-3); border-radius: 999px; padding: 3px; }
.range-btn {
  border: none; background: transparent; cursor: pointer; font-family: var(--sans);
  font-size: 12px; font-weight: 600; color: var(--ink-soft); padding: 4px 12px; border-radius: 999px;
}
.range-btn.active { background: var(--surface); color: var(--navy); box-shadow: var(--shadow-sm); }

/* time-series chart */
.inv-chart { margin-top: 6px; }
.chart-svg { width: 100%; height: 200px; display: block; }
.chart-line { fill: none; stroke: var(--blue); stroke-width: 2; }
.chart-area { fill: rgba(44, 121, 173, 0.12); stroke: none; }
.chart-dot { fill: var(--blue-bright); stroke: #fff; stroke-width: 1.5; }
.chart-legend { display: flex; justify-content: space-between; align-items: baseline; margin-top: 4px; font-size: 12px; color: var(--ink-faint); }
.chart-cur { font-family: var(--mono); font-size: 15px; font-weight: 700; color: var(--navy); }

/* breakdown by source */
.inv-breakdown { display: flex; flex-direction: column; gap: 16px; }
.inv-src-row { display: flex; flex-direction: column; gap: 5px; }
.inv-src-head { display: flex; justify-content: space-between; align-items: baseline; }
.inv-src-name { font-weight: 600; color: var(--ink); }
.inv-src-val { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.inv-bar { height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.inv-bar-fill { height: 100%; border-radius: 999px; background: var(--blue); min-width: 2px; }
.inv-bar-fill.src-ibkr { background: var(--debit); }
.inv-bar-fill.src-kraken { background: #5741d9; }
.inv-bar-fill.src-atomic { background: var(--blue-bright); }
.inv-bar-fill.src-metals { background: var(--gold); }
.inv-src-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-faint); }

/* status colours on KPI ties + breakdown */
.k-tie.not_configured, .tie.not_configured { color: var(--ink-faint); }
.k-tie.error, .tie.error { color: var(--neg); }

/* venue + holding tables */
.inv-table { width: 100%; }
.inv-name { display: block; font-size: 11.5px; color: var(--ink-faint); }
.inv-notice {
  display: flex; flex-direction: column; gap: 4px; padding: 16px;
  background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: var(--r-sm);
}
.inv-notice b { color: var(--ink); }
.inv-notice span { font-size: 13px; color: var(--ink-soft); }
.inv-holding-list { min-height: 40px; }

/* viewers see the tab read-only — hide write affordances */
body[data-role="viewer"] .inv-write { display: none !important; }

/* Member loans progress */
.mloan-table td { vertical-align: middle; }
.mloan-progress { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.mloan-progress .inv-bar { flex: 1; }
.mloan-progress .inv-bar-fill { background: var(--credit); }
.mloan-progress span { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); min-width: 44px; text-align: right; }
.badge.past_due, .badge.defaulted { background: rgba(180, 69, 58, 0.12); color: var(--neg); }
.badge.repaid { background: var(--surface-3); color: var(--ink-soft); }
.badge.active { background: rgba(28, 125, 107, 0.13); color: var(--credit); }
/* Member sidebar order: My Portal, Investments, Loans */
body[data-role="member"] .nav { display: flex; flex-direction: column; }
body[data-role="member"] .nav-item[data-view="loans"] { order: 1; }
