/* ============================================================
   Калькула — дизайн-система
   Чистый CSS, без внешних зависимостей и шрифтов (макс. скорость)
   ============================================================ */

:root {
  --bg:            #f6f7fb;
  --surface:       #ffffff;
  --surface-2:     #f1f3f9;
  --surface-3:     #e8ebf3;
  --text:          #14161f;
  --text-2:        #4b5162;
  --text-3:        #767d91;
  --border:        #e2e5ee;
  --border-strong: #cfd4e2;
  --accent:        #4f46e5;
  --accent-hover:  #4338ca;
  --accent-soft:   #eef0ff;
  --accent-text:   #ffffff;
  --green:         #0e9f6e;
  --green-soft:    #e6f7f1;
  --amber:         #b45309;
  --amber-soft:    #fdf3e3;
  --red:           #dc2626;
  --red-soft:      #fdecec;
  --shadow-sm:     0 1px 2px rgba(16, 20, 40, .05);
  --shadow:        0 4px 16px rgba(16, 20, 40, .07);
  --shadow-lg:     0 12px 40px rgba(16, 20, 40, .11);
  --radius:        14px;
  --radius-sm:     9px;
  --maxw:          1200px;
  --header-h:      64px;
}

[data-theme="dark"] {
  --bg:            #0d0f16;
  --surface:       #161923;
  --surface-2:     #1d2130;
  --surface-3:     #262b3d;
  --text:          #f2f4fa;
  --text-2:        #b3b9cc;
  --text-3:        #868da5;
  --border:        #262b3b;
  --border-strong: #39405480;
  --accent:        #7c74ff;
  --accent-hover:  #8f88ff;
  --accent-soft:   #1f2044;
  --green:         #34d399;
  --green-soft:    #0f2a22;
  --amber:         #fbbf24;
  --amber-soft:    #2e2412;
  --red:           #f87171;
  --red-soft:      #2e1616;
  --shadow-sm:     0 1px 2px rgba(0, 0, 0, .4);
  --shadow:        0 4px 16px rgba(0, 0, 0, .45);
  --shadow-lg:     0 12px 40px rgba(0, 0, 0, .55);
}

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, "Noto Sans", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; height: auto; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 10px 16px; z-index: 999;
}
.skip:focus { left: 8px; top: 8px; }

/* ---------------- Шапка ---------------- */
.hdr {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.hdr-in {
  height: var(--header-h);
  display: flex; align-items: center; gap: 18px;
}
.logo {
  display: flex; align-items: center; gap: 9px;
  font-weight: 800; font-size: 19px; letter-spacing: -.02em;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.logo:hover { text-decoration: none; }
.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #9333ea);
  display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 900;
  box-shadow: var(--shadow-sm);
}
.logo b { color: var(--accent); font-weight: 800; }

.hdr-nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.hdr-nav a {
  color: var(--text-2); font-size: 14.5px; font-weight: 500;
  padding: 7px 11px; border-radius: 8px; text-decoration: none;
}
.hdr-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }

.icon-btn {
  width: 36px; height: 36px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  font-size: 16px; line-height: 1; transition: .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }

/* ---------------- Поиск ---------------- */
.search { position: relative; width: min(340px, 40vw); }
.search input {
  width: 100%; padding: 9px 12px 9px 36px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  font-size: 14.5px; outline: none; transition: .15s;
}
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent); background: var(--surface); box-shadow: 0 0 0 3px var(--accent-soft); }
.search .s-ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 14px; pointer-events: none; }

.s-res {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 400px; overflow-y: auto; display: none; z-index: 60;
  padding: 6px;
}
.s-res.on { display: block; }
.s-item {
  display: block; padding: 9px 11px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 14.5px;
}
.s-item:hover, .s-item.hl { background: var(--accent-soft); text-decoration: none; }
.s-item span { display: block; font-size: 12.5px; color: var(--text-3); }
.s-empty { padding: 14px; color: var(--text-3); font-size: 14px; text-align: center; }

/* ---------------- Хлебные крошки ---------------- */
.crumbs { font-size: 13.5px; color: var(--text-3); padding: 18px 0 0; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--accent); }
.crumbs i { font-style: normal; margin: 0 7px; opacity: .55; }
.crumbs [aria-current] { color: var(--text-2); }

/* ---------------- Главная: герой ---------------- */
.hero { padding: 46px 0 34px; }
.hero-in { display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center; }
.hero h1 {
  font-size: clamp(30px, 4.4vw, 48px); line-height: 1.12;
  letter-spacing: -.033em; margin: 0 0 16px; font-weight: 800;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p.lead { font-size: 17.5px; color: var(--text-2); margin: 0 0 22px; max-width: 54ch; }
.hero-stats { display: flex; gap: 26px; flex-wrap: wrap; margin-top: 26px; }
.hstat b { display: block; font-size: 25px; font-weight: 800; letter-spacing: -.02em; color: var(--text); }
.hstat span { font-size: 13.5px; color: var(--text-3); }

/* ---------------- Обычный калькулятор ---------------- */
.basic-calc {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 20px; padding: 18px; box-shadow: var(--shadow-lg);
}
.bc-screen {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 13px; padding: 14px 16px; text-align: right;
  margin-bottom: 12px; overflow: hidden;
}
.bc-expr { font-size: 14px; color: var(--text-3); min-height: 20px; word-break: break-all; }
.bc-val {
  font-size: clamp(26px, 5vw, 38px); font-weight: 700;
  letter-spacing: -.02em; line-height: 1.2; word-break: break-all;
}
.bc-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bc-grid button {
  padding: 15px 0; font-size: 17.5px; font-weight: 600;
  border: 1px solid var(--border); border-radius: 11px;
  background: var(--surface-2); color: var(--text); cursor: pointer;
  transition: .1s; font-family: inherit;
}
.bc-grid button:hover { background: var(--surface-3); border-color: var(--border-strong); }
.bc-grid button:active { transform: scale(.97); }
.bc-grid .op { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.bc-grid .op:hover { background: var(--accent); color: #fff; }
.bc-grid .eq { background: var(--accent); color: #fff; border-color: transparent; grid-column: span 2; }
.bc-grid .eq:hover { background: var(--accent-hover); }
.bc-grid .fn { color: var(--text-3); }
.bc-note { font-size: 12.5px; color: var(--text-3); text-align: center; margin: 12px 0 0; }

/* ---------------- Секции ---------------- */
.sec { padding: 34px 0; }
.sec-hd { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.sec-hd h2 { font-size: clamp(22px, 2.6vw, 28px); margin: 0; letter-spacing: -.025em; font-weight: 750; }
.sec-hd .more { font-size: 14.5px; font-weight: 500; }
.sec-sub { color: var(--text-2); margin: -8px 0 20px; font-size: 15.5px; }

/* ---------------- Каталог тем ---------------- */
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 14px; }
.topic-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 17px 17px 15px;
  color: var(--text); text-decoration: none; transition: .16s; box-shadow: var(--shadow-sm);
}
.topic-card:hover {
  text-decoration: none; border-color: var(--accent);
  transform: translateY(-2px); box-shadow: var(--shadow);
}
.tc-top { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }
.tc-ico {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 19px;
  background: var(--accent-soft);
}
.tc-name { font-weight: 700; font-size: 16px; letter-spacing: -.015em; }
.tc-desc { font-size: 13.5px; color: var(--text-2); margin: 0 0 11px; line-height: 1.5; }
.tc-meta { display: flex; gap: 10px; font-size: 12.5px; color: var(--text-3); flex-wrap: wrap; }
.tc-meta i { font-style: normal; background: var(--surface-2); border-radius: 6px; padding: 2px 7px; }

/* ---------------- Список калькуляторов ---------------- */
.calc-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 13px; }
.calc-card {
  display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 15px 16px;
  color: var(--text); text-decoration: none; transition: .15s; box-shadow: var(--shadow-sm);
}
.calc-card:hover {
  text-decoration: none; border-color: var(--accent);
  transform: translateY(-2px); box-shadow: var(--shadow);
}
.cc-title { font-weight: 650; font-size: 15.5px; letter-spacing: -.01em; margin-bottom: 5px; }
.cc-desc { font-size: 13.5px; color: var(--text-2); line-height: 1.5; margin: 0; }

/* ---------------- Страница калькулятора ---------------- */
.calc-page { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 28px; align-items: start; padding-bottom: 40px; }
.calc-main { min-width: 0; }
.calc-side { position: sticky; top: calc(var(--header-h) + 16px); }

h1.calc-h1 {
  font-size: clamp(25px, 3.4vw, 36px); letter-spacing: -.03em;
  line-height: 1.18; margin: 12px 0 8px; font-weight: 800;
}
.calc-sub { color: var(--text-2); font-size: 16px; margin: 0 0 22px; }

.calc-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow);
}
.calc-grid { display: grid; grid-template-columns: 1fr 1fr; }
.calc-inputs { padding: 20px; border-right: 1px solid var(--border); }
.calc-outputs { padding: 20px; background: var(--surface-2); }
@media (max-width: 800px) {
  .calc-grid { grid-template-columns: 1fr; }
  .calc-inputs { border-right: 0; border-bottom: 1px solid var(--border); }
}

.fld { margin-bottom: 15px; }
.fld:last-child { margin-bottom: 0; }
.fld > label {
  display: block; font-size: 13.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.fld .hint { display: block; font-size: 12.5px; color: var(--text-3); font-weight: 400; margin-top: 3px; }
.in-row { display: flex; gap: 8px; }
.in-row > * { flex: 1; min-width: 0; }

.inp, select.inp, textarea.inp {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-size: 15.5px; font-family: inherit; outline: none; transition: .13s;
}
.inp:hover { border-color: var(--accent); }
.inp:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.inp[readonly] { background: var(--surface-2); color: var(--text-2); cursor: default; }
select.inp { cursor: pointer; appearance: auto; }

.sfx { position: relative; }
.sfx .inp { padding-right: 42px; }
.sfx .unit {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-3); font-size: 14px; pointer-events: none; font-weight: 500;
}

input[type="range"] {
  width: 100%; accent-color: var(--accent); height: 26px; cursor: pointer; background: transparent;
}
.range-val { font-size: 13.5px; color: var(--text-3); text-align: right; margin-top: -2px; }

.seg { display: flex; gap: 5px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label {
  flex: 1; text-align: center; padding: 7px 6px; font-size: 13.5px;
  border-radius: 7px; cursor: pointer; color: var(--text-2);
  font-weight: 550; transition: .13s; border: 1px solid transparent;
}
.seg input:checked + label { background: var(--surface); color: var(--accent); border-color: var(--border); box-shadow: var(--shadow-sm); }

/* Результаты */
.out {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 15px; margin-bottom: 10px;
}
.out-lab { font-size: 13px; color: var(--text-3); margin-bottom: 3px; font-weight: 500; }
.out-val {
  font-size: clamp(21px, 3vw, 27px); font-weight: 750;
  letter-spacing: -.025em; line-height: 1.25; word-break: break-word;
}
.out-val small { font-size: .58em; font-weight: 600; color: var(--text-3); margin-left: 4px; }
.out.hl { border-color: var(--accent); background: var(--accent-soft); }
.out.hl .out-val { color: var(--accent); }
.out-sub { font-size: 13.5px; color: var(--text-2); margin-top: 5px; }
.out-bad { color: var(--red); }
.out-good { color: var(--green); }

.out-list { margin: 0; padding: 0; list-style: none; }
.out-list li {
  display: flex; justify-content: space-between; gap: 14px;
  padding: 8px 0; border-bottom: 1px dashed var(--border);
  font-size: 14.5px;
}
.out-list li:last-child { border-bottom: 0; }
.out-list li b { font-weight: 650; text-align: right; }

.out-msg { font-size: 14px; color: var(--text-2); padding: 14px; text-align: center; }

/* Таблица результата */
.tbl-wrap { overflow-x: auto; margin-top: 10px; }
table.res {
  width: 100%; border-collapse: collapse; font-size: 13.5px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
table.res th, table.res td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.res th:first-child, table.res td:first-child { text-align: left; }
table.res thead th { background: var(--surface-2); font-weight: 650; color: var(--text-2); position: sticky; top: 0; }
table.res tbody tr:last-child td { border-bottom: 0; }
table.res tfoot td { font-weight: 700; background: var(--surface-2); }

.tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border-radius: 9px; font-size: 14px; font-weight: 550;
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); cursor: pointer; font-family: inherit; transition: .14s;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent); text-decoration: none; }
.btn-pri { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-pri:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

/* ---------------- Текстовый контент ---------------- */
.txt { margin-top: 30px; }
.txt h2 { font-size: clamp(20px, 2.4vw, 25px); letter-spacing: -.02em; margin: 32px 0 12px; font-weight: 700; }
.txt h3 { font-size: 17.5px; margin: 26px 0 10px; font-weight: 650; letter-spacing: -.01em; }
.txt p { margin: 0 0 14px; color: var(--text-2); }
.txt ul, .txt ol { margin: 0 0 16px; padding-left: 22px; color: var(--text-2); }
.txt li { margin-bottom: 7px; }
.txt strong { color: var(--text); font-weight: 650; }

.formula {
  background: var(--surface-2); border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 13px 16px; margin: 0 0 16px;
  font-size: 15px; color: var(--text); overflow-x: auto;
}
.formula code { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 14.5px; }

/* SEO-статья под калькулятором: факты и советы */
.article { border-top: 1px solid var(--border); padding-top: 8px; }
.article h3 { color: var(--text); }
.art-facts li { position: relative; }
.art-facts li::marker { color: var(--accent); }
.art-tips li::marker { color: var(--green); }
.art-facts strong, .art-tips strong { color: var(--text); }

.faq { margin-top: 8px; }
.faq details {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 9px; overflow: hidden;
}
.faq summary {
  padding: 14px 17px; cursor: pointer; font-weight: 600;
  font-size: 15.5px; list-style: none; position: relative; padding-right: 42px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; position: absolute; right: 17px; top: 50%;
  transform: translateY(-50%); font-size: 21px; color: var(--accent);
  font-weight: 400; line-height: 1;
}
.faq details[open] summary::after { content: "−"; }
.faq summary:hover { background: var(--surface-2); }
.faq .faq-body { padding: 0 17px 15px; color: var(--text-2); font-size: 15px; }
.faq .faq-body p { margin: 0; }

/* ---------------- Боковая панель ---------------- */
.side-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.side-box h4 { margin: 0 0 11px; font-size: 14px; font-weight: 700; letter-spacing: -.01em; color: var(--text-2); text-transform: uppercase; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a {
  display: block; padding: 7px 9px; border-radius: 8px;
  color: var(--text); font-size: 14.5px; text-decoration: none;
}
.side-links a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* Рекламные блоки */
.ad {
  background: var(--surface-2); border: 1px dashed var(--border-strong);
  border-radius: 12px; min-height: 96px; display: grid; place-items: center;
  color: var(--text-3); font-size: 12.5px; text-align: center; padding: 14px;
  margin: 18px 0; overflow: hidden; position: relative;
}
.ad::before {
  content: "Реклама"; position: absolute; top: 6px; left: 9px;
  font-size: 10px; text-transform: uppercase; letter-spacing: .06em; opacity: .7;
}
.ad-tall { min-height: 600px; }

/* Партнёрский блок */
.partner {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 17px; margin: 18px 0;
}
.partner h4 { margin: 0 0 7px; font-size: 15.5px; font-weight: 700; }
.partner p { margin: 0 0 12px; font-size: 14px; color: var(--text-2); }

/* ---------------- Подвал ---------------- */
.ftr {
  background: var(--surface); border-top: 1px solid var(--border);
  padding: 40px 0 28px; margin-top: 40px;
}
.ftr-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 26px; }
.ftr h5 { margin: 0 0 11px; font-size: 13.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); }
.ftr ul { list-style: none; margin: 0; padding: 0; }
.ftr li { margin-bottom: 7px; }
.ftr a { color: var(--text-2); font-size: 14.5px; }
.ftr a:hover { color: var(--accent); }
.ftr-about { max-width: 46ch; font-size: 14.5px; color: var(--text-2); }
.ftr-bot {
  margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-3); display: flex;
  justify-content: space-between; gap: 16px; flex-wrap: wrap;
}

/* ---------------- Уведомление о cookie (согласие) ---------------- */
.cookie-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 90;
  background: var(--surface); border-top: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 13px 0;
}
.cookie-bar[hidden] { display: none !important; }
.cookie-in {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}
.cookie-in p {
  margin: 0; font-size: 14px; line-height: 1.45; color: var(--text-2);
  flex: 1 1 380px;
}
.cookie-in a { color: var(--accent); text-decoration: underline; }
.cookie-btns { display: flex; gap: 10px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .cookie-in { flex-direction: column; align-items: stretch; }
  .cookie-btns .btn { flex: 1; text-align: center; }
}

/* ---------------- Адаптив ---------------- */
@media (max-width: 1000px) {
  .calc-page { grid-template-columns: 1fr; }
  .calc-side { position: static; }
  .hero-in { grid-template-columns: 1fr; gap: 26px; }
}
@media (max-width: 760px) {
  .hdr-nav .hide-sm { display: none; }
  .search { width: auto; flex: 1; }
  .hero { padding: 30px 0 22px; }
  .sec { padding: 26px 0; }
  .topics { grid-template-columns: 1fr; }
  .calc-list { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .hdr-in { gap: 10px; }
  .logo span { display: none; }
  .hero-stats { gap: 18px; }
}

/* ---------------- Утилиты ---------------- */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.dim { color: var(--text-3); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

@media print {
  .hdr, .ftr, .calc-side, .ad, .crumbs, .tools, .cookie-bar { display: none !important; }
  body { background: #fff; }
  .calc-box { box-shadow: none; border-color: #ccc; }
}
