:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172622;
  background: #f4f6f3;
  --paper: #fff;
  --text: #172622;
  --muted: #4e625a;
  --line: #dbe3de;
  --field-line: #aebeb6;
  --accent: #205b49;
  --dark: #173c32;
  --soft: #eaf3ed;
  --error: #922b2b;
  --radius: 16px;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select { font: inherit; }
button, summary, select, input[role="switch"] { cursor: pointer; }
button:disabled { cursor: default; }
h1, h2, p, dl, dd { margin: 0; }
button:focus-visible, a:focus-visible, summary:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid #287c63;
  outline-offset: 3px;
}

.shell { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.topbar { background: var(--paper); border-bottom: 1px solid var(--line); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 68px; }
.site-name { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-size: 15px; font-weight: 750; white-space: nowrap; }
.site-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--dark); }
.site-mark > span { position: relative; width: 13px; height: 17px; border: 1.5px solid #e4f5e9; border-radius: 3px; }
.site-mark > span::before { position: absolute; content: ""; inset: 3px 2px auto; height: 2px; border-radius: 1px; background: #e4f5e9; }
.site-mark > span::after { position: absolute; content: ""; top: 7px; left: 2px; width: 2px; height: 2px; border-radius: 1px; background: #e4f5e9; box-shadow: 4px 0 #e4f5e9, 0 4px #e4f5e9, 4px 4px #e4f5e9; }
.site-region { color: var(--muted); font-size: 13px; font-weight: 550; border-left: 1px solid var(--line); padding-left: 10px; }
.page-intro { padding-block: 37px 23px; }
.page-intro h1 { font-size: clamp(30px, 4.7vw, 53px); line-height: 1.08; letter-spacing: -.055em; font-weight: 760; }
.page-intro p { color: var(--muted); font-size: 16px; margin-top: 10px; line-height: 1.55; }

.mode-control { display: inline-grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: #e8eeea; margin-bottom: 20px; max-width: 100%; }
.mode-control button { min-height: 45px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 6px 17px; color: var(--muted); font-weight: 660; font-size: 14px; line-height: 1.25; }
.mode-control button:hover { color: var(--text); }
.mode-control button[aria-pressed="true"] { color: var(--dark); background: var(--paper); border-color: #d8e0db; box-shadow: 0 1px 3px #19382c14; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.input-stack, .result-stack { display: grid; gap: 16px; min-width: 0; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.form-panel, .breakdown-panel, .comparison-panel { padding: 22px; }
.section-heading h2, .optional-details summary { font-size: 18px; font-weight: 740; letter-spacing: -.022em; line-height: 1.3; }
.section-heading p, .details-body > p { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 5px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 13px; }
.field-identity { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); margin-bottom: 15px; }
.section-heading + .field-grid, .section-heading + .switch-list { margin-top: 17px; }
.field { display: grid; align-content: start; gap: 6px; min-width: 0; color: var(--text); font-size: 13px; font-weight: 650; }
.field > :is(span, label):first-child { line-height: 1.35; }
.field small { font-size: 12px; font-weight: 450; color: var(--muted); line-height: 1.4; }
.field > input, .input-box, .scenario-name { min-height: 42px; width: 100%; min-width: 0; border: 1px solid var(--field-line); border-radius: 8px; background: var(--paper); color: var(--text); font-size: 15px; font-weight: 520; }
.field > input, .scenario-name { padding: 8px 11px; }
.input-box { display: flex; align-items: stretch; }
.input-box > span { display: grid; place-items: center; padding-inline: 10px 0; color: var(--muted); font-size: 13px; }
.input-box > input { width: 100%; min-width: 0; border: 0; padding: 8px 10px; color: inherit; background: transparent; border-radius: inherit; }
.input-suffix > span { padding-inline: 0 10px; }
.input-suffix > select { color: var(--dark); padding: 0 6px; border: 0; border-left: 1px solid var(--line); border-radius: 0 7px 7px 0; background: #f0f5f1; font-size: 13px; font-weight: 660; }
.input-box:focus-within { outline: 2px solid #287c63; outline-offset: 2px; }
.input-box > input:focus-visible { outline: 0; }
.input-box:has(input:disabled) { background: #f1f4f2; color: #596a62; }
.field input[aria-invalid="true"], .input-box:has(input[aria-invalid="true"]) { border-color: var(--error); }
input::placeholder { color: #64776e; opacity: 1; }

.switch-list { margin-bottom: 15px; border-block: 1px solid var(--line); }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 61px; padding-block: 7px; }
.switch-row + .switch-row { border-top: 1px solid var(--line); }
.switch-row strong, .switch-row small { display: block; }
.switch-row strong { font-size: 14px; font-weight: 680; }
.switch-row small { color: var(--muted); font-size: 12px; margin-top: 3px; }
input[role="switch"] { appearance: none; flex: 0 0 43px; position: relative; margin: 0; width: 43px; height: 25px; border: 1px solid #788b82; border-radius: 30px; background: #e1e8e3; }
input[role="switch"]::after { content: ""; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; border: 1px solid #75877e; border-radius: 100%; background: white; }
input[role="switch"]:checked { background: var(--accent); border-color: var(--accent); }
input[role="switch"]:checked::after { left: 21px; border-color: white; }

summary { display: flex; align-items: center; gap: 9px; color: var(--dark); list-style: none; }
summary::-webkit-details-marker { display: none; }
summary::after { content: ""; width: 8px; height: 8px; margin: -3px 2px 0 auto; transform: rotate(45deg); border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; flex: 0 0 8px; }
details[open] > summary::after { transform: rotate(225deg); margin-top: 3px; }
.nested-details { margin-top: 17px; border-top: 1px solid var(--line); padding-top: 9px; }
.nested-details summary { min-height: 34px; font-size: 14px; font-weight: 720; }
.details-body { margin-top: 10px; }
.details-body > p { margin-bottom: 12px; }
.details-body fieldset { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; margin: 12px 0 0; }
.details-body legend { color: var(--muted); font-size: 12px; font-weight: 720; padding: 0 5px; }
.optional-details summary { min-height: 24px; }
.optional-details summary > span { color: var(--muted); font-size: 12px; font-weight: 550; letter-spacing: normal; }
.optional-details .details-body { margin-top: 17px; }

.result-panel { overflow: hidden; }
.result-top { background: var(--dark); color: #fff; padding: 22px; }
.result-eyebrow { display: flex; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; align-items: center; }
.result-eyebrow h2 { font-size: 18px; line-height: 1.28; font-weight: 730; letter-spacing: -.025em; }
.result-eyebrow > span { color: #d5e8dc; border: 1px solid #729387; border-radius: 20px; padding: 2px 8px 3px; font-size: 11px; font-weight: 620; }
.result-top > p { color: #d9eae1; font-size: 13px; line-height: 1.5; margin-top: 6px; }
.demo-note { color: #fbe4ae; font-size: 12px; line-height: 1.5; margin-top: 12px; }
.primary-metrics, .secondary-metrics { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 10px; }
.primary-metrics { margin-top: 20px; padding-top: 17px; border-top: 1px solid #62877a; }
.primary-metrics > div + div, .secondary-metrics > div + div { padding-left: 12px; border-left: 1px solid #62877a; }
.primary-metrics dt, .secondary-metrics dt, .recommended dt { font-size: 13px; font-weight: 580; line-height: 1.35; }
.primary-metrics dt { color: #d9eae1; }
.primary-metrics dd, .secondary-metrics dd, .recommended dd, .breakdown-table, .scenario-card dd { font-variant-numeric: tabular-nums; }
.primary-metrics dd, .recommended dd { color: #e3f7e9; font-size: clamp(24px, 3.05vw, 40px); font-weight: 760; line-height: 1.13; letter-spacing: -.055em; margin-top: 3px; overflow-wrap: anywhere; }
.primary-metrics.is-loss dd { color: #ffd5ca; }
.recommended { padding: 11px 13px; margin-top: 15px; border: 1px solid #729387; background: #254d41; border-radius: 9px; }
.recommended + .primary-metrics { margin-top: 15px; }
.recommended dt { color: #e1f0e8; }
.recommended dd { font-size: clamp(26px, 3.2vw, 43px); }
.secondary-metrics { padding: 15px 22px; background: #edf5ef; }
.secondary-metrics > div + div { border-color: #d3dfd8; }
.secondary-metrics dt { color: var(--muted); }
.secondary-metrics dd { margin-top: 3px; color: var(--dark); font-size: clamp(17px, 2vw, 24px); font-weight: 740; letter-spacing: -.035em; overflow-wrap: anywhere; }
.calculation-status { padding: 12px 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); line-height: 1.45; }
.calculation-status:empty { display: none; }
.calculation-status.is-error { color: var(--error); background: #fff5f3; }

.empty-copy { color: var(--muted); background: #f5f8f5; border: 1px dashed #c5d3cb; border-radius: 8px; padding: 13px 12px; margin-top: 14px; font-size: 13px; line-height: 1.45; }
.breakdown-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 13px; line-height: 1.35; }
.breakdown-table :is(th, td) { text-align: left; vertical-align: top; padding: 7px 0; }
.breakdown-table :is(th, td):not(:first-child) { text-align: right; padding-left: 7px; }
.breakdown-table th { font-weight: 610; }
.breakdown-table th:first-child { overflow-wrap: anywhere; }
.breakdown-table thead { color: var(--muted); border-bottom: 1px solid var(--line); }
.breakdown-table tbody + tbody, .breakdown-table tfoot { border-top: 1px solid var(--line); }
.breakdown-table tbody { color: #344940; }
.breakdown-table .key-row { color: var(--text); background: #f0f5f1; }
.breakdown-table .key-row th, .breakdown-table .key-row td { font-weight: 730; }
.breakdown-table .key-row > :first-child { padding-left: 6px; }
.breakdown-table .key-row > :last-child { padding-right: 5px; }
.breakdown-table .loss-row { color: var(--error); }
.rates-used { color: var(--muted); font-size: 12px; line-height: 1.5; margin-top: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; border: 1px solid transparent; border-radius: 8px; padding: 7px 13px; font-size: 13px; line-height: 1.25; font-weight: 700; }
.button-outline { background: var(--paper); color: var(--accent); border-color: var(--field-line); }
.button-outline:hover { background: #eef5ef; }
.button-primary { color: white; background: var(--accent); border-color: var(--accent); }
.button-primary:hover { background: var(--dark); }
.button-primary:disabled { color: #4c6157; background: #e7eeea; border-color: #e0e7e3; }
.breakdown-panel > .button { width: 100%; margin-top: 15px; }

.comparison-panel { margin-block: 20px 35px; }
.comparison-header { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.comparison-header > .button { flex-shrink: 0; }
.comparison-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.comparison-grid:not(:empty) { margin-top: 14px; }
.comparison-status { margin-top: 7px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.comparison-status:empty { margin-top: 0; }
.scenario-card { min-width: 0; padding: 13px; background: #f6f9f6; border: 1px solid var(--line); border-radius: 10px; }
.scenario-card header { display: flex; gap: 7px; align-items: center; }
.scenario-name { font-size: 14px; font-weight: 690; }
.scenario-remove { width: 40px; flex: 0 0 40px; font-size: 20px; padding: 4px; }
.scenario-product { overflow-wrap: anywhere; color: var(--muted); font-size: 12px; margin-top: 8px; min-height: 1.4em; }
.scenario-card dl { margin-top: 7px; }
.scenario-card dl > div { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 3px 8px; padding: 6px 0; border-top: 1px solid var(--line); font-size: 13px; }
.scenario-card dt { color: var(--muted); }
.scenario-card dd { color: var(--text); font-weight: 660; }
.scenario-card .scenario-margin dd { font-size: 18px; color: var(--dark); }
.scenario-card .scenario-loss dd { color: var(--error); }
.noscript { color: var(--error); margin-bottom: 20px; }

@media (max-width: 860px) {
  .shell { width: calc(100% - 40px); }
  .workspace { gap: 12px; }
  .form-panel, .breakdown-panel, .comparison-panel, .result-top { padding: 17px; }
  .secondary-metrics, .calculation-status { padding-inline: 17px; }
}

@media (max-width: 680px) {
  .shell { width: calc(100% - 28px); }
  .topbar-inner { min-height: 60px; }
  .site-region { display: none; }
  .page-intro { padding-block: 26px 17px; }
  .page-intro p { font-size: 14px; }
  .mode-control { display: grid; margin-bottom: 13px; }
  .mode-control button { padding-inline: 6px; }
  .workspace, .comparison-grid { grid-template-columns: minmax(0, 1fr); }
  .workspace, .input-stack, .result-stack { gap: 12px; }
  .primary-metrics dd, .recommended dd { font-size: 33px; }
  .secondary-metrics dd { font-size: 21px; }
  .comparison-header { flex-wrap: wrap; }
  .comparison-panel { margin-top: 12px; }
  .field > input, .input-box { font-size: 16px; }
}

@media (max-width: 360px) {
  .shell { width: calc(100% - 20px); }
  .topbar-inner { gap: 7px; }
  .site-name { gap: 5px; font-size: 13px; }
  .site-mark { width: 28px; height: 28px; }
  .example-button { padding-inline: 7px; font-size: 12px; }
  .form-panel, .breakdown-panel, .comparison-panel, .result-top { padding: 13px; }
  .secondary-metrics, .calculation-status { padding-inline: 13px; }
  .field-grid { column-gap: 9px; }
  .breakdown-table { font-size: 12px; }
}
