/* TierTek report design system — matches the approved ProactiveMD report.
   Self-contained (no external fonts / CDN). Adds CSS entrance animations. */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f8;
  --ink: #171b30;
  --ink-2: #474d6c;
  --ink-muted: #838aa6;
  --brand: #28326f;
  --brand-strong: #1d2557;
  --brand-soft: #b9bfe0;
  --brand-wash: #e7e9f5;
  --track: #e7e9f2;
  --line: #e4e7f0;
  --good: #2e7d5b;
  --warn: #b5852a;
  --crit: #b4453c;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --shadow: 0 1px 2px rgba(23,27,48,.05), 0 8px 24px -12px rgba(23,27,48,.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0f1e; --surface: #16192c; --surface-2: #1d2138;
    --ink: #edeff7; --ink-2: #b3b8d2; --ink-muted: #7e85a3;
    --brand: #8b93d4; --brand-strong: #a7ade0; --brand-soft: #3a416b;
    --brand-wash: #212545; --track: #262a44; --line: #262a44;
    --good: #4bb285; --warn: #d6a84e; --crit: #d9695f;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px -14px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="light"] {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #eef0f8;
  --ink: #171b30; --ink-2: #474d6c; --ink-muted: #838aa6;
  --brand: #28326f; --brand-strong: #1d2557; --brand-soft: #b9bfe0;
  --brand-wash: #e7e9f5; --track: #e7e9f2; --line: #e4e7f0;
  --good: #2e7d5b; --warn: #b5852a; --crit: #b4453c;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0d0f1e; --surface: #16192c; --surface-2: #1d2138;
  --ink: #edeff7; --ink-2: #b3b8d2; --ink-muted: #7e85a3;
  --brand: #8b93d4; --brand-strong: #a7ade0; --brand-soft: #3a416b;
  --brand-wash: #212545; --track: #262a44; --line: #262a44;
  --good: #4bb285; --warn: #d6a84e; --crit: #d9695f;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 28px 64px;
}
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Masthead ---------- */
.mast {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 24px; flex-wrap: wrap; padding-bottom: 22px;
  border-bottom: 2px solid var(--brand);
}
.wordmark {
  font-weight: 800; font-size: 22px; letter-spacing: -.02em;
  color: var(--brand); display: flex; align-items: center; gap: 10px;
}
.wordmark .tag {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--ink-muted);
  border-left: 1px solid var(--line); padding-left: 10px;
}
.mast-meta { text-align: right; }
.eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: .16em;
  text-transform: uppercase; color: var(--ink-muted); margin: 0 0 4px;
}
.draft-flag {
  display: inline-block; font-family: var(--font-mono); font-size: 10px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--warn);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 999px; padding: 2px 9px; margin-top: 8px;
}

.report-title {
  margin: 26px 0 4px; font-size: clamp(28px, 5vw, 40px); line-height: 1.04;
  letter-spacing: -.025em; font-weight: 800; text-wrap: balance;
}
.report-sub { margin: 0; color: var(--ink-2); font-size: 16px; }
.report-sub b { color: var(--ink); font-weight: 700; }

/* ---------- Section scaffolding ---------- */
section { margin-top: 40px; }
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 0 0 16px; }
.sec-head h2 {
  font-size: 13px; font-family: var(--font-mono); letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink); margin: 0; font-weight: 700;
}
.sec-head .rule { flex: 1; height: 1px; background: var(--line); }
.sec-note { color: var(--ink-muted); font-size: 12.5px; margin: 0; font-family: var(--font-mono); }

/* ---------- KPI row ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px 16px 15px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 6px;
}
.kpi .k-val {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 30px; font-weight: 700; letter-spacing: -.02em;
  color: var(--brand); line-height: 1;
}
.kpi .k-val small { font-size: 15px; color: var(--ink-2); font-weight: 600; }
.kpi .k-label { font-size: 11.5px; color: var(--ink-2); line-height: 1.3; }
.kpi .k-foot { font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-muted); margin-top: 2px; }

/* ---------- Card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 22px 20px; box-shadow: var(--shadow);
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.card h3 { margin: 0 0 2px; font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card .cap { margin: 0 0 18px; font-size: 12.5px; color: var(--ink-muted); }

/* ---------- Column chart (weekly) ---------- */
.cols {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px;
  align-items: end; height: 190px; padding-top: 8px;
}
.col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 8px; }
.col .bar {
  width: 100%; max-width: 74px; height: var(--h, 0%);
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-strong) 100%);
  border-radius: 5px 5px 3px 3px; position: relative; min-height: 4px;
  transform-origin: bottom; animation: growY .9s cubic-bezier(.2,.7,.2,1) both;
}
.col .bar.soft { background: var(--brand-soft); }
.col .cval { font-family: var(--font-mono); font-weight: 700; font-size: 15px; color: var(--ink); }
.col .clabel { font-size: 11px; color: var(--ink-2); text-align: center; line-height: 1.25; }
.col .clabel span { display: block; font-family: var(--font-mono); color: var(--ink-muted); font-size: 10px; }

/* ---------- Horizontal bars ---------- */
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar { display: grid; grid-template-columns: 148px 1fr; gap: 12px; align-items: center; }
.hbar .name { font-size: 12.5px; color: var(--ink-2); text-align: right; line-height: 1.2; }
.hbar .track { position: relative; background: var(--track); border-radius: 5px; height: 22px; overflow: hidden; }
.hbar .fill {
  height: 100%; width: var(--w, 0%); background: var(--brand-soft); border-radius: 5px;
  display: flex; align-items: center;
  transform-origin: left; animation: growX 1s cubic-bezier(.2,.7,.2,1) both;
}
.hbar .fill.hot { background: linear-gradient(90deg, var(--brand-strong), var(--brand)); }
.hbar .v {
  position: absolute; top: 0; bottom: 0; display: flex; align-items: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--ink);
}
.hbar .v.inside { right: 8px; color: #fff; }
.hbar .v.outside { left: calc(var(--w) + 8px); color: var(--ink-2); }
.tag-hot {
  display: inline-block; font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: .06em; text-transform: uppercase; color: var(--brand);
  background: var(--brand-wash); border-radius: 4px; padding: 1px 6px; margin-left: 6px;
  vertical-align: middle;
}

/* ---------- Stacked channel bar ---------- */
.stack { display: flex; height: 34px; border-radius: 7px; overflow: hidden; gap: 2px; background: var(--surface); }
.stack .seg { display: flex; align-items: center; justify-content: center; color: #fff; font-family: var(--font-mono); font-size: 12px; font-weight: 700; min-width: 2px; }
.stack .s1 { background: var(--brand-strong); }
.stack .s2 { background: var(--brand); }
.stack .s3 { background: var(--brand-soft); color: var(--ink); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; }
.legend .li { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.legend .num { color: var(--ink); font-weight: 700; }

/* ---------- Status pills ---------- */
.statrow { display: flex; flex-direction: column; gap: 12px; }
.statline { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; align-items: center; }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.good { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.neutral { background: var(--ink-muted); }
.statline .lab { font-size: 13px; color: var(--ink-2); }
.statline .fig { font-family: var(--font-mono); font-weight: 700; font-size: 14px; color: var(--ink); }
.statline .pct { color: var(--ink-muted); font-weight: 600; font-size: 12px; }

/* ---------- Mini list (sites) ---------- */
.minilist { display: flex; flex-direction: column; gap: 0; }
.minirow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.minirow:last-child { border-bottom: 0; }
.minirow .code { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); font-weight: 700; }
.minirow .desc { color: var(--ink-muted); font-size: 11.5px; margin-left: 8px; font-family: var(--font-sans); font-weight: 400; }
.minirow .cnt { font-family: var(--font-mono); font-weight: 700; font-size: 13px; color: var(--brand); }

/* ---------- Insight box ---------- */
.insight {
  background: var(--brand-wash);
  border: 1px solid color-mix(in srgb, var(--brand) 24%, transparent);
  border-radius: 14px; padding: 24px 24px 22px;
}
.insight h3 { margin: 0 0 14px; font-size: 16px; color: var(--brand-strong); }
.insight ul { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.insight li { display: grid; grid-template-columns: 22px 1fr; gap: 12px; font-size: 13.5px; color: var(--ink-2); line-height: 1.5; }
.insight li b { color: var(--ink); }
.insight .mk {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--brand);
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--brand) 22%, transparent);
  border-radius: 6px; height: 22px; display: flex; align-items: center; justify-content: center;
}

/* ---------- Footnotes ---------- */
.foot { margin-top: 40px; padding-top: 18px; border-top: 1px solid var(--line); }
.foot p { margin: 0 0 7px; font-size: 11px; color: var(--ink-muted); line-height: 1.5; }
.foot .fh { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .1em; font-size: 10px; color: var(--ink-2); margin-bottom: 9px; }

/* ---------- Entrance animations ---------- */
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes revealUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.reveal { animation: revealUp .55s ease both; }
.report-scope section.reveal:nth-of-type(1) { animation-delay: .05s; }
.report-scope section.reveal:nth-of-type(2) { animation-delay: .12s; }
.report-scope section.reveal:nth-of-type(3) { animation-delay: .19s; }
.report-scope section.reveal:nth-of-type(4) { animation-delay: .26s; }
.report-scope section.reveal:nth-of-type(5) { animation-delay: .33s; }
.report-scope section.reveal:nth-of-type(6) { animation-delay: .40s; }

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 116px 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal, .col .bar, .hbar .fill { animation: none !important; }
}

@media print {
  /* Visual-effect PDF — render EXACTLY like the on-screen light report:
     keep the navy, gradients, chart fills and shadows; just force the light
     theme + color-adjust so browsers don't strip backgrounds when saving to PDF. */
  :root, :root[data-theme="dark"], :root[data-theme="light"] {
    --bg: #f6f7fb; --surface: #ffffff; --surface-2: #eef0f8;
    --ink: #171b30; --ink-2: #474d6c; --ink-muted: #838aa6;
    --brand: #28326f; --brand-strong: #1d2557; --brand-soft: #b9bfe0;
    --brand-wash: #e7e9f5; --track: #e7e9f2; --line: #e4e7f0;
    --good: #2e7d5b; --warn: #b5852a; --crit: #b4453c;
    --shadow: 0 1px 2px rgba(23,27,48,.05), 0 8px 24px -12px rgba(23,27,48,.12);
    color-scheme: light;
  }
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
  .card, .kpi, .insight, section { break-inside: avoid; }
  .reveal, .col .bar, .hbar .fill { animation: none !important; opacity: 1 !important; transform: none !important; }
  @page { margin: 14mm; }
}
