:root {
  --bg: #121417; --panel: #1c1f23; --panel2: #262a30; --line: #32373e;
  --text: #f3f5f7; --muted: #98a1ab; --accent: #ff8a1f; --accent-text: #ff9a3c;
  --accent-soft: rgba(255,138,31,.14); --accent-ink: #1a1206;
  --ok: #4cc38a; --bad: #ff6b5e; --shadow: none;
}
:root[data-theme="light"] {
  --bg: #f4f5f7; --panel: #ffffff; --panel2: #fff6ec; --line: #e2e5e9;
  --text: #22262b; --muted: #66707b; --accent: #f08a2c; --accent-text: #c9640c;
  --accent-soft: rgba(240,138,44,.12); --ok: #1f9d63; --bad: #d63b2e;
  --shadow: 0 1px 3px rgba(20,25,35,.08), 0 6px 18px rgba(20,25,35,.05);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); transition: background .25s, color .25s;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
[hidden] { display: none !important; }

/* Шапка */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px;
  padding: 12px max(16px, calc((100vw - 1100px) / 2)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.logo img { width: 30px; height: 30px; }
nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; }
nav::-webkit-scrollbar { display: none; }
nav a { text-decoration: none; color: var(--muted); padding: 8px 12px; border-radius: 10px; white-space: nowrap; font-size: 15px; }
nav a:hover { color: var(--text); background: var(--panel); }
nav a.on { color: var(--text); background: var(--panel2); box-shadow: inset 0 -2px 0 var(--accent); }
.badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 12px; font-weight: 700;
  padding: 1px 7px; margin-left: 2px; }
.theme { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  width: 40px; height: 40px; cursor: pointer; display: grid; place-items: center; flex: none; box-shadow: var(--shadow); }
.theme:hover { border-color: var(--accent); }
.theme svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme .moon { display: none; }
:root[data-theme="light"] .theme .sun { display: none; }
:root[data-theme="light"] .theme .moon { display: block; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  nav { order: 3; flex-basis: 100%; }
  .theme { margin-left: auto; }
}

main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 64px; }
h1 { font-size: 26px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lead { color: var(--muted); margin: 0 0 22px; }
.view { animation: in .28s ease both; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Шаги */
.step { margin-bottom: 26px; }
.step-h { font-weight: 650; margin-bottom: 12px; display: flex; align-items: center; gap: 10px; }
.step-h b { background: var(--accent); color: var(--accent-ink); border-radius: 50%; width: 26px; height: 26px;
  display: grid; place-items: center; font-size: 13px; flex: none; }
.step-h .sub { color: var(--muted); font-weight: 400; font-size: 14px; }
.chosen { display: flex; align-items: center; gap: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow); }
.chosen svg { width: 40px; height: 40px; }
.chosen .name { font-weight: 600; flex: 1; }

/* Карточки типов */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 10px 14px;
  color: var(--text); cursor: pointer; text-align: center; font: inherit; font-size: 15px; box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s, background .15s; }
.card:hover { transform: translateY(-3px); border-color: var(--accent); background: var(--panel2); }
svg.ic { width: 56px; height: 56px; stroke: var(--accent); fill: none; stroke-width: 3;
  stroke-linejoin: round; stroke-linecap: round; display: block; margin: 0 auto 8px; }
svg.ic .f { fill: var(--accent-soft); }

/* Чипы */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 15px; font: inherit; font-size: 15px; cursor: pointer; transition: all .15s; }
.chips button:hover { border-color: var(--accent); }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.chips small { opacity: .6; margin-left: 4px; font-size: 12px; }
.chips + .chips, .chips + .grade-box { margin-top: 12px; }
.grade-box { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); }
.grade-box .chips button { background: var(--bg); }
.grade-box .chips button.on { background: var(--accent); }
.cls-info { color: var(--accent-text); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.sub-h { color: var(--muted); font-size: 13px; margin: 14px 0 8px; }
.sub-h:first-of-type { margin-top: 4px; }

/* Поля */
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
label { display: block; font-size: 13px; color: var(--muted); }
label .u { color: var(--accent-text); }
input, select { width: 100%; margin-top: 6px; background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 13px; font: inherit; font-size: 17px; box-shadow: var(--shadow); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.bad { border-color: var(--bad); }
.err { color: var(--bad); font-size: 12px; margin-top: 4px; }
.err:empty { display: none; }

/* Результат */
.result { background: var(--panel); border: 1px solid var(--line); border-left: 5px solid var(--accent);
  border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.main-lbl { color: var(--muted); }
.main-val { font-size: clamp(40px, 9vw, 64px); font-weight: 750; line-height: 1.05; letter-spacing: -.02em;
  font-variant-numeric: tabular-nums; }
.main-val small { font-size: .38em; color: var(--muted); font-weight: 500; margin-left: 8px; letter-spacing: 0; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 18px; margin-top: 20px;
  padding-top: 18px; border-top: 1px solid var(--line); }
.kv .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.kv .l { color: var(--muted); font-size: 13px; }
.sub-block { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.sub-block h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline input { width: 140px; margin: 0; }
.inline select { width: auto; margin: 0; }
.inline b { font-size: 18px; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); color: var(--muted); }
.tag.manual { background: var(--accent-soft); color: var(--accent-text); }
.note { color: var(--muted); font-size: 13px; margin-top: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; align-items: center; }

/* Кнопки */
.btn { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; padding: 11px 18px;
  font: inherit; font-weight: 650; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: var(--panel); color: var(--text); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { border-color: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.danger:hover { border-color: var(--bad); color: var(--bad); }

/* Списки / таблицы */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 16px; }
.list { display: grid; gap: 10px; }
.row { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.row .t { font-weight: 600; }
.row .m { color: var(--muted); font-size: 13px; }
.row .w { font-size: 20px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.row .ctrl { grid-column: 1 / -1; display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.row .ctrl label { width: 130px; }
.row .ctrl .btns { margin-left: auto; display: flex; gap: 8px; white-space: nowrap; }
.mcell { display: flex; align-items: center; gap: 8px; }
.mcell .meter { flex: 1; }
.mcell span { min-width: 52px; text-align: right; }
.row .ctrl input, .row .ctrl select { font-size: 15px; padding: 8px 10px; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; border: 1px dashed var(--line); border-radius: 16px; }
.layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.sticky { position: sticky; top: 90px; }
.totals .line { display: flex; justify-content: space-between; padding: 6px 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.totals .line b { color: var(--text); font-weight: 600; }
.totals .big { font-size: 30px; font-weight: 750; color: var(--text); }
details summary { cursor: pointer; color: var(--muted); margin: 6px 0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; }
tr.best td { background: var(--accent-soft); font-weight: 600; }
.scroll { overflow-x: auto; }
.ok { color: var(--ok); } .no { color: var(--bad); }
.meter { height: 6px; border-radius: 3px; background: var(--panel2); overflow: hidden; min-width: 60px; }
.meter i { display: block; height: 100%; background: var(--ok); }
.meter i.over { background: var(--bad); }

/* Раскрой */
.bar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; background: repeating-linear-gradient(45deg, var(--panel2) 0 6px, transparent 6px 12px);
  border: 1px solid var(--line); margin: 6px 0 14px; }
.bar span { background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 600; display: grid; place-items: center;
  border-right: 2px solid var(--panel); overflow: hidden; white-space: nowrap; }
.bar span:nth-child(even) { background: color-mix(in srgb, var(--accent) 75%, var(--panel)); }
.piece-row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }

/* Подвал с контактами */
.foot { border-top: 1px solid var(--line); margin-top: 24px; color: var(--muted); font-size: 14px; }
.foot-in { max-width: 1100px; margin: 0 auto; padding: 24px 16px 32px; display: grid; gap: 14px; }
.foot-contacts h3 { margin: 0 0 10px; font-size: 15px; color: var(--text); }
.foot-contacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 24px; }
.foot-contacts h3 { grid-column: 1 / -1; }
.foot-contacts span { display: block; font-size: 12px; opacity: .8; }
.foot-contacts a { color: var(--accent-text); text-decoration: none; }
.foot-contacts a:hover { text-decoration: underline; }
.foot-note { margin: 0; }
.foot-copy { font-size: 13px; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent; }

/* Шаг «Марка»: карточки классов, плитки марок, сводка выбора */
.cls-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.cls-card { text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  color: var(--text); font: inherit; cursor: pointer; display: grid; gap: 3px; box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s, background .15s; }
.cls-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.cls-card b { font-size: 15px; line-height: 1.25; }
.cls-card span { color: var(--muted); font-size: 12.5px; }
.cls-card em { font-style: normal; color: var(--accent-text); font-size: 12.5px; }
.cls-card.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
.grade-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.grade-head b { font-size: 16px; } .grade-head .cls-info { margin: 0 0 0 10px; }
.gfilter { width: 220px; margin: 0; padding: 8px 12px; font-size: 15px; box-shadow: none; }
.gtiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.gtile { position: relative; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 6px;
  font: inherit; font-size: 15px; font-weight: 500; text-align: center; cursor: pointer; transition: all .12s; }
.gtile:hover { border-color: var(--accent); transform: translateY(-1px); }
.gtile.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.gtile small { display: block; font-size: 10.5px; opacity: .65; font-weight: 400; margin-top: 1px; }
.gtiles-wide { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.gtile-lg { display: grid; gap: 2px; padding: 12px 10px; background: var(--panel); box-shadow: var(--shadow); }
.gtile-lg b { font-size: 16px; } .gtile-lg span { font-size: 11.5px; opacity: .65; font-weight: 400; } .gtile-lg em { font-style: normal; font-size: 12px; color: var(--accent-text); }
.gtile-lg.on em, .gtile-lg.on span { color: inherit; }
.gsub[hidden], .gtile[hidden] { display: none; }
.mark-sum { display: flex; align-items: center; gap: 16px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); flex-wrap: wrap; }
.mark-sum-name { font-size: 26px; font-weight: 750; letter-spacing: -.01em; }
.mark-sum-info { flex: 1; min-width: 180px; display: grid; gap: 2px; font-size: 14px; }
.mark-sum-info span { color: var(--muted); font-size: 13px; }

/* Инструменты, справочник марок, SEO-текст, места под рекламу */
.gchip { display: inline-block; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 6px 13px;
  margin: 0 8px 8px 0; color: var(--text); text-decoration: none; font-size: 15px; transition: border-color .15s; }
.gchip:hover { border-color: var(--accent); }
.g-h { margin: 22px 0 10px; font-size: 16px; } .g-h small { color: var(--muted); font-weight: 400; margin-left: 10px; font-size: 13px; }
.back-link { color: var(--muted); text-decoration: none; display: inline-block; margin-bottom: 8px; }
.back-link:hover { color: var(--accent-text); }
.chosen .name { font-weight: 600; flex: 1; }
.ad-slot { display: none; margin-top: 18px; padding: 16px; border: 1px dashed var(--line); border-radius: 12px; color: var(--muted);
  text-align: center; font-size: 13px; }
.show-slots .ad-slot { display: block; }
.seo { max-width: 1100px; margin: 8px auto 0; padding: 0 16px 8px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.seo h1 { font-size: 22px; color: var(--text); } .seo h2 { font-size: 17px; color: var(--text); margin-top: 22px; }
.seo a { color: var(--accent-text); } .seo-links a { white-space: nowrap; }
.seo-table { border-collapse: collapse; } .seo-table th { color: var(--text); text-align: left; padding: 4px 18px 4px 0; font-weight: 500; }
.embed .seo { display: none; }

/* Админка */
.toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.toggle { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font-size: 15px; cursor: pointer; }
.toggle input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); box-shadow: none; flex: none; }
.toggle:has(input:not(:checked)) { opacity: .55; }
.admin-login { max-width: 460px; }
.admin-login form label { margin-bottom: 14px; }
.admin-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-head h1 { margin: 0; }
.admin-head .btn { margin-left: auto; }
.admin-bar { position: sticky; bottom: 0; display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap;
  padding: 12px 0; margin-top: 18px; background: linear-gradient(transparent, var(--bg) 30%); }
.admin-bar .err { margin: 0 auto 0 0; flex: 1 1 260px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
table.edit input { margin: 0; padding: 7px 9px; font-size: 15px; min-width: 90px; box-shadow: none; }
table.edit td { padding: 4px 6px; border: 0; }
table.edit th { padding: 4px 6px; white-space: nowrap; }
details.cls summary { cursor: pointer; font-size: 16px; padding: 2px 0; }
details.cls[open] summary { margin-bottom: 14px; }
.subgroup { border-top: 1px dashed var(--line); margin-top: 16px; padding-top: 12px; }
.subgroup .inline { align-items: end; margin-bottom: 8px; }
.subgroup .inline input { width: 100%; }
.dot { color: var(--accent); }
.tabs button small { opacity: .7; font-size: 11px; }
code { background: var(--panel2); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 12px; font-weight: 500; z-index: 50; animation: in .2s ease; }
