:root {
  --bg: #f7f7f4;
  --surface: #ffffff;
  --text: #1d2125;
  --muted: #5d6670;
  --border: #dde0e3;
  --accent: #1f6feb;
  --accent-soft: #e7f0ff;
  --good: #14804a;
  --result-bg: #f1f6ff;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --surface: #1c2024;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --border: #30363d;
    --accent: #5b9dff;
    --accent-soft: #1d2a3d;
    --good: #3fbf7f;
    --result-bg: #1a2433;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); font-size: 0.9rem; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; gap: 20px; min-height: 56px; flex-wrap: wrap; }
.logo { font-weight: 700; font-size: 1.15rem; color: var(--text); text-decoration: none; white-space: nowrap; }
.logo-mark { color: var(--accent); }
.top-nav { display: flex; gap: 16px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.top-nav a { color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 0.95rem; padding: 14px 0; }
.top-nav a:hover { color: var(--text); }

main { padding-top: 16px; padding-bottom: 48px; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; margin: 8px 0 8px; }
h2 { font-size: 1.3rem; margin: 32px 0 12px; }
h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.lead { color: var(--muted); font-size: 1.08rem; margin-top: 0; }
.crumbs { font-size: 0.85rem; color: var(--muted); }
.crumbs a { color: var(--muted); }

.hero { padding: 24px 0 8px; }
.search { width: 100%; font-size: 1.05rem; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); margin-bottom: 12px; }
.home-cat h2 a { color: var(--text); text-decoration: none; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); transition: border-color .15s; }
.card:hover { border-color: var(--accent); }
.card-title { font-weight: 600; }
.card-desc { font-size: 0.88rem; color: var(--muted); line-height: 1.4; }

/* Tool box */
.tool-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin: 16px 0 8px; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.field label, .field .label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 4px; }
.field small { display: block; color: var(--muted); font-size: 0.8rem; margin-top: 2px; }
input[type=text], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { min-height: 160px; resize: vertical; }
.inline { display: flex; gap: 8px; }
.inline > * { flex: 1; }
.btn { font: inherit; font-weight: 600; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.btn.secondary { background: transparent; color: var(--accent); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

.results { margin-top: 18px; background: var(--result-bg); border-radius: var(--radius); padding: 16px; }
.big { font-size: clamp(1.8rem, 6vw, 2.4rem); font-weight: 700; line-height: 1.15; color: var(--accent); }
.big-label { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-top: 12px; }
.stat b { display: block; font-size: 1.15rem; }
.stat span { font-size: 0.85rem; color: var(--muted); }
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin-top: 14px; background: var(--border); }
.bar > div { height: 100%; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.table-scroll { overflow-x: auto; max-height: 420px; overflow-y: auto; margin-top: 12px; }
.table-scroll thead th { position: sticky; top: 0; background: var(--surface); }

.explainer, .faq, .related { max-width: 720px; }
.formula { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.92rem; overflow-x: auto; }
.faq details { border-bottom: 1px solid var(--border); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details div { margin-top: 6px; color: var(--muted); }

.ad { margin: 24px 0; min-height: 100px; }
.page { max-width: 720px; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface); padding: 24px 0; font-size: 0.9rem; }
.footer-cats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 8px; }
.footer-cats a { color: var(--text); text-decoration: none; }

@media (max-width: 560px) {
  .tool-box { padding: 14px; }
  .site-header .wrap { gap: 4px 20px; padding-top: 8px; }
  .top-nav a { padding: 6px 0 10px; }
}
