/* «КатегорИИ» — оформление в духе iOS: сгруппированный серый фон, белые карточки,
   один синий акцент, крупные заголовки, тихие подписи. Все значения — в токенах ниже. */

:root {
  --bg: #f2f2f7;            /* сгруппированный фон */
  --card: #ffffff;          /* карточки и поля */
  --fill: rgba(118, 118, 128, .12);   /* поля ввода, сегменты */
  --ink: #000000;
  --ink-2: rgba(60, 60, 67, .62);     /* вторичный текст */
  --ink-3: rgba(60, 60, 67, .32);     /* третичный, плейсхолдеры */
  --sep: rgba(60, 60, 67, .16);       /* разделители */
  --accent: #007aff;
  --accent-ink: #ffffff;
  --accent-tint: rgba(0, 122, 255, .12);
  --red: #ff3b30; --green: #34c759; --orange: #ff9500; --yellow: #c79500;
  --warn-tint: rgba(255, 149, 0, .14);
  --bar: rgba(242, 242, 247, .78);    /* полупрозрачные панели */
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --pop: 0 10px 30px rgba(0, 0, 0, .14), 0 0 0 .5px rgba(0, 0, 0, .06);
  --r-card: 14px; --r-ctl: 10px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000; --card: #1c1c1e; --fill: rgba(118, 118, 128, .24);
    --ink: #ffffff; --ink-2: rgba(235, 235, 245, .62); --ink-3: rgba(235, 235, 245, .3); --sep: rgba(84, 84, 88, .6);
    --accent: #0a84ff; --accent-tint: rgba(10, 132, 255, .2);
    --red: #ff453a; --green: #30d158; --orange: #ff9f0a; --yellow: #ffd60a; --warn-tint: rgba(255, 159, 10, .18);
    --bar: rgba(28, 28, 30, .78); --shadow: none; --pop: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 .5px rgba(255, 255, 255, .1);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #000000; --card: #1c1c1e; --fill: rgba(118, 118, 128, .24);
  --ink: #ffffff; --ink-2: rgba(235, 235, 245, .62); --ink-3: rgba(235, 235, 245, .3); --sep: rgba(84, 84, 88, .6);
  --accent: #0a84ff; --accent-tint: rgba(10, 132, 255, .2);
  --red: #ff453a; --green: #30d158; --orange: #ff9f0a; --yellow: #ffd60a; --warn-tint: rgba(255, 159, 10, .18);
  --bar: rgba(28, 28, 30, .78); --shadow: none; --pop: 0 10px 30px rgba(0, 0, 0, .5), 0 0 0 .5px rgba(255, 255, 255, .1);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.warn { color: var(--orange); }
.hint { display: block; color: var(--ink-2); font-size: 12px; font-weight: 400; margin-top: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ——— Шапка, полоса тестовой версии, подвал ——— */
.top {
  position: sticky; top: 0; z-index: 10; background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.top .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 600; font-size: 17px; }
.logo:hover { text-decoration: none; }
.logo img { border-radius: 7px; }
#save-state { font-size: 12px; color: var(--ink-3); }
.test-banner { font-size: 12px; color: var(--ink-2); padding: 6px 0; text-align: center; }
.test-banner #fb-status { color: var(--ink); font-weight: 600; }
.foot { padding: 28px 0 96px; font-size: 12px; color: var(--ink-3); text-align: center; }
.foot .wrap > div + div { margin-top: 4px; }

/* ——— Страница: навигация, крупный заголовок ——— */
.page { padding: 8px 0 8px; }
.navbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.navbar .back { font-size: 17px; display: inline-flex; align-items: center; gap: 4px; min-height: 44px; min-width: 0; }
.navbar .back span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.navbar .back::before { content: '‹'; font-size: 28px; line-height: 1; margin-top: -3px; }
.navbar .back:hover { text-decoration: none; opacity: .7; }
.navbar .right { display: flex; align-items: center; gap: 4px; flex: none; }
.navbar .step { font-size: 15px; padding: 10px 8px; }
h1 { font-size: 34px; line-height: 1.12; letter-spacing: -.02em; font-weight: 700; margin: 2px 0 16px; overflow-wrap: anywhere; }
h2 { font-size: 20px; letter-spacing: -.01em; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 18px 0 6px; }
.group-title { font-size: 13px; font-weight: 400; color: var(--ink-2); text-transform: uppercase; letter-spacing: .02em; margin: 0 16px 6px; }
.group-foot { font-size: 13px; color: var(--ink-2); margin: -16px 16px 24px; }

.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.two.room { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.side { position: sticky; top: 64px; }
.mini { display: none; }
@media (max-width: 900px) {
  .two, .two.room { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .side { position: static; }
  .side .result { scroll-margin-top: 60px; }
  .page:has(.mini) { padding-bottom: 64px; }
  .mini {
    display: flex; align-items: center; gap: 10px; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border: 0; border-top: .5px solid var(--sep);
    background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
    color: var(--ink); font: inherit; font-size: 15px; text-align: left; cursor: pointer;
  }
  .mini .go { margin-left: auto; color: var(--accent); }
  h1 { font-size: 30px; }
}

/* ——— Карточки и группы ——— */
.card { background: var(--card); border-radius: var(--r-card); padding: 16px; margin-bottom: 24px; box-shadow: var(--shadow); }
.card > h2:first-child { margin-top: 2px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.sub { background: var(--bg); border-radius: 12px; padding: 12px; margin: 12px 0; }

/* Список в стиле «Настроек»: строки с разделителями, шеврон справа */
.rows { background: var(--card); border-radius: var(--r-card); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 24px; }
.card .rows { box-shadow: none; margin: 0 -16px -16px; border-radius: 0 0 var(--r-card) var(--r-card); }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 16px; color: var(--ink);
  position: relative; transition: background .15s var(--ease);
}
a.row:hover { text-decoration: none; background: var(--fill); }
.row + .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; border-top: .5px solid var(--sep); }
.row .num-chip { min-width: 24px; color: var(--ink-3); font-size: 15px; font-variant-numeric: tabular-nums; flex: none; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub-line { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--ink-3); font-size: 22px; line-height: 1; flex: none; }
.row.add { color: var(--accent); cursor: pointer; border: 0; background: none; width: 100%; font: inherit; font-size: 16px; text-align: left; }
.row.add:hover { background: var(--fill); }

/* ——— Кнопки и меню «⋯» ——— */
.btn {
  font: inherit; font-size: 16px; font-weight: 500; padding: 0 16px; min-height: 44px; border-radius: var(--r-ctl);
  border: 0; cursor: pointer; background: var(--accent-tint); color: var(--accent);
  transition: transform .12s var(--ease), opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.plain { background: none; padding: 0 8px; }
.btn.danger { background: none; color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn:focus-visible, .in:focus-visible, .x:focus-visible, .row:focus-visible, .menu-btn:focus-visible { outline: 3px solid var(--accent-tint); outline-offset: 1px; }
.actions, .row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.row-actions { margin-top: 12px; }
.x { border: 0; background: none; color: var(--ink-3); font-size: 22px; line-height: 1; cursor: pointer; width: 36px; height: 36px; border-radius: 50%; }
.x:hover { color: var(--red); background: var(--fill); }

.more-menu { position: relative; }
.more-menu > summary { list-style: none; }
.more-menu > summary::-webkit-details-marker { display: none; }
.menu-btn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  color: var(--accent); font-size: 22px; line-height: 1; user-select: none;
}
.menu-btn:hover { background: var(--fill); }
.menu {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 250px; padding: 6px 0;
  background: var(--card); border-radius: 14px; box-shadow: var(--pop); animation: pop .18s var(--ease);
}
.menu button {
  display: block; width: 100%; text-align: left; font: inherit; font-size: 16px; padding: 11px 16px;
  background: none; border: 0; color: var(--ink); cursor: pointer;
}
.menu button:hover { background: var(--fill); }
.menu button.danger { color: var(--red); }
.menu hr { border: 0; border-top: .5px solid var(--sep); margin: 6px 0; }
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(-4px); } to { opacity: 1; transform: none; } }

/* ——— Поля ввода ——— */
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px 12px; margin-bottom: 4px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.field.wide, .fields .wide { grid-column: 1 / -1; }
.lbl { font-weight: 500; color: var(--ink-2); }
.unit { font-weight: 400; color: var(--ink-3); }
.in {
  font: inherit; font-size: 16px; padding: 0 12px; min-height: 44px; border: 0; border-radius: var(--r-ctl);
  background: var(--fill); color: var(--ink); width: 100%; min-width: 0; transition: box-shadow .15s var(--ease);
}
.in::placeholder { color: var(--ink-3); }
.in:focus { outline: none; box-shadow: 0 0 0 3px var(--accent-tint); }
select.in {
  appearance: none; -webkit-appearance: none; padding-right: 32px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.in.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Переключатель вместо флажка: подпись слева, тумблер справа */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 6px 0; cursor: pointer; font-size: 16px; }
.toggle + .toggle { border-top: .5px solid var(--sep); }
.switch {
  appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; border-radius: 31px; margin: 0;
  background: var(--fill); position: relative; cursor: pointer; transition: background .25s var(--ease);
}
.switch::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .1); transition: transform .25s var(--ease);
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }
.switch:disabled { opacity: .4; }
.switch:focus-visible { outline: 3px solid var(--accent-tint); outline-offset: 2px; }

/* Сегментированный выбор */
.segmented { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 4px 0 16px; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; font-size: 14px; font-weight: 500; padding: 7px 8px; border-radius: 7px; cursor: pointer; transition: background .2s var(--ease); }
.segmented input:checked + span { background: var(--card); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); }
.segmented input:focus-visible + span { outline: 3px solid var(--accent-tint); }

details.more { margin: 8px 0; }
details.more > summary { cursor: pointer; color: var(--accent); font-size: 15px; list-style: none; padding: 6px 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::after { content: ' ›'; display: inline-block; margin-left: 4px; transition: transform .2s var(--ease); }
details.more[open] > summary::after { transform: rotate(90deg); }

/* ——— Таблицы ——— */
.scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid th, .grid td { text-align: left; padding: 8px 6px; border-bottom: .5px solid var(--sep); vertical-align: middle; }
.grid th { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.grid tr:last-child td { border-bottom: 0; }
.grid .num { text-align: right; white-space: nowrap; }
.grid.items td { padding: 4px 3px; border-bottom: 0; }
.grid.items th { padding: 0 3px 4px; border-bottom: 0; }
.grid.items td.mat { min-width: 220px; }
.grid.items td:nth-child(2), .grid.items td:nth-child(3) { width: 100px; }
.grid.items td:nth-child(4) { width: 92px; }
.grid.items td:last-child { width: 40px; text-align: center; }
@media (max-width: 560px) {
  .grid.items thead { display: none; }
  .grid.items tr { display: grid; grid-template-columns: 1fr 1fr 1fr auto; gap: 6px; padding: 10px 0; }
  .grid.items tr + tr { border-top: .5px solid var(--sep); }
  .grid.items td { display: block; padding: 0; width: auto !important; min-width: 0 !important; }
  .grid.items td.mat { grid-column: 1 / -1; }
  .grid.items td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--ink-2); margin-bottom: 2px; }
  .grid.items td:last-child { align-self: end; }
}

/* ——— Категория ——— */
.cat {
  display: inline-grid; place-items: center; min-width: 36px; height: 26px; padding: 0 8px; border-radius: 7px;
  font-weight: 700; font-size: 14px; color: var(--ink-2); background: var(--fill); font-variant-numeric: tabular-nums; flex: none;
}
.cat.big { min-width: 76px; height: 76px; font-size: 36px; border-radius: 18px; letter-spacing: -.02em; }
.cat-ab { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
.cat-v { color: var(--orange); background: color-mix(in srgb, var(--orange) 15%, transparent); }
.cat-g { color: var(--yellow); background: color-mix(in srgb, var(--yellow) 16%, transparent); }
.cat-d { color: var(--green); background: color-mix(in srgb, var(--green) 15%, transparent); }
.result-cat { display: flex; gap: 16px; align-items: center; margin-bottom: 4px; }
.result-cat .what { font-size: 13px; color: var(--ink-2); }
.result-cat .value { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }

.zone { border-top: .5px solid var(--sep); margin-top: 16px; padding-top: 4px; }
.zone p { margin: 4px 0; }
.tag { white-space: nowrap; margin-left: 8px; font-size: 12px; padding: 2px 8px; border-radius: 6px; background: var(--accent-tint); color: var(--accent); font-weight: 500; vertical-align: 1px; }
.note { padding: 12px 14px; border-radius: 12px; margin: 14px 0; font-size: 15px; }
.note.warn { background: var(--warn-tint); color: var(--ink); }
.note .btn { margin-top: 10px; }

.list { margin: 6px 0; padding-left: 20px; font-size: 14px; }
.list li { margin: 4px 0; }
.list.steps li.hit { font-weight: 600; }
.list.warn li { color: var(--orange); }
.list li.ok::marker { content: '✓  '; color: var(--green); }
.list li.bad::marker { content: '✕  '; color: var(--red); }
.proto { border-top: .5px solid var(--sep); margin-top: 12px; padding-top: 4px; }
.proto > summary { font-size: 17px; font-weight: 600; color: var(--ink); }
.proto > summary::after { color: var(--ink-3); }
.sc { margin: 8px 0; font-size: 14px; }

/* ——— Пустой список ——— */
.empty { background: var(--card); border-radius: var(--r-card); padding: 32px 20px; text-align: center; color: var(--ink-2); }
.empty p { margin: 0 0 16px; }

/* ——— Выпадающий список с поиском ——— */
.combo { position: relative; }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; max-height: min(340px, 50vh); overflow-y: auto;
  background: var(--card); border-radius: 12px; box-shadow: var(--pop); min-width: 260px; padding: 4px 0; animation: pop .15s var(--ease);
}
.combo-opt { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; cursor: pointer; font-size: 15px; line-height: 1.3; }
.combo-opt:hover, .combo-opt.active { background: var(--fill); }
.combo-note { color: var(--ink-2); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.combo-empty { padding: 10px 14px; color: var(--ink-2); font-size: 13px; }
.combo-custom { color: var(--accent); border-top: .5px solid var(--sep); font-weight: 500; }

/* ——— Замечания тестировщиков ——— */
.fb-open {
  position: fixed; right: 16px; bottom: 16px; z-index: 30; font: inherit; font-size: 14px; font-weight: 500;
  min-height: 40px; padding: 0 16px; border-radius: 20px; border: 0; cursor: pointer; color: var(--accent);
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--pop); transition: transform .12s var(--ease);
}
.fb-open:active { transform: scale(.96); }
@media (max-width: 900px) { body:has(.mini) .fb-open { bottom: 76px; } }
dialog.fb {
  border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--card); color: var(--ink); box-shadow: var(--pop);
}
dialog.fb[open] { animation: pop .2s var(--ease); }
dialog.fb::backdrop { background: rgba(0, 0, 0, .35); }
.fb-form { display: flex; flex-direction: column; gap: 14px; padding: 20px; }
.fb-form h2 { margin: 0; }
.fb-form p { margin: 0; }
.fb-form textarea.in { resize: vertical; padding: 10px 12px; min-height: 120px; }
.fb-form .check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.fb-form .check input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); }
.fb-form .actions { justify-content: flex-end; }

/* Шторка снизу: «Отправить… / Скачать / Отмена» */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: min(520px, 100vw); max-width: 100vw;
  background: transparent; color: var(--ink);
}
dialog.sheet[open] { animation: sheet-up .28s var(--ease); }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .35); }
.sheet-body {
  display: flex; flex-direction: column; gap: 10px; background: var(--card); border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(16px + env(safe-area-inset-bottom)); box-shadow: var(--pop);
}
.sheet-title { font-size: 17px; font-weight: 600; text-align: center; }
.sheet-file { font-size: 13px; color: var(--ink-2); text-align: center; overflow-wrap: anywhere; margin-bottom: 4px; }
@media (min-width: 600px) { dialog.sheet { margin: auto; } .sheet-body { border-radius: 16px; } }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Инструкция */
.top-right { display: flex; align-items: center; gap: 14px; }
.top-help { font-size: 15px; }
@media (max-width: 480px) { #save-state { display: none; } }
.help-link { display: inline-block; font-size: 15px; margin: -8px 0 16px; }
.card .help-link { margin: 0; font-size: 14px; }
.help-item { scroll-margin-top: 60px; }
.help-item > summary { list-style: none; cursor: pointer; }
.help-item > summary::-webkit-details-marker { display: none; }
.help-item > summary .title { font-weight: 500; }
.help-item > summary .chev { transition: transform .2s var(--ease); }
.help-item[open] > summary .chev { transform: rotate(90deg); }
.help-item + .help-item { border-top: .5px solid var(--sep); margin-left: 16px; }
.help-item + .help-item > summary { margin-left: -16px; }
.help-body { padding: 0 16px 16px; font-size: 15px; line-height: 1.5; }
.help-body p { margin: 0 0 10px; }
.help-body ol, .help-body ul { margin: 0 0 10px; padding-left: 20px; }
.help-body li { margin: 6px 0; }
.page.help { max-width: 760px; }
