:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1a2230;
  --muted: #5b6676;
  --border: #e2e6ec;
  --primary: #0f6e56;
  --primary-hover: #0b5945;
  --primary-soft: #e6f3ef;
  --accent: #c2410c;
  --warn-bg: #fff7e6;
  --warn-border: #f2c46d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .08);
  --max: 1080px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --surface: #171e27;
    --text: #e6eaf0;
    --muted: #9aa5b4;
    --border: #2a3441;
    --primary: #34b18f;
    --primary-hover: #4cc6a3;
    --primary-soft: #16302a;
    --accent: #fb923c;
    --warn-bg: #2b2414;
    --warn-border: #7a5d1f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.6;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

.container { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 60px; flex-wrap: wrap;
}
.brand {
  font-weight: 800; font-size: 1.2rem; text-decoration: none; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--primary);
  color: #fff; display: grid; place-items: center; font-size: .95rem;
}
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a {
  text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px;
  font-size: .95rem; font-weight: 500;
}
.nav a:hover, .nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }

/* Hero */
.hero { padding: 40px 0 16px; }
.hero h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.2; margin: 0 0 12px; }
.hero p { color: var(--muted); margin: 0; max-width: 720px; font-size: 1.05rem; }
.breadcrumbs { font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--muted); }
.updated { display: inline-block; margin-top: 12px; font-size: .85rem; color: var(--muted); }

/* Cards grid (home) */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 24px 0 40px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); text-decoration: none; color: var(--text);
  display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, transform .15s;
}
.card:hover { border-color: var(--primary); transform: translateY(-2px); color: var(--text); }
.card h2, .card h3 { margin: 0; font-size: 1.15rem; }
.card p { margin: 0; color: var(--muted); font-size: .95rem; }
.card .icon { font-size: 1.6rem; }

/* Calculator layout */
.calc {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; margin: 20px 0 32px;
}
@media (max-width: 820px) { .calc { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); min-width: 0;
}
.panel h2 { margin: 0 0 16px; font-size: 1.15rem; }

.field { margin-bottom: 14px; }
.field label, .field .label { display: block; font-weight: 600; font-size: .93rem; margin-bottom: 6px; }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .row { grid-template-columns: 1fr; } }

input[type="number"], input[type="date"], select {
  width: 100%; padding: 10px 12px; font-size: 1rem; font-family: inherit;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: var(--primary); }

.input-suffix { position: relative; }
.input-suffix input { padding-right: 40px; }
.input-suffix span {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none;
}

.check { display: flex; gap: 8px; align-items: flex-start; font-size: .93rem; }
.check input { margin-top: 5px; }

.segmented { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented label {
  flex: 1; text-align: center; padding: 9px 6px; cursor: pointer; font-weight: 500; font-size: .93rem; margin: 0;
  background: var(--bg);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented input:checked + span { color: var(--primary); }
.segmented label:has(input:checked) { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.segmented label + label { border-left: 1px solid var(--border); }

/* Results */
.result-main {
  background: var(--primary-soft); border-radius: 10px; padding: 16px; margin-bottom: 16px; text-align: center;
}
.result-main .label { font-size: .9rem; color: var(--muted); }
.result-main .value { font-size: clamp(1.8rem, 5vw, 2.4rem); font-weight: 800; color: var(--primary); line-height: 1.2; }
.result-main .sub { font-size: .9rem; color: var(--muted); }

.kv { width: 100%; border-collapse: collapse; font-size: .95rem; }
.kv td { padding: 8px 0; border-bottom: 1px solid var(--border); }
.kv td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.kv tr.total td { font-weight: 800; border-bottom: none; }
.kv .neg { color: var(--accent); }

.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 12px 0 6px; background: var(--border); }
.bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .82rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: middle; }

.note {
  background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 8px;
  padding: 10px 12px; font-size: .88rem; margin-top: 14px;
}
.note:empty { display: none; }

.table-wrap { overflow-x: auto; margin: 12px 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: var(--muted); font-weight: 600; font-size: .82rem; text-transform: uppercase; letter-spacing: .02em; }

details.more { margin-top: 12px; }
details.more summary { cursor: pointer; font-weight: 600; color: var(--primary); }

/* Article content */
.content { max-width: 760px; margin: 0 0 48px; }
.content h2 { font-size: 1.45rem; margin: 36px 0 12px; line-height: 1.3; }
.content h3 { font-size: 1.15rem; margin: 24px 0 8px; }
.content p, .content li { color: var(--text); }
.content table { border-collapse: collapse; width: 100%; font-size: .95rem; margin: 12px 0; }
.content th, .content td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.content th { background: var(--surface); }
.faq details { border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 10px; background: var(--surface); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 10px 0 0; }

.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 16px 0; }

/* Ads: invisible until you paste the AdSense code inside */
.ad-slot { margin: 24px 0; text-align: center; min-height: 0; }
.ad-slot:empty { display: none; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 28px 0; font-size: .9rem; color: var(--muted); }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; }
.site-footer a { color: var(--muted); }
.disclaimer { max-width: 620px; margin: 0; }

.legal { max-width: 760px; padding: 32px 0 48px; }
.legal h1 { line-height: 1.2; }
