.tool-surface {
  --bg: #f8f7f3;
  --panel: #ffffff;
  --ink: #17211d;
  --muted: #5e6a64;
  --line: #dcd8cf;
  --accent: #0f6b57;
  --accent-dark: #0a4d3f;
  --warning: #a95b18;
  --bad: #9f2d2d;
  --good: #1d7a4d;
  --shadow: 0 18px 40px rgba(23, 33, 29, 0.08);
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  padding-bottom: 80px;
}

*, *::before, *::after { box-sizing: border-box; }
button, input, select { font: inherit; }

.tool-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 0;
}

.hero { max-width: 760px; margin-bottom: 32px; }
.eyebrow, .section-label {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
h1 { margin: 0 0 12px; font-size: clamp(2.2rem, 5vw, 3.8rem); line-height: 1.0; letter-spacing: -0.01em; }
h2 { margin: 0; font-size: clamp(1.35rem, 3vw, 1.85rem); line-height: 1.15; }
h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 700; }
p { margin-top: 0; }
.hero-copy { color: var(--muted); font-size: 1.1rem; max-width: 680px; }

.calculator {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.calc-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.form-body { padding: 28px; }
.form-intro { color: var(--muted); font-size: 0.95rem; margin-bottom: 20px; }

.form-section-title {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 4px;
}
.form-grid-2 { grid-template-columns: repeat(2, 1fr); }

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ink);
}
.field small { font-size: 0.76rem; font-weight: 400; color: var(--muted); margin-top: -2px; }

.field input, .field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  color: var(--ink);
  padding: 10px 13px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,107,87,0.13);
}

.input-prefix, .input-suffix-pct {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fffefa;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-prefix:focus-within, .input-suffix-pct:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15,107,87,0.13);
}
.input-prefix span { padding: 0 10px 0 13px; color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.input-suffix-pct span { padding: 0 13px 0 10px; color: var(--muted); font-weight: 700; font-size: 0.9rem; }
.input-prefix input, .input-suffix-pct input {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  min-height: 44px;
  flex: 1;
  padding: 10px 8px;
}
.input-prefix input:focus, .input-suffix-pct input:focus { box-shadow: none; }

.actions { display: flex; align-items: center; gap: 14px; margin-top: 24px; }

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--accent-dark);
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  padding: 12px 20px;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.15s;
}
.primary-button:hover { background: var(--accent-dark); }

.text-button {
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}
.text-button:hover { background: #ece8df; }

/* Results */
.results {
  padding: 28px;
  border-top: 1px solid var(--line);
  background: #fbfaf6;
}
.results-inner { display: flex; flex-direction: column; gap: 20px; }

.result-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.kpi-block {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.kpi-block.primary { border-color: var(--accent); background: rgba(15,107,87,0.04); }
.kpi-label { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin-bottom: 6px; }
.kpi-value { font-size: 1.9rem; font-weight: 900; line-height: 1; color: var(--ink); margin-bottom: 4px; }
.kpi-block.primary .kpi-value { color: var(--accent); }
.kpi-sub { font-size: 0.75rem; color: var(--muted); }

.result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.result-block {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  display: flex;
  flex-direction: column;
}
.result-block.next-action { gap: 8px; }
.muted-text { color: var(--muted); font-size: 0.9rem; }

.metric-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px solid #f0ece4;
  font-size: 0.9rem;
}
.metric-row:last-child { border-bottom: 0; }
.metric-row .label { color: var(--muted); }
.metric-row .value { font-weight: 700; }
.metric-row .value.good { color: var(--good); }
.metric-row .value.bad { color: var(--bad); }
.metric-row .value.warn { color: var(--warning); }

.diagnosis-text { font-size: 0.9rem; color: var(--ink); line-height: 1.5; }
.diagnosis-verdict {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.verdict-good { background: rgba(29,122,77,0.1); color: var(--good); }
.verdict-warn { background: rgba(169,91,24,0.1); color: var(--warning); }
.verdict-bad { background: rgba(159,45,45,0.1); color: var(--bad); }

/* Bar chart */
.bar-chart { margin: 12px 0; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.82rem; }
.bar-label { width: 130px; color: var(--muted); flex-shrink: 0; text-align: right; }
.bar-track { flex: 1; background: #ece8df; border-radius: 3px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; display: flex; align-items: center; padding-left: 8px; font-size: 0.78rem; font-weight: 700; color: #fff; transition: width 0.4s ease; }
.bar-fill.good { background: var(--good); }
.bar-fill.warn { background: var(--warning); }
.bar-fill.bad { background: var(--bad); }
.bar-fill.neutral { background: var(--accent); }

/* FAQ */
.faq {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
  margin-bottom: 24px;
}
details { border-top: 1px solid var(--line); padding: 14px 0; }
details:first-of-type { margin-top: 16px; }
details:last-child { padding-bottom: 0; }
summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; }
summary:focus { outline: none; }
details p { margin: 10px 0 0; color: var(--muted); font-size: 0.9rem; }

/* Related links */
.related-links {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 28px;
}
.link-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 16px; }
.link-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s, transform 0.15s;
}
.link-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.link-card-label { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); }
.link-card-title { font-size: 0.88rem; font-weight: 600; line-height: 1.35; color: var(--ink); }

.is-hidden { display: none !important; }

@media (max-width: 840px) {
  .tool-shell { padding: 32px 0 0; }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .result-kpis { grid-template-columns: repeat(2, 1fr); }
  .result-grid { grid-template-columns: 1fr; }
  .link-grid { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .tool-shell { width: calc(100% - 24px); }
  .form-body, .calc-header { padding: 18px; }
  .form-grid, .form-grid-2 { grid-template-columns: 1fr; }
  .result-kpis { grid-template-columns: repeat(2, 1fr); }
  .actions { flex-direction: column; align-items: stretch; }
  .primary-button, .text-button { width: 100%; }
}

/* Waterfall section */
.waterfall-section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.waterfall-section h3 { margin-bottom: 14px; }

/* Bad KPI accent */
.kpi-block.primary.bad-kpi { border-color: var(--bad); background: rgba(159,45,45,0.04); }
.kpi-block.primary.bad-kpi .kpi-value { color: var(--bad); }
