:root {
  --bg: #f9fafb;
  --card: #fff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #6366f1;
  --accent-ink: #fff;
  --radius: 12px;
  --pill: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  --side-bg: #111827;
  --side-ink: #f9fafb;
  --side-line: #374151;
  --tile-bg: #f9fafb;
  --grid: #eef0f3;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  /* Горизонты риска: чем ближе горизонт, тем темнее и тревожнее цвет.
     Шкала одного оттенка, проверена валидатором палитры (различимость при дальтонизме). */
  --s1: #7f1d1d;
  --s2: #b91c1c;
  --s3: #ef4444;
  --s4: #fb923c;
  --label-ink: #fff;
  /* Области диаграммы исходов: событие интереса — акцентный красный, конкурирующая смерть —
     нейтральный серый, оставшиеся живыми — самый светлый тон. */
  --c-cvd: #b91c1c;
  --c-other: #94a3b8;
  --c-alive: #e8eaee;
  --c-on-dark: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.shell { display: grid; grid-template-columns: 330px 1fr; min-height: 100vh; }
.side { background: var(--side-bg); color: var(--side-ink); padding: 28px 24px; }
.side .brand { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; opacity: .6; font-weight: 600; margin-bottom: 18px; }
.side h2 { color: var(--side-ink); opacity: .6; }
.top { padding: 28px 0 8px; }
h1 { font: 650 24px/1.25 var(--font); margin: 6px 0 8px; letter-spacing: -.01em; }
.sub { margin: 0; opacity: .8; max-width: 70ch; }
h2 { font-size: 13px; margin: 0 0 16px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 650; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); }
.form-group { margin: 0 0 18px; }
.control-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 8px; color: var(--side-ink); }
.shiny-options-group { display: flex; gap: 8px; flex-wrap: wrap; }
.radio label { position: relative; display: inline-flex; align-items: center; padding: 8px 16px; border: 1px solid var(--side-line); border-radius: var(--pill); cursor: pointer; font-size: 15px; background: transparent; color: var(--side-ink); }
.radio input { position: absolute; opacity: 0; width: 0; height: 0; }
.radio label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.radio label:has(input:focus-visible) { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
input[type=number] { width: 100%; max-width: 220px; font: inherit; padding: 9px 12px; border: 1px solid var(--side-line); border-radius: 8px; background: transparent; color: var(--side-ink); }
input[type=number]:focus { outline: 2px solid var(--accent); border-color: transparent; }
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.tile { border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; padding: 12px 14px; background: var(--tile-bg); }
.tile .val { font: 700 26px var(--font); line-height: 1.2; }
.tile .lab { font-size: 13px; color: var(--muted); }
#chart { display: block; width: 100%; height: 400px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.key { display: inline-flex; align-items: center; gap: 7px; }
.sw { width: 12px; height: 12px; border-radius: 3px; background: var(--k); border: 1px solid rgba(0, 0, 0, .08); }
.caption { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.sr-only { position: absolute; left: -9999px; }
.foot { color: var(--muted); font-size: 13px; padding: 8px 24px 40px; }
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; min-height: auto; }
  .side { padding: 20px 18px; }
  .top { padding: 20px 0 4px; }
  .card { padding: 18px; }
  .tiles { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  h1 { font-size: 21px; }
}
