:root {
  /* --- Brighter Arc brand: chrome/identity only, never status --- */
  --ink: #122241;       /* Navy */
  --accent: #2452AF;    /* Blue -- primary interactive: links, buttons, focus */
  --bg: #EFF8FA;
  --panel: #ffffff;
  --border: #dce7ea;
  --accent-soft: #e7edf8;
  /* Teal/Green/Yellow are logo + decorative/illustrative use only, per the
     visual identity spec -- they fail text contrast (checked below) and
     must never color-code a result, flag, or suggestion. Sky is a usable
     secondary accent but untested here; don't use any of these four for
     body text or small meaning-bearing UI without a fresh contrast check. */
  --brand-sky: #4C80AC;
  --brand-teal: #2CA9A3;
  --brand-green: #8FB37A;
  --brand-yellow: #F4C147;

  --ink-soft: #4a5560;

  /* --- Existing status colors: audited, deliberately left unchanged.
     Do not repoint these at brand palette values even where a hue happens
     to be close (e.g. --review vs. brand teal) -- any coincidence there is
     incidental, not a coded relationship. --attention's contrast against
     its own tag background is already marginal (~3.2:1, pre-existing, not
     introduced by this pass) -- flagged separately, not fixed here. --- */
  --positive: #4f7a5b;
  --positive-soft: #e7efe8;
  --attention: #a8783a;
  --attention-soft: #f3e9d9;
  --negative: #9c4c40;
  --negative-soft: #f4e6e3;
  /* Same value as before this pass, on purpose -- kept as its own variable
     so a brand-color change to --accent (nav/buttons/links) doesn't
     silently recolor the "worth reviewing" suggestion card, which must
     stay non-directional per the visual identity spec's status-color
     guardrail. Don't merge this back into --accent. */
  --review: #2b6e6e;
  --review-soft: #e4eeec;

  --display: "Sora", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sans: "Inter", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; color: var(--ink); margin: 0 0 0.4em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--accent);
  border-bottom: 1px solid var(--accent);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.topbar .brand { display: flex; align-items: center; gap: 12px; font-family: var(--display); font-size: 1.55rem; color: #ffffff; }
.topbar .brand img { display: block; flex-shrink: 0; }
.topbar .brand .accent-arc { color: #ffffff; }
.topbar nav a { margin-right: 18px; color: rgba(255, 255, 255, 0.78); font-size: 0.92rem; }
.topbar nav a:hover { color: #ffffff; }
.topbar .logout-form { margin-left: auto; }
.topbar .link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: rgba(255, 255, 255, 0.78); font-size: 0.92rem; font-family: inherit;
}
.topbar .link-btn:hover { color: #ffffff; text-decoration: underline; }

.wrap { max-width: 980px; margin: 0 auto; padding: 28px; }
.wrap.narrow { max-width: 640px; }

/* --- Typography experiment: Sora for body copy, not just headings ---
   Scoped to specific pages via {% block wrapclass %}font-test-sora{% endblock %}
   so it can be tried on /  and /people without committing the whole app to
   it. Remove the wrapclass (or this rule) to revert a page. */
.wrap.font-test-sora, .wrap.font-test-sora input, .wrap.font-test-sora textarea, .wrap.font-test-sora select, .wrap.font-test-sora button {
  font-family: var(--display);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 20px 24px;
  margin-bottom: 18px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}
.stat {
  background: var(--panel);
  padding: 18px 20px;
}
.stat .n { font-family: var(--display); font-size: 2rem; line-height: 1; display: block; margin-bottom: 4px; }
.stat .label { color: var(--ink-soft); font-size: 0.85rem; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.bar-row .label { width: 150px; font-size: 0.88rem; color: var(--ink-soft); flex-shrink: 0; }
.bar-track { flex: 1; background: var(--bg); height: 10px; border: 1px solid var(--border); }
.bar-fill { background: var(--accent); height: 100%; }
.bar-row .n { width: 34px; text-align: right; font-size: 0.85rem; color: var(--ink-soft); }

.tag {
  display: inline-block;
  padding: 2px 9px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-right: 6px;
}
.tag.positive { background: var(--positive-soft); border-color: var(--positive); color: var(--positive); }
.tag.attention { background: var(--attention-soft); border-color: var(--attention); color: var(--attention); }
.tag.negative { background: var(--negative-soft); border-color: var(--negative); color: var(--negative); }
.tag.accent { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--ink-soft); font-weight: 600; font-size: 0.82rem; }

.loop-step {
  border-left: 2px solid var(--border);
  padding: 4px 0 18px 18px;
  margin-left: 4px;
  position: relative;
}
.loop-step::before {
  content: attr(data-n);
  position: absolute;
  left: -11px;
  top: 2px;
  width: 20px; height: 20px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  font-size: 0.72rem;
  display: flex; align-items: center; justify-content: center;
}
.loop-step:last-child { border-left-color: transparent; }

form label { display: block; margin: 14px 0 5px; font-size: 0.88rem; color: var(--ink-soft); }
form input[type=text], form input[type=number], form input[type=date],
form textarea, form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  font-family: var(--sans);
  font-size: 0.92rem;
  color: var(--ink);
}
form textarea { min-height: 80px; resize: vertical; }
form .checkbox-row { display: flex; align-items: center; gap: 8px; margin: 14px 0; }
form .checkbox-row input { width: auto; }
form .checkbox-row label { margin: 0; }

.btn {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 9px 18px;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  margin-top: 14px;
}
.btn:hover { background: #1d438f; text-decoration: none; }
.btn.secondary { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.small { padding: 5px 12px; font-size: 0.82rem; margin-top: 0; }

.flash {
  background: var(--positive-soft);
  border: 1px solid var(--positive);
  color: var(--positive);
  padding: 10px 16px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.muted { color: var(--ink-soft); font-size: 0.86rem; }
.metric-pair { display: flex; gap: 30px; margin: 10px 0 4px; }
.metric-pair .metric { text-align: center; }
.metric-pair .metric .val { font-family: var(--display); font-size: 1.5rem; }
.metric-pair .metric .lab { font-size: 0.78rem; color: var(--ink-soft); }
.metric-pair .arrow { font-size: 1.2rem; color: var(--ink-soft); align-self: center; }

/* --- Mobile: single-word values (e.g. "Independent") have a fixed
   min-content width flexbox can't shrink below -- three side by side
   don't fit under ~480px no matter how much text wrapping is allowed,
   so stack them instead of letting the row force horizontal scroll. --- */
@media (max-width: 480px) {
  .metric-pair { flex-direction: column; align-items: center; gap: 10px; }
  .metric-pair .arrow { transform: rotate(90deg); }
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--ink-soft);
  border-top: 1px dashed var(--border);
  padding-top: 10px;
  margin-top: 14px;
}

/* --- Case header (Pass 1) --- */
.case-header {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 18px;
  margin-bottom: 4px;
}
.case-header .field .k { font-size: 0.78rem; color: var(--ink-soft); margin-bottom: 2px; }
.case-header .field .v { font-family: var(--display); font-size: 1.15rem; }
.status-select { display: inline-block; }
.status-select select { display: inline-block; width: auto; padding: 4px 8px; font-size: 0.85rem; }

/* --- Rule + evidence + suggestion primitive --- */
.suggestion-card {
  border: 1px solid var(--border);
  border-left-width: 4px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: 0.88rem;
}
.suggestion-card.attention { border-left-color: var(--attention); background: var(--attention-soft); }
.suggestion-card.review { border-left-color: var(--review); background: var(--review-soft); }
.suggestion-card .suggestion-text { margin: 0 0 4px; }
.suggestion-card .suggestion-evidence { margin: 0; font-size: 0.78rem; color: var(--ink-soft); }
.suggestion-card .suggestion-evidence a { margin-left: 4px; }

/* --- Observation perspective cards --- */
.perspective-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.perspective-card { border: 1px solid var(--border); padding: 12px 14px; background: var(--bg); }
.perspective-card h4 { margin: 0 0 8px; font-size: 0.82rem; color: var(--ink-soft); font-weight: 600; }
.perspective-card p { margin: 0 0 8px; font-size: 0.88rem; }
.perspective-card .date { font-size: 0.76rem; color: var(--ink-soft); }

/* --- Methodology stage groups --- */
.stage-group { margin: 22px 0; }
.stage-label {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.95rem;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
  margin-bottom: 12px;
}

/* --- Automated indicators --- */
.indicator-row { display: flex; align-items: center; gap: 8px; font-size: 0.86rem; margin-bottom: 4px; }
.indicator-row .metric-name { width: 150px; color: var(--ink-soft); }
.indicator-row .direction { font-weight: 600; }
.indicator-row .direction.improving { color: var(--positive); }
.indicator-row .direction.worsening { color: var(--negative); }
.indicator-row .direction.stable { color: var(--attention); }
.indicator-row .direction.insufficient_data { color: var(--ink-soft); font-weight: 400; }
.indicator-label { font-size: 0.74rem; text-transform: none; color: var(--ink-soft); letter-spacing: 0.02em; margin-bottom: 4px; }

/* --- Goal perspective cards (Client/Family/Coach/Shared Focus) ---
   Reuses .perspective-card/.perspective-grid above; the border-left color
   is purely categorical identity, not a status/result signal, so it draws
   from the decorative brand hues (sky/teal/green), never the
   positive/attention/negative status colors used elsewhere. */
.perspective-card.goal-client { border-left: 4px solid var(--accent); }
.perspective-card.goal-family { border-left: 4px solid var(--brand-sky); }
.perspective-card.goal-coach { border-left: 4px solid var(--brand-teal); }
.perspective-card.goal-shared-focus { border-left: 4px solid var(--brand-green); background: var(--accent-soft); }

/* --- Weekly checklist (client/sprint dashboards) --- */
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.checklist-item form { display: contents; }
.checklist-item .checklist-btn {
  width: 20px; height: 20px; border: 1px solid var(--border); background: var(--panel);
  cursor: pointer; flex-shrink: 0; padding: 0;
}
.checklist-item.completed .checklist-btn { background: var(--positive); border-color: var(--positive); }
.checklist-item.completed span.desc { color: var(--ink-soft); text-decoration: line-through; }

/* --- Case cards on client overview --- */
.case-card { display: block; text-decoration: none; color: inherit; cursor: pointer; }
.case-card:hover { border-color: var(--accent); text-decoration: none; }
.case-card-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }

/* --- Collapsible quick actions --- */
details { margin: 6px 0; }
details summary { cursor: pointer; font-size: 0.88rem; padding: 4px 0; }
details summary::marker { color: var(--accent); }

/* --- Sparkline --- */
.sparkline { display: block; margin: 2px 0 6px; }

/* --- Evidence jump-link highlight --- */
:target {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  animation: target-fade 2.5s ease-out;
}
@keyframes target-fade {
  from { background-color: var(--accent-soft); }
  to { background-color: transparent; }
}

@media print {
  .topbar, .no-print { display: none; }
  body { background: white; }
  .panel { border: none; }
}

/* --- Resource library --- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.resource-card {
  display: block;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 18px 20px;
  color: inherit;
}
.resource-card:hover { border-color: var(--accent); text-decoration: none; }
.resource-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.resource-draft-badge { display: inline-block; margin: 0 0 8px; }
.resource-card-excerpt {
  font-size: 0.88rem;
  color: var(--ink-soft);
  margin: 0 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.resource-card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.resource-card-tags .tag { margin-right: 0; }

.evidence-type-list, .source-list { padding-left: 20px; margin: 0; }
.evidence-type-list li, .source-list li { margin-bottom: 10px; font-size: 0.92rem; line-height: 1.5; }
.source-list li a { font-size: 0.85rem; }
