/* Flock: design tokens carried over from the mockups. No external fonts or CDNs, so nothing leaves the browser. */
:root {
  --bg: #F4F5F2;
  --card: #FFFFFF;
  --ink: #17201F;
  --ink-2: #3F4946;
  --muted: #5A6461;
  --line: #E1E4DE;
  --line-soft: #EEF0EC;
  --side: #14302E;
  --side-hover: #22504B;
  --side-text: #D3E2DE;
  --brand: #1F6E62;
  --brand-dark: #134B43;
  --amber: #F2B45A;
  --warn: #A14A08;
  --warn-bg: #FDF1E2;
  --warn-ink: #6E3A07;
  --ts-bg: #E3ECFB;
  --ts-ink: #1E3F8A;
  --ya-bg: #EFE7F8;
  --ya-ink: #55307F;
  --ok-bg: #DDEBE7;
  --ok-ink: #1F4F49;
  --danger: #A12A1F;
  --radius: 16px;
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-head: "Avenir Next", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.45; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 34px; line-height: 1.1; letter-spacing: -0.02em; }
h2 { font-size: 19px; }
a { color: var(--brand); }
a:hover { color: var(--brand-dark); }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.wrap { overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: none; position: sticky; top: 0; height: 100vh; background: var(--side); color: var(--side-text);
  padding: 28px 16px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 26px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--amber); color: var(--side);
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px; }
.brand-name { font-family: var(--font-head); font-size: 20px; font-weight: 700; color: #fff; line-height: 1.1; }
.brand-sub { font-size: 12px; color: #A9C2BD; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 12px; min-height: 44px; border-radius: 10px;
  color: var(--side-text); text-decoration: none; font-weight: 500; font-size: 15px; }
.nav-link:hover { background: var(--side-hover); color: #fff; }
.nav-link.is-active { background: var(--side-hover); color: #fff; font-weight: 600; }
.nav-link svg { flex: none; }
.nav-badge { margin-left: auto; flex: none; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px; }
.nav-spacer { flex: 1; min-height: 16px; }
.signed-in { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; padding: 14px 12px 0; border-top: 1px solid #2A4B47; color: var(--side-text); }
.signed-in .muted { color: inherit; opacity: 0.75; }
.signed-in + .signout { border-top: 0; padding-top: 4px; }
.signout { margin-top: 4px; padding-top: 14px; border-top: 1px solid #2A4B47; }
.signout button { width: 100%; text-align: left; background: none; border: 0; cursor: pointer; font: inherit; }

.main { flex: 1; min-width: 0; padding: 36px clamp(16px, 4vw, 48px) 56px; }
.container { max-width: 1120px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head .eyebrow { font-size: 14px; color: var(--muted); font-weight: 600; }
.page-head .lede { font-size: 16px; color: var(--ink-2); margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- buttons, badges ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px; border-radius: 10px;
  border: 1px solid #C9CFC8; background: #fff; color: var(--ink); font: 600 15px var(--font); text-decoration: none; cursor: pointer; }
.btn:hover { background: #F6F7F4; color: var(--ink); }
.btn--primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: #7E1F17; color: #fff; }
.btn--small { min-height: 40px; padding: 0 14px; font-size: 14px; }
.icon-btn { width: 36px; height: 36px; flex: none; border-radius: 8px; border: 1px solid transparent; background: none; color: var(--muted);
  font-size: 20px; line-height: 1; cursor: pointer; }
.icon-btn:hover { background: var(--line-soft); color: var(--danger); }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  background: var(--line-soft); color: var(--ink-2); }
.badge--ts { background: var(--ts-bg); color: var(--ts-ink); }
.badge--ya { background: var(--ya-bg); color: var(--ya-ink); }
.badge--warn { background: var(--warn-bg); color: var(--warn-ink); }
.badge--ok { background: var(--ok-bg); color: var(--ok-ink); }
/* A <select> styled like a badge pill, so changing someone's group reads the same as the static badge did. */
.group-select { display: inline-block; width: auto; min-height: 0; font-size: 12px; font-weight: 700;
  padding: 4px 10px; border: none; border-radius: 999px; cursor: pointer; }
.group-select.badge--ts { background: var(--ts-bg); color: var(--ts-ink); }
.group-select.badge--ya { background: var(--ya-bg); color: var(--ya-ink); }
.tag { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 6px; background: var(--ok-bg); color: var(--ok-ink); white-space: nowrap; }

.alert { padding: 14px 16px; border-radius: 12px; font-weight: 600; font-size: 15px; }
.alert--ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert--warn { background: var(--warn-bg); color: var(--warn-ink); }
.alert--error { background: #FBE4E1; color: #7E1F17; }

/* ---------- cards & lists ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.grid-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.stat-label { font-size: 14px; color: var(--muted); font-weight: 600; }
.stat-value { font-family: var(--font-head); font-size: 34px; font-weight: 700; line-height: 1.1; }
.stat-sub { font-size: 13px; color: var(--muted); }
.stat--ts .stat-value { color: var(--ts-ink); }
.stat--ya .stat-value { color: var(--ya-ink); }
.stat--warn .stat-value { color: var(--warn); }
.two-up { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; align-items: start; }
.profile-cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.profile-cols > .col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.profile-cols > .col--side { flex: 1 1 300px; }
.profile-cols > .col--main { flex: 2 1 480px; }

.row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.row:first-of-type { border-top: 0; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row-title { font-weight: 700; font-size: 16px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
a.row-title:hover { text-decoration: underline; }
.row-sub { font-size: 14px; color: var(--muted); }
.row-sub.warn { color: var(--warn); font-weight: 600; }
.date-chip { width: 52px; flex: none; text-align: center; border-radius: 10px; background: var(--warn-bg); padding: 6px 0; }
.date-chip .m { font-size: 11px; font-weight: 700; color: #8A4A0B; letter-spacing: 0.06em; text-transform: uppercase; }
.date-chip .d { font-family: var(--font-head); font-size: 20px; font-weight: 700; color: var(--warn-ink); line-height: 1.2; }
.empty { color: var(--muted); font-size: 15px; padding: 6px 0; }

.avatar { width: 40px; height: 40px; flex: none; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: var(--ink); }
.avatar--lg { width: 88px; height: 88px; font-family: var(--font-head); font-size: 32px; color: var(--side); }
.av-0 { background: #F6E3CC; } .av-1 { background: #DDEBE7; } .av-2 { background: #E3ECFB; }
.av-3 { background: #EFE7F8; } .av-4 { background: #F8E1E7; }

.activity { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; padding: 12px 0; border-top: 1px solid var(--line-soft); }
.activity:first-of-type { border-top: 0; }
.activity .when { font-size: 13px; color: var(--muted); width: 96px; flex: none; }
.activity .what { flex: 1 1 280px; font-size: 15px; }

/* ---------- members table ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.toolbar form { flex: 1 1 280px; display: flex; gap: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid #C9CFC8;
  background: #fff; color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; }
.chip:hover { background: #F6F7F4; color: var(--ink); }
.chip.is-on { background: var(--side); border-color: var(--side); color: #fff; }
.filter-groups { display: flex; flex-direction: column; gap: 10px; }
.filter-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.filter-group-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.03em; min-width: 80px; }
.bulk-bar { margin-bottom: 12px; }
.bulk-bar select { flex: none; }
th.checkbox-col, td.checkbox-col { width: 1%; }
.table-wrap { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; min-width: 860px; border-collapse: collapse; font-size: 15px; }
th { text-align: left; color: var(--muted); font-size: 13px; letter-spacing: 0.02em; padding: 16px 12px; font-weight: 700; }
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--ink); text-decoration: underline; }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--ink); }
td { padding: 14px 12px; border-top: 1px solid var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
.name-cell { display: flex; align-items: center; gap: 12px; }
.name-cell .avatar { width: 38px; height: 38px; font-size: 13px; }
.name-cell a { font-weight: 700; color: var(--ink); text-decoration: none; }
.name-cell a:hover { text-decoration: underline; }
.due { color: var(--warn); font-weight: 600; }

/* ---------- profile ---------- */
.hero { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px; display: flex; flex-wrap: wrap; gap: 24px; align-items: center; }
.hero-main { flex: 1 1 320px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hero-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.hero h1 { font-size: 32px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 15px; color: var(--ink-2); }
.crumbs { font-size: 14px; color: var(--muted); }
.crumbs a { font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 2px; }
.field .k { font-size: 13px; color: var(--muted); font-weight: 600; }
.sub-card { display: flex; align-items: center; gap: 10px; padding: 14px; border-radius: 12px; background: #F6F7F4; }
.sub-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.milestone { display: flex; align-items: center; gap: 12px; }
.milestone .tick { width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--ok-bg); color: var(--ok-ink); display: flex; align-items: center; justify-content: center; }
.milestone .grow { flex: 1; display: flex; flex-direction: column; }

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 16px; }
.tl-rail { display: flex; flex-direction: column; align-items: center; width: 16px; flex: none; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; margin-top: 5px; background: #9AA39F; border: 3px solid #fff; box-shadow: 0 0 0 2px #9AA39F; }
.tl-item.is-now .tl-dot { background: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.tl-line { width: 2px; flex: 1; background: var(--line); min-height: 24px; }
.tl-item:last-child .tl-line { display: none; }
.tl-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-bottom: 22px; }
.tl-item:last-child .tl-body { padding-bottom: 4px; }
.tl-years { font-size: 13px; font-weight: 700; color: var(--muted); }
.tl-item.is-now .tl-years { color: var(--brand); }
.tl-head { display: flex; align-items: flex-start; gap: 8px; }
.tl-head .grow { flex: 1; min-width: 0; }

.checkin { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 12px 0; border-top: 1px solid var(--line-soft); align-items: flex-start; }
.checkin:first-of-type { border-top: 0; }
.checkin .date { font-size: 14px; font-weight: 700; width: 110px; flex: none; }
.checkin .text { flex: 1 1 240px; min-width: 0; color: var(--ink-2); }
.note { display: flex; gap: 8px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: #F6F7F4; }
.note .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.note .when { font-size: 13px; color: var(--muted); font-weight: 600; }
.lock { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.consent { border: 1px dashed #C9CFC8; border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--ink-2); }
.consent strong { color: var(--ink); }

/* ---------- forms ---------- */
label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
input, select, textarea { width: 100%; min-height: 44px; padding: 10px 14px; border-radius: 10px; border: 1px solid #C9CFC8; background: #fff;
  font: 500 16px var(--font); color: var(--ink); }
textarea { resize: vertical; min-height: 88px; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); outline: 3px solid rgba(31, 110, 98, 0.25); }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .span-all { grid-column: 1 / -1; }
.f { display: flex; flex-direction: column; gap: 6px; }
.f .hint { font-size: 13px; color: var(--muted); font-weight: 400; }
.f .err { font-size: 13px; color: var(--danger); font-weight: 600; }
details.add { border: 1px dashed #C9CFC8; border-radius: 12px; padding: 0; }
details.add > summary { list-style: none; cursor: pointer; padding: 12px 16px; font-weight: 700; font-size: 14px; color: var(--brand); border-radius: 12px; min-height: 44px; display: flex; align-items: center; }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { border-bottom: 1px dashed #C9CFC8; border-radius: 12px 12px 0 0; }
details.add > .form { padding: 16px; }
details.danger { border: 1px solid #E8C5C0; border-radius: 12px; }
details.danger > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; color: var(--danger); font-size: 14px; min-height: 44px; display: flex; align-items: center; }
details.danger > .form { padding: 0 16px 16px; }

[hidden] { display: none !important; }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 32px; display: flex; flex-direction: column; gap: 20px; }
.auth-card .brand { padding: 0; }
.auth-card .brand-name { color: var(--ink); }
.auth-card .brand-sub { color: var(--muted); }
.auth-stack { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; max-width: 400px; }
.auth-stack .auth-card { max-width: none; }
.auth-card > form { display: flex; flex-direction: column; gap: 16px; }
.auth-card .btn { width: 100%; justify-content: center; }
.link-button { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); text-decoration: underline; cursor: pointer; }
.link-button:disabled { opacity: 0.6; cursor: default; }

/* ---------- small screens: sidebar becomes a bottom bar ---------- */
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 10; top: auto; left: 0; right: 0; bottom: 0; width: auto; height: auto; flex-direction: row;
    justify-content: space-around; align-items: stretch; gap: 0; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .brand, .nav-spacer, .signout, .signed-in { display: none; }
  .nav-link { flex: 1; min-width: 0; flex-direction: column; justify-content: center; gap: 3px; padding: 6px 2px; font-size: 11px; text-align: center; }
  .nav-link.is-active { background: var(--side-hover); }
  .main { padding: 20px 16px 96px; }
  h1 { font-size: 28px; }
  .hero { padding: 20px; }
  .avatar--lg { width: 64px; height: 64px; font-size: 24px; }
  .hero h1 { font-size: 26px; }
}

/* Inline "Edit" on an education stage or a note: a quieter version of the dashed add box. */
details.add.edit { border: none; margin-top: 4px; }
details.add.edit > summary { min-height: 32px; padding: 4px 0; font-size: 13px; }
details.add.edit[open] { border: 1px dashed #C9CFC8; }
details.add.edit[open] > summary { padding: 4px 16px; }

/* Messages from a background save float at the bottom of the screen, so they're seen wherever you've scrolled to. */
#flash.is-toast { position: fixed; right: 16px; bottom: 16px; left: 16px; max-width: 420px; margin-left: auto; z-index: 50; }
#flash.is-toast .alert { box-shadow: 0 6px 24px rgba(0, 0, 0, .15); }

/* ---------- leaders page ---------- */
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { width: auto; min-height: 40px; }
.invite-text { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
    padding: 14px; font-family: inherit; font-size: 14px; user-select: all; }

/* ---------- confidential notes ---------- */
.check-line { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check-line input { width: auto; margin: 0; }
.badge--private { background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; padding: 2px 8px; margin-left: 6px; }
form.handover { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }

/* ---------- scheduled check-ins ---------- */
.scheduled { display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; margin-bottom: 10px;
    border: 1px solid var(--line, #e5e5e5); border-radius: 10px; }
.scheduled .grow { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.scheduled .grow > div { flex-basis: 100%; }
.scheduled.is-overdue { border-color: var(--warn-ink); }

/* "Just this date" / "This and the later dates" on a repeating event */
fieldset.scope { border: 0; padding: 0; margin: 4px 0 14px; display: grid; gap: 8px; }
fieldset.scope legend { font-size: 13px; font-weight: 600; margin-bottom: 6px; padding: 0; }

/* ---------- the register (built for a phone) ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.register-bar { position: sticky; top: 0; z-index: 5; display: flex; gap: 18px; align-items: baseline; padding: 12px 14px;
    margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.register-bar strong { font-size: 20px; }
.register-search { width: 100%; font-size: 16px; padding: 12px 14px; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 10px; }
.register-list { list-style: none; margin: 0; padding: 0; }
.register-list > li + li { border-top: 1px solid var(--line-soft); }
.register-list form { margin: 0; }
.register-person { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 8px 4px;
    background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.register-person .grow, .register-visitor .grow { flex: 1; display: flex; flex-direction: column; }
.register-person .name { font-weight: 600; }
.register-person .tick { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); display: grid;
    place-items: center; color: transparent; font-weight: 700; flex: none; }
.register-person.is-present .tick { background: var(--ok-ink); border-color: var(--ok-ink); color: #fff; }
.register-person.is-pending { opacity: .6; }
.register-visitor { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.register-add { margin-top: 12px; }
details.card > summary { cursor: pointer; font-weight: 600; }

/* ---------- event report ---------- */
dl.report { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
dl.report dt { font-weight: 600; color: var(--muted); }
dl.report dd { margin: 0; }
@media (max-width: 600px) { dl.report { grid-template-columns: 1fr; } dl.report dd { margin-bottom: 8px; } }

/* ---------- action items ---------- */
.action-row form { margin: 0; }
.action-tick { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--line); background: none;
    color: transparent; font-weight: 700; cursor: pointer; flex: none; }
.action-tick:hover { border-color: var(--ok-ink); color: var(--ok-ink); }
.action-tick.is-done { background: var(--ok-ink); border-color: var(--ok-ink); color: #fff; }
.action-row.is-done .row-title { text-decoration: line-through; color: var(--muted); }
