:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --surface: #ffffff;
  --paper: #f5f7fb;
  --navy: #19324d;
  --teal: #0f766e;
  --amber: #b7791f;
  --red: #c2413b;
  --blue: #2f6fbb;
  --green: #237a57;
  --shadow: 0 18px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

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

.topbar,
.section-heading,
.control-band,
.summary-grid,
.workspace {
  display: grid;
  gap: 16px;
}

.topbar {
  grid-template-columns: 1fr auto;
  align-items: end;
  padding: 18px 0 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 760px;
  font-size: clamp(2rem, 5vw, 4.6rem);
  line-height: 0.95;
}

h2 {
  font-size: 1.15rem;
}

.source-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.source-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.control-band {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.control-group {
  min-width: 0;
}

.control-group label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.control-group input,
.control-group select {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c8d2dd;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.metric,
.risk-panel,
.recommendation-panel,
.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  min-height: 128px;
  padding: 18px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
}

.metric strong {
  display: block;
  margin: 12px 0 4px;
  font-size: 2.25rem;
  line-height: 1;
}

.workspace {
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.8fr);
  align-items: stretch;
}

.risk-panel,
.recommendation-panel,
.table-section {
  padding: 18px;
}

.section-heading {
  grid-template-columns: 1fr auto;
  align-items: center;
  margin-bottom: 16px;
}

#sortButton {
  min-height: 38px;
  border: 1px solid var(--navy);
  border-radius: 6px;
  background: var(--navy);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 74px;
  gap: 12px;
  align-items: center;
}

.bar-label,
.bar-value {
  font-weight: 700;
  font-size: 0.9rem;
}

.bar-value {
  text-align: right;
}

.bar-track {
  position: relative;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8edf3;
}

.bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
}

.recommendations {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recommendations li {
  border-left: 4px solid var(--line);
  padding: 4px 0 6px 12px;
}

.recommendations strong {
  display: block;
  margin-bottom: 3px;
}

.recommendations span {
  color: var(--muted);
  font-size: 0.92rem;
}

.table-section {
  margin-top: 18px;
}

.table-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 13px 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

td:not(:first-child) {
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
}

.risk-critical {
  background: var(--red);
}

.risk-high {
  background: var(--amber);
}

.risk-watch {
  background: var(--blue);
}

.risk-healthy {
  background: var(--green);
}

@media (max-width: 900px) {
  .topbar,
  .control-band,
  .summary-grid,
  .workspace {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  .source-pill {
    width: max-content;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .section-heading {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 74px 1fr 58px;
    gap: 8px;
  }
}
