:root {
  --bg: #f4efe4;
  --panel: rgba(255, 251, 244, 0.84);
  --panel-strong: rgba(255, 248, 238, 0.96);
  --ink: #1c1e1b;
  --muted: #5d625b;
  --line: rgba(32, 39, 31, 0.12);
  --accent: #005f73;
  --accent-soft: #7cc6b8;
  --warm: #ee9b00;
  --hot: #bb3e03;
  --shadow: 0 22px 60px rgba(38, 35, 20, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(238, 155, 0, 0.22), transparent 26%),
    radial-gradient(circle at top right, rgba(0, 95, 115, 0.16), transparent 24%),
    linear-gradient(180deg, #f9f5ee 0%, var(--bg) 60%, #efe6d6 100%);
}

.page-shell {
  width: min(2500px, 94vw);
  margin: 0 auto;
  padding: 12px 0 22px;
}

.masthead,
.panel,
.metric-card {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.masthead,
.panel {
  border-radius: 22px;
  padding: 18px;
}

.eyebrow,
.label,
.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--muted);
}

h1,
h2,
strong,
th {
  font-family: "Manrope", sans-serif;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(340px, 1.55fr) repeat(3, minmax(190px, 1fr));
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.toolbar-title h1 {
  margin: 2px 0 0;
  font-size: clamp(1.05rem, 1.45vw, 1.4rem);
  line-height: 1.02;
  max-width: none;
}

.hero-text,
.section-heading p,
.metric-note,
#summary-text {
  color: var(--muted);
  line-height: 1.5;
}

.toolbar-title .eyebrow {
  margin: 0;
}

.toolbar-chip {
  border-radius: 16px;
  padding: 9px 11px;
  background: linear-gradient(180deg, rgba(0, 95, 115, 0.08), rgba(255, 255, 255, 0.72));
  border: 1px solid rgba(32, 39, 31, 0.08);
}

.toolbar-chip strong {
  display: block;
  margin-top: 3px;
  font-size: 0.88rem;
  line-height: 1.18;
}

.tab-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.tab-button {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 251, 244, 0.72);
  color: var(--muted);
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.tab-button.is-active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr) minmax(300px, 350px);
  gap: 16px;
  align-items: start;
}

.workspace-sidebar {
  position: sticky;
  top: 16px;
}

.workspace-sidebar-right {
  align-self: start;
}

.workspace-main {
  display: grid;
  gap: 14px;
}

.controls-panel {
  background: var(--panel-strong);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 12px;
}

.section-heading h2 {
  margin: 0;
  font-size: 1.1rem;
}

.section-heading p {
  margin: 0;
  max-width: 48ch;
}

.section-heading-compact {
  display: grid;
  gap: 4px;
  align-items: start;
}

.section-heading-live {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.section-heading-live p {
  max-width: none;
}

.control-grid,
.metrics-grid,
.heatmap-grid {
  display: grid;
  gap: 12px;
}

.compact-controls {
  grid-template-columns: 1fr;
}

.control {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(32, 39, 31, 0.08);
}

.control span {
  font-weight: 700;
}

.control-conditional {
  max-height: 180px;
  opacity: 1;
  overflow: clip;
  transform: translateY(0);
  transition:
    max-height 240ms ease,
    opacity 180ms ease,
    transform 180ms ease,
    padding 240ms ease,
    margin 240ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.control-hint {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.82rem;
}

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

select {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: white;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
}

input[type="range"] {
  accent-color: var(--accent);
}

.control strong {
  font-family: "IBM Plex Mono", monospace;
  color: var(--accent);
}

.control.is-disabled {
  opacity: 0.48;
  background: rgba(255, 255, 255, 0.24);
}

.control.is-disabled input,
.control.is-disabled select {
  cursor: not-allowed;
}

.control-conditional.is-collapsed {
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  padding-top: 0;
  padding-bottom: 0;
  margin-top: -4px;
  margin-bottom: -4px;
  border-width: 0;
  pointer-events: none;
}

.metrics-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metrics-grid-dense {
  gap: 12px;
}

.metric-card {
  border-radius: 20px;
  padding: 16px;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.detail-panel-wide {
  grid-column: 1 / -1;
}

.detail-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.formula-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.formula-card {
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.46);
  border: 1px solid rgba(32, 39, 31, 0.08);
}

.formula-text {
  margin: 8px 0 0;
  color: var(--ink);
  line-height: 1.5;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
}

.metric-value {
  display: block;
  margin: 10px 0 6px;
  font-size: clamp(1.55rem, 2.4vw, 2.2rem);
  line-height: 1;
}

.legend-wrap {
  display: grid;
  gap: 8px;
}

.compact-panel {
  padding: 16px;
}

.legend-bar {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #f4d35e 0%, #7cc6b8 45%, #005f73 100%);
}

.legend-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.heatmap-grid-dense {
  align-items: start;
}

.heatmap {
  display: grid;
  gap: 4px;
}

.heatmap-row {
  display: grid;
  gap: 4px;
  grid-template-columns: 70px repeat(7, minmax(0, 1fr));
  align-items: center;
}

.heatmap-cell,
.heatmap-axis {
  min-height: 52px;
  border-radius: 16px;
  padding: 10px;
  display: flex;
  align-items: end;
  justify-content: start;
  position: relative;
  overflow: hidden;
}

.heatmap-axis {
  background: rgba(28, 30, 27, 0.06);
  color: var(--muted);
  font-size: 0.72rem;
  font-family: "IBM Plex Mono", monospace;
}

.heatmap-cell {
  color: white;
  font-weight: 800;
  font-size: 0.84rem;
  box-shadow: inset 0 -14px 24px rgba(0, 0, 0, 0.12);
}

.heatmap-cell small {
  position: absolute;
  top: 10px;
  left: 10px;
  opacity: 0.82;
  font-size: 0.68rem;
  font-weight: 500;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
}

td {
  color: var(--muted);
}

tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1080px) {
  .masthead,
  .section-heading-live,
  .workspace,
  .heatmap-grid,
  .metrics-grid,
  .control-grid,
  .details-grid,
  .formula-grid {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: grid;
    align-items: start;
  }

  .workspace-sidebar {
    position: static;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 10px, 2500px);
    padding-top: 10px;
  }

  .masthead,
  .panel,
  .metric-card {
    padding: 16px;
    border-radius: 18px;
  }

  .heatmap-row {
    grid-template-columns: 60px repeat(7, minmax(0, 1fr));
  }

  .heatmap-cell,
  .heatmap-axis {
    min-height: 46px;
    padding: 8px;
  }
}
