/* App-shell layout for the Throughline UI kit. */
@import url('/colors_and_type.css');

html, body, #root { height: 100%; margin: 0; }
body { background: var(--bg); }

/* ----- App shell ----- */
.tl-app { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }

.tl-sidenav {
  border-right: 1px solid var(--rule);
  padding: 18px 14px;
  display: flex; flex-direction: column;
  background: var(--bg);
  position: sticky; top: 0; height: 100vh;
}
.tl-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 24px; }
.tl-brand-name { font-family: var(--font-display); font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.tl-nav { display: flex; flex-direction: column; gap: 2px; }
.tl-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 6px;
  font-family: var(--font-display); font-size: 14px; font-weight: 500;
  color: var(--fg-2); cursor: pointer; user-select: none;
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.tl-nav-item:hover { background: var(--bg-1); color: var(--fg-1); }
.tl-nav-item.active { background: var(--bg-2); color: var(--fg-1); }
.tl-nav-item svg { width: 18px; height: 18px; stroke-width: 1.5; flex-shrink: 0; }
.tl-nav-spacer { flex: 1; }
.tl-nav-foot { padding: 12px 10px; font-family: var(--font-display); font-size: 12px; color: var(--fg-3); border-top: 1px solid var(--rule); }

/* ----- Top bar ----- */
.tl-main { display: flex; flex-direction: column; min-width: 0; }
.tl-topbar {
  height: 56px; flex-shrink: 0;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 32px;
  background: var(--bg);
  position: sticky; top: 0; z-index: 5;
}
.tl-topbar-title { font-family: var(--font-display); font-weight: 600; font-size: 15px; white-space: nowrap; }
.tl-topbar-right { display: flex; align-items: center; gap: 14px; font-family: var(--font-display); font-size: 13px; color: var(--fg-2); white-space: nowrap; flex-shrink: 0; }
.tl-avatar {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
}

/* ----- Screen container ----- */
.tl-screen { padding: 40px 32px 64px; max-width: 1100px; width: 100%; margin: 0 auto; box-sizing: border-box; }
.tl-screen.brief { max-width: 880px; }
.tl-screen-h1 { font-family: var(--font-display); font-weight: 600; font-size: 28px; letter-spacing: -0.02em; }
.tl-screen-sub { font-family: var(--font-body); font-size: 15px; color: var(--fg-2); margin-top: 4px; }
.tl-screen-head { margin-bottom: 28px; display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ----- Cards ----- */
.tl-card { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-card); padding: 24px; }
.tl-card + .tl-card { margin-top: 16px; }
.tl-card-title { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 0 0 14px; }

.tl-section-label { font-family: var(--font-display); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; color: var(--fg-3); text-transform: uppercase; margin-bottom: 10px; }

/* ----- Chips ----- */
.tl-chip {
  font-family: var(--font-display); font-size: 11px; font-weight: 500;
  padding: 4px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0; white-space: nowrap;
}
.tl-chip .dot { width: 6px; height: 6px; border-radius: 50%; }
.tl-chip.ok       { background: var(--ok-soft);   color: #3a6347; }
.tl-chip.ok       .dot { background: var(--ok); }
.tl-chip.warn     { background: var(--warn-soft); color: #8e6629; }
.tl-chip.warn     .dot { background: var(--warn); }
.tl-chip.bad      { background: var(--bad-soft);  color: #8a3f33; }
.tl-chip.bad      .dot { background: var(--bad); }
.tl-chip.info     { background: var(--info-soft); color: #3b5670; }
.tl-chip.info     .dot { background: var(--info); }
.tl-chip.neutral  { background: var(--bg-1); color: var(--fg-2); border: 1px solid var(--rule); }
.tl-chip.neutral  .dot { background: var(--fg-3); }

/* ----- Buttons ----- */
.tl-btn {
  font-family: var(--font-display); font-weight: 500; font-size: 14px;
  padding: 9px 14px; border-radius: 4px; border: 1px solid transparent;
  cursor: pointer; transition: all 120ms var(--ease);
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap; flex-shrink: 0;
}
.tl-btn svg { width: 16px; height: 16px; stroke-width: 1.5; }
.tl-btn.primary { background: var(--accent); color: var(--bg); }
.tl-btn.primary:hover { background: var(--accent-hover); }
.tl-btn.secondary { background: transparent; color: var(--fg-1); border-color: var(--rule-2); }
.tl-btn.secondary:hover { background: var(--bg-1); }
.tl-btn.ghost { background: transparent; color: var(--accent); }
.tl-btn.ghost:hover { background: var(--accent-soft); }

/* Disabled "coming soon" treatment — soft, intentional, with a v2 pill.
   Used on Play brief / Play all briefs until audio briefings are wired. */
.tl-btn.is-disabled {
  cursor: not-allowed;
  opacity: 0.55;
  position: relative;
}
.tl-btn.is-disabled:hover {
  background: transparent;
}
.tl-btn.is-disabled::after {
  content: "v2";
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-3);
  background: var(--bg-1);
  border: 1px solid var(--rule-2);
  border-radius: 999px;
  padding: 1px 5px;
  margin-left: 2px;
}

/* ----- List rows ----- */
.tl-list { display: flex; flex-direction: column; gap: 8px; }
.tl-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--r-card);
  transition: background 120ms var(--ease);
  cursor: pointer;
}
.tl-row:hover { background: var(--bg-1); }
.tl-row .body { flex: 1; min-width: 0; }
.tl-row .title { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.3; color: var(--fg-1); }
.tl-row .preview { font-family: var(--font-body); font-size: 14px; color: var(--fg-2); line-height: 1.4; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-row .meta { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); flex-shrink: 0; }
.tl-row.large .title { font-size: 16px; }

.tl-pavatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
  flex-shrink: 0;
}

/* ----- Brief ----- */
.brief-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.brief-head .who { font-family: var(--font-display); font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.brief-head .when { font-family: var(--font-display); font-size: 12px; font-weight: 600; letter-spacing: 0.08em; color: var(--fg-3); text-transform: uppercase; }
.brief-section { padding: 22px 0; border-top: 1px solid var(--rule); }
.brief-section:first-of-type { border-top: 0; padding-top: 6px; }
.brief-section h3 { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 0 0 12px; }
.brief-list { font-family: var(--font-body); font-size: 16px; line-height: 1.55; color: var(--fg-1); padding-left: 20px; margin: 0; max-width: 64ch; }
.brief-list li { margin-bottom: 10px; }
.brief-list li:last-child { margin-bottom: 0; }
.brief-list li.closed { color: var(--fg-3); text-decoration: line-through; text-decoration-color: var(--fg-4); }
.brief-list a { color: var(--accent); }
.suggestions-banner {
  font-family: var(--font-display); font-size: 12px; color: var(--fg-3);
  padding: 8px 0 0; max-width: 64ch;
}

/* ----- Tabs ----- */
.tl-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 24px; }
.tl-tab {
  font-family: var(--font-display); font-weight: 500; font-size: 14px;
  padding: 10px 14px; cursor: pointer;
  color: var(--fg-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: color 120ms;
}
.tl-tab:hover { color: var(--fg-1); }
.tl-tab.active { color: var(--fg-1); border-bottom-color: var(--accent); }

/* ----- Timeline ----- */
.tl-timeline { display: flex; flex-direction: column; gap: 0; border-left: 1px solid var(--rule); padding-left: 24px; margin-left: 8px; }
.tl-tle { padding: 16px 0; border-bottom: 1px solid var(--rule); position: relative; }
.tl-tle:last-child { border-bottom: 0; }
.tl-tle::before {
  content: ""; position: absolute; left: -29px; top: 22px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 1.5px solid var(--accent);
}
.tl-tle .date { font-family: var(--font-mono); font-size: 12px; color: var(--fg-3); }
.tl-tle .head { display: flex; align-items: flex-start; gap: 10px; margin-top: 4px; }
.tl-tle .ttl { flex: 1; min-width: 0; }
.tl-tle .ttl { font-family: var(--font-display); font-weight: 600; font-size: 15px; }
.tl-tle .from { font-family: var(--font-display); font-size: 13px; color: var(--fg-3); margin-top: 2px; }
.tl-tle .ex { font-family: var(--font-body); font-size: 14px; color: var(--fg-2); margin-top: 6px; max-width: 64ch; line-height: 1.5; }
.tag-pill { font-family: var(--font-display); font-size: 11px; padding: 2px 8px; border-radius: 4px; background: var(--bg-1); color: var(--fg-2); border: 1px solid var(--rule); white-space: nowrap; flex-shrink: 0; }

/* ----- People grid ----- */
.tl-people { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tl-person { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; }
.tl-person .info { min-width: 0; }
.tl-person .nm { font-family: var(--font-display); font-weight: 600; font-size: 14px; }
.tl-person .ro { font-family: var(--font-body); font-size: 13px; color: var(--fg-2); }
.tl-person .lc { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); margin-top: 2px; }

/* ----- Ask ----- */
.ask-thread { display: flex; flex-direction: column; gap: 18px; max-width: 64ch; margin-bottom: 24px; }
.ask-q { font-family: var(--font-display); font-size: 15px; font-weight: 500; color: var(--fg-1); padding: 10px 14px; background: var(--bg-1); border-radius: 8px; align-self: flex-end; max-width: 80%; }
.ask-a { font-family: var(--font-body); font-size: 15px; line-height: 1.55; color: var(--fg-1); }
.ask-a .src { font-family: var(--font-display); font-size: 12px; color: var(--fg-3); margin-top: 6px; }
.ask-input {
  display: flex; gap: 8px; padding: 10px 14px;
  border: 1px solid var(--rule-2); border-radius: 8px;
  background: var(--paper); max-width: 64ch;
}
.ask-input input { flex: 1; border: 0; background: transparent; font-family: var(--font-body); font-size: 15px; outline: none; color: var(--fg-1); }

/* ----- Inbox ----- */
.inbox-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px; }
.inbox-row .from { font-family: var(--font-display); font-size: 13px; color: var(--fg-3); }
.inbox-row .subj { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--fg-1); margin-top: 2px; }
.inbox-row .routed-to { font-family: var(--font-mono); font-size: 12px; color: var(--accent); margin-top: 4px; }

.empty-state { font-family: var(--font-body); color: var(--fg-3); padding: 24px 0; }

/* ============================================================
   Source drawer — stylised reconstruction of source documents
   with the relevant passage highlighted in soft yellow.
   ============================================================ */
.tl-scrim {
  position: fixed; inset: 0; background: rgba(26, 24, 20, 0.28);
  opacity: 0; pointer-events: none;
  transition: opacity var(--d-base) var(--ease);
  z-index: 50;
}
.tl-scrim.open { opacity: 1; pointer-events: auto; }

.tl-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(560px, 92vw);
  background: var(--bg);
  border-left: 1px solid var(--rule);
  box-shadow: -16px 0 40px rgba(26, 24, 20, 0.10);
  transform: translateX(100%);
  transition: transform var(--d-screen) var(--ease);
  z-index: 51;
  display: flex; flex-direction: column;
}
.tl-drawer.open { transform: translateX(0); }

.tl-drawer-head {
  height: var(--topbar-h); flex-shrink: 0;
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px 0 22px;
}
.tl-drawer-head .lbl { font-family: var(--font-display); font-size: 13px; font-weight: 600; color: var(--fg-2); letter-spacing: 0.02em; }
.tl-drawer-close {
  background: transparent; border: 0; cursor: pointer; padding: 8px;
  border-radius: 4px; color: var(--fg-2);
  display: inline-flex; align-items: center; justify-content: center;
}
.tl-drawer-close:hover { background: var(--bg-1); color: var(--fg-1); }
.tl-drawer-close svg { width: 18px; height: 18px; stroke-width: 1.5; }

.tl-drawer-body {
  flex: 1; overflow-y: auto;
  padding: 28px 36px 64px;
}

/* Source paper — a stylised printed-letter look */
.src-paper {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 32px 36px;
  box-shadow: 0 1px 2px rgba(26, 24, 20, 0.04);
  font-family: var(--font-body);
  font-size: 14px; line-height: 1.6; color: var(--fg-2);
  max-width: 60ch;
}
.src-paper .src-letterhead {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  color: var(--fg-1); letter-spacing: -0.005em;
  padding-bottom: 12px; margin-bottom: 16px;
  border-bottom: 1px solid var(--rule);
}
.src-paper .src-meta {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-3);
  margin-bottom: 4px;
}
.src-paper .src-re {
  font-family: var(--font-display); font-size: 13px; color: var(--fg-1);
  font-weight: 600; margin-bottom: 16px;
}
.src-paper p { margin: 0 0 12px; max-width: none; }
.src-paper p:last-child { margin-bottom: 0; }

/* Highlight: the passage Throughline cited. Soft yellow with the rest dimmed. */
.src-paper.has-highlight p:not(.src-highlight) { opacity: 0.42; }
.src-paper p.src-highlight {
  background: rgba(244, 207, 89, 0.32);
  border-radius: 3px;
  padding: 4px 6px;
  margin-left: -6px; margin-right: -6px;
  color: var(--fg-1);
  position: relative;
}
.src-paper p.src-highlight::before {
  content: ""; position: absolute; left: -10px; top: 4px; bottom: 4px;
  width: 2px; background: #C9A227; border-radius: 1px;
}

/* Voice-memo source variant */
.src-paper.voicememo {
  background: var(--bg-1);
}
.src-paper.voicememo .src-letterhead {
  display: flex; align-items: center; gap: 10px;
}
.src-paper.voicememo .src-letterhead svg { width: 16px; height: 16px; stroke-width: 1.5; color: var(--accent); }

/* Mini audio player used in timeline + voice memo source */
.tl-audio {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  font-family: var(--font-display); font-size: 13px; color: var(--fg-1);
  margin: 12px 0 16px;
}
.tl-audio.in-source { background: var(--paper); margin: 0 0 18px; }
.tl-audio button {
  width: 32px; height: 32px; border-radius: 999px;
  background: var(--accent); color: var(--bg);
  border: 0; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tl-audio button:hover { background: var(--accent-hover); }
.tl-audio button svg { width: 14px; height: 14px; stroke-width: 1.5; fill: currentColor; }
.tl-audio .wave { flex: 1; height: 22px; display: flex; align-items: center; gap: 2px; min-width: 0; }
.tl-audio .wave .bar { flex: 1; background: var(--rule-2); border-radius: 1px; min-width: 2px; transition: background 80ms; }
.tl-audio .wave .bar.played { background: var(--accent); }
.tl-audio .time { font-family: var(--font-mono); font-size: 11px; color: var(--fg-3); flex-shrink: 0; }

/* New-input live indicator on the brief */
.brief-live-banner {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-family: var(--font-display); font-size: 12px; font-weight: 500;
  margin-bottom: 18px; cursor: pointer;
  transition: background var(--d-fast) var(--ease);
}
.brief-live-banner:hover { background: rgba(31, 95, 91, 0.18); }
.brief-live-banner .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: tl-pulse 2.4s var(--ease) infinite;
}
@keyframes tl-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}

/* ============================================================
   Charts — WISC-V plot, pathology table, growth chart.
   Used inside source-drawer paper, and as inline previews.
   ============================================================ */
.chart-block {
  margin: 8px 0 18px;
  font-family: var(--font-display);
}
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  font-family: var(--font-display); font-size: 11px; color: var(--fg-3);
  margin-top: 8px;
}
.chart-legend .sw {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: 5px; vertical-align: -1px;
}

/* Pathology table */
.pathology-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-display); font-size: 12px; color: var(--fg-1);
}
.pathology-table th {
  text-align: left; font-weight: 500; color: var(--fg-3);
  font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 6px 8px; border-bottom: 1px solid var(--rule);
}
.pathology-table td {
  padding: 7px 8px; border-bottom: 1px solid var(--rule);
}
.pathology-table tr.path-group td {
  font-weight: 600; font-size: 11px; color: var(--fg-3);
  letter-spacing: 0.04em; text-transform: uppercase;
  background: var(--bg-1);
  padding: 5px 8px;
  border-bottom: 1px solid var(--rule);
}
.pathology-table tr.flag-low td,
.pathology-table tr.flag-high td { background: rgba(180, 90, 60, 0.05); }
.flag-pill {
  display: inline-block; width: 14px; height: 14px;
  background: #B45A3C; color: #fff;
  border-radius: 3px; font-size: 9px; font-weight: 700;
  text-align: center; line-height: 14px; margin-left: 6px;
  vertical-align: 1px;
}

/* Trend-pattern callouts under the table */
.path-patterns {
  margin-top: 14px; padding: 12px 14px;
  background: rgba(244, 207, 89, 0.18);
  border-left: 2px solid #C9A227; border-radius: 0 4px 4px 0;
}
.path-patterns-label {
  font-family: var(--font-display); font-size: 10px; font-weight: 600;
  color: var(--fg-2); letter-spacing: 0.06em; text-transform: uppercase;
  margin-bottom: 6px;
}
.path-pattern-row {
  font-family: var(--font-body); font-size: 13px; color: var(--fg-1);
  line-height: 1.5; padding: 3px 0;
}

/* When a chart is rendered inside src-paper, give it room and a soft frame */
.src-paper .chart-block {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 14px 16px;
  margin: 0 0 18px;
}
.src-paper .chart-block + .chart-block { margin-top: -8px; }

/* Inline brief sparkline */
.brief-list .inline-spark {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 6px;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-3);
}
.inbox-resolve {
  margin-top: 12px; padding: 14px; background: var(--bg-1);
  border: 1px solid var(--rule); border-radius: 6px;
}
.inbox-resolve .candidate {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 6px;
  cursor: pointer; transition: background 120ms var(--ease);
}
.inbox-resolve .candidate:hover { background: var(--paper); }
.inbox-resolve .candidate .conf {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-3);
  flex-shrink: 0; min-width: 38px; text-align: right;
}
.inbox-resolve .candidate .name {
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--fg-1);
}
.inbox-resolve .candidate .reason {
  font-family: var(--font-body); font-size: 13px; color: var(--fg-2); margin-top: 2px;
}
.inbox-resolve .candidate .meter {
  width: 60px; height: 4px; background: var(--rule); border-radius: 2px; overflow: hidden;
  flex-shrink: 0;
}
.inbox-resolve .candidate .meter > div {
  height: 100%; background: var(--accent); border-radius: 2px;
}

/* ============================================================
   Brief — Trended evidence rows
   Sparkline + test name + value sequence + ref + interpretation.
   Clickable; opens the underlying source (pathology / growth).
   ============================================================ */
.brief-trended {
  display: flex; flex-direction: column;
  border: 1px solid var(--rule); border-radius: 6px; overflow: hidden;
  background: var(--paper);
}
.trended-row {
  display: grid;
  grid-template-columns: 80px 180px 1fr;
  grid-template-areas:
    "spark test values"
    "spark interp interp";
  gap: 4px 18px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: var(--fg-1);
  transition: background 120ms var(--ease);
}
.trended-row:last-child { border-bottom: none; }
.trended-row:hover { background: var(--bg-1); }
.trended-row.flag-low,
.trended-row.flag-high { background: rgba(180, 90, 60, 0.04); }
.trended-row.flag-low:hover,
.trended-row.flag-high:hover { background: rgba(180, 90, 60, 0.08); }

.trended-spark {
  grid-area: spark;
  display: flex; align-items: center;
  padding-top: 2px;
}
.trended-test {
  grid-area: test;
  font-family: var(--font-display); font-size: 14px; font-weight: 600;
  color: var(--fg-1); align-self: center;
}
.trended-test .flag-pill { margin-left: 6px; }
.trended-values {
  grid-area: values;
  font-family: var(--font-mono); font-size: 12px; color: var(--fg-2);
  align-self: center;
}
.trended-values .unit { color: var(--fg-3); margin-left: 4px; }
.trended-values .ref {
  margin-left: 14px; padding-left: 14px;
  border-left: 1px solid var(--rule);
  color: var(--fg-3);
}
.trended-interp {
  grid-area: interp;
  font-family: var(--font-body); font-size: 13px; color: var(--fg-2);
  line-height: 1.45;
}

/* ============================================================
   Results tab — longitudinal view of every quantitative parameter.
   Grouped by parameter family. Each row: name, latest value, ref,
   sparkline of the trend, dates, source.
   ============================================================ */
.results-tab { font-family: var(--font-body); }
.results-blurb {
  font-family: var(--font-display); font-size: 12px; color: var(--fg-3);
  margin-bottom: 18px; max-width: 64ch; line-height: 1.5;
}
.results-group { margin-bottom: 28px; }
.results-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px; padding-bottom: 6px; border-bottom: 1px solid var(--rule);
}
.results-group-head h4 {
  font-family: var(--font-display); font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2);
  margin: 0; white-space: nowrap;
}
.results-group-head .cnt {
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-3);
  white-space: nowrap;
}
.results-list {
  border: 1px solid var(--rule); border-radius: 6px; overflow: hidden;
  background: var(--paper);
}
.results-row {
  display: grid;
  grid-template-columns: 180px 110px 130px 70px 1fr;
  grid-template-areas:
    "name latest ref spark trend"
    "name source source source source";
  gap: 2px 16px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--rule);
  text-decoration: none; color: var(--fg-1);
  transition: background 120ms var(--ease);
  align-items: center;
}
.results-row:last-child { border-bottom: none; }
.results-row:hover { background: var(--bg-1); }
.results-row.flag-low,
.results-row.flag-high { background: rgba(180, 90, 60, 0.04); }
.results-row.flag-low:hover,
.results-row.flag-high:hover { background: rgba(180, 90, 60, 0.08); }

.results-row .r-name { grid-area: name; }
.results-row .r-name .t {
  font-family: var(--font-display); font-size: 14px; font-weight: 600; color: var(--fg-1);
}
.results-row .r-name .g {
  font-family: var(--font-display); font-size: 11px; color: var(--fg-3);
  margin-top: 2px;
}
.results-row .r-latest {
  grid-area: latest;
  font-family: var(--font-mono);
  display: flex; align-items: baseline; gap: 4px;
}
.results-row .r-latest .v { font-size: 16px; font-weight: 600; color: var(--fg-1); }
.results-row .r-latest .u { font-size: 11px; color: var(--fg-3); }
.results-row .r-ref {
  grid-area: ref;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-3);
}
.results-row .r-spark { grid-area: spark; }
.results-row .r-trend-vals {
  grid-area: trend;
  font-family: var(--font-mono); font-size: 11px; color: var(--fg-2);
  text-align: right;
}
.results-row .r-source {
  grid-area: source;
  font-family: var(--font-display); font-size: 11px; color: var(--fg-3);
  margin-top: 2px;
}


/* ============================================================
   Source drawer — WhatsApp thread
   ============================================================ */
.src-paper.whatsapp { background: #ECE5DD; max-width: 56ch; }
.src-paper.whatsapp .src-letterhead {
  display: flex; align-items: center; gap: 8px;
  background: #075E54; color: #fff;
  margin: -28px -28px 16px;
  padding: 12px 20px;
  border-bottom: none;
  border-top-left-radius: 3px; border-top-right-radius: 3px;
}
.src-paper.whatsapp .src-letterhead svg { color: #fff; stroke-width: 1.6; }
.src-paper.whatsapp .src-meta {
  text-align: center; color: #6e7a7a; margin: 0 0 14px;
  font-family: var(--font-mono); font-size: 11px;
}
.wa-thread { display: flex; flex-direction: column; gap: 6px; }
.wa-bubble {
  max-width: 80%; padding: 8px 11px 6px;
  border-radius: 8px;
  font-family: var(--font-body); font-size: 14px; line-height: 1.4;
  color: #1f2c34;
  position: relative;
  box-shadow: 0 1px 0.5px rgba(0,0,0,0.08);
}
.wa-bubble.wa-mum {
  background: #fff; align-self: flex-start;
  border-top-left-radius: 2px;
}
.wa-bubble.wa-practice {
  background: #DCF8C6; align-self: flex-end;
  border-top-right-radius: 2px;
}
.wa-bubble .wa-time {
  font-family: var(--font-mono); font-size: 10px;
  color: #6e7a7a; margin-bottom: 2px;
  text-transform: none; letter-spacing: 0;
}
.wa-bubble .wa-text { white-space: pre-wrap; }

/* Highlighted message — soft yellow, brighten while dimming the rest of the thread */
.src-paper.whatsapp.has-highlight .wa-bubble:not(.wa-highlight) { opacity: 0.5; }
.wa-bubble.wa-highlight {
  background: #FFF3B8 !important;
  box-shadow: 0 0 0 2px #C9A227, 0 1px 0.5px rgba(0,0,0,0.08);
}

/* ============================================================
   Source drawer — medication list table
   ============================================================ */
.meds-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-display);
  margin: 12px 0;
  font-size: 12.5px;
}
.meds-table thead th {
  text-align: left;
  font-weight: 600; font-size: 10.5px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--fg-3);
  padding: 6px 8px;
  border-bottom: 1px solid var(--rule);
}
.meds-table tbody td {
  padding: 8px 8px;
  border-bottom: 1px solid var(--rule);
  color: var(--fg-2);
  vertical-align: top;
}
.meds-table tbody td.m-name {
  font-weight: 600; color: var(--fg-1);
  font-family: var(--font-display);
}
.meds-table .med-note-row td.m-note {
  padding-top: 0; padding-bottom: 12px;
  font-family: var(--font-body); font-style: italic;
  font-size: 12px; color: var(--fg-3);
  border-bottom: 1px solid var(--rule);
}

/* Flagged meds get the same yellow highlight treatment as text passages */
.src-paper.has-highlight .meds-table tbody tr:not(.med-flag-changed):not(.med-flag-watch):not(.med-flag-new) { opacity: 0.55; }
.meds-table tbody tr.med-flag-changed td { background: rgba(244, 207, 89, 0.32); }
.meds-table tbody tr.med-flag-watch td   { background: rgba(244, 207, 89, 0.18); }
.meds-table tbody tr.med-flag-new td     { background: rgba(143, 175, 138, 0.18); }
.meds-table tbody tr.med-flag-changed td.m-name::before {
  content: "↻"; margin-right: 4px; color: #C9A227; font-weight: 700;
}
.meds-table tbody tr.med-flag-new td.m-name::before {
  content: "+"; margin-right: 4px; color: #4F6F4D; font-weight: 700;
}

/* ============================================================
   Source drawer — pathology longitudinal table
   ============================================================ */
.path-table {
  width: 100%; border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 11.5px;
  margin: 12px 0;
}
.path-table thead th {
  text-align: right; vertical-align: bottom;
  padding: 6px 5px;
  border-bottom: 1px solid var(--rule);
  color: var(--fg-2);
  font-weight: 600;
}
.path-table thead th:first-child,
.path-table thead th:nth-child(2) { text-align: left; }
.path-table thead th .path-unit { font-weight: 400; color: var(--fg-3); font-size: 10px; margin-top: 2px; }
.path-table thead th .path-ref  { font-weight: 400; color: var(--fg-3); font-size: 10px; }
.path-table tbody td {
  padding: 6px 5px;
  border-bottom: 1px solid var(--rule);
  text-align: right;
  color: var(--fg-2);
}
.path-table tbody td.path-date {
  text-align: left;
  font-family: var(--font-display); font-weight: 600; color: var(--fg-1);
  font-size: 12px;
  white-space: nowrap;
}
.path-table tbody td.path-note {
  text-align: left;
  font-family: var(--font-body); font-size: 11.5px; color: var(--fg-3);
  font-style: italic;
}
.path-table tbody td.path-empty { color: var(--fg-3); }
.path-table tbody td.path-val.low,
.path-table tbody td.path-val.high {
  background: rgba(244, 207, 89, 0.28);
  font-weight: 600; color: var(--fg-1);
}
.path-table tbody tr.path-flag-watch td:first-child::before {
  content: "•"; color: #C9A227; margin-right: 4px;
}
.path-table tbody tr.path-flag-abnormal td:first-child::before {
  content: "▲"; color: #B0413E; margin-right: 4px;
}
.path-table tbody tr.path-flag-abnormal td.path-date { color: #B0413E; }

.path-patterns {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--rule);
}
.path-patterns p { margin-bottom: 8px; }
