:root {
  color-scheme: light;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #182826;
  --muted: #52645e;
  --paper: #f5f6f1;
  --white: #fff;
  --line: #dce4db;
  --green: #175844;
  --green-ink: #124c3b;
  --green-bg: #eaf4ed;
  --red: #9c3e34;
  --red-bg: #fbefec;
  --focus: #38856d;
  --radius: 15px;
  --sidebar: 224px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--paper); color: var(--ink); }
a { color: var(--green-ink); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button:disabled { cursor: wait; opacity: .72; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.skip-link { position: fixed; z-index: 3; top: 8px; left: 8px; padding: 10px 14px; background: var(--white); transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); display: flex;
  flex-direction: column; padding: 28px 16px 20px; color: #ecf6ef; background: #182826;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 3px 10px 27px; color: inherit; text-decoration: none; font-weight: 760; font-size: 23px; letter-spacing: -.045em; line-height: 1.07; }
.brand small { display: block; margin-top: 6px; color: #aec1b8; font-size: 11px; font-weight: 520; letter-spacing: .015em; }
.brand-mark { display: flex; flex: none; gap: 3px; align-items: end; justify-content: center; width: 37px; height: 37px; padding: 9px; border-radius: 10px; background: #c8e9ad; }
.brand-mark i { width: 4px; height: 7px; border-radius: 2px; background: #23463a; }
.brand-mark i:nth-child(2) { height: 12px; }
.brand-mark i:nth-child(3) { height: 18px; }
.sidebar nav { display: grid; gap: 5px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 12px 13px; min-height: 46px; border: 1px solid transparent; border-radius: 9px; color: #bfcec7; text-decoration: none; font-weight: 580; font-size: .91rem; }
.sidebar nav a:hover { background: #223733; color: #fff; }
.sidebar nav a[aria-current] { background: #2b423b; border-color: #3d534a; color: #e8f7e9; }
.sidebar nav a span { font-size: 17px; width: 19px; text-align: center; line-height: 1; }
.sidebar-footer { display: flex; align-items: center; gap: 8px; margin-top: auto; padding: 15px 10px 1px; border-top: 1px solid #3a4b45; color: #aec1b8; font-size: .82rem; }
.mode-dot { width: 7px; height: 7px; flex: none; border-radius: 50%; background: currentColor; }
.sidebar-footer .mode-dot { color: #afd897; }

.workspace { margin-left: var(--sidebar); }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 clamp(22px, 4vw, 54px); border-bottom: 1px solid var(--line); background: #fafbf7; }
.breadcrumb { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: .86rem; }
.breadcrumb strong { color: var(--ink); font-weight: 650; }
.status-badge, .source-tag { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid #d4e4d8; background: var(--green-bg); color: var(--green-ink); border-radius: 99px; font-weight: 620; font-size: .75rem; white-space: nowrap; }
.source-tag[data-source="demo"] { color: #6a4c21; background: #faf3e3; border-color: #ece1c7; }
main { max-width: 1440px; margin: 0 auto; padding: 35px clamp(22px, 4vw, 54px) 42px; }
.page-heading { margin-bottom: 24px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(2rem, 4vw, 3rem); line-height: 1.1; letter-spacing: -.05em; font-weight: 760; overflow-wrap: anywhere; }
h2 { font-size: 1.1rem; line-height: 1.3; letter-spacing: -.025em; }
.page-heading p { margin-top: 9px; color: var(--muted); max-width: 65ch; }
.simulation-grid, .tool-grid { display: grid; grid-template-columns: minmax(260px, .82fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.result-stack { display: grid; gap: 18px; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); box-shadow: 0 2px 4px #18282606; }
.configuration, .chart-panel, .outcomes, .tool-results { padding: 21px; }
.panel-heading { margin-bottom: 17px; }
.panel-heading p, .chart-heading p { margin-top: 4px; color: var(--muted); font-size: .84rem; }

form { display: grid; gap: 13px; }
.field { min-width: 0; display: grid; gap: 5px; }
label, legend { font-weight: 650; font-size: .88rem; }
small { color: var(--muted); font-size: .77rem; }
input:not([type=radio], [type=checkbox]), select, textarea {
  width: 100%; min-width: 0; min-height: 42px; padding: 8px 10px;
  background: #fcfdfa; border: 1px solid #cdd9ce; border-radius: 8px;
}
input[type=time], input[type=number], .metric strong, .summary-row dd { font-variant-numeric: tabular-nums; }
input[type=checkbox] { width: 19px; height: 19px; accent-color: var(--green); }
textarea { min-height: 104px; resize: vertical; }
.field-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.check-field { display: flex; gap: 7px; align-items: center; min-height: 44px; }
fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
legend { padding: 0; margin-bottom: 5px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.segmented label { display: block; position: relative; text-align: center; color: var(--muted); cursor: pointer; }
.segmented input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.segmented span { display: grid; place-items: center; min-height: 35px; border-radius: 6px; }
.segmented input:checked + span { color: var(--green-ink); background: var(--white); box-shadow: 0 1px 4px #1a382024; }
.segmented input:focus-visible + span { outline: 2px solid var(--focus); }
.primary { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 46px; margin-top: 4px; padding: 9px 12px; border: 1px solid var(--green); border-radius: 9px; background: var(--green); color: #fff; font-size: .9rem; font-weight: 680; text-align: left; }
.primary:hover:not(:disabled) { background: #104734; }
.primary span { font-size: 1.1rem; }
.simulation-status { color: var(--green-ink); font-size: .85rem; }
.simulation-status:empty { position: absolute; }
#simulation-form [aria-invalid="true"] { border-color: var(--red); }
.error { padding: 9px 11px; border: 1px solid #eed2cd; border-radius: 8px; background: var(--red-bg); color: var(--red); font-size: .85rem; overflow-wrap: anywhere; }

.chart-heading { display: flex; justify-content: space-between; align-items: start; gap: 8px 12px; flex-wrap: wrap; }
.chart-frame { position: relative; height: 236px; margin-top: 12px; }
#chart { display: block; width: 100%; height: 100%; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); text-align: center; padding: 12px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 5px 17px; margin: 4px 0 0; color: var(--muted); font-size: .79rem; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.legend-line { width: 16px; height: 3px; border-radius: 3px; background: #217054; }
.legend-band { width: 16px; height: 9px; border-radius: 3px; background: #c5e4cf; border: 1px solid #9fc9ad; }

.outcomes .panel-heading { margin-bottom: 12px; }
.outcome-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.metric { display: flex; flex-direction: column; justify-content: space-between; gap: 3px; min-width: 0; padding: 10px 13px; border-radius: 9px; }
.metric span { font-size: .8rem; font-weight: 650; }
.metric strong { font-size: clamp(1.15rem, 2.3vw, 1.85rem); line-height: 1.2; letter-spacing: -.045em; }
.gain { background: var(--green-bg); color: var(--green-ink); }
.loss { background: var(--red-bg); color: var(--red); }
.neutral { background: #eef0ec; color: #30433e; }
.summary-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 14px 0 0; padding-top: 13px; border-top: 1px solid var(--line); }
.summary-row dt { color: var(--muted); font-size: .8rem; }
.summary-row dd { margin: 2px 0 0; font-weight: 715; }
.method { margin-top: 18px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px; background: #f9faf6; }
.method summary { color: var(--green-ink); font-size: .9rem; font-weight: 650; }
.method p { max-width: 90ch; margin-top: 8px; color: var(--muted); font-size: .87rem; }

.back-link { display: inline-block; margin-bottom: 7px; font-size: .86rem; font-weight: 620; }
.tool-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(250px, 100%), 1fr)); gap: 12px; }
.tool-card { display: flex; flex-direction: column; gap: 6px; padding: 17px; text-decoration: none; color: var(--ink); }
.tool-card:hover { border-color: #8eae9e; background: #f9fdf9; }
.tool-card small { font-size: .88rem; }
.tool-card > span { color: var(--green); font-size: .83rem; font-weight: 650; margin-top: auto; }
.tool-results .panel-heading { margin-bottom: 12px; }
#tool-status, #catalog-status { color: var(--muted); }
#tool-output p { margin-bottom: 10px; overflow-wrap: anywhere; }
.table-scroll { overflow-x: auto; margin: 7px 0; }
table { border-collapse: collapse; width: 100%; font-size: .84rem; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { color: var(--muted); background: var(--paper); font-weight: 650; }
td { max-width: 370px; }
.result-detail { margin-top: 12px; }
.result-detail summary { color: var(--green-ink); font-weight: 650; }
pre { max-height: 420px; overflow: auto; padding: 10px; background: var(--paper); border-radius: 8px; font: .78rem/1.5 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 980px) {
  :root { --sidebar: 174px; }
  .chart-frame { height: 205px; }
  .configuration, .chart-panel, .outcomes, .tool-results { padding: 16px; }
}
@media (max-width: 820px) {
  :root { --sidebar: 0px; }
  .sidebar { position: static; width: auto; padding: 10px 16px 8px; }
  .brand { padding: 2px 0 10px; font-size: 20px; }
  .brand-mark { width: 31px; height: 31px; padding: 6px; }
  .brand small { display: inline; margin-left: 8px; }
  .sidebar nav { display: flex; gap: 4px; flex-wrap: wrap; }
  .sidebar nav a { font-size: .84rem; justify-content: center; padding: 7px 8px; min-height: 44px; }
  .sidebar nav a span { display: none; }
  .sidebar-footer { display: none; }
  .topbar { height: 44px; }
}
@media (max-width: 640px) {
  .simulation-grid, .tool-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  main { padding: 23px 14px 25px; }
  .topbar { padding: 0 14px; }
  .page-heading { margin-bottom: 16px; }
  #simulation-form { gap: 8px; }
  .configuration .panel-heading { margin-bottom: 13px; }
  .result-stack { gap: 12px; }
}
@media (max-width: 360px) {
  .metric { padding: 8px 6px; }
  .metric span, .summary-row dt { font-size: .74rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
