:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --ink: #1b2528;
  --muted: #667274;
  --line: #dce3e5;
  --panel: #ffffff;
  --accent: #17746d;
  --blue: #2474a6;
  --warn: #b8402a;
  --low: #dde9ee;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 4vw, 38px);
}

h2 {
  font-size: 18px;
}

h3 {
  margin: 16px 0 0;
  font-size: 15px;
}

.source {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.language-control {
  display: flex;
  align-items: center;
  gap: 6px;
}

.language-control select {
  width: auto;
  min-width: 108px;
  height: 32px;
}

main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 24px 40px;
}

.controls,
.kpis,
.split {
  display: grid;
  gap: 12px;
}

.controls {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="range"] {
  width: 100%;
}

select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  padding: 0 12px;
}

select:disabled,
input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.threshold-control {
  grid-column: span 2;
  grid-template-columns: max-content minmax(120px, 1fr) auto;
  align-items: center;
}

.threshold-control input {
  min-width: 140px;
}

.threshold-control output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.kpis {
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  margin-bottom: 16px;
}

.kpis article,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpis article {
  padding: 16px;
}

.kpis span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpis strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 20px;
  margin-bottom: 14px;
}

.panel-head p,
.note p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.type-defs {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 12px;
  margin: 10px 0 0;
  font-size: 13px;
}

.source-links {
  display: grid;
  gap: 4px;
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 13px;
}

.type-defs dt {
  color: var(--ink);
  font-weight: 700;
}

.type-defs dd {
  margin: 0;
  color: var(--muted);
}

.source-note {
  font-size: 12px;
}

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.legend-bar {
  width: 148px;
  height: 10px;
  border-radius: 99px;
  background: linear-gradient(90deg, #e9f0f2, #f4d384, #c7442f, #62221d);
}

.heatmap-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.heatmap {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 11px;
}

.heatmap th,
.heatmap td {
  border-right: 1px solid rgba(255, 255, 255, .55);
  border-bottom: 1px solid rgba(255, 255, 255, .55);
  padding: 0;
  text-align: center;
}

.heatmap th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 34px;
  background: #edf2f3;
  color: #344043;
  font-weight: 700;
  white-space: nowrap;
}

.heatmap th:first-child,
.heatmap td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  min-width: 68px;
  background: #fff;
  color: #344043;
  font-weight: 700;
  border-right: 1px solid var(--line);
}

.heatmap td {
  min-width: 48px;
  height: 34px;
  color: #172022;
  font-variant-numeric: tabular-nums;
}

.cell {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 34px;
  padding: 3px;
}

.cell small {
  display: block;
  color: rgba(23, 32, 34, .74);
  font-size: 9px;
}

.split {
  grid-template-columns: minmax(280px, 1fr) minmax(280px, .9fr);
  margin-top: 16px;
}

.alerts {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.alert {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfc;
}

.alert b {
  display: block;
}

.alert span {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 860px) {
  .topbar,
  .panel-head {
    display: grid;
  }

  .source {
    flex-wrap: wrap;
    white-space: normal;
  }

  main {
    padding: 16px;
  }

  .controls,
  .kpis,
  .split {
    grid-template-columns: 1fr;
  }

  .threshold-control {
    grid-column: auto;
    grid-template-columns: 1fr auto;
  }

  .threshold-control input {
    grid-column: 1 / -1;
  }

  .type-defs {
    grid-template-columns: 1fr;
  }

  .type-defs dd {
    margin-bottom: 4px;
  }
}
