/*
:root {
  --bg: #f6f1e9;
  --fg: #2a2320;
  --muted: #6b615b;
  --card: #ffffff;
  --border: #e4ddd3;
  --primary: #b5561f;
  --accent: #f2e6d8;
}
*/
/*
:root {
  --bg: #F4F7FB;
  --fg: #172033;
  --muted: #5E6B7E;
  --card: #FFFFFF;
  --border: #D9E1EC;
  --primary: #2563EB;
  --accent: #E5EEF9;
}
*/
/*
:root {
--bg: #F4F7F2;
--fg: #1F2923;
--muted: #66736A;
--card: #FFFFFF;
--border: #DCE5DB;
--primary: #3F7656;
--accent: #E4F0E5;
}
*/

:root {
--bg: #F5F7FA;
--fg: #172338;
--muted: #667085;
--card: #FFFFFF;
--border: #D9E0EA;
--primary: #173B63;
--accent: #E8EEF5;
}

/*
:root {
  --bg: #111827;
--fg: #F3F4F6;
--muted: #9CA3AF;
--card: #1F2937;
--border: #374151;
--primary: #60A5FA;
--accent: #243B53;
}*/
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--fg);
}
/* split screen: scenarios scroll on the left, results scroll on the right */
body { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  display: flex; align-items: baseline; gap: 20px; flex-wrap: wrap;
  padding: 12px 24px; border-bottom: 1px solid var(--border); background: (--bg);
}
.topbar-main { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.topbar .eyebrow { margin: 0; }
.topbar h1 { font-size: 20px; }
.topbar-help { margin-left: 0; max-width: 100%; }
.topbar-help > summary {
  cursor: pointer; font-size: 12px; color: var(--primary); font-weight: 600;
}
.topbar-help p.lede { margin: 8px 0 0; font-size: 13px; max-width: 900px; }
.app {
  display: grid;
  grid-template-columns: minmax(0, var(--left-w, 55%)) 6px minmax(0, 1fr);
  flex: 1; min-height: 0;
}
.splitter {
  cursor: col-resize; background: var(--border);
  border-left: 1px solid var(--border); border-right: 1px solid var(--border);
}
.splitter:hover, .splitter.dragging { background: var(--primary); }
body.resizing { user-select: none; cursor: col-resize; }
.pane { overflow-y: auto; overflow-x: hidden; padding: 28px 24px 48px; }
.pane-left { background: (--bg); }
@media (max-width: 1000px) {
  .app { display: block; height: auto; }
  body { display: block; height: auto; }
  .pane { overflow: visible; height: auto; }
  .splitter { display: none; }
  .pane-left { border-bottom: 1px solid var(--border); }
}

header { margin-bottom: 32px; }
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: .2em; font-size: 12px; font-weight: 600; margin: 0 0 8px; }
h1 { margin: 0; font-size: 34px; letter-spacing: -0.02em; }
p.lede { color: var(--muted); max-width: 720px; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--accent); padding: 1px 6px; border-radius: 4px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
}
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); margin: 0 0 16px; }
h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 14px 0 8px; }
label { display: block; margin-bottom: 10px; }
label > span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 4px; }
.field {
  display: flex; align-items: center;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.field:focus-within { outline: 2px solid var(--primary); outline-offset: 1px; }
.field input {
  width: 100%; border: 0; outline: 0; padding: 8px 10px; background: transparent;
  font: inherit;
}
.field .suf { padding-right: 8px; color: var(--muted); font-size: 13px; }
.field .apply {
  border: 0; border-left: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 11px; padding: 6px 8px; cursor: pointer;
  border-radius: 0 8px 8px 0;
}
.field .apply:hover { background: var(--accent); color: var(--primary); }
.pill {
  border: 1px dashed var(--border); background: var(--bg); border-radius: 8px; padding: 8px 10px;
  margin-bottom: 10px;
}
.pill small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }
.pill div { font-weight: 600; font-variant-numeric: tabular-nums; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 6px; text-align: right; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
tbody tr { border-top: 1px solid var(--border); }
tbody tr:hover { background: var(--accent); }
.grouphead th { border-bottom: 1px solid var(--border); }
.divider { border-left: 1px solid var(--border); }
.num { font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
button {
  font: inherit; cursor: pointer; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; padding: 6px 12px; color: var(--fg);
}
button:hover { background: var(--accent); }
button.primary { background: var(--primary); color: #ffffff; border-color: var(--primary); }
button.primary:hover { filter: brightness(1.05); }
button.danger { color: #a13a1a; border-color: #e4c8bd; }
button.small { padding: 4px 10px; font-size: 13px; }
button.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.scenarios { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.scenario-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.scenario-head h3 { margin: 0; font-size: 15px; }
.toolbar { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 13px; color: var(--muted); }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 6px; }
#chart svg { display: block; height: 320px; max-width: 100%; }
.detail-block { margin-top: 16px; }
.detail-block h3 { font-size: 14px; margin: 0 0 8px; }

/* Events + Monte Carlo */
.events { margin-top: 10px; }
.event-row { display: grid; grid-template-columns: 60px 1fr 1fr 28px; gap: 6px; margin-bottom: 6px; align-items: center; }
.event-row input, .event-row select { font: inherit; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; background: #fff; width: 100%; }
.event-row button { padding: 4px 8px; font-size: 12px; }
.event-add { font-size: 12px; padding: 4px 10px; }
.mc-controls { align-items: end; }
.mc-field { margin: 0; min-width: 160px; }
#mcChart svg { display: block; height: 320px; max-width: 100%; }

/* Toggles, disabled groups, saved note */
.switch { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--primary); }
.switch > span { display: inline; font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--fg); margin: 0; }
.group.disabled { opacity: .45; pointer-events: none; }
.saved { color: var(--muted); font-size: 12px; align-self: center; }
.event-row { grid-template-columns: 20px 56px 1fr 1fr 28px; }
.event-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); padding: 0; border: 0; }
.event-row.off { opacity: .45; }

/* chart tooltip */
.chart-host { position: relative; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: #fff; border: 1px solid var(--line, #e4ddd3); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.12);
  white-space: nowrap; display: none;
}
.chart-tip b { display: block; margin-bottom: 4px; }
.chart-tip .row { display: flex; align-items: center; gap: 6px; justify-content: space-between; }
.chart-tip .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.chart-tip .val { font-variant-numeric: tabular-nums; font-weight: 600; }
#mcChart svg { display: block; height: 320px; max-width: 100%; }

/* best-value highlight in the summary table */
#summary td.best{
  background:var(--accent);
  color:var(--text);
  font-weight:700;
  border-radius:6px;
}

/* validation warnings on scenario cards */
.warns:empty { display: none; }
.warn {
  background: #fdf1e7; border: 1px solid #eccfb6; color: #8a4416;
  border-radius: 8px; padding: 6px 9px; font-size: 12px; line-height: 1.35;
  margin-bottom: 8px;
}

/* events footer buttons */
.event-actions { display: flex; align-items: stretch; gap: 6px; margin-top: 4px; }
.event-actions .event-all {
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
  color: var(--muted); font-size: 11px; padding: 4px 10px; cursor: pointer;
}
.event-actions .event-all:hover { background: var(--accent); color: var(--primary); }

/* add-scenario placeholder card + matching toolbar button height */
.add-card {
    border: 1px dashed var(--border); border-radius: 16px; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  min-height: 120px;
}
.toolbar .event-add, .add-card .event-add {
  font-size: 12px; padding: 4px 10px; line-height: 1.5;
}


/* scenario cards flow multi-column in the left pane */
.scenarios { grid-template-columns: repeat(auto-fill, 236px); align-items: start; justify-content: start; }
.pane-left .card { background: var(--card); }

/* sections inside a scenario card (always expanded) */
.acc { border-top: 1px solid var(--border); }
.acc:last-of-type { border-bottom: 1px solid var(--border); }
.acc-head { padding: 8px 2px 4px; }
.acc-head .acc-title {
  display: block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .15em; color: var(--fg);
}
.acc-body { padding: 2px 2px 10px; }
.acc-body h4:first-child { margin-top: 0; }

/* compact cards: keep every input visible without tall cards */
.scenarios .card { padding: 14px; min-width: 0; }
.scenarios .card * { min-width: 0; }
.scenarios .scenario-head { margin-bottom: 8px; }
.scenarios label { margin-bottom: 6px; }
.scenarios label > span { margin-bottom: 2px; font-size: 10px; }
.scenarios .field input { padding: 5px 8px; }
.scenarios .field .apply { padding: 4px 6px; }
.scenarios .pill { padding: 6px 8px; margin-bottom: 6px; }
.scenarios .switch { margin-bottom: 6px; }
.scenarios .event-row { margin-bottom: 4px; }
.scenarios .warns { overflow: hidden; }


/* narrow cards: all fields stacked vertically */
.scenarios .acc-body { display: block; }
.scenarios .group { display: block; }


/* ---- events: roomy, readable rows ---- */
.event-row {
  display: block; border: 1px solid var(--border); border-radius: 10px;
/*  background: #fbf6ee; padding: 8px; margin-bottom: 8px;*/
background: var(--bg); padding: 8px; margin-bottom: 8px;
}
.event-line { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 6px; }
.event-line:last-child { margin-bottom: 0; }
.ev-f { margin: 0; flex: 0 0 auto; }
.ev-f.ev-grow { flex: 1 1 auto; min-width: 0; }
.ev-f > span { font-size: 10px; margin-bottom: 2px; }
.ev-f input, .ev-f select {
  font: inherit; padding: 5px 6px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; width: 100%;
}
.ev-f:not(.ev-grow) input { width: 68px; }
.ev-btns { display: flex; flex: 0 0 auto; gap: 4px; align-items: center; padding-bottom: 1px; }
.ev-btns .apply {
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  color: var(--muted); font-size: 10px; padding: 5px 5px; cursor: pointer; white-space: nowrap;
}
.ev-btns .apply:hover { background: var(--accent); color: var(--primary); }
.ev-btns .danger { padding: 4px 7px; font-size: 12px; }
.ev-f input[type="number"] { -moz-appearance: textfield; }

/* ---- compact, fixed-height warning chips ---- */
.warns {
  display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; overflow-y: hidden;
  min-height: 28px; align-items: center; margin-bottom: 6px;
}
.warns:empty { display: flex; }
.warn {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 4px;
  background: #fdf1e7; border: 1px solid #eccfb6; color: #8a4416;
  border-radius: 999px; padding: 3px 9px; font-size: 11px; line-height: 1.3;
  cursor: help; max-width: 100%; margin: 0;
}
.warn > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warn:hover { background: #fbe6d5; }
.warn-popup {
  position: fixed; display: none; z-index: 50; max-width: 320px;
  background: #fff; border: 1px solid #eccfb6; color: #8a4416;
  border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.4;
  box-shadow: 0 8px 22px rgba(0,0,0,.15);
}

/* section title + "active" switch on one line, tighter card top spacing */
.section-head { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.acc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 2px 2px; }
.acc-head .switch { margin: 0; gap: 5px; }
.acc-head .switch > span { font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.acc-head .switch input { width: 13px; height: 13px; }
.scenarios .scenario-head { margin-bottom: 4px; }
.scenarios .warns { min-height: 22px; margin-bottom: 2px; }
.scenarios .acc:first-of-type { border-top: 0; }

/* privacy, disclaimer, and methodology information */
.info-card details {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.info-card details:first-of-type { border-top: 0; padding-top: 0; }
.info-card details:last-of-type { padding-bottom: 0; }
.info-card summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
}
.info-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  max-width: 900px;
  padding-top: 8px;
}
.info-copy p { margin: 0 0 9px; }
.info-copy p:last-child { margin-bottom: 0; }
