:root {
  color-scheme: light;
  --bg: #eef1f8;
  --bg-tint: #e3e8f6;
  --panel: #ffffff;
  --panel-strong: #f2f4fb;
  --ink: #1a1f2e;
  --ink-soft: #3b4256;
  --muted: #6b7280;
  --line: #dfe3ee;
  --line-soft: #e9ecf5;
  --accent: #4f46e5;
  --accent-dark: #4338ca;
  --accent-soft: rgba(79, 70, 229, 0.12);
  --warn: #e11d48;
  --chart: #0ea5e9;
  --chart-soft: #bae6fd;
  --success: #6366f1;
  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(28, 45, 39, 0.06), 0 1px 1px rgba(28, 45, 39, 0.04);
  --shadow: 0 1px 2px rgba(28, 45, 39, 0.05), 0 12px 28px -12px rgba(28, 45, 39, 0.18);
  --shadow-lg: 0 2px 4px rgba(28, 45, 39, 0.05), 0 24px 48px -18px rgba(28, 45, 39, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

.site-home {
  position: fixed;
  z-index: 2;
  top: 18px;
  left: 24px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.site-home span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--accent);
  font-size: 10px;
  letter-spacing: .04em;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 72px 24px 32px;
}

@media (max-width: 700px) {
  .site-home { left: 18px; top: 14px; }
  .app-shell { padding: 60px 14px 18px; }
}

.workspace {
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 24px;
  max-width: 1480px;
  margin: 0 auto;
}

.inputs-pane,
.content-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

.inputs-pane {
  align-self: start;
  padding: 24px;
  position: sticky;
  top: 32px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.inputs-pane::-webkit-scrollbar {
  width: 10px;
}

.inputs-pane::-webkit-scrollbar-thumb {
  background: var(--line);
  border: 3px solid var(--panel);
  border-radius: 999px;
}

.brand-row,
.group-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}

.group-title-row {
  align-items: center;
}

.group-title-row .secondary-action {
  min-height: 28px;
  padding: 0 11px;
  font-size: 12px;
  border-radius: 7px;
}

.brand-row > *,
.group-title-row > *,
.section-header > * {
  min-width: 0;
}

.section-header-copy {
  min-width: 0;
}

.section-header-copy-with-action {
  display: flex;
  align-items: start;
  gap: 12px;
}

.section-header-text {
  min-width: 0;
}

.section-header-copy-with-action .icon-action {
  margin-top: 2px;
}

.brand-row {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line-soft);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 23px;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  font-weight: 750;
}

p {
  color: var(--muted);
  line-height: 1.5;
}

.brand-row p {
  margin-top: 7px;
  font-size: 13.5px;
}

.primary-action,
.secondary-action,
.page-button,
.remove-flow {
  border: 1px solid transparent;
  border-radius: 10px;
  min-height: 40px;
  padding: 0 16px;
  font-weight: 700;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease, transform 80ms ease;
}

.primary-action:active,
.secondary-action:active,
.page-button:active {
  transform: translateY(1px);
}

.primary-action {
  background: linear-gradient(180deg, #5b53ea, var(--accent));
  color: #fff;
  min-width: 78px;
  box-shadow: 0 1px 1px rgba(67, 56, 202, 0.2), 0 8px 18px -8px rgba(67, 56, 202, 0.5);
}

.primary-action:hover {
  background: linear-gradient(180deg, #4f46e5, var(--accent-dark));
}

.primary-action.is-running {
  background: linear-gradient(180deg, #f43f5e, var(--warn));
  color: #fff;
}

.primary-action.is-running:hover {
  background: linear-gradient(180deg, #e11d48, #be123c);
}

.primary-action:disabled {
  background: #dde4df;
  border-color: #d2dad4;
  color: #8b988f;
  box-shadow: none;
  cursor: default;
}

.primary-action:disabled:hover {
  background: #dde4df;
}

.run-controls {
  display: grid;
  gap: 7px;
  justify-items: end;
  min-width: 172px;
}

.run-button-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.share-action {
  min-width: 78px;
}

.run-progress {
  width: 92px;
  height: 6px;
  overflow: hidden;
  background: #dce5e0;
  border-radius: 999px;
}

.run-progress > div {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--chart), var(--accent));
  border-radius: 999px;
  transition: width 120ms linear;
}

.run-progress-label {
  min-height: 14px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
}

.secondary-action,
.page-button {
  background: #fff;
  border-color: var(--line);
  color: var(--ink-soft);
}

.secondary-action:hover,
.page-button:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 4px 12px -8px rgba(79, 70, 229, 0.6);
}

.secondary-action:disabled {
  background: #f3f6f3;
  border-color: var(--line);
  color: #97a39d;
  box-shadow: none;
  cursor: default;
}

.secondary-action:disabled:hover {
  border-color: var(--line);
  color: #97a39d;
}

.page-button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 6px 16px -10px rgba(67, 56, 202, 0.8);
}

.page-button.active:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
  box-shadow: 0 6px 16px -10px rgba(67, 56, 202, 0.8);
}

form {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.control-group {
  display: grid;
  gap: 13px;
}

legend,
.legend-label {
  padding: 0;
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-dark);
}

legend {
  margin-bottom: 4px;
}

.control-group > label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  color: var(--ink);
  background: #fff;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

input:hover,
select:hover {
  border-color: #c5d1cb;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.flow-list {
  display: grid;
  gap: 12px;
}

.flow-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 11px;
  align-items: end;
  position: relative;
  padding: 14px;
  padding-right: 54px;
  background: var(--panel-strong);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}

.flow-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.flow-row label:first-child,
.flow-row label:nth-child(2) {
  grid-column: 1 / -1;
}

.flow-row input,
.flow-row select {
  min-height: 38px;
  padding-inline: 10px;
  min-width: 0;
}

.remove-flow {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  background: #fff;
  border-color: var(--line);
  color: var(--warn);
  font-size: 20px;
  line-height: 1;
  border-radius: 9px;
}

.remove-flow:hover {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

.results-pane {
  display: grid;
  gap: 22px;
  align-content: start;
  align-items: start;
  min-width: 0;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.page-button {
  flex: 0 0 auto;
  background: transparent;
  border-color: transparent;
  min-height: 36px;
}

.page-button:hover {
  box-shadow: none;
  background: var(--panel-strong);
}

.page-panel {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  min-width: 0;
}

.metric {
  display: grid;
  gap: 10px;
  min-height: 100px;
  padding: 18px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
  position: relative;
  overflow: hidden;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--chart));
  opacity: 0.85;
}

.metric span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.3;
  text-wrap: balance;
}

.metric strong {
  display: block;
  align-self: end;
  max-width: 100%;
  min-width: 0;
  font-size: clamp(19px, 1.9vw, 29px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-variant-numeric: tabular-nums;
}

.content-section {
  padding: 24px;
}

.methodology-page {
  width: 100%;
  min-width: 0;
}

.method-grid {
  display: block;
  width: 100%;
}

.method-grid article {
  padding: 16px 0;
  border-top: 1px solid var(--line-soft);
  min-width: 0;
}

.method-grid article:first-child {
  border-top: 0;
}

.method-grid h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.25;
  font-weight: 750;
  color: var(--accent-dark);
}

.method-grid p {
  margin-top: 7px;
  font-size: 14px;
  color: var(--muted);
  width: 100%;
  max-width: none;
  overflow-wrap: break-word;
  word-break: normal;
}

.section-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 16px;
  min-width: 0;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}

.section-header p {
  margin-top: 5px;
  font-size: 13.5px;
  line-height: 1.4;
}

.inspection-section .canvas-wrap {
  margin-bottom: 18px;
}

.policy-subsection {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.policy-subsection:first-of-type {
  margin-top: 0;
}

.policy-subsection h3 {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
}

.policy-subsection-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.policy-subsection-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: right;
  max-width: 720px;
}

.policy-bucket-picker {
  flex-basis: 320px;
}

.policy-metric-picker {
  flex-basis: 260px;
}

.policy-path-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

.policy-path-controls .simulation-picker {
  flex-basis: auto;
  min-width: 0;
}

.policy-path-canvas {
  height: min(44vh, 400px);
  min-height: 320px;
}

.policy-bucket-canvas {
  height: min(40vh, 360px);
  min-height: 300px;
}

.zoom-control {
  display: grid;
  gap: 6px;
  min-width: 190px;
}

.zoom-control span,
.simulation-picker span {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.simulation-picker {
  display: grid;
  flex: 0 1 220px;
  gap: 6px;
  min-width: 140px;
  max-width: 100%;
}

.section-toolbar {
  display: flex;
  align-items: start;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  flex: 0 0 auto;
  min-width: 0;
}

.simulation-picker select {
  width: 100%;
  max-width: 100%;
}

.icon-action {
  flex: 0 0 auto;
  width: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-action svg {
  width: 18px;
  height: 18px;
}

.zoom-control input[type="range"] {
  width: 100%;
  min-height: 20px;
  accent-color: var(--accent);
  padding: 0;
}

.zoom-control output {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.inline-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-strong);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  min-width: max-content;
}

.inline-toggle input {
  width: 18px;
  min-height: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.inline-toggle span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
}

.canvas-wrap {
  position: relative;
}

canvas {
  display: block;
  width: 100%;
  height: min(54vh, 460px);
  min-height: 320px;
  background: #fcfdff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

.detail-chart-canvas {
  height: min(40vh, 340px);
}

[hidden] {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

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

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

tbody tr:nth-child(even) {
  background: var(--panel-strong);
}

tbody tr:hover {
  background: var(--accent-soft);
}

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

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

th {
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: var(--panel-strong);
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .inputs-pane {
    position: static;
    max-height: none;
  }

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

@media (max-width: 640px) {
  .app-shell {
    padding: 16px 12px;
  }

  .inputs-pane,
  .content-section {
    padding: 16px;
  }

  .brand-row {
    align-items: stretch;
    flex-direction: column;
  }

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

  .primary-action {
    width: 100%;
  }

  .run-button-row .primary-action,
  .run-button-row .secondary-action {
    flex: 1 1 0;
  }

  .run-controls,
  .run-button-row {
    width: 100%;
  }

  .run-controls {
    justify-items: stretch;
  }

  .run-progress {
    width: 100%;
  }

  .section-toolbar {
    justify-content: stretch;
    width: 100%;
  }

  .policy-subsection-header {
    align-items: stretch;
    flex-direction: column;
  }

  .policy-subsection-header p {
    max-width: none;
    text-align: left;
  }

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

  .simulation-picker {
    flex: 1 1 auto;
    width: auto;
  }

  .flow-row {
    grid-template-columns: 1fr;
    padding-right: 54px;
  }

  .flow-row label:first-child,
  .flow-row label:nth-child(2) {
    grid-column: 1 / -1;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .method-grid {
    grid-template-columns: 1fr;
  }

  canvas {
    min-height: 300px;
  }
}
