:root {
  --ink: #edf4f7;
  --muted: #8ca1af;
  --line: #26384b;
  --paper: #071521;
  --surface: #0d1728;
  --surface-2: #101c2f;
  --rf: #ff7b6b;
  --ua: #43c9ed;
  --gold: #e9bd62;
  --green: #39d1a3;
  --accent: #43c9ed;
  --dark: #08131f;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% 17%, rgba(21, 88, 81, .22), transparent 31rem),
    radial-gradient(circle at 3% 3%, rgba(18, 76, 101, .2), transparent 34rem),
    var(--paper);
  font: 15px/1.45 "IBM Plex Sans", "Noto Sans", sans-serif;
}
button, select, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.site-header { color: var(--ink); }
.header-inner, main, footer { width: min(1440px, calc(100% - 48px)); margin-inline: auto; }
.header-inner { min-height: 128px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
h1 { margin: 0 0 4px; font-size: clamp(30px, 3.4vw, 46px); line-height: 1.04; letter-spacing: -.035em; font-weight: 800; white-space: nowrap; }
.site-header p { margin: 0; color: var(--muted); font-size: 14px; }
.update-state { max-width: 300px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; background: rgba(10, 22, 38, .72); color: var(--muted); text-align: right; font-size: 12px; }

main { padding-block: 0 40px; }
.controls { border: 0; background: transparent; }
.control-group { padding: 0; }
.control-label, .filter-row > label, .date-range label, .granularity-label {
  color: var(--muted);
  font-size: 12px;
  line-height: 18px;
}
.control-label { display: block; margin-bottom: 6px; }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 8px 0 12px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab.is-active { border-color: var(--accent); color: var(--ink); font-weight: 700; }

.filter-row {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) minmax(410px, 2fr) max-content max-content;
  align-items: end;
  gap: 16px;
  padding: 18px 0 4px;
}
.filter-row > label, .date-range label {
  display: grid;
  grid-template-rows: 18px 42px;
  gap: 5px;
}
select, input[type="date"] {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
select { min-width: 190px; padding: 0 34px 0 12px; }
input[type="date"] { min-width: 145px; padding: 0 11px; }
select:hover, input[type="date"]:hover { border-color: #38516a; }
.date-range {
  position: relative;
  display: grid;
  grid-template-columns: minmax(145px, 1fr) minmax(145px, 1fr) auto;
  align-items: end;
  gap: 8px;
}
.apply-button {
  height: 42px;
  padding: 0 16px;
  border: 1px solid #2b7188;
  border-radius: 8px;
  background: #123247;
  color: #eafaff;
  font-weight: 650;
}
.apply-button:hover { background: #173e55; }
.filter-error { position: absolute; top: 68px; left: 0; color: var(--rf); font-size: 12px; line-height: 1.2; white-space: nowrap; }
.granularity {
  display: grid;
  grid-template-columns: repeat(4, auto);
  grid-template-rows: 18px 42px;
  gap: 5px 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.granularity-label { grid-column: 1 / -1; display: block; margin: 0; padding: 0; }
.granularity button { min-width: 58px; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-right: 0; background: var(--surface); color: var(--muted); }
.granularity button:first-of-type { border-radius: 8px 0 0 8px; }
.granularity button:last-of-type { border-right: 1px solid var(--line); border-radius: 0 8px 8px 0; }
.granularity button:hover { color: var(--ink); background: var(--surface-2); }
.granularity button.is-active { background: #14374b; color: #eafaff; border-color: #2b7188; }
.reset-button, .text-button { border: 0; background: transparent; color: #a8bac4; text-decoration: underline; text-underline-offset: 4px; }
.reset-button { height: 42px; padding: 0 4px; align-self: end; }
.reset-button:hover, .text-button:hover { color: var(--ink); }

.metrics { margin-top: 18px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metrics article { min-height: 112px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 11px; background: rgba(13, 23, 40, .94); display: grid; align-content: center; gap: 8px; }
.metrics span { color: var(--muted); font-size: 12px; }
.metrics strong { color: var(--ink); font-size: clamp(27px, 3vw, 38px); line-height: 1; font-variant-numeric: tabular-nums; }
.metrics article:nth-child(1) strong { color: var(--rf); }
.metrics article:nth-child(2) strong { color: var(--ua); }

.chart-section, .sources-section { margin-top: 16px; border: 1px solid var(--line); border-radius: 11px; background: rgba(13, 23, 40, .96); padding: 18px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.section-heading h2 { margin-bottom: 0; }
.section-heading > span { color: var(--muted); font-size: 12px; }
.chart-title { display: grid; gap: 3px; min-width: 0; }
.chart-title h2 { margin: 0; }
.chart-section > .chart-title { margin-bottom: 14px; }
.chart-period { display: block; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.3; }
.section-actions { display: flex; align-items: center; justify-content: flex-end; gap: 16px; }
.chart-kind-control { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.chart-kind-control select { width: auto; min-width: 116px; height: 34px; padding: 0 30px 0 10px; border-radius: 7px; }
h2 { margin: 0 0 14px; color: var(--ink); font-size: 17px; line-height: 1.25; }
h3 { margin: 0 0 10px; color: #dfe9ee; font-size: 14px; line-height: 1.25; }
.chart-wrap { position: relative; height: 340px; min-width: 0; }
.chart-large { height: 430px; }
.chart-note { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
.detail-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.comparison-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; }
.pie-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.pie-wrap { position: relative; height: 320px; min-width: 0; }
.type-summary-grid { display: grid; grid-template-columns: minmax(260px, .7fr) minmax(0, 1.3fr); gap: 16px; }
.type-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.type-summary-grid .type-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.type-total { padding: 12px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(16, 28, 47, .55); }
.type-total.is-total { background: rgba(20, 55, 75, .32); }
.type-total > span { display: block; min-height: 38px; color: var(--muted); font-size: 12px; }
.type-total strong { display: block; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.type-ratio { display: flex !important; align-items: baseline; gap: 5px; white-space: nowrap; }
.ratio-launched { color: var(--ink); }
.ratio-separator { color: #667c89; font-weight: 400; }
.ratio-neutralized { color: var(--accent); }
.type-ratio-note strong { color: #cbd8de; font-weight: 650; }
.type-ratio-note strong span { color: var(--accent); }
.ratio-example { color: var(--accent); font-weight: 650; white-space: nowrap; }
.is-hidden { display: none !important; }

.table-scroll { max-width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; color: #dbe6eb; font-size: 13px; font-variant-numeric: tabular-nums; }
th { padding: 9px 10px; border-bottom: 1px solid #385068; color: var(--muted); text-align: left; white-space: nowrap; font-weight: 650; }
td { padding: 9px 10px; border-bottom: 1px solid #1e3043; white-space: nowrap; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: rgba(33, 63, 80, .28); }
a { color: #69d3ef; text-underline-offset: 3px; }
.source-links { display: flex; gap: 10px; }

.methodology { margin-top: 16px; padding: 14px 16px; border: 1px solid #315245; border-left: 4px solid var(--green); border-radius: 8px; background: #0d211f; color: #a8c9bd; font-size: 13px; }
footer { padding: 18px 0 30px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; }

@media (max-width: 1120px) {
  .filter-row { grid-template-columns: minmax(190px, .8fr) minmax(410px, 1.6fr); }
  .granularity { justify-self: start; }
  .reset-button { justify-self: start; }
}

@media (max-width: 900px) {
  .header-inner { min-height: 112px; }
  h1 { white-space: normal; }
  .update-state { display: none; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .detail-grid, .comparison-grid { grid-template-columns: 1fr; }
  .type-summary-grid { grid-template-columns: 1fr; }
  .type-totals { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .header-inner, main, footer { width: min(100% - 24px, 1440px); }
  .header-inner { align-items: flex-start; padding-block: 24px; }
  .tabs { gap: 18px; }
  .filter-row { grid-template-columns: 1fr; gap: 12px; }
  .date-range { grid-template-columns: 1fr 1fr; }
  .apply-button { grid-column: 1 / -1; }
  .filter-error { position: static; grid-column: 1 / -1; white-space: normal; }
  .granularity { width: 100%; grid-template-columns: repeat(4, 1fr); }
  .granularity button { min-width: 0; padding: 0 7px; }
  .metrics { grid-template-columns: 1fr 1fr; gap: 8px; }
  .metrics article { min-height: 96px; padding: 13px; }
  .metrics strong { font-size: 24px; }
  .chart-section, .sources-section { padding: 14px 12px; }
  .chart-wrap, .chart-large { height: 330px; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .section-actions { width: 100%; justify-content: space-between; }
  .pie-grid { grid-template-columns: 1fr; }
  .pie-wrap { height: 260px; }
  .type-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { flex-direction: column; gap: 5px; }
}
