/* ==========================================================================
   Caledonia Leads Group — design system.

   Two audiences, one sheet: a member on a phone in a parking lot, and the
   whole group looking at a projector. So: mobile-first layout, generous type,
   real hierarchy, and numbers set in a serif so the board reads like a local
   business association rather than a SaaS dashboard.

   No external fonts, no CDN, no network requests. Everything ships inline.
   ========================================================================== */

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface-2: #faf9f5;
  --surface-3: #f0eee7;
  --line: #e5e2d9;
  --line-strong: #d6d2c6;

  --ink: #14201c;
  --ink-2: #4c5a53;
  /* Small print sits on --surface-2, not white, so this is tuned against the
     tinted card rather than the page: #74756c measured 4.43:1 there. */
  --ink-3: #6b6c63;

  --brand: #1d4d3f;
  --brand-2: #2a6b57;
  --brand-soft: #e7efeb;
  --accent: #b0703a;
  --accent-soft: #f7eee4;

  --good: #2f7d5d;
  --warn: #b0703a;
  --quiet: #8a8b80;

  --shadow-sm: 0 1px 2px rgba(20, 32, 28, .05), 0 1px 3px rgba(20, 32, 28, .04);
  --shadow-md: 0 2px 4px rgba(20, 32, 28, .04), 0 8px 24px rgba(20, 32, 28, .07);
  --shadow-lg: 0 4px 8px rgba(20, 32, 28, .05), 0 20px 48px rgba(20, 32, 28, .11);

  --r-sm: 8px;
  --r: 13px;
  --r-lg: 20px;

  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;

  --maxw: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1512;
    --surface: #161e1a;
    --surface-2: #1b2520;
    --surface-3: #202b25;
    --line: #2a3630;
    --line-strong: #37453d;

    --ink: #edf2ee;
    --ink-2: #a7b5ad;
    /* Small uppercase labels ride on this; at #73827a they measured 4.21:1 on
       the card background, under the 4.5:1 floor for text this size. */
    --ink-3: #8d9c94;

    --brand: #55a988;
    --brand-2: #6cbc9b;
    --brand-soft: #182c25;
    --accent: #d0995f;
    --accent-soft: #2c2318;

    --good: #55a988;
    --warn: #d0995f;
    --quiet: #73827a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-md: 0 2px 4px rgba(0, 0, 0, .25), 0 8px 24px rgba(0, 0, 0, .3);
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, .3), 0 20px 48px rgba(0, 0, 0, .42);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.011em; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---------- top bar ---------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-in {
  max-width: var(--maxw); margin: 0 auto; padding: 11px 18px;
  display: flex; align-items: center; gap: 12px;
}
.brandmark { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; min-width: 0; }
.brandmark .glyph {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: var(--brand); color: #fff;
  display: grid; place-items: center;
  font: 600 13px/1 var(--sans); letter-spacing: .04em;
}
.brandmark .txt { font: 600 15px/1.2 var(--sans); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brandmark .sub { display: block; font: 400 11px/1.3 var(--sans); color: var(--ink-3); letter-spacing: .02em; }

.topnav { display: none; margin-left: auto; gap: 2px; }
@media (min-width: 720px) { .topnav { display: flex; } }
.topnav a {
  padding: 7px 13px; border-radius: 999px; text-decoration: none;
  color: var(--ink-2); font: 500 14px/1 var(--sans);
}
.topnav a:hover { background: var(--surface-3); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

.whoami {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--ink-2); font: 500 13px/1 var(--sans);
}
@media (min-width: 720px) { .whoami { margin-left: 10px; } }

/* ---------- bottom nav (phones) ---------------------------------------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
@media (min-width: 720px) { .tabbar { display: none; } }
.tabbar a {
  padding: 9px 4px 8px; text-align: center; text-decoration: none;
  color: var(--ink-3); font: 500 10.5px/1.35 var(--sans);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a[aria-current="page"] { color: var(--brand); }
body.has-tabbar { padding-bottom: calc(62px + env(safe-area-inset-bottom)); }
@media (min-width: 720px) { body.has-tabbar { padding-bottom: 0; } }

/* ---------- hero ------------------------------------------------------- */

.hero { padding: 26px 0 6px; }
.hero h1 {
  font: 400 clamp(26px, 5.2vw, 40px)/1.15 var(--serif);
  letter-spacing: -.015em; margin-bottom: 6px;
}
.hero .lede { color: var(--ink-2); font-size: 15.5px; max-width: 60ch; }

.statband {
  display: grid; gap: 10px; margin: 18px 0 6px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 620px) { .statband { grid-template-columns: repeat(4, 1fr); gap: 14px; } }

.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 16px 14px; box-shadow: var(--shadow-sm);
}
.stat .n {
  font: 400 clamp(30px, 7vw, 44px)/1 var(--serif);
  font-variant-numeric: tabular-nums; letter-spacing: -.02em;
  color: var(--ink); display: block;
}
.stat .k {
  margin-top: 7px; font: 500 12px/1.3 var(--sans);
  color: var(--ink-3); letter-spacing: .045em; text-transform: uppercase;
}
.stat.is-accent .n { color: var(--brand); }

/* ---------- cards ------------------------------------------------------ */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  padding: 20px; margin: 16px 0;
}
@media (min-width: 720px) { .card { padding: 26px; } }

.card-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.card-head h2 { font: 400 22px/1.25 var(--serif); letter-spacing: -.01em; }
.card-head .hint { color: var(--ink-3); font-size: 13.5px; }
.card > .sub { color: var(--ink-2); font-size: 14.5px; margin: 4px 0 18px; max-width: 68ch; }

.section-label {
  font: 600 11.5px/1 var(--sans); letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3); margin-bottom: 10px;
}

/* ---------- buttons ---------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 10px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink);
  font: 600 15px/1 var(--sans); cursor: pointer; text-decoration: none;
  transition: background .14s, border-color .14s, transform .06s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--surface-3); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-lg { padding: 15px 26px; font-size: 16.5px; border-radius: 12px; }
.btn-block { display: flex; width: 100%; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-3); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- avatars ---------------------------------------------------- */

.av {
  position: relative; flex: none; border-radius: 11px; overflow: hidden;
  display: grid; place-items: center; color: #fff;
  font: 600 14px/1 var(--sans); letter-spacing: .01em;
  width: 44px; height: 44px; background: var(--brand);
}
/* Sits over the initials and only becomes visible once it has actually loaded. */
.av img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; background: #fff; padding: 4px;
  opacity: 0; transition: opacity .18s ease;
}
.av img.ok { opacity: 1; }
.av-sm { width: 32px; height: 32px; border-radius: 9px; font-size: 11.5px; }
.av-lg { width: 72px; height: 72px; border-radius: 16px; font-size: 22px; }

/* ---------- member grid ------------------------------------------------ */

.mgrid { display: grid; gap: 11px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .mgrid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .mgrid { grid-template-columns: repeat(3, 1fr); } }

.mcard {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 14px;
  transition: border-color .14s, box-shadow .14s, transform .12s;
}
.mcard:hover { border-color: var(--line-strong); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.mcard-top { display: flex; gap: 12px; align-items: center; }
.mcard .nm { font: 600 15.5px/1.25 var(--sans); }
.mcard .pr { font-size: 12.5px; color: var(--ink-3); line-height: 1.35; margin-top: 2px; }
.mcard .numbers {
  display: flex; gap: 14px; margin-top: 13px; padding-top: 12px;
  border-top: 1px solid var(--line);
}
.mcard .numbers div { min-width: 0; }
.mcard .numbers b {
  display: block; font: 400 19px/1 var(--serif);
  font-variant-numeric: tabular-nums; color: var(--ink);
}
.mcard .numbers span {
  display: block; margin-top: 3px; font-size: 10.5px;
  letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3);
}

/* ---------- leaderboard ------------------------------------------------ */

.lb { display: flex; flex-direction: column; gap: 2px; }
.lb-row {
  display: grid; grid-template-columns: 26px 44px 1fr auto;
  align-items: center; gap: 12px; padding: 9px 8px; border-radius: 10px;
  text-decoration: none; color: inherit;
}
.lb-row:hover { background: var(--surface-3); }
.lb-rank { font: 500 13px/1 var(--sans); color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: right; }
.lb-name { font: 600 15px/1.3 var(--sans); min-width: 0; }
.lb-name small { display: block; font: 400 12px/1.3 var(--sans); color: var(--ink-3); }
.lb-bar { position: relative; height: 5px; border-radius: 3px; background: var(--surface-3); margin-top: 6px; overflow: hidden; }
.lb-bar i { position: absolute; inset: 0 auto 0 0; background: var(--brand); border-radius: 3px; }
.lb-val { font: 400 22px/1 var(--serif); font-variant-numeric: tabular-nums; }

.segmented {
  display: inline-flex; background: var(--surface-3); border-radius: 999px;
  padding: 3px; gap: 2px; flex-wrap: wrap;
}
.segmented button {
  border: 0; background: transparent; cursor: pointer; color: var(--ink-2);
  font: 500 13px/1 var(--sans); padding: 8px 13px; border-radius: 999px;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

/* ---------- network graph ---------------------------------------------- */

.net-wrap { position: relative; margin: 4px -6px 0; }
.net-svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.net-edge { fill: none; stroke: var(--brand); stroke-opacity: .18; transition: stroke-opacity .16s, stroke-width .16s; }
.net-edge.hot { stroke-opacity: .85; }
.net-edge.dim { stroke-opacity: .05; }
.net-node { cursor: pointer; }
.net-node circle { transition: r .16s, stroke-width .16s; }
.net-node text { font: 500 10px/1 var(--sans); fill: var(--ink-2); }
.net-node.dim { opacity: .3; }
.net-empty {
  text-align: center; padding: 34px 20px; color: var(--ink-3);
  border: 1px dashed var(--line-strong); border-radius: var(--r); font-size: 14.5px;
}

/* ---------- gap map ---------------------------------------------------- */

.gap-scroll { overflow-x: auto; margin: 0 -6px; padding: 0 6px 6px; }
.gap-tbl { border-collapse: separate; border-spacing: 3px; }
.gap-tbl th {
  font: 500 11px/1.2 var(--sans); color: var(--ink-3); font-weight: 500;
  text-align: right; padding-right: 6px; white-space: nowrap;
}
.gap-tbl thead th { text-align: center; padding: 0 0 4px; }
.gap-tbl thead th span {
  display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg);
  font-size: 10.5px; max-height: 84px; overflow: hidden;
}
.gap-cell { width: 22px; height: 22px; border-radius: 5px; background: var(--surface-3); }
.gap-cell.met { background: var(--brand); }
.gap-cell.self { background: transparent; border: 1px dashed var(--line-strong); }
.gap-legend { display: flex; gap: 16px; align-items: center; margin-top: 12px; font-size: 13px; color: var(--ink-2); flex-wrap: wrap; }
.gap-legend i { display: inline-block; width: 13px; height: 13px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

/* ---------- feed ------------------------------------------------------- */

.feed { display: flex; flex-direction: column; }
.feed-item {
  display: flex; gap: 12px; padding: 12px 0;
  border-top: 1px solid var(--line); align-items: flex-start;
}
.feed-item:first-child { border-top: 0; }
.feed-ico {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  display: grid; place-items: center; font-size: 14px;
  background: var(--surface-3);
}
.feed-txt { font-size: 14.5px; line-height: 1.5; min-width: 0; }
.feed-txt b { font-weight: 600; }
.feed-when { display: block; margin-top: 2px; font-size: 12px; color: var(--ink-3); }

/* ---------- log flow --------------------------------------------------- */

.tiles { display: grid; gap: 11px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .tiles { grid-template-columns: repeat(2, 1fr); } }

.tile {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 17px 18px; cursor: pointer; color: inherit;
  transition: border-color .14s, box-shadow .14s, transform .1s;
  font-family: var(--sans);
}
.tile:hover { border-color: var(--brand); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.tile .emoji { font-size: 25px; line-height: 1; flex: none; }
.tile .t { font: 600 16.5px/1.25 var(--sans); }
.tile .d { font-size: 13.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.45; }

.picker { display: grid; gap: 9px; grid-template-columns: repeat(2, 1fr); }
@media (min-width: 620px) { .picker { grid-template-columns: repeat(3, 1fr); } }
.pick {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-sm);
  padding: 11px; cursor: pointer; color: inherit; font-family: var(--sans);
  transition: border-color .12s, background .12s;
  min-height: 62px;
}
.pick:hover { border-color: var(--line-strong); background: var(--surface-2); }
.pick[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.pick .nm { font: 600 13.5px/1.25 var(--sans); min-width: 0; }
.pick .pr { font-size: 11px; color: var(--ink-3); line-height: 1.3; margin-top: 2px; }

label.field { display: block; margin: 16px 0 0; }
label.field > span {
  display: block; font: 600 13px/1.3 var(--sans); color: var(--ink-2); margin-bottom: 6px;
}
label.field > span em { font-style: normal; font-weight: 400; color: var(--ink-3); }
input[type="text"], input[type="email"], input[type="tel"], input[type="date"],
input[type="password"], input[type="url"], textarea, select {
  width: 100%; padding: 12px 13px; border-radius: 10px;
  border: 1.5px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font: 400 16px/1.4 var(--sans);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 16%, transparent);
}

.steps { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.steps i {
  height: 4px; flex: 1; border-radius: 2px; background: var(--surface-3);
  transition: background .2s;
}
.steps i.on { background: var(--brand); }

.done-mark {
  width: 62px; height: 62px; border-radius: 50%; margin: 0 auto 18px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 30px;
}

/* ---------- misc ------------------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font: 500 12px/1.5 var(--sans);
  background: var(--surface-3); color: var(--ink-2);
}
.pill.good { background: var(--brand-soft); color: var(--brand); }
.pill.warn { background: var(--accent-soft); color: var(--accent); }

.notice {
  display: flex; gap: 11px; align-items: flex-start;
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--ink); border-radius: var(--r); padding: 13px 15px; font-size: 14px; line-height: 1.5;
  margin: 14px 0;
}
.notice.plain { background: var(--surface-2); border-color: var(--line); }

.empty { color: var(--ink-3); font-size: 14.5px; padding: 14px 0; }

.footer {
  margin: 40px 0 0; padding: 22px 0 30px; border-top: 1px solid var(--line);
  color: var(--ink-3); font-size: 13px; display: flex; gap: 14px;
  flex-wrap: wrap; align-items: center; justify-content: space-between;
}
.footer a { color: var(--ink-2); text-decoration: none; }
.footer a:hover { color: var(--brand); text-decoration: underline; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: var(--r);
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* Tables (admin, meetings) */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font: 600 11.5px/1 var(--sans); letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-3); padding: 0 10px 9px; white-space: nowrap;
}
.tbl td { padding: 11px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .num { text-align: center; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
