:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #18212f;
  --muted: #687384;
  --line: #dce1e8;
  --teal: #087d73;
  --blue: #2d5f93;
  --coral: #c95f46;
  --gold: #ad7b12;
  --green: #2f7d4c;
  --shadow: 0 1px 2px rgba(24, 33, 47, 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;
  line-height: 1.45;
}

button, input, select { font: inherit; }

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

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

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(24px, 3vw, 36px); line-height: 1.08; }
h2 { margin-bottom: 4px; font-size: 17px; }
h3 { margin: 14px 0 8px; font-size: 14px; }

.source-note {
  max-width: 720px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

main { padding: 18px 28px 36px; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.tabs { display: flex; flex-wrap: wrap; gap: 6px; }

.tab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 12px;
  cursor: pointer;
}

.tab.active { background: var(--ink); border-color: var(--ink); color: #ffffff; }

.search-control, .controls-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.filter-controls { display: flex; align-items: end; gap: 12px; }

.search-control input, .search-control select, .controls-row input, .controls-row select {
  min-height: 36px;
  width: min(320px, 100%);
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 10px;
  text-transform: none;
  font-weight: 500;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.kpi {
  min-height: 88px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 12px;
}

.kpi .label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }
.kpi .value { margin-top: 7px; font-size: 26px; font-weight: 800; line-height: 1; }
.kpi .hint { margin-top: 8px; color: var(--muted); font-size: 12px; }

.view { display: none; }
.view.active { display: block; }
.view > .panel + .panel { margin-top: 14px; }

.layout { display: grid; gap: 14px; margin-bottom: 14px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide-left { grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr); }

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.panel-heading p { margin-bottom: 0; color: var(--muted); font-size: 13px; text-align: right; }
.panel-heading.with-control { align-items: end; }
.panel-heading.with-control label {
  display: grid;
  gap: 5px;
  min-width: 140px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.panel-heading.with-control input,
.panel-heading.with-control select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 7px 10px;
  font-weight: 500;
}
.controls-row { display: flex; align-items: end; gap: 12px; margin-bottom: 14px; }

.bar-list { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 180px) minmax(120px, 1fr) 82px; gap: 10px; align-items: center; min-height: 34px; }
.bar-row .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.bar-track { height: 10px; border-radius: 999px; background: #e9edf2; overflow: hidden; }
.bar-fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--teal); }
.bar-row:nth-child(3n+1) .bar-fill { background: var(--blue); }
.bar-row:nth-child(3n+2) .bar-fill { background: var(--coral); }
.bar-value { color: var(--muted); font-variant-numeric: tabular-nums; text-align: right; }
.dense .bar-row { grid-template-columns: 54px minmax(120px, 1fr) 78px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #f9fafc; color: var(--muted); font-size: 11px; text-transform: uppercase; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: 0; }

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: inherit;
  gap: 4px;
  width: 100%;
  min-height: 22px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  text-align: inherit;
  text-transform: inherit;
  cursor: pointer;
}

.sort-button.active { color: var(--ink); }
.sort-button span { min-width: 30px; color: var(--teal); font-size: 10px; text-transform: none; }

.table-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.pagination-buttons button,
.table-reset {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 5px 9px;
  cursor: pointer;
}

.pagination-buttons button:disabled {
  color: #a4acb8;
  cursor: default;
}

.table-reset {
  color: var(--blue);
  font-weight: 700;
}

.link { color: var(--blue); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }

.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge { border: 1px solid var(--line); border-radius: 999px; background: #f7f9fb; color: var(--muted); padding: 2px 7px; font-size: 12px; }
.badge.hit { border-color: rgba(8, 125, 115, 0.35); background: rgba(8, 125, 115, 0.08); color: var(--teal); }

.definitions { display: grid; gap: 12px; margin: 0; }
.definitions dt { font-weight: 800; }
.definitions dd { margin: 2px 0 0; color: var(--muted); }

.requirement-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.requirement-summary > div {
  min-height: 78px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafc;
  padding: 11px;
}

.requirement-summary .label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.requirement-summary strong {
  display: block;
  margin-top: 4px;
}

.requirement-summary span:last-child {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.compact-table th,
.compact-table td {
  padding-top: 7px;
  padding-bottom: 7px;
}

.heatmap { overflow: auto; }
.heatmap-grid { display: grid; grid-template-columns: 64px repeat(24, minmax(34px, 1fr)); gap: 3px; min-width: 980px; }
.heat-cell, .heat-head, .heat-day { min-height: 30px; display: grid; place-items: center; border-radius: 4px; font-size: 11px; font-variant-numeric: tabular-nums; }
.heat-head, .heat-day { color: var(--muted); font-weight: 700; }
.heat-cell { background: #edf1f5; color: #15202d; cursor: default; }
.empty-state { border: 1px dashed var(--line); border-radius: 8px; color: var(--muted); padding: 18px; text-align: center; }

.detail-main { max-width: 1500px; margin: 0 auto; }
.detail-header .eyebrow a { color: inherit; }
.detail-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: 18px; align-items: start; }
.detail-copy { min-width: 0; display: grid; gap: 12px; }
.detail-description { margin: 0; max-width: 980px; color: var(--ink); }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.scenario-cover { min-height: 220px; border: 1px solid var(--line); border-radius: 8px; background: #f7f9fb; overflow: hidden; }
.scenario-cover img { display: block; width: 100%; height: 100%; max-height: 320px; object-fit: cover; }
.chart-wrap { overflow: auto; }
.chart { display: block; width: 100%; min-width: 520px; height: auto; }
.chart-bg { fill: #f9fafc; stroke: var(--line); }
.chart-grid-line { stroke: #e2e7ee; stroke-width: 1; }
.chart-axis-label { fill: var(--muted); font-size: 11px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; }
.legend-item i { display: inline-block; width: 10px; height: 10px; border-radius: 999px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .two-col, .wide-left, .detail-hero { grid-template-columns: 1fr; }
  .panel-heading { display: block; }
  .panel-heading.with-control { display: grid; gap: 10px; }
  .panel-heading p { text-align: left; }
}

@media (max-width: 720px) {
  .app-header, .toolbar, .controls-row, .filter-controls { display: grid; }
  .source-note { text-align: left; }
  main, .app-header { padding-left: 16px; padding-right: 16px; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: minmax(82px, 120px) minmax(90px, 1fr) 64px; }
  .requirement-summary { grid-template-columns: 1fr; }
}
