:root {
  --bg: #f6f7f5;
  --surface: #ffffff;
  --text: #17201b;
  --muted: #5b6861;
  --border: #dfe4e0;
  --accent: #0b7a53;
  --accent-soft: #e3f3ec;
  --line-2: #c2571a;
  --good: #0b7a53;
  --bad: #b3261e;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111613;
    --surface: #1a211d;
    --text: #e8eeea;
    --muted: #9aa8a0;
    --border: #2c3731;
    --accent: #4fd1a1;
    --accent-soft: #17352a;
    --line-2: #f0a05f;
    --good: #4fd1a1;
    --bad: #ff8a80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 5vw, 2.5rem); margin: 0 0 0.5rem; }
h2 { font-size: 1.4rem; margin: 2.2rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 1.4rem 0 0.3rem; }
p { margin: 0 0 1rem; }
code {
  font: 0.92em ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--accent-soft);
  padding: 0.15em 0.4em;
  border-radius: 6px;
  white-space: nowrap;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.prose { max-width: 68ch; }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 62ch; }

.site-header { border-bottom: 1px solid var(--border); background: var(--surface); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; min-height: 58px; gap: 16px; }
.logo { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; }
.logo span { color: var(--accent); }
.site-header nav { display: flex; gap: 20px; }
.site-header nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.site-header nav a:hover { color: var(--text); }

main { padding: 32px 0 56px; }
.crumbs { font-size: 0.88rem; color: var(--muted); margin-bottom: 0.8rem; }
.crumbs a { color: var(--muted); }

.calc {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: 20px;
  margin: 24px 0 8px;
  align-items: start;
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; }
@media (max-width: 760px) { .calc { grid-template-columns: minmax(0, 1fr); } }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.control {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}
.control:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.control input, .control select {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  padding: 9px 10px;
  outline: none;
}
.unit { padding: 0 10px; color: var(--muted); font-size: 0.92rem; white-space: nowrap; }
.unit:first-child { padding-right: 0; }
.currency-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 0.9rem; color: var(--muted); }
.currency-row select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.stat { display: flex; flex-direction: column; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; }
.stat.primary { grid-column: 1 / -1; background: var(--accent-soft); border-color: transparent; }
.stat-label { font-size: 0.85rem; color: var(--muted); }
.stat-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.primary .stat-value { font-size: 2rem; color: var(--accent); }
.stat.good .stat-value { color: var(--good); }
.stat.bad .stat-value { color: var(--bad); }
.note { margin: 14px 0 0; font-size: 0.92rem; color: var(--muted); }

.chart { margin: 18px 0 0; }
.chart svg { display: block; width: 100%; height: auto; }
.chart figcaption { text-align: center; font-size: 0.8rem; color: var(--muted); }
.grid { stroke: var(--border); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; }
.line { fill: none; stroke-width: 2.5; stroke-linejoin: round; }
.line-0 { stroke: var(--accent); }
.line-1 { stroke: var(--line-2); stroke-dasharray: 6 4; }
.area { fill: var(--accent); opacity: 0.1; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); margin-bottom: 6px; }
.key::before { content: ''; display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; background: var(--accent); }
.key-1::before { background: var(--line-2); }

.table-wrap { overflow-x: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
td:not(:first-child), th:not(:first-child) { text-align: right; }

.example { border-left: 4px solid var(--accent); background: var(--surface); padding: 14px 16px; border-radius: 0 10px 10px 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; padding: 0; margin: 20px 0; list-style: none; }
.tile { display: block; height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; text-decoration: none; color: var(--text); }
.tile:hover { border-color: var(--accent); }
.tile strong { display: block; color: var(--accent); margin-bottom: 2px; }
.tile span { color: var(--muted); font-size: 0.93rem; }

.ad { margin: 24px 0; min-height: 280px; text-align: center; }
.ad::before { content: 'Advertisement'; display: block; font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }

.site-footer { border-top: 1px solid var(--border); padding: 28px 0 40px; font-size: 0.9rem; color: var(--muted); }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: var(--muted); }
.site-footer p { max-width: 72ch; margin-bottom: 0.6rem; }
