:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-strong: #eff3f0;
  --text: #18211f;
  --muted: #68736f;
  --line: #d9e0dc;
  --teal: #287c78;
  --teal-dark: #195c59;
  --rose: #c4475f;
  --amber: #d18722;
  --violet: #6e56cf;
  --radius: 8px;
  --shadow: 0 18px 50px rgba(29, 43, 39, 0.11);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(40, 124, 120, 0.1), transparent 320px),
    var(--bg);
}

a {
  color: var(--teal-dark);
  text-decoration-color: rgba(40, 124, 120, 0.32);
  text-underline-offset: 3px;
}

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

.app-header,
.panel-heading,
.summary-grid,
.workspace-grid,
.detail-grid,
.assumption-strip,
.source-footer {
  width: 100%;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

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

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  font-size: 1.02rem;
}

h3 {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.rule-badge {
  flex: 0 0 auto;
  padding: 8px 11px;
  border: 1px solid rgba(40, 124, 120, 0.35);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

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

.metric-card,
.control-panel,
.chart-panel,
.detail-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

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

.metric-card span,
.panel-heading span,
.legend-item small,
dt {
  color: var(--muted);
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  font-size: 0.84rem;
  font-weight: 700;
}

.metric-card strong {
  display: block;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(340px, 0.92fr) minmax(360px, 1.08fr);
  gap: 14px;
  align-items: start;
}

.control-panel,
.chart-panel,
.detail-panel {
  padding: 18px;
}

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

.panel-heading span {
  flex: 0 0 auto;
  font-size: 0.86rem;
  font-weight: 700;
}

.control-group {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.control-group:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(92px, auto);
  gap: 9px 12px;
  align-items: center;
  margin-top: 14px;
}

.control-row label {
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 750;
}

.control-row output {
  color: var(--teal-dark);
  font-size: 0.9rem;
  font-weight: 850;
  text-align: right;
}

.control-row input[type="range"] {
  grid-column: 1;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  appearance: none;
  outline: none;
}

.control-row input[type="range"]::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  appearance: none;
  background: var(--teal);
  box-shadow: 0 4px 14px rgba(25, 92, 89, 0.35);
  cursor: pointer;
}

.control-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 999px;
  background: var(--teal);
  box-shadow: 0 4px 14px rgba(25, 92, 89, 0.35);
  cursor: pointer;
}

.number-input {
  grid-column: 2;
  width: 112px;
  min-height: 36px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  background: var(--surface-strong);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 700;
}

.split-control input[type="range"] {
  box-shadow: 0 0 18px rgba(49, 191, 167, 0.2);
}

.optimal-band {
  grid-column: 1;
  display: flex;
  justify-content: space-between;
  width: 4%;
  min-width: 52px;
  margin-left: 11%;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.chart-panel {
  min-height: 100%;
}

.chart-wrap {
  display: grid;
  place-items: center;
  min-height: 340px;
}

.doughnut-chart {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 360px);
  aspect-ratio: 1;
  border-radius: 50%;
  transition: background 140ms ease;
}

.doughnut-chart::after {
  position: absolute;
  width: 58%;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  content: "";
}

.chart-center {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  width: 46%;
  text-align: center;
}

.chart-center span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.chart-center strong {
  font-size: clamp(1rem, 3vw, 1.55rem);
}

.chart-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

.legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.legend-label {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
  font-weight: 760;
}

.legend-item strong {
  font-size: 0.86rem;
}

.legend-item small {
  grid-column: 2 / 4;
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(230px, 0.65fr) minmax(230px, 0.65fr) minmax(700px, 1.7fr);
  gap: 14px;
  margin-top: 14px;
}

.snapshot-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.snapshot-list div {
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-strong);
}

dt {
  margin-bottom: 8px;
  font-size: 0.82rem;
  font-weight: 800;
}

dd {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 850;
}

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

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

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

th:first-child,
td:first-child {
  text-align: left;
}

thead th {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

tbody th {
  font-size: 0.88rem;
  font-weight: 800;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
  color: var(--teal-dark);
  font-weight: 900;
}

.assumption-strip,
.source-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.assumption-strip span,
.source-footer a {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
  font-weight: 750;
}

@media (max-width: 1060px) {
  .summary-grid,
  .workspace-grid,
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-panel,
  .family-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 18px;
  }

  .app-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-grid,
  .workspace-grid,
  .detail-grid,
  .snapshot-list,
  .chart-legend {
    grid-template-columns: 1fr;
  }

  .control-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .control-row output {
    text-align: left;
  }

  .control-row input[type="range"],
  .number-input,
  .optimal-band {
    grid-column: 1;
  }

  .number-input {
    width: 100%;
  }

  .chart-wrap {
    min-height: 270px;
  }
}
