/* Affiliate NGO – design language.
   Reduced and calm: white canvas, light-grey sidebar, hairline rules instead of boxes,
   the system typeface (SF on Apple devices, Inter elsewhere), navy for the brand and
   primary actions. No rounded containers, no chips, no decoration. Corners are square;
   only form controls get a 4px radius so they read as controls. */

@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-wght-normal.8e433c0592f7.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --bg-side: #eeeeee;
  --bg-hover: #f6f6f7;
  --line: #e4e4e7;
  --line-strong: #c9ccd3;
  --ink: #15191f;
  --ink-2: #4b5160;
  --muted: #6b7180;
  --brand: #1c3258;
  --on-brand: #ffffff;
  --accent: #30599d;
  --positive: #63a375;
  --positive-ink: #3d7a4f;
  --negative: #d76262;
  --negative-ink: #b03f3c;
  --warning-ink: #96620f;
  --success-bg: #eff6f1;
  --success-line: #cfe3d5;
  --error-bg: #fbefef;
  --error-line: #f0cfce;
  --warning-bg: #fbf5ea;
  --warning-line: #ecdcbc;
  --focus: rgba(48, 89, 157, 0.2);
  --radius: 4px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); color: var(--ink); text-wrap: balance; }
h1 { font-size: 30px; line-height: 36px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 15px; line-height: 22px; font-weight: 600; }
p { margin: 0 0 12px; }
small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Shell ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; background: linear-gradient(to right, var(--bg-side) 231px, var(--line) 231px, var(--line) 232px, var(--bg) 232px); }
.sidebar {
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 24px 0 20px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.wordmark {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 600; letter-spacing: -0.015em;
  color: var(--brand); padding: 0 24px;
}
.wordmark:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; margin-top: 32px; }
.nav a {
  padding: 8px 24px; color: var(--ink-2); font-size: 14px; font-weight: 500;
}
.nav a:hover { color: var(--ink); text-decoration: none; background: rgba(0, 0, 0, 0.03); }
.nav a.active { color: var(--ink); background: var(--bg); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 0 24px; display: flex; flex-direction: column; gap: 16px; font-size: 13px; color: var(--ink-2); }
.sidebar-foot .nav { margin: 0 -24px; }
.switch label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.switch select { background: var(--bg); font-size: 14px; min-height: 34px; padding: 6px 8px; }
.user { border-top: 1px solid var(--line-strong); padding-top: 16px; line-height: 1.4; }
.user strong { display: block; color: var(--ink); font-weight: 500; }
.user span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user .links { display: flex; gap: 16px; margin-top: 8px; }
.linkbutton { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }
.linkbutton:hover { text-decoration: underline; }

.main { min-width: 0; padding: 40px 48px 80px; max-width: 1240px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 32px; }
.page-head .lead { color: var(--muted); margin: 6px 0 0; max-width: 640px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.back { display: inline-block; font-size: 14px; margin-bottom: 8px; color: var(--muted); }
.mobilebar { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; background: var(--bg); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform 0.2s ease; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.3); }
  .mobilebar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 40; }
  .mobilebar .wordmark { padding: 0; }
  .main { padding: 24px 16px 64px; }
  h1 { font-size: 26px; line-height: 32px; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Sections ---------- */
.section { margin-bottom: 48px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.section-head .meta { color: var(--muted); font-size: 13px; }
.section-body { padding-top: 16px; }
.columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 48px; }
.columns-wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
@media (max-width: 1000px) { .columns, .columns-wide { grid-template-columns: 1fr; gap: 0; } }

/* ---------- Key figures ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); border-bottom: 1px solid var(--line); }
.stat { padding: 20px 24px 20px 0; }
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--line); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-size: 28px; line-height: 34px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; margin-top: 4px; white-space: nowrap; }
.stat-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.trend { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 6px; }
.trend.up { color: var(--positive-ink); }
.trend.down { color: var(--negative-ink); }
@media (max-width: 700px) {
  .stat + .stat { padding-left: 0; border-left: 0; }
  .stat { border-top: 1px solid var(--line); }
}

/* ---------- Charts ---------- */
.chart { padding-top: 24px; }
.chart svg { width: 100%; height: 160px; display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .area { fill: var(--accent); fill-opacity: 0.07; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; }
.chart .dot { fill: transparent; }
.chart .dot:hover { fill: var(--accent); }
.chart-axis { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 8px; }
.split-bar { display: flex; height: 10px; background: var(--line); margin: 20px 0 16px; }
.split-bar span { display: block; height: 100%; }
.split-bar span + span { margin-left: 2px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 24px; }
.legend li { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); }
.legend li span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--swatch); }
.legend strong { font-size: 15px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }

/* ---------- Tables & lists ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 16px 12px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; font-weight: 500; color: var(--muted); padding-top: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:hover td { background: var(--bg-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td .sub { display: block; color: var(--muted); font-size: 13px; }
.row-link { color: var(--ink); font-weight: 500; }
tfoot td { font-weight: 600; border-bottom: 0; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: baseline; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list .grow { flex: 1; min-width: 0; }
.list .sub { display: block; color: var(--muted); font-size: 13px; }
.list .value { font-variant-numeric: tabular-nums; font-weight: 500; white-space: nowrap; }
dl.kv { display: grid; grid-template-columns: 180px minmax(0, 1fr); margin: 0; }
dl.kv dt, dl.kv dd { padding: 10px 0; border-bottom: 1px solid var(--line); margin: 0; }
dl.kv dt { color: var(--muted); }
.summary { display: flex; flex-direction: column; }
.summary div { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.summary div span:last-child { font-variant-numeric: tabular-nums; }
.summary .total { font-weight: 600; border-bottom: 0; }

/* ---------- Status ---------- */
.st { white-space: nowrap; }
.st-plain { color: var(--ink); }
.st-negative { color: var(--negative-ink); }
.st-warning { color: var(--warning-ink); }
.st-accent { color: var(--accent); }
.st-muted { color: var(--muted); }

/* ---------- Notices ---------- */
.notices { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.notice { padding: 12px 16px; background: var(--bg-hover); border: 1px solid var(--line); font-size: 14px; }
.notice p { margin: 0; }
.notice-success { background: var(--success-bg); border-color: var(--success-line); }
.notice-error { background: var(--error-bg); border-color: var(--error-line); }
.notice-warning { background: var(--warning-bg); border-color: var(--warning-line); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 16px;
  border: 1px solid var(--brand); border-radius: var(--radius); background: var(--brand); color: var(--on-brand);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--on-brand); text-decoration: none; }
.btn-secondary { background: var(--bg); border-color: var(--line-strong); color: var(--ink); }
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--line-strong); color: var(--ink); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--accent); padding: 0 8px; }
.btn-quiet:hover { background: var(--bg-hover); border-color: transparent; color: var(--accent); }
.btn-danger { background: var(--bg); border-color: var(--line-strong); color: var(--negative-ink); }
.btn-danger:hover { background: var(--error-bg); border-color: var(--error-line); color: var(--negative-ink); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; height: 42px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
form.inline { display: inline; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 20px; max-width: 600px; }
.form-wide { max-width: none; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 13px; font-weight: 500; color: var(--ink); }
.field .optional { color: var(--muted); font-weight: 400; }
.help { color: var(--muted); font-size: 13px; }
.errorlist { list-style: none; padding: 0; margin: 0; color: var(--negative-ink); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 38px; padding: 8px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 15px;
}
textarea { min-height: 100px; resize: vertical; }
input[type=file] { font: inherit; font-size: 14px; }
input[type=color] { width: 56px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg); cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); margin: 0; flex: none; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; cursor: pointer; }
.check input { margin-top: 3px; }
.fieldset { border-top: 1px solid var(--line); padding-top: 24px; display: flex; flex-direction: column; gap: 20px; }
.fieldset > p { color: var(--muted); margin: -12px 0 0; font-size: 14px; }
.form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 24px; }
.filters input, .filters select { width: auto; min-width: 180px; min-height: 34px; padding: 6px 10px; font-size: 14px; }
.current-image { display: flex; align-items: center; gap: 16px; }
.current-image img { height: 48px; width: auto; border: 1px solid var(--line); background: var(--bg); padding: 4px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); border: 1px solid var(--line-strong); border-radius: var(--radius); }
.option { display: flex; gap: 12px; padding: 16px; cursor: pointer; }
.option + .option { border-left: 1px solid var(--line-strong); }
.option input { margin-top: 3px; }
.option h3 { margin-bottom: 4px; }
.option p { margin: 0; color: var(--ink-2); font-size: 14px; }
@media (max-width: 700px) { .option + .option { border-left: 0; border-top: 1px solid var(--line-strong); } }

/* ---------- Tabs, empty states, checklist ---------- */
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 32px; }
.tabs a { padding: 0 0 10px; color: var(--muted); font-size: 14px; font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--ink); }
.empty { padding: 40px 0; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.empty p { max-width: 460px; margin: 0 0 16px; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li a { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.checklist li a:hover { text-decoration: none; background: var(--bg-hover); }
.checklist .box { width: 16px; height: 16px; border: 1.5px solid var(--line-strong); flex: none; display: grid; place-items: center; font-size: 11px; line-height: 1; }
.checklist .done { color: var(--muted); }
.checklist .done .box { background: var(--positive); border-color: var(--positive); color: var(--on-brand); }
.checklist .go { margin-left: auto; color: var(--accent); font-size: 14px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 24px; }
.steps li { counter-increment: step; color: var(--ink-2); font-size: 14px; }
.steps li::before { content: counter(step); display: block; font-family: var(--font-display); font-size: 22px; font-weight: 600; color: var(--brand); margin-bottom: 4px; }

/* ---------- Link box, QR ---------- */
.linkbox { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 32px; align-items: center; padding: 24px 0; border-bottom: 1px solid var(--line); }
.linkbox input { font-family: var(--mono); font-size: 14px; margin-bottom: 12px; }
.qr { width: 132px; height: 132px; border: 1px solid var(--line); padding: 6px; background: var(--bg); }
.qr img { width: 100%; height: 100%; display: block; }
@media (max-width: 700px) { .linkbox { grid-template-columns: 1fr; } }

/* ---------- Auth & landing ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; background: var(--bg-side); }
.auth-box { width: 100%; max-width: 400px; }
.auth-box .wordmark { display: block; text-align: center; padding: 0; margin-bottom: 24px; font-size: 20px; }
.auth-card { background: var(--bg); border: 1px solid var(--line); padding: 32px; }
.auth-card h1 { font-size: 24px; line-height: 30px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); margin-bottom: 24px; }
.auth-foot { text-align: center; font-size: 14px; color: var(--muted); margin-top: 16px; }
.landing-nav { max-width: 1080px; margin: 0 auto; padding: 24px; display: flex; justify-content: space-between; align-items: center; }
.landing-nav .wordmark { padding: 0; }
.landing-hero { max-width: 1080px; margin: 0 auto; padding: 96px 24px 72px; }
.landing-hero h1 { font-size: 56px; line-height: 1.05; letter-spacing: -0.035em; max-width: 820px; margin-bottom: 20px; }
.landing-hero p { font-size: 19px; color: var(--ink-2); max-width: 600px; margin-bottom: 32px; }
.landing-points { max-width: 1080px; margin: 0 auto; padding: 0 24px 96px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 32px; }
.landing-points div { border-top: 1px solid var(--line); padding-top: 16px; }
.landing-points p { color: var(--ink-2); margin: 4px 0 0; font-size: 15px; }
@media (max-width: 700px) { .landing-hero { padding-top: 48px; } .landing-hero h1 { font-size: 38px; } }

/* ---------- Printable documents ---------- */
.document-wrap { background: var(--bg-side); min-height: 100vh; padding: 32px 16px; }
.document { background: var(--bg); color: var(--ink); max-width: 820px; margin: 0 auto; padding: 56px; border: 1px solid var(--line); }
.document h1 { font-size: 26px; color: var(--brand); }
.document-toolbar { max-width: 820px; margin: 0 auto 16px; display: flex; justify-content: flex-end; }
@media print {
  .document-wrap { background: var(--bg); padding: 0; }
  .document { border: 0; padding: 0; max-width: none; }
  .no-print { display: none !important; }
}
