/* MEMBER - single stylesheet. Mobile first, system font stack, no CDN, no @import.
   The brand colour always comes from the injected `--brand` custom property. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5c6470;
  --border: #e3e6eb;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --danger-border: #fda29b;
  --success: #067647;
  --success-bg: #ecfdf3;
  --success-border: #75e0a7;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --text: #e8eaee;
    --muted: #a2a9b6;
    --border: #2a2f3a;
    --shadow: none;
    --danger: #fda29b;
    --danger-bg: #2a1414;
    --danger-border: #7a2620;
    --success: #75e0a7;
    --success-bg: #0f2419;
    --success-border: #1d5c3a;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); }
a:hover { text-decoration: none; }
img { max-width: 100%; height: auto; }
time { color: var(--muted); font-size: .85rem; }

.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 1rem; }
.main { padding-top: 1.25rem; padding-bottom: 2.5rem; }

.skip-link {
  position: absolute; left: -9999px; top: 0; background: var(--surface);
  padding: .5rem .75rem; border-radius: 0 0 var(--radius-sm) 0; z-index: 10;
}
.skip-link:focus { left: 0; }

/* ---------- header / footer ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; min-height: 64px; padding-top: .5rem; padding-bottom: .5rem;
}
/* The brand block keeps its natural width: a logo squeezed by a long nav bar is the one
   thing that must never happen (the image would be distorted, not just scaled). */
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: inherit;
  flex: 0 0 auto; max-width: 100%; }
/* The logo scales with the viewport so it always fits the header frame: 26px on a small
   phone, 40px from tablet up. width:auto keeps the aspect ratio, and the height attribute
   in the markup still reserves space before the image loads (no layout shift). */
.brand-logo { display: block; width: auto; height: clamp(26px, 7.5vw, 40px); flex: 0 0 auto;
  max-width: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
.brand-tagline { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; }
/* The nav never shrinks: if the logo + links do not fit, the container wraps the links onto
   their own row (mobile) instead of squeezing anything. */
.site-nav { display: flex; gap: 1rem; font-size: .95rem; flex: 0 0 auto; align-items: center;
  flex-wrap: wrap; justify-content: flex-end; }
.site-nav a { padding: .35rem .1rem; }
.site-nav a { text-decoration: none; }
.site-nav a:hover { text-decoration: underline; }

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: .875rem;
}
.footer-inner { padding: 1rem; display: flex; flex-wrap: wrap; gap: .25rem 1rem; }
.footer-inner p { margin: 0; }

/* ---------- cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card-narrow { max-width: 560px; margin-inline: auto; }
.center { text-align: center; }
.page-title { font-size: 1.5rem; }
.page-subtitle { color: var(--muted); }
.section-title { font-size: 1.1rem; margin-top: 1.25rem; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.page-head .page-subtitle { margin: 0; }
.breadcrumb { margin-bottom: .75rem; font-size: .9rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.inline-form { display: inline; }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: .6rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: inherit; font-weight: 600; line-height: 1.2;
  text-decoration: none; cursor: pointer; background: transparent; color: var(--text);
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(.93); }
.btn-ghost { border-color: var(--border); background: var(--surface); color: var(--text); }
.btn-ghost:hover { border-color: var(--muted); }
.btn-block { width: 100%; }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: 1rem; }

/* ---------- forms ---------- */
.form { margin-top: 1rem; }
.field { margin-bottom: 1rem; text-align: left; }
.field label { display: block; font-weight: 600; margin-bottom: .3rem; }
.req { color: var(--danger); }
input[type="text"], input[type="email"], input[type="tel"], input[type="search"],
input[type="password"], input[type="date"], select, textarea {
  width: 100%; padding: .6rem .7rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
input:focus, select:focus { border-color: var(--brand); }
input[aria-invalid="true"] { border-color: var(--danger); }
.hint { color: var(--muted); font-size: .8rem; margin: .25rem 0 0; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; }
.check input { width: 1.1rem; height: 1.1rem; margin-top: .2rem; flex: 0 0 auto; }
.field-error { color: var(--danger); font-weight: 600; margin: 0 0 .75rem; }
.field-error[hidden] { display: none; }
.filter-bar { padding: 1rem; }
.filter-grid { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
.filter-actions { display: flex; gap: .5rem; }

/* ---------- alerts ---------- */
.alert { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem 1rem; margin: 0 0 1rem; text-align: left; }
.alert > :last-child { margin-bottom: 0; }
.alert-title { font-weight: 600; }
.alert-list { margin: 0; padding-left: 1.1rem; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert-info { background: var(--surface); border-color: var(--border); color: var(--text); }
@supports (background: color-mix(in srgb, red 10%, white)) {
  .alert-info {
    background: color-mix(in srgb, var(--brand) 8%, var(--surface));
    border-color: color-mix(in srgb, var(--brand) 25%, var(--border));
  }
}

/* ---------- state blocks ---------- */
.state-icon { font-size: 2.25rem; line-height: 1; margin-bottom: .5rem; }
.state-icon-success { color: var(--success); }
.state-icon-error { color: var(--danger); }
.state-icon-info { color: var(--brand); }
.error-code { font-size: 3.5rem; font-weight: 700; color: var(--brand); margin: 0; }
.steps { text-align: left; color: var(--text); padding-left: 1.25rem; margin: 1rem 0; }
.steps li { margin-bottom: .4rem; }
.steps-plain { list-style: disc; }
.cta-secondary { margin-top: 1rem; color: var(--muted); font-size: .9rem; }
.muted { color: var(--muted); }

/* ---------- key/value lists ---------- */
.kv { display: grid; grid-template-columns: 1fr; gap: .15rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .02em; margin-top: .6rem; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.mono { font-family: var(--mono); font-size: .85rem; }
.break { overflow-wrap: anywhere; }

/* ---------- tables ---------- */
.table-wrap { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 760px; }
.table th, .table td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table thead th { background: var(--bg); font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); position: sticky; top: 0; }
.table tbody tr:hover { background: var(--bg); }
.table .empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }
.nowrap { white-space: nowrap; }

/* ---------- pills ---------- */
.pill {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem;
  font-weight: 600; border: 1px solid var(--border); background: var(--bg); color: var(--text);
  white-space: nowrap;
}
.pill-verified { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.pill-pending { background: var(--bg); border-color: var(--border); }
.pill-blocked { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.pill-unsubscribed { color: var(--muted); }
.pill-event { font-family: var(--mono); font-size: .7rem; }

/* ---------- pagination ---------- */
.pagination { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .5rem; }
.page-link {
  display: inline-block; min-width: 2.2rem; text-align: center; padding: .35rem .5rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  color: var(--text); text-decoration: none; font-size: .875rem;
}
.page-link.is-current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.page-link.is-disabled { opacity: .45; pointer-events: none; }
.page-gap { color: var(--muted); padding: 0 .2rem; }
.page-info { color: var(--muted); font-size: .85rem; margin-left: auto; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-item { border-left: 2px solid var(--border); padding: 0 0 .9rem 1rem; margin-left: .35rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-time { display: block; }
.json {
  font-family: var(--mono); font-size: .78rem; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .5rem; margin: .4rem 0 0; white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------- a11y helper ---------- */
.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;
}

/* ---------- >= 640px ---------- */
@media (min-width: 640px) {
  .main { padding-top: 2rem; }
  .card { padding: 1.75rem; }
  .page-title { font-size: 1.85rem; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kv { grid-template-columns: 220px minmax(0, 1fr); }
  .kv dt { margin-top: 0; padding: .3rem 0; border-bottom: 1px solid var(--border); }
  .kv dd { padding: .3rem 0; border-bottom: 1px solid var(--border); }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  /* the nav drops to a second row when it no longer fits next to the logo, instead of
     squeezing the brand */
  .header-inner { min-height: 56px; gap: .35rem .5rem; flex-wrap: wrap; row-gap: .3rem; }
  .site-nav { justify-content: flex-start; gap: .35rem 1rem; font-size: .92rem; }
  .site-nav a { padding: .45rem .1rem; }
  /* the tagline is the widest part of the header and is already in the hero on the
     landing page - dropping it here is what keeps the logo inside the frame */
  .brand-tagline { display: none; }
  .brand-name { font-size: 1rem; }
  .main { padding: 1.25rem 0 2rem; }
  .card { padding: 1.15rem; border-radius: 10px; }
  .page-title { font-size: 1.4rem; }
  /* comfortable touch targets on phones */
  .btn, .btn-sm, button[type="submit"] { min-height: 44px; padding: .7rem 1rem; }
  .btn-sm { padding: .55rem .75rem; }
  .actions { flex-direction: column; }
  .actions .btn { width: 100%; }
  /* iOS never zooms on focus when the field is at least 16px */
  input, select, textarea { font-size: 16px; }
  .table { font-size: .85rem; }
  /* 14 columns with date labels need ~35px each; below that the wrapper scrolls instead of
     mashing the labels together */
  .chart { min-width: 500px; height: 160px; gap: .45rem; }
  .chart-label { font-size: .58rem; }
  .chart-value { font-size: .66rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 420px) {
  /* the logo already carries the brand name, so on a narrow phone it gets the whole row */
  .has-logo .brand-text { display: none; }
  .wrap { padding: 0 .85rem; }
}

@media print {
  .site-header, .site-footer, .pagination, .toolbar, .filter-bar { display: none; }
  .card { box-shadow: none; border-color: #ccc; }
}

/* hidden tracking pixel (noscript fallback) - kept out of a style attribute so the
   nonce based CSP style-src policy never blocks it */
.pixel-noscript { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- admin dashboard (appended; nothing above this line was modified) ---------- */

/* A <button> that must look like the other nav links: no default chrome, inherits the
   nav's font and the brand colour. */
.link-button {
  background: none; border: 0; padding: 0; margin: 0; font: inherit; color: var(--brand);
  cursor: pointer; text-decoration: none;
}
.link-button:hover { text-decoration: underline; }
.site-nav-admin { flex-wrap: wrap; align-items: center; row-gap: .25rem; }

/* ---------- stat cards ---------- */
.stat-grid {
  display: grid; gap: .75rem; margin-bottom: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: .9rem 1rem; display: flex; flex-direction: column;
}
.stat-label { color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.25; }

/* Two management tables side by side on wide screens, stacked on mobile. */
.split { display: grid; gap: 0; grid-template-columns: 1fr; }

/* Small tables must not inherit the 760px min-width of the member list. */
.table-compact { min-width: 0; }

/* ---------- bar chart (pure HTML/CSS, no JS, no style attributes) ----------
   The height of a bar is a decile class rather than an inline `style="height: 42%"`:
   the CSP is nonce based and a nonce covers <style> elements, not style attributes,
   so inline declarations would be dropped by the browser. */
.chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart {
  display: flex; align-items: flex-end; gap: .3rem; height: 180px;
  min-width: 320px; padding-top: .25rem;
}
.chart-col {
  flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: center; gap: .2rem;
}
.chart-value { font-size: .7rem; font-weight: 600; color: var(--muted); }
.chart-label { font-size: .62rem; color: var(--muted); }
.bar {
  width: 100%; max-width: 2.5rem; min-height: 2px; background: var(--brand);
  border-radius: 4px 4px 0 0;
}
.bar-0 { height: 2px; background: var(--border); border-radius: 0; }
.bar-10 { height: 10%; }
.bar-20 { height: 20%; }
.bar-30 { height: 30%; }
.bar-40 { height: 40%; }
.bar-50 { height: 50%; }
.bar-60 { height: 60%; }
.bar-70 { height: 70%; }
.bar-80 { height: 80%; }
.bar-90 { height: 90%; }
.bar-100 { height: 100%; }

/* Small button used by the inline quick actions (member list / dashboard rows). */
.btn-sm { padding: .3rem .55rem; font-size: .8rem; font-weight: 500; }
.actions-start { justify-content: flex-start; }

/* ---------- >= 900px ---------- */
@media (min-width: 900px) {
  .split { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem; }
  .split > .card { margin-bottom: 1.25rem; }
}

