:root {
  --ink: #171717;
  --muted: #666;
  --line: #dedede;
  --soft: #f6f6f3;
  --accent: #176b45;
  --accent-soft: #edf6f1;
  --current: #555;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #fff;
  line-height: 1.5;
}

main {
  width: min(820px, calc(100% - 32px));
  margin: auto;
  padding: 28px 0 72px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 42px;
}

.brand { font-weight: 750; font-size: .95rem; }

button {
  border: 0;
  border-radius: 10px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.secondary {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #cfe6d9;
  padding: 7px 10px;
  font-size: .78rem;
  font-weight: 650;
  white-space: nowrap;
}

h1 {
  font-size: clamp(2.5rem, 7vw, 4.4rem);
  line-height: 1;
  letter-spacing: -.055em;
  margin: 0 0 22px;
}

.lead {
  font-size: 1.18rem;
  color: #3f3f3f;
  max-width: 690px;
  margin: 0 0 18px;
}

.intro {
  color: var(--muted);
  max-width: 690px;
  margin: 0 0 20px;
}

.formula {
  display: none;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
  margin: 0 0 28px;
}

.formula.open { display: block; }
.formula > h2 { font-size: 1.08rem; margin: 0 0 6px; }
.formula-intro { font-size: .86rem; color: var(--muted); margin: 0 0 20px; }

.formula-section {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-top: 14px;
}

.formula-section h3 { font-size: .96rem; margin: 0 0 10px; }
.formula-section p { margin: 8px 0; color: #444; font-size: .84rem; }
.formula-step { margin: 13px 0; }
.formula-step strong { display: block; font-size: .82rem; margin-bottom: 4px; }

.formula code {
  display: block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .78rem;
  line-height: 1.55;
  background: #f7f7f5;
  border-radius: 6px;
  padding: 8px 10px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.formula-note { font-size: .76rem !important; color: #777 !important; }

.section {
  border-top: 1px solid var(--line);
  padding-top: 30px;
  margin-top: 30px;
}

.assumptions-section { border-top: 0; }
.section h2 { font-size: 1.08rem; margin: 0 0 22px; }

.quick-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.quick-label { font-size: .78rem; color: var(--muted); min-width: 84px; }

.chip {
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  font: inherit;
  font-size: .77rem;
  cursor: pointer;
}

.chip:hover,
.chip.active {
  border-color: #9fc7b0;
  background: var(--accent-soft);
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 28px 0 0;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  font-size: .9rem;
}

.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

.tab-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  margin-left: 5px;
  border: 1px solid #c9c9c9;
  border-radius: 50%;
  font-size: .68rem;
  font-weight: 700;
  color: #8a8a8a;
  vertical-align: 1px;
  cursor: help;
  position: relative;
}

.tab-help:hover,
.tab-help:focus { color: var(--ink); border-color: #999; outline: none; }

.tab-help::after {
  content: attr(data-help);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  transform: translateX(-50%);
  width: 275px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #555;
  font-size: .76rem;
  font-weight: 400;
  line-height: 1.4;
  text-align: left;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s;
  z-index: 5;
}

.tab-help:hover::after,
.tab-help:focus::after { opacity: 1; }
.premium-help::after { width: 380px; }

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

.slider-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.slider-head label { font-size: .92rem; font-weight: 650; }
.slider-value { font-variant-numeric: tabular-nums; font-weight: 750; white-space: nowrap; font-size: .88rem; }
input[type=range] { width: 100%; accent-color: var(--accent); cursor: pointer; }
.price-source { font-size: .7rem; color: #aaa; font-weight: 400; margin-left: 6px; white-space: nowrap; }

.premium-option {
  display: flex;
  align-items: center;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  font-weight: 650;
  cursor: pointer;
}

.check-label a,
.slider-head label a,
h1 a,
h2 a,
h3 a,
.detail-heading a,
.result-label a {
  color: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.check-label a:hover,
.slider-head label a:hover,
h1 a:hover,
h2 a:hover,
h3 a:hover,
.detail-heading a:hover,
.result-label a:hover { color: var(--accent); }

.check-label input[type=checkbox] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.check-label:has(input:disabled) {
  color: #999;
  cursor: not-allowed;
}

.details { display: none; }
.details.active { display: block; }
.detail-heading { font-size: .92rem; font-weight: 750; margin: 28px 0 16px; }
.detail-note { font-size: .8rem; color: var(--muted); margin: -8px 0 20px; }

.result-section { text-align: center; padding: 42px 0 10px; }
.result-label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px; }
.verdict { font-size: clamp(2rem, 6vw, 3.6rem); line-height: 1.05; font-weight: 800; letter-spacing: -.05em; margin-bottom: 12px; }
.result-explainer { color: var(--muted); max-width: 650px; margin: 0 auto; }

.key-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 26px;
  text-align: left;
}

.key-metric { border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.key-metric span { display: block; color: var(--muted); font-size: .78rem; margin-bottom: 3px; }
.positive { color: var(--accent); }
.negative { color: #9b3a33; }

.chart-header { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.chart-header h2 { margin: 0; }
.legend { display: flex; gap: 16px; font-size: .78rem; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 20px; height: 3px; border-radius: 3px; background: var(--current); }
.legend-line.ev { background: var(--accent); }
.chart-wrap { position: relative; width: 100%; height: 340px; }
canvas { width: 100%; height: 100%; display: block; }
.table-note { font-size: .76rem; color: var(--muted); margin: 8px 0 0; }
.table-note:empty { display: none; }
.table-wrap { overflow-x: hidden; margin-top: 18px; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .77rem;
  font-variant-numeric: tabular-nums;
  table-layout: fixed;
}

th, td { padding: 8px 3px; border-bottom: 1px solid #eee; text-align: right; white-space: nowrap; }
th { color: var(--muted); font-weight: 650; font-size: .72rem; white-space: normal; line-height: 1.15; }
th:first-child, td:first-child { width: 30px; text-align: center; padding-left: 1px; padding-right: 1px; }
.cost-group { text-align: center; border-bottom-color: #d7d7d7; }

.actions { margin-top: 26px; }
.export-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.feedback-text { border-top: 1px solid var(--line); margin: 18px 0 0; padding-top: 18px; color: var(--muted); font-size: .84rem; }
.feedback-text a { color: var(--accent); text-decoration: none; }
.feedback-text a:hover { text-decoration: underline; }

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: .84rem;
  font-weight: 650;
}

.action-btn:hover { border-color: #aaa; background: var(--soft); }
.action-icon { width: 20px; height: 20px; display: inline-block; flex: none; }
.pdf-icon { color: #c62828; }
.excel-icon { color: #1f6e43; }
.copy-status { font-size: .78rem; color: var(--accent); align-self: center; }

@media (max-width: 650px) {
  main { padding-top: 20px; }
  .topbar { align-items: flex-start; margin-bottom: 30px; }
  .sliders { grid-template-columns: 1fr; gap: 22px; }
  .key-metrics { grid-template-columns: 1fr; }
  .chart-header { display: block; }
  .legend { margin-top: 10px; }
  .chart-wrap { height: 280px; }
  .quick-label { width: 100%; min-width: 0; margin-top: 6px; }
  .secondary { font-size: .72rem; }
  .tab-help::after { left: auto; right: -10px; transform: none; width: 230px; }
  .premium-help::after { width: 260px; }
  .export-actions { display: grid; grid-template-columns: 1fr; }
  .action-btn { width: 100%; justify-content: center; }
  .formula { padding: 16px; }
  .formula-section { padding: 13px; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 620px; }
}
