:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-strong: #eef3f8;
  --ink: #17202a;
  --muted: #627084;
  --border: #dbe3ed;
  --blue: #2563eb;
  --teal: #0f9f8f;
  --green: #258a55;
  --amber: #c98211;
  --red: #ca3f3a;
  --violet: #7657c8;
  --shadow: 0 14px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
select,
table {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 18px;
}

.eyebrow,
.panel-kicker,
.control-label,
.select-label span,
.kpi-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.98;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.meta-pill {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  padding: 10px 14px;
  color: var(--muted);
  font-size: 0.92rem;
  box-shadow: var(--shadow);
}

.kpi-grid,
.dashboard-grid,
.insight-grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card,
.panel,
.control-strip,
.disclaimer {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.kpi-card {
  min-height: 128px;
  padding: 18px;
  border-top: 4px solid var(--blue);
}

.kpi-card:nth-child(2) {
  border-top-color: var(--teal);
}

.kpi-card:nth-child(3) {
  border-top-color: var(--amber);
}

.kpi-card.accent {
  border-top-color: var(--red);
}

.kpi-card strong {
  display: block;
  margin-top: 16px;
  font-size: clamp(1.8rem, 3vw, 2.8rem);
  line-height: 1;
}

.kpi-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
}

.control-group,
.select-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-strong);
}

.segmented button {
  min-width: 64px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  font-weight: 700;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--ink);
  color: #ffffff;
}

select {
  min-width: 170px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 9px 12px;
}

.index-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
  font-weight: 700;
}

.chip input {
  accent-color: var(--blue);
}

.dashboard-grid {
  grid-template-columns: 1.4fr 0.9fr;
  align-items: stretch;
}

.insight-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

.wide {
  grid-row: span 2;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  min-height: 48px;
}

.panel-note {
  color: var(--muted);
  font-size: 0.86rem;
  text-align: right;
}

.chart-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 430px;
  margin-top: 12px;
}

.chart-wrap.compact {
  height: 276px;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.chart-wrap > svg {
  flex: 1 1 auto;
}

.axis-line,
.grid-line {
  stroke: #dfe7f0;
  stroke-width: 1;
}

.grid-line {
  stroke-dasharray: 3 5;
}

.axis-label {
  fill: var(--muted);
  font-size: 11px;
}

.line-path {
  fill: none;
  stroke-width: 2.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.scatter-dot {
  stroke: #ffffff;
  stroke-width: 2;
}

.chart-label {
  fill: var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.heatmap {
  display: grid;
  grid-template-columns: repeat(12, minmax(22px, 1fr));
  gap: 6px;
  margin-top: 12px;
}

.heat-cell {
  display: grid;
  min-height: 39px;
  place-items: center;
  border-radius: 6px;
  color: #ffffff;
  font-size: 0.72rem;
  font-weight: 800;
}

.brief-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.brief-item {
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: var(--surface-strong);
  padding: 12px;
}

.brief-item:nth-child(2) {
  border-left-color: var(--teal);
}

.brief-item:nth-child(3) {
  border-left-color: var(--amber);
}

.brief-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.98rem;
}

.brief-item span {
  color: var(--muted);
  font-size: 0.86rem;
}

.table-panel {
  margin-top: 16px;
}

.table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 12px 10px;
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  user-select: none;
  cursor: pointer;
}

td {
  font-size: 0.92rem;
}

.score-pill,
.regime-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 68px;
  border-radius: 999px;
  padding: 6px 9px;
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 800;
}

.regime-pill {
  min-width: 116px;
}

.disclaimer {
  margin-top: 16px;
  padding: 14px 16px;
  color: var(--muted);
  line-height: 1.55;
}

.disclaimer strong {
  color: var(--ink);
}

@media (max-width: 1100px) {
  .kpi-grid,
  .dashboard-grid,
  .insight-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wide {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .control-strip,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .meta-pill,
  .panel-note {
    text-align: left;
  }

  .kpi-grid,
  .dashboard-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .control-group,
  .select-label {
    align-items: stretch;
    flex-direction: column;
  }

  .segmented,
  select {
    width: 100%;
  }

  .segmented button {
    flex: 1 1 0;
    min-width: 0;
    padding-inline: 8px;
  }

  .chart-wrap {
    height: 320px;
  }

  .chart-wrap.compact {
    height: 300px;
  }
}
