:root {
  --bg: #f6f8fb;
  --card: #ffffff;
  --text: #1b2330;
  --muted: #5d6b7e;
  --line: #dfe5ee;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --good: #137a3f;
  --bad: #b42318;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 16px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f141b;
    --card: #171e28;
    --text: #e6ebf2;
    --muted: #93a1b5;
    --line: #2a3442;
    --accent: #5b9bff;
    --accent-soft: #1b2a42;
    --good: #4cc38a;
    --bad: #ff7a6e;
    --shadow: none;
    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, Arial, sans-serif;
}
a { color: var(--accent); }
.wrap { max-width: 860px; margin: 0 auto; padding: 0 16px; }

.site-header { background: var(--card); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; color: var(--text); text-decoration: none; }
.logo-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 20px; }
.top-nav { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; }
.top-nav a { color: var(--muted); text-decoration: none; }
.top-nav a:hover { color: var(--accent); }

.crumbs { font-size: 14px; color: var(--muted); margin: 18px 0 4px; }
.crumbs a { color: var(--muted); }
h1 { font-size: clamp(26px, 5vw, 36px); line-height: 1.2; margin: 8px 0 8px; }
h2 { font-size: 22px; margin: 32px 0 10px; line-height: 1.3; }
h3 { font-size: 18px; margin: 22px 0 8px; }
.lead { font-size: 18px; color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); font-size: 14px; }

.calc, .content, .related { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.related h2 { margin-top: 0; }
.content > h2:first-child { margin-top: 4px; }

/* формы */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; font-weight: 400; }
input[type=text], input[type=number], input[type=date], select {
  width: 100%; font: inherit; font-size: 17px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg label { margin: 0; font-weight: 500; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 14px; cursor: pointer; font-size: 15px; }
.seg input:checked + span { background: var(--accent); color: #fff; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.row { margin-bottom: 14px; }

/* результат */
.result { margin-top: 18px; border-top: 1px dashed var(--line); padding-top: 16px; }
.result:empty { display: none; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; line-height: 1.25; font-variant-numeric: tabular-nums; word-break: break-word; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.main b { font-size: 28px; color: var(--accent); }
.note { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.err { color: var(--bad); font-weight: 600; }

.table-wrap { overflow-x: auto; margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; max-height: 420px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { position: sticky; top: 0; background: var(--card); font-weight: 600; }
.btn-link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; margin-top: 10px; }

/* мини-калькуляторы процентов */
.mini { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.mini-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 16px; }
.mini-line input { width: 130px; font-size: 16px; padding: 8px 10px; }
.mini-out { font-weight: 700; font-size: 20px; color: var(--accent); font-variant-numeric: tabular-nums; }

/* контент */
.content p, .content li { max-width: 72ch; }
.content table { margin: 12px 0; }
.content td, .content th { white-space: normal; }
.formula { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-family: ui-monospace, Consolas, monospace; font-size: 15px; overflow-x: auto; }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { margin: 8px 0 0; }
.updated { margin-top: 20px; }

/* списки инструментов */
.hero { padding: 28px 0 8px; }
.cat h2 { margin-top: 24px; }
.tool-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-grid a { display: block; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; color: var(--text); transition: border-color .15s; }
.tool-grid a:hover { border-color: var(--accent); }
.tool-grid b { display: block; margin-bottom: 4px; }
.tool-grid span { font-size: 14px; color: var(--muted); }
.related .tool-grid a { background: var(--bg); }

.ad { margin: 0 0 20px; min-height: 90px; }
.site-footer { padding: 24px 0 40px; font-size: 14px; }
.site-footer p { margin: 6px 0; }

@media (max-width: 560px) {
  .calc, .content, .related { padding: 16px; border-radius: 12px; }
  .top-nav { display: none; }
  .stat.main b { font-size: 24px; }
}
