:root {
    color-scheme: light;
    --surface-1:      #fcfcfb;
    --page:           #f9f9f7;
    --text-primary:   #0b0b0b;
    --text-secondary: #52514e;
    --text-muted:     #898781;
    --grid:           #e1e0d9;
    --axis:           #c3c2b7;
    --border:         rgba(11,11,11,0.10);
    --series-1:       #2a78d6;
    --series-2:       #eb6834;
    --series-3:       #1baf7a;
    --neg:            #e34948;
    --blue-250:       #86b6ef;
    --blue-550:       #1c5cab;
    --deemph:         #c9c8c1;
    --good:           #0ca30c;
    --warning:        #fab219;
    --serious:        #ec835a;
    --critical:       #d03b3b;
    --good-text:      #006300;
    --shadow:         0 1px 2px rgba(11,11,11,0.04), 0 4px 16px rgba(11,11,11,0.04);
  }
  @media (prefers-color-scheme: dark) {
    :root:where(:not([data-theme="light"])) {
      color-scheme: dark;
      --surface-1:      #1a1a19;
      --page:           #0d0d0d;
      --text-primary:   #ffffff;
      --text-secondary: #c3c2b7;
      --text-muted:     #898781;
      --grid:           #2c2c2a;
      --axis:           #383835;
      --border:         rgba(255,255,255,0.10);
      --series-1:       #3987e5;
      --series-2:       #d95926;
      --series-3:       #199e70;
      --neg:            #e66767;
      --blue-250:       #5598e7;
      --blue-550:       #184f95;
      --deemph:         #4a4a46;
      --good-text:      #0ca30c;
      --shadow:         0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
    }
  }
  :root[data-theme="dark"] {
    color-scheme: dark;
    --surface-1:      #1a1a19;
    --page:           #0d0d0d;
    --text-primary:   #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted:     #898781;
    --grid:           #2c2c2a;
    --axis:           #383835;
    --border:         rgba(255,255,255,0.10);
    --series-1:       #3987e5;
    --series-2:       #d95926;
    --series-3:       #199e70;
    --neg:            #e66767;
    --blue-250:       #5598e7;
    --blue-550:       #184f95;
    --deemph:         #4a4a46;
    --good-text:      #0ca30c;
    --shadow:         0 1px 2px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  }

  * { box-sizing: border-box; }
  html { scroll-behavior: smooth; scroll-padding-top: 76px; }
  body {
    margin: 0;
    background: var(--page);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.62;
    -webkit-font-smoothing: antialiased;
  }

  /* ---------- top bar ---------- */
  .topbar {
    position: sticky; top: 0; z-index: 40;
    background: color-mix(in srgb, var(--page) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
  }
  .topbar-inner {
    max-width: 1120px; margin: 0 auto; padding: 10px 24px;
    display: flex; align-items: center; gap: 20px;
  }
  .brand { font-weight: 650; font-size: 14px; letter-spacing: -0.01em; white-space: nowrap; }
  .brand span { color: var(--text-muted); font-weight: 450; }
  .navlinks { display: flex; gap: 18px; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .navlinks::-webkit-scrollbar { display: none; }
  .navlinks a {
    color: var(--text-secondary); text-decoration: none; font-size: 13.5px;
    white-space: nowrap; padding: 4px 0; border-bottom: 2px solid transparent;
  }
  .navlinks a:hover { color: var(--text-primary); border-bottom-color: var(--series-1); }
  .themetoggle {
    background: var(--surface-1); border: 1px solid var(--border); color: var(--text-secondary);
    border-radius: 8px; padding: 5px 10px; font: inherit; font-size: 12.5px; cursor: pointer;
  }
  .themetoggle:hover { color: var(--text-primary); }

  /* ---------- layout ---------- */
  .wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px 96px; }
  section { padding-top: 56px; }
  h1 { font-size: 40px; line-height: 1.15; letter-spacing: -0.025em; margin: 0 0 12px; font-weight: 680; }
  h2 {
    font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--text-muted); font-weight: 620; margin: 0 0 6px;
  }
  h3 { font-size: 25px; line-height: 1.25; letter-spacing: -0.018em; margin: 0 0 14px; font-weight: 640; }
  h4 { font-size: 15.5px; margin: 0 0 4px; font-weight: 620; letter-spacing: -0.008em; }
  p { margin: 0 0 14px; color: var(--text-secondary); max-width: 74ch; }
  p strong, li strong { color: var(--text-primary); font-weight: 620; }
  a { color: var(--series-1); }
  .lede { font-size: 18.5px; line-height: 1.6; color: var(--text-secondary); max-width: 70ch; }

  /* ---------- hero ---------- */
  .hero { padding-top: 52px; }
  .eyebrow {
    display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px;
    color: var(--text-muted); letter-spacing: 0.04em; text-transform: uppercase;
    font-weight: 600; margin-bottom: 18px;
  }
  .eyebrow::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--series-1);
  }
  .pricebar {
    display: flex; flex-wrap: wrap; gap: 0; margin: 26px 0 8px;
    border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
    background: var(--surface-1); box-shadow: var(--shadow);
  }
  .pricebar > div {
    flex: 1 1 150px; padding: 14px 18px; border-right: 1px solid var(--border);
  }
  .pricebar > div:last-child { border-right: none; }
  .pricebar dt { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
  .pricebar dd { margin: 0; font-size: 19px; font-weight: 630; letter-spacing: -0.015em; }

  /* ---------- hero figure ---------- */
  .herofig {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 20px;
    margin: 34px 0 6px;
  }
  .herofig .num {
    font-size: 76px; line-height: 1; font-weight: 700; letter-spacing: -0.04em;
    color: var(--neg);
  }
  .herofig .cap { font-size: 15.5px; color: var(--text-secondary); max-width: 34ch; }

  /* ---------- cards / grid ---------- */
  .card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: 14px; padding: 22px 24px; box-shadow: var(--shadow);
  }
  .grid { display: grid; gap: 18px; }
  .g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .g5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
  @media (max-width: 940px) {
    .g3, .g4, .g5 { grid-template-columns: repeat(2, minmax(0,1fr)); }
    .g2 { grid-template-columns: 1fr; }
  }
  @media (max-width: 560px) {
    .g3, .g4, .g5 { grid-template-columns: 1fr; }
    h1 { font-size: 30px; }
    .herofig .num { font-size: 56px; }
    .wrap { padding: 0 16px 72px; }
  }

  /* ---------- stat tile ---------- */
  .tile { display: flex; flex-direction: column; gap: 3px; padding: 18px 20px; }
  .tile .lbl { font-size: 12.5px; color: var(--text-muted); line-height: 1.35; }
  .tile .val { font-size: 30px; font-weight: 660; letter-spacing: -0.025em; line-height: 1.15; }
  .tile .sub { font-size: 12.5px; color: var(--text-secondary); }
  .delta { font-size: 13px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
  .delta.up   { color: var(--good-text); }
  .delta.down { color: var(--critical); }
  .delta.flat { color: var(--text-muted); }

  /* ---------- chart card ---------- */
  .chart-card { padding: 22px 24px 18px; }
  .chart-head { margin-bottom: 4px; }
  .chart-head h4 { margin-bottom: 2px; }
  .chart-sub { font-size: 13px; color: var(--text-muted); margin: 0 0 14px; max-width: 70ch; }
  .legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 12px; }
  .legend .item { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-secondary); }
  .legend .sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
  .legend .swline { width: 14px; height: 2px; border-radius: 2px; flex: none; }
  svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
  .branch .ico { width: 24px; height: 24px; flex: none; }
  .ax { font-size: 11.5px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
  .dl { font-size: 12px; fill: var(--text-primary); font-weight: 600; }
  .dl-sec { font-size: 11.5px; fill: var(--text-secondary); }
  .cat { font-size: 12.5px; fill: var(--text-secondary); }
  .annot { font-size: 11.5px; fill: var(--text-muted); }
  .hitzone { fill: transparent; cursor: default; }
  .mark { transition: opacity .12s ease; }
  .mark.dim { opacity: .45; }

  /* ---------- tooltip ---------- */
  .tt {
    position: fixed; z-index: 60; pointer-events: none; opacity: 0;
    transition: opacity .1s ease; background: var(--surface-1);
    border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px;
    box-shadow: 0 6px 24px rgba(0,0,0,.16); font-size: 13px; min-width: 130px;
  }
  .tt .tt-cat { font-size: 11.5px; color: var(--text-muted); margin-bottom: 3px; }
  .tt .tt-row { display: flex; align-items: center; gap: 8px; }
  .tt .tt-key { width: 14px; height: 2px; border-radius: 2px; flex: none; }
  .tt .tt-val { font-weight: 660; color: var(--text-primary); font-variant-numeric: tabular-nums; }
  .tt .tt-name { color: var(--text-secondary); font-size: 12px; }

  /* ---------- table view ---------- */
  details.tv { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
  details.tv summary {
    cursor: pointer; font-size: 12.5px; color: var(--text-muted); list-style: none;
    display: inline-flex; align-items: center; gap: 6px; user-select: none;
  }
  details.tv summary::-webkit-details-marker { display: none; }
  details.tv summary::before { content: "▸"; font-size: 10px; transition: transform .15s; }
  details.tv[open] summary::before { transform: rotate(90deg); }
  details.tv summary:hover { color: var(--text-primary); }
  table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; }
  th, td { text-align: right; padding: 7px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
  th:first-child, td:first-child { text-align: left; font-variant-numeric: normal; }
  th { color: var(--text-muted); font-weight: 600; font-size: 12px; }
  td { color: var(--text-secondary); }
  td:first-child { color: var(--text-primary); }

  /* ---------- branch cards ---------- */
  .branch { position: relative; padding: 20px 22px 18px; overflow: hidden; }
  .branch::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--bc, var(--series-1));
  }
  .branch .ico { color: var(--bc, var(--series-1)); margin-bottom: 10px; display: block; }
  .branch .share { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
  .branch ul { margin: 10px 0 0; padding-left: 17px; font-size: 13px; color: var(--text-secondary); }
  .branch li { margin-bottom: 2px; }
  .branch .nums { display: flex; gap: 22px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }
  .branch .nums div { min-width: 0; }
  .branch .nums .k { font-size: 11.5px; color: var(--text-muted); }
  .branch .nums .v { font-size: 17px; font-weight: 640; letter-spacing: -0.015em; }

  /* ---------- chips ---------- */
  .chip {
    display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 620;
    padding: 2px 9px 2px 7px; border-radius: 999px; border: 1px solid var(--border);
    color: var(--text-primary); background: color-mix(in srgb, var(--cc) 12%, transparent);
    white-space: nowrap;
  }
  .chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cc); flex: none; }
  .chip.critical { --cc: var(--critical); }
  .chip.serious  { --cc: var(--serious); }
  .chip.warning  { --cc: var(--warning); }
  .chip.good     { --cc: var(--good); }

  /* ---------- threat rows ---------- */
  .threat { display: flex; gap: 18px; padding: 18px 22px; }
  .threat .rank {
    font-size: 26px; font-weight: 700; color: var(--deemph); line-height: 1;
    min-width: 34px; letter-spacing: -0.03em;
  }
  .threat .body { flex: 1; min-width: 0; }
  .threat .top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 5px; }
  .threat p { margin: 0; font-size: 14px; }
  .threat .mit { margin-top: 8px; font-size: 13px; color: var(--text-muted); }
  .threat .mit b { color: var(--good-text); font-weight: 620; }

  /* ---------- callout ---------- */
  .callout {
    border-left: 3px solid var(--series-1); background: color-mix(in srgb, var(--series-1) 6%, var(--surface-1));
    padding: 16px 20px; border-radius: 0 12px 12px 0; margin: 22px 0;
  }
  .callout p:last-child { margin-bottom: 0; }
  .callout.warn { border-left-color: var(--critical); background: color-mix(in srgb, var(--critical) 6%, var(--surface-1)); }

  ul.clean { margin: 0; padding-left: 19px; color: var(--text-secondary); }
  ul.clean li { margin-bottom: 7px; }

  footer {
    border-top: 1px solid var(--border); margin-top: 72px; padding: 28px 0 0;
    font-size: 12.5px; color: var(--text-muted);
  }
  footer a { color: var(--text-secondary); }

  @media print {
    .topbar, .themetoggle { display: none; }
    .card { break-inside: avoid; box-shadow: none; }
    details.tv[open] { break-inside: avoid; }
  }
