/* ============================================================
   Northbridge Alliance — member platform prototype
   Platform UI conventions from the brand book; the marketing
   site's Cobalt tokens, product density.
   ============================================================ */

/* fonts: the marketing site's own files, served from here (no third-party requests) */
@font-face { font-family: "Geist"; src: url("fonts/geist-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("fonts/geist-mono-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url("fonts/inter-tight-latin-wght-normal.woff2") format("woff2-variations"); font-weight: 100 900; font-display: swap; }

:root {
  /* Cobalt institutional, the marketing site's tokens (sandbox/landing/src/index.css),
     dark by default, like the site; light only when the reader chose it with the
     site's toggle (mw-theme). Ratios as measured there. */
  color-scheme: light;
  --ink: #f5f6f8;            /* page (paper) */
  --surface: #ffffff;        /* card */
  --surface-2: #eceef2;      /* paper-2 */
  --surface-3: #e3e6ec;
  --line: #d3d7df;
  --line-soft: #e3e6ec;
  --heading: #0a0a0b;        /* 18.3:1 on paper */
  --fg: #2e3138;             /* 12.0:1 */
  --muted: #5f6470;          /* 5.1:1 on paper-2, 5.5:1 on paper */

  --sapphire: #1f3bff;       /* signal: focus, active tab, text accents (6.2:1) */
  --sky: #1f3bff;
  --action: #1f3bff;         /* cobalt fill, white text 6.7:1, both themes */
  --action-hover: #2a2fe8;
  --brand-a: #1f3bff;        /* the mark and avatars: cobalt into deep cobalt */
  --brand-b: #0f22a8;
  --violet: #1f3bff;         /* the old violet moments are cobalt now */
  --violet-hover: #2a2fe8;

  --ok: #0f7a4b;
  --ok-fill: #0f7a4b;
  --warn: #2e3138;           /* "due" is neutral: the palette keeps red for problems */
  --err: #b42318;
  --err-fill: #b42318;
  --glass: rgb(245 246 248 / .85);
  --shadow: 0 24px 60px -24px rgb(10 10 11 / .22), 0 8px 18px -12px rgb(10 10 11 / .16);

  --f-body: "Geist", system-ui, -apple-system, sans-serif;
  --f-display: "Inter Tight", "Geist", system-ui, sans-serif;
  --f-mono: "Geist Mono", ui-monospace, monospace;

  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-pill: 999px;
  --nav-w: 240px;
}
:root:not([data-theme="light"]) {
  --ink: #0b0c10; --surface: #16181e; --surface-2: #111318; --surface-3: #22252c;
  --line: #2e323a; --line-soft: #22252c;
  --heading: #f2f3f5; --fg: #c9ccd4; --muted: #9298a5;
  --sapphire: #8e9cff; --sky: #a3aeff;
  --ok: #6fd6a0; --warn: #c9ccd4; --err: #ff8b82;
  --glass: rgb(11 12 16 / .85);
  --shadow: 0 24px 60px -24px rgb(0 0 0 / .7), 0 8px 18px -12px rgb(0 0 0 / .6);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--ink);
  color: var(--fg);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 3px solid var(--sapphire); outline-offset: 2px; border-radius: 6px; }
.vh {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- prototype banner ---------- */
.proto {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  font-size: 12.5px; color: var(--muted);
}
.proto b { color: var(--sky); font-family: var(--f-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; font-weight: 500; }
.proto a { color: var(--sky); text-decoration: underline; text-underline-offset: 3px; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; min-height: calc(100vh - 39px); }
.app.collapsed { --nav-w: 64px; }

.side {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 16px 12px;
  gap: 6px;
  position: sticky; top: 0; height: calc(100vh - 39px);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 16px;
  font-family: var(--f-body); font-weight: 700; letter-spacing: -0.02em;
  color: var(--heading); font-size: 16px; white-space: nowrap; overflow: hidden;
}
.brand-dot {
  width: 26px; height: 26px; flex: none; border-radius: 8px;
  background: linear-gradient(130deg, var(--brand-a), var(--brand-b));
  display: grid; place-items: center; font-size: 12px; color: #fff;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-family: var(--f-mono); font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted);
  padding: 14px 10px 6px;
}
.navlink {
  display: flex; align-items: center; gap: 11px;
  min-height: 44px; padding: 0 10px;
  border-radius: var(--r-sm);
  color: var(--fg); font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden;
  border: none; background: none; width: 100%; cursor: pointer; text-align: left;
}
.navlink svg { width: 18px; height: 18px; flex: none; stroke-width: 1.7; }
.navlink:hover { background: var(--surface-2); color: var(--heading); }
.navlink[aria-current="page"] { background: var(--surface-3); color: var(--heading); }
.navlink .count {
  margin-left: auto; font-family: var(--f-mono); font-size: 11px;
  background: var(--action); color: #fff; border-radius: var(--r-pill);
  padding: 2px 7px; min-width: 20px; text-align: center;
}
.app.collapsed .navlink span:not(.count), .app.collapsed .nav-label,
.app.collapsed .brand span { display: none; }
.app.collapsed .navlink { justify-content: center; padding: 0; }
.divider { height: 1px; background: var(--line); margin: 14px 4px 0; }

/* ---------- top bar ---------- */
.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--glass);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.icon-btn {
  width: 40px; height: 40px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: none; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--heading); }
.icon-btn svg { width: 18px; height: 18px; stroke-width: 1.7; }
.search {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 13px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.search svg { width: 16px; height: 16px; color: var(--muted); flex: none; stroke-width: 1.7; }
.search input { flex: 1; background: none; border: none; outline: none; font-size: 14px; }
.search input::placeholder { color: var(--muted); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 10px 5px 5px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer;
}
.who small { display: block; color: var(--muted); font-size: 11px; }
.who b { font-size: 13px; color: var(--heading); font-weight: 600; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--brand-a), var(--brand-b));
  display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff;
}

/* ---------- page ---------- */
.page { padding: 26px 22px 60px; max-width: 1180px; width: 100%; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 {
  font-family: var(--f-display); font-weight: 600; font-size: 26px;
  letter-spacing: -0.02em; color: var(--heading); line-height: 1.2;
}
.page-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.page-head .spacer { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.eyebrow {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); display: block; margin-bottom: 7px;
}
.screen[hidden] { display: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid transparent;
  background: var(--action); color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background 150ms ease;
}
.btn:hover { background: var(--action-hover); }
.btn svg { width: 16px; height: 16px; stroke-width: 1.8; }
.btn--ghost { background: none; border-color: var(--line); color: var(--fg); }
.btn--ghost:hover { background: var(--surface-2); color: var(--heading); }
.btn--brand { background: var(--violet); }   /* plan and renewal moments only */
.btn--brand:hover { background: var(--violet-hover); }
.btn--danger { background: none; border-color: var(--line); color: var(--err); }
.btn--danger:hover { background: color-mix(in srgb, var(--err) 12%, transparent); }
.btn--sm { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

/* ---------- cards (members get space) ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
}
.card h3 { font-size: 16px; color: var(--heading); font-weight: 600; letter-spacing: -0.01em; }
.card .meta { color: var(--muted); font-size: 13px; }
.card-actions { margin-top: auto; padding-top: 6px; display: flex; gap: 8px; }
.stat { display: flex; flex-direction: column; gap: 3px; }
.stat b {
  font-family: var(--f-display); font-size: 30px; font-weight: 600;
  letter-spacing: -0.02em; color: var(--heading); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat span { color: var(--muted); font-size: 13px; }

/* ---------- chips / tags ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .08em;
  text-transform: uppercase;
  padding: 5px 9px; border-radius: 6px;
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--line);
  cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--action); border-color: var(--action); color: #fff; }
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; padding: 3px 9px; border-radius: var(--r-pill);
  background: var(--surface-2); color: var(--fg); border: 1px solid var(--line);
}
.tag.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.tag.warn { color: var(--warn); border-color: var(--line); }
.tag.err { color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- filter rail (top, never a sidebar) ---------- */
.rail {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}
.rail .search { max-width: 320px; background: var(--surface-2); }
.rail-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 2px; }
.result-count { margin-left: auto; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------- tables (staff get rows) ---------- */
.tablewrap { border: 1px solid var(--line); border-radius: var(--r); overflow: auto; background: var(--surface); }
table { border-collapse: separate; border-spacing: 0; width: 100%; min-width: 780px; font-size: 14px; }
th, td { text-align: left; padding: 0 14px; height: 48px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-2); color: var(--muted);
  font-family: var(--f-mono); font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; font-weight: 500; height: 40px;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--heading); }
th .dir { opacity: 0; margin-left: 5px; }
th[aria-sort] .dir { opacity: 1; color: var(--sky); }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel { background: color-mix(in srgb, var(--sapphire) 12%, transparent); }
tbody td:first-child, thead th:first-child {
  position: sticky; left: 0; z-index: 1; background: var(--surface);
}
thead th:first-child { z-index: 3; background: var(--surface-2); }
tbody tr:hover td:first-child { background: var(--surface-2); }
tbody tr.sel td:first-child { background: color-mix(in srgb, var(--sapphire) 12%, var(--surface)); }
td .name { color: var(--heading); font-weight: 600; }
td.num { font-variant-numeric: tabular-nums; text-align: right; }
.mono { font-family: var(--f-mono); font-size: 12.5px; color: var(--muted); }
.rowlink { background: none; border: none; cursor: pointer; padding: 0; text-align: left; }
.rowlink:hover .name { color: var(--sky); }

.tablebar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px;
}
.bulk {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--sapphire) 10%, transparent);
  font-size: 13.5px; color: var(--heading);
}
.bulk[hidden] { display: none; }

/* ---------- record (a single page, never a modal) ---------- */
.record { display: grid; grid-template-columns: 1.55fr 1fr; gap: 18px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-h {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--heading);
  display: flex; align-items: center; gap: 10px;
}
.panel-b { padding: 16px 18px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 11px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { color: var(--fg); }
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); padding: 0 8px; }
.tab {
  min-height: 42px; padding: 0 13px; background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--sapphire); }
.timeline { display: flex; flex-direction: column; }
.tl-row { display: grid; grid-template-columns: 108px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.tl-row:first-child { border-top: none; }
.tl-row time { font-family: var(--f-mono); font-size: 11.5px; color: var(--muted); padding-top: 2px; }
.tl-row p { font-size: 13.5px; }
.tl-row p b { color: var(--heading); font-weight: 600; }

/* ---------- forms ---------- */
.form { max-width: 480px; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 14px; font-weight: 600; color: var(--heading); }
.field input, .field select, .field textarea {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm);
  min-height: 44px; padding: 10px 13px; outline: none; font-size: 14px;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--sapphire); box-shadow: 0 0 0 4px color-mix(in srgb, var(--sapphire) 20%, transparent);
}
.field .help { font-size: 12.5px; color: var(--muted); }
.field .err { font-size: 12.5px; color: var(--err); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--err); }

/* ---------- empty state ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 54px 20px; text-align: center;
  border: 1px dashed var(--line); border-radius: var(--r); color: var(--muted);
}
.empty svg { width: 22px; height: 22px; stroke-width: 1.6; color: var(--muted); }
.empty p { font-size: 14px; }

/* ---------- skeleton (never a full-page spinner) ---------- */
.skel { border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%); background-size: 400% 100%; animation: sh 1.3s linear infinite; }
@keyframes sh { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- toasts, bottom-left, one at a time ---------- */
.toasts { position: fixed; left: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 15px; box-shadow: var(--shadow);
  font-size: 13.5px; color: var(--heading); max-width: 380px;
  animation: rise 220ms cubic-bezier(.2,.7,.2,1);
}
.toast .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); flex: none; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- responsive ---------- */
@media (max-width: 1023px) {
  .record { grid-template-columns: 1fr; }
}
@media (max-width: 767px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 39px auto 0 0; width: 258px; height: auto;
    transform: translateX(-100%); transition: transform 220ms ease; z-index: 60;
  }
  .app.nav-open .side { transform: none; }
  .app.nav-open::after { content: ""; position: fixed; inset: 0; background: rgb(10 10 11 / .4); z-index: 50; }
  .page { padding: 20px 15px 50px; }
  .search { max-width: none; }
  .who small, .who b { display: none; }
  .who { padding: 4px; }
}
@media (min-width: 768px) { .only-mobile { display: none !important; } }

/* Book 16 requires 44px targets on touch. The compact sizes are for pointers
   that can hit 34px; a coarse pointer gets the full target. */
@media (pointer: coarse) {
  .btn--sm { min-height: 44px; padding: 0 15px; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; }
  .tab { min-height: 46px; }
  .rowlink { padding: 6px 0; }
  .proto a { display: inline-block; padding: 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; }
  .toast { animation: none; }
  .side { transition: none; }
}
