/* Geffen Ventures — Family: the component layer.
 *
 * Tailwind supplies the utilities; this supplies the component vocabulary the
 * templates were written against — `card`, `btn`, `badge`, `stat`, `note`,
 * `table-scroll`, `page-head`, the journal timeline, the notice letterhead.
 * Thirty-one pages use it.
 *
 * Restyled 2026-07-30 to match the fleet shell, rather than rewriting all
 * thirty-one templates by hand. Those templates already use this vocabulary
 * consistently, so retuning it here restyles every page at once and coherently,
 * without touching markup the render-contract tests are pinned to. Rewriting the
 * markup instead would have been a great deal of churn for the same pixels, plus a
 * real chance of breaking a page nobody happened to look at.
 *
 * The palette moved from the old warm walnut to the platform's grey-on-#f5f6fa with
 * indigo accents, so a page styled from here sits beside a page built from Tailwind
 * utilities without a visible seam. The pages that are ALREADY Tailwind
 * (dossier/show, calendar, waterfall, achievements) are unaffected — utilities and
 * these component classes do not collide.
 *
 * Still hand-written and CSP-clean: no build step, no CDN. */

:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface-alt: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --ink: #111827;
  --ink-soft: #4b5563;
  --ink-faint: #9ca3af;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-line: #a5b4fc;
  --good: #047857;
  --good-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --bad: #be123c;
  --bad-soft: #fff1f2;
  --info: #0369a1;
  --info-soft: #f0f9ff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 1px 2px rgba(16, 24, 40, .06);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 13px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .ui, .nav, table, .btn, label, .badge, .stat { font-family: var(--sans); }
h1 { font-size: 1.25rem; font-weight: 650; letter-spacing: -.021em; margin: 0 0 .15rem; }
h2 { font-size: .95rem; font-weight: 640; letter-spacing: -.012em; margin: 0 0 .6rem; }
h3 { font-size: .85rem; font-weight: 640; margin: 0 0 .4rem; }
h4 { font-size: .78rem; font-weight: 640; margin: 0 0 .35rem; }
p  { margin: 0 0 .7rem; }
a  { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .85em; }

/* ── legacy shell: only the signed-out pages still render this ──────────── */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: .55rem 1.2rem; display: flex; align-items: center; gap: 1.2rem;
  position: sticky; top: 0; z-index: 40;
}
.brand { font-weight: 650; letter-spacing: -.02em; color: var(--ink);
         line-height: 1.15; white-space: nowrap; }
.brand small { display: block; font-size: .6rem; font-weight: 500; color: var(--ink-faint);
               letter-spacing: .1em; text-transform: uppercase; }
.nav { display: flex; gap: .15rem; margin-left: auto; align-items: center;
       font-size: .8rem; flex-wrap: wrap; }
.nav a { color: var(--ink-soft); padding: .3rem .55rem; border-radius: 6px; }
.nav a:hover { background: var(--accent-soft); color: var(--ink); text-decoration: none; }
.nav a.active { color: var(--accent); font-weight: 620; background: var(--accent-soft); }
.nav .sep { width: 1px; height: 16px; background: var(--border); margin: 0 .35rem; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }
.wrap.narrow { max-width: 760px; }

.page-head { margin-bottom: 1.1rem; display: flex; align-items: flex-start;
             gap: .9rem; flex-wrap: wrap; }
.page-head > div:first-child { flex: 1; min-width: 240px; }
.page-head p { color: var(--ink-soft); margin: 0; font-size: .8rem; }
.crumb { font-size: .74rem; margin-bottom: .45rem; }
.crumb a { color: var(--ink-faint); }

/* ── cards ─────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  margin-bottom: .9rem; overflow: hidden;
}
.card-head {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .6rem .95rem; border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
}
.card-title {
  font-size: .68rem; font-weight: 700; letter-spacing: .075em;
  text-transform: uppercase; color: var(--ink-faint);
}
.card-head .right { margin-left: auto; }
.card-body { padding: .9rem .95rem; }
.card-body.flush { padding: 0; }
.card-foot {
  padding: .55rem .95rem; border-top: 1px solid var(--border);
  background: var(--surface-alt); font-size: .78rem; font-weight: 650;
  font-variant-numeric: tabular-nums; text-align: right;
}

.grid { display: grid; gap: .9rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(310px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

/* ── stats ─────────────────────────────────────────────────────────────── */
.stat {
  padding: .8rem .95rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.stat .n {
  font-size: 1.35rem; font-weight: 650; letter-spacing: -.025em; display: block;
  line-height: 1.15; font-variant-numeric: tabular-nums; font-family: var(--mono);
}
.stat .l {
  font-size: .62rem; text-transform: uppercase; letter-spacing: .085em;
  color: var(--ink-faint); font-weight: 700; display: block; margin-top: .15rem;
}
.stat .sub { font-size: .7rem; color: var(--ink-faint); margin-top: .15rem; display: block; }
.stat.good .n { color: var(--good); }
.stat.warn .n { color: var(--warn); }
.stat.bad  .n { color: var(--bad); }
.stat.good { border-color: #a7f3d0; background: var(--good-soft); }
.stat.warn { border-color: #fde68a; background: var(--warn-soft); }
.stat.bad  { border-color: #fecdd3; background: var(--bad-soft); }

/* ── tables ────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th {
  text-align: left; font-size: .62rem; text-transform: uppercase;
  letter-spacing: .075em; color: var(--ink-faint); font-weight: 700;
  padding: .5rem .6rem; border-bottom: 1px solid var(--border);
  white-space: nowrap; background: var(--surface-alt);
}
td { padding: .45rem .6rem; border-bottom: 1px solid #f3f4f6; vertical-align: top; }
.calc td { padding-top: .6rem; padding-bottom: .6rem; }
.calc td:nth-child(4) { border-left: 1px solid #f3f4f6; max-width: 20rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--accent-soft); }
tfoot td { border-top: 2px solid var(--border-strong); font-weight: 700;
           background: var(--surface-alt); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap;
       font-family: var(--mono); }
.nowrap { white-space: nowrap; }
td.tight, th.tight { width: 1%; white-space: nowrap; }
.row-void td { opacity: .45; text-decoration: line-through; }
.row-flag td { background: var(--warn-soft); }
.row-flag td:first-child { box-shadow: inset 3px 0 0 var(--warn); }
.row-group td { background: var(--accent-soft); font-weight: 650;
                font-size: .74rem; letter-spacing: .02em; }

/* ── badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; font-size: .6rem; font-weight: 700; letter-spacing: .045em;
  text-transform: uppercase; padding: .12rem .38rem; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
  vertical-align: middle;
}
.badge.good { background: var(--good-soft); color: var(--good); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad  { background: var(--bad-soft);  color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.plain { background: #f3f4f6; color: var(--ink-soft); }
.badge.dot::before { content: '●'; margin-right: .22rem; font-size: .7em; }

/* ── buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--accent); color: #fff; border: 1px solid transparent;
  padding: .38rem .8rem; border-radius: 6px; font-size: .76rem; font-weight: 620;
  cursor: pointer; text-decoration: none; line-height: 1.3;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: #4338ca; text-decoration: none; color: #fff; }
.btn.ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--border-strong); }
.btn.ghost:hover { background: var(--surface-alt); color: var(--ink); border-color: var(--ink-faint); }
.btn.danger { background: var(--bad); }
.btn.sm { padding: .22rem .5rem; font-size: .68rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }

/* ── forms ─────────────────────────────────────────────────────────────── */
label { font-size: .72rem; font-weight: 600; color: var(--ink-soft); }
input, select, textarea { font-family: inherit; font-size: .78rem; }
input[type=date], input.inline, select.inline {
  border: 1px solid var(--border-strong); border-radius: 5px;
  padding: .25rem .4rem; background: var(--surface); color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-line); outline-offset: -1px; border-color: var(--accent);
}
.field { margin-bottom: .7rem; }
.form-row { display: flex; gap: .6rem; flex-wrap: wrap; }
.form-row > div { flex: 1; min-width: 170px; }

/* ── notes & flashes ───────────────────────────────────────────────────── */
.note {
  border: 1px solid var(--border); border-left: 3px solid var(--accent-line);
  background: var(--surface); border-radius: var(--radius);
  padding: .65rem .85rem; font-size: .78rem; color: var(--ink-soft);
  margin-bottom: .9rem;
}
.note strong { color: var(--ink); }
.note.warn { border-color: #fde68a; border-left-color: var(--warn);
             background: var(--warn-soft); color: #78350f; }
.note.bad  { border-color: #fecdd3; border-left-color: var(--bad);
             background: var(--bad-soft); color: #881337; }

.flash {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: .55rem .8rem; margin-bottom: .5rem; font-size: .78rem;
  background: var(--surface);
}
.flash.success { border-color: #a7f3d0; background: var(--good-soft); color: #065f46; }
.flash.warning { border-color: #fde68a; background: var(--warn-soft); color: #78350f; }
.flash.error   { border-color: #fecdd3; background: var(--bad-soft);  color: #881337; }

.empty { padding: 1.6rem .9rem; text-align: center; color: var(--ink-faint); font-size: .78rem; }
.muted { color: var(--ink-faint); }
.small { font-size: .74rem; }
.tiny  { font-size: .66rem; }

/* ── key/value ─────────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .25rem .8rem;
      margin: 0; font-size: .78rem; }
.kv dt { color: var(--ink-faint); font-size: .66rem; text-transform: uppercase;
         letter-spacing: .06em; font-weight: 700; }
.kv dd { margin: 0; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--accent);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: .7rem; font-weight: 700; flex-shrink: 0;
}
.person-line { display: flex; align-items: center; gap: .5rem; padding: .4rem 0;
               border-bottom: 1px solid #f3f4f6; }
.person-line:last-child { border-bottom: 0; }

/* ── the journal timeline ──────────────────────────────────────────────── */
.jr { position: relative; padding-left: 1.1rem; }
.jr::before { content: ''; position: absolute; left: 4px; top: .3rem; bottom: .3rem;
              width: 1px; background: var(--border); }
.jr-entry { position: relative; padding: .4rem 0 .4rem .2rem; font-size: .78rem; }
.jr-entry::before {
  content: ''; position: absolute; left: -1.1rem; top: .72rem;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--ink-faint);
}
.jr-entry.payment::before    { border-color: var(--good); }
.jr-entry.milestone::before  { border-color: var(--accent); }
.jr-entry.life_event::before { border-color: var(--info); }
.jr-entry.action::before     { border-color: var(--warn); }

.tl-year { display: flex; gap: .8rem; padding: .4rem 0; }
.tl-year .yr { font-family: var(--mono); font-weight: 700; color: var(--ink-faint);
               min-width: 3rem; font-size: .78rem; }
.tl-year .items { flex: 1; }
.tl-item { display: flex; gap: .6rem; padding: .2rem 0; font-size: .78rem; }
.tl-item + .tl-item { border-top: 1px solid #f3f4f6; }
.tl-item .when { color: var(--ink-faint); font-family: var(--mono);
                 font-size: .68rem; min-width: 5.2rem; }
.tl-item .what { flex: 1; }

/* ── the distribution notice is a letter, so it stays serif ────────────── */
.notice-doc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.2rem 2.4rem;
  font-family: var(--serif); font-size: .92rem; line-height: 1.7;
  box-shadow: var(--shadow);
}
.notice-doc .letterhead {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid var(--ink); padding-bottom: .8rem; margin-bottom: 1.4rem;
}
.notice-doc .letterhead .org { font-family: var(--sans); font-weight: 700;
                               font-size: 1rem; letter-spacing: -.01em; }
.notice-doc .letterhead .meta { text-align: right; font-family: var(--sans);
                                font-size: .74rem; color: var(--ink-faint); }
.notice-total td { border-top: 2px solid var(--ink); font-weight: 700; }

/* ── auth pages, which render without the shell ────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center;
             justify-content: center; padding: 1.5rem; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow);
  padding: 2rem; width: 100%; max-width: 380px;
}
.auth-card h1 { text-align: center; margin-bottom: .2rem; }
.auth-card .sub { text-align: center; color: var(--ink-faint); font-size: .74rem;
                  margin-bottom: 1.3rem; }

/* ── the old topbar switcher, kept in case a page still renders it ─────── */
.switcher { position: relative; }
.switcher-btn {
  display: inline-flex; align-items: center; gap: .35rem; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 6px;
  padding: .28rem .6rem; font-size: .74rem; cursor: pointer; color: var(--ink-soft);
}
.switcher-btn:hover { background: var(--surface-alt); }
.switcher-btn .dot { width: 6px; height: 6px; border-radius: 50%;
                     background: var(--good); display: inline-block; }
.switcher-btn .caret { color: var(--ink-faint); font-size: .65rem; }
.switcher-menu {
  display: none; position: absolute; left: 0; top: 100%; margin-top: .3rem;
  min-width: 190px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow); padding: .3rem; z-index: 60;
}
.switcher:hover .switcher-menu, .switcher:focus-within .switcher-menu { display: block; }
.switcher-menu a { display: block; padding: .32rem .55rem; border-radius: 6px;
                   font-size: .78rem; color: var(--ink); }
.switcher-menu a:hover { background: var(--accent-soft); text-decoration: none; }

/* ── responsive ────────────────────────────────────────────────────────── */
@media (max-width: 760px) {
  .nav { gap: 0; font-size: .76rem; }
  .nav a { padding: .28rem .42rem; }
  .wrap { padding: 1.1rem .8rem 3.5rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .notice-doc { padding: 1.4rem 1.2rem; }
  .kv { grid-template-columns: 1fr; gap: .1rem .5rem; }
  .kv dt { padding-top: .5rem; }
}

/* ── print: notices and registers must survive a printer ───────────────── */
@media print {
  .topbar, .nav, .btn, .btn-row, .no-print, .flash { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .wrap { max-width: none; padding: 0; }
  .card, .notice-doc, .stat { box-shadow: none; border: 1px solid #ccc;
                              break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
}

/* ── registers: sortable headers, search, link cards ────────────────────── */

/* Only headers JS has actually upgraded get the affordance. Styling every th
   as clickable would promise sorting on tables that do not have it. */
th.is-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.1rem;
}
th.is-sortable:hover { color: var(--ink); }
th.is-sortable::after {
  content: "95";                      /* ↕ — sortable, not yet sorted */
  position: absolute;
  right: .35rem;
  opacity: .3;
  font-size: .75em;
}
th.sorted-asc::after  { content: "91"; opacity: .9; }
th.sorted-desc::after { content: "93"; opacity: .9; }
th.is-sortable:focus-visible { outline: 2px solid var(--accent, #2563eb); outline-offset: -2px; }

.card-head input[type="search"] {
  font-size: .8rem;
  padding: .2rem .45rem;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: .3rem;
  margin-right: .45rem;
}

/* A card that is entirely a link. Kept as a block so the whole tile is the
   target, not just the words. */
a.link-card {
  display: block;
  padding: .75rem .85rem;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s ease, background .12s ease;
}
a.link-card:hover { border-color: var(--accent, #2563eb); background: var(--surface-2, #f9fafb); }
a.link-card strong { display: block; margin-bottom: .15rem; }
a.link-card .muted { font-size: .78rem; }

/* A note row belongs to the record above it — never striped, never sorted
   away from its parent (JS skips [data-norow]). */
tr.sub-row > td { border-top: 0; padding-top: 0; }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .82em; }

/* A cheque settles several obligations, so the picker is a checkbox list. Kept
   scrollable rather than truncated: dropping candidates past the eighth would
   hide the right one on a control whose whole job is picking it. */
.pick-list {
  max-height: 9rem;
  overflow-y: auto;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: .3rem;
  padding: .25rem .4rem;
  margin-bottom: .35rem;
  min-width: 22rem;
}
label.pick {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  font-size: .8rem;
  padding: .12rem 0;
  cursor: pointer;
}
label.pick:hover { background: var(--surface-2, #f9fafb); }
label.pick input { margin: 0; flex: 0 0 auto; }

/* An inline "remove" that must not look like a primary action — it sits inside
   a sentence, and a button there would read as the thing to press. */
button.linkish {
  background: none;
  border: 0;
  padding: 0 .15rem;
  cursor: pointer;
  color: var(--bad, #b91c1c);
  font-size: 1em;
  line-height: 1;
}
button.linkish:hover { text-decoration: underline; }
