/* tat.css — дизайн-система портала «ТАТ · Инструменты» под бренд ТАТ
   (docs/brand/TAT_Guideline_15_10_19.pdf, docs/BRAND.md). Перенесена из clear-address и расширена:
   тёмная тема, оболочка портала, плитки сервисов, единое меню админки.
   Внешний лист (CSP style-src 'self'); никаких inline style-атрибутов в разметке. */

/* ---------- Шрифт Geometria (самохостинг; веб-лицензию обеспечивает владелец) ---------- */
/* ---------- Шрифт Geometria (самохостинг ассетов TAT) ---------- */
@font-face {
  font-family: 'geo-medium';
  src:
    url(/assets/fonts/geometria-medium.woff2) format('woff2'),
    url(/assets/fonts/geometria-medium.woff) format('woff');
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: 'geo-extra';
  src:
    url(/assets/fonts/geometria-extrabold.woff2) format('woff2'),
    url(/assets/fonts/geometria-extrabold.woff) format('woff');
  font-weight: 400 900;
  font-display: swap;
}
@font-face {
  font-family: 'geo-reg';
  src: url(/assets/fonts/geometria-regular.woff) format('woff');
  font-weight: 400;
  font-display: swap;
}

/* ---------- Токены ---------- */
:root {
  /* фирменные цвета (гайдлайн ТАТ: 171C, 2735C, 2766C) */
  --c-orange: #ff5c39;
  --c-orange-press: #e84924;
  --c-orange-dark: #c03a1f;
  --c-blue: #2f1daa;
  --c-blue-press: #24168a;
  --c-navy: #11154f;
  --c-excel: #217346;
  --c-excel-press: #185c37;
  /* Заливка опасной кнопки с белым текстом (≈5:1) — одинакова в обеих темах. */
  --c-danger-solid: #c0391b;

  /* поверхности и текст — светлая тема */
  --c-ink: #353535;
  --c-muted: #6b6b6b;
  --c-faint: #9a9a9a;
  --c-bg: #f0f0f0;
  --c-surface: #ffffff;
  --c-tint: #fafafa;
  --c-tint2: #efefef;
  --c-border: #d4d4d4;
  --c-ok: #2f8f57;
  --c-warn: #b26a00;
  --c-err: #d53e1b;

  /* семантические роли */
  --accent: var(--c-orange);
  --accent-press: var(--c-orange-press);
  /* Белый на фирменном оранжевом даёт ≈3:1 (< WCAG AA 4,5:1) — решение владельца:
     текст на оранжевом тёмно-синий (≈5,5:1). */
  --on-accent: var(--c-navy);
  --secondary: var(--c-blue);
  --secondary-press: var(--c-blue-press);
  --on-secondary: #ffffff;
  --text: var(--c-ink);
  --muted: var(--c-muted);
  --heading: var(--c-navy);
  --bg: var(--c-bg);
  --surface: var(--c-surface);
  --border: var(--c-border);
  --ring: var(--c-orange);
  /* Текстовые ссылки — тёмный оранжевый (≈5:1 на белом), фирменный оранжевый остаётся для фона. */
  --link: var(--c-orange-dark);
  --link-hover: #9c2e17;
  --overlay-bg: rgba(255, 255, 255, 0.72);
  --logo-blue: var(--c-blue);
  --logo-orange: var(--c-orange);
  --nav-active-bg: rgba(255, 92, 57, 0.1);
  --nav-active-bd: rgba(255, 92, 57, 0.3);
  --nav-active-fg: var(--c-orange-dark);
  /* Текст на светлых подложках акцента/инфо (бейджи, алерты) — контраст ≥ 4,5:1. */
  --accent-fg: var(--c-orange-dark);
  --info-fg: var(--c-blue);

  /* шрифты */
  --font-body: 'geo-medium', 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-head: 'geo-extra', 'Montserrat', system-ui, sans-serif;
  --font-reg: 'geo-reg', var(--font-body);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  /* радиусы (near-square, геометрия бренда) */
  --r-1: 1px;
  --r-2: 2px;
  --r-3: 4px;
  --r-pill: 999px;

  /* отступы 4/8 */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* тени (синий подтон, blur ≤8px) */
  --sh-1: 0 1px 2px rgba(17, 21, 79, 0.06);
  --sh-2: 0 2px 8px rgba(17, 21, 79, 0.09);

  /* z-index */
  --z-dropdown: 20;
  --z-sticky: 30;
  --z-backdrop: 40;
  --z-modal: 50;
  --z-toast: 60;
  --z-tooltip: 70;

  /* motion */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --t-press: 120ms;
  --t-drop: 180ms;
  --t-modal: 240ms;

  /* раскладка */
  --container: 1120px;
  --container-app: 980px;
  --header-h: 64px;
  --sidebar-w: 260px;

  color-scheme: light;
}

/* ---------- Тёмная тема: явно выбранная или системная ---------- */
:root[data-theme='dark'] {
  --c-ink: #e7e8f2;
  --c-muted: #a9adc9;
  --c-faint: #6d7196;
  --c-bg: #0b0e2e;
  --c-surface: #12164a;
  --c-tint: #181d5a;
  --c-tint2: #1e2466;
  --c-border: #2c3378;
  --c-ok: #4cc27f;
  --c-warn: #e0a030;
  --c-err: #ff6b4a;
  --secondary: #5a49e0;
  --secondary-press: #4836cc;
  --heading: #ffffff;
  --link: #ff8a6b;
  --link-hover: #ffb19c;
  --overlay-bg: rgba(11, 14, 46, 0.72);
  --logo-blue: #ffffff;
  --nav-active-fg: #ff8a6b;
  --accent-fg: #ff8a6b;
  --info-fg: #b3abff;
  --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
  --sh-2: 0 2px 8px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme='system'] {
    --c-ink: #e7e8f2;
    --c-muted: #a9adc9;
    --c-faint: #6d7196;
    --c-bg: #0b0e2e;
    --c-surface: #12164a;
    --c-tint: #181d5a;
    --c-tint2: #1e2466;
    --c-border: #2c3378;
    --c-ok: #4cc27f;
    --c-warn: #e0a030;
    --c-err: #ff6b4a;
    --secondary: #5a49e0;
    --secondary-press: #4836cc;
    --heading: #ffffff;
    --link: #ff8a6b;
    --link-hover: #ffb19c;
    --overlay-bg: rgba(11, 14, 46, 0.72);
    --logo-blue: #ffffff;
    --nav-active-fg: #ff8a6b;
    --accent-fg: #ff8a6b;
    --info-fg: #b3abff;
    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.35);
    --sh-2: 0 2px 8px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

/* ---------- Reset / база ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.7 var(--font-body);
  letter-spacing: 0.01em;
}
img,
svg {
  max-width: 100%;
}
svg {
  display: block;
}
a {
  color: var(--link);
  text-decoration: none;
}
a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}
h1,
h2,
h3,
h4,
h5 {
  font-family: var(--font-head);
  color: var(--heading);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 {
  font-size: clamp(28px, 5vw, 40px);
}
h2 {
  font-size: clamp(22px, 4vw, 32px);
}
h3 {
  font-size: 22px;
}
h4 {
  font-size: 18px;
}
h5 {
  font-size: 16px;
}
p {
  margin: 0 0 1em;
  max-width: 72ch;
}
strong,
b {
  font-family: var(--font-head);
  font-weight: 400;
}
small {
  font-size: 0.85rem;
}
:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--r-2);
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--s-5) 0;
}

/* утилиты */
.muted {
  color: var(--muted);
}
.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.eyebrow {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: var(--muted);
}
.overflow {
  overflow-x: auto;
}
.center {
  text-align: center;
}
.stack > * + * {
  margin-top: var(--s-3);
}
.nowrap {
  white-space: nowrap;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Раскладка ---------- */
.wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--s-5) var(--s-4);
}
.wrap.app {
  max-width: var(--container-app);
}
.grid-2 {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 860px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: start;
  }
}
.row {
  display: flex;
  gap: var(--s-3);
  flex-wrap: wrap;
}
.row > * {
  flex: 1 1 220px;
}
.actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- Скип-ссылка (a11y) ---------- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: var(--z-tooltip);
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 0 0 var(--r-2) 0;
  font-family: var(--font-head);
}
.skip-link:focus {
  left: 0;
  text-decoration: none;
}

/* ---------- Шапка / подвал ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: var(--header-h);
  padding: 0 var(--s-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  text-decoration: none;
  color: inherit;
}
.brand:hover {
  text-decoration: none;
}
.brand__logo {
  height: 26px;
  width: auto;
}
.brand__desc {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 10px;
  color: var(--muted);
}
.site-nav {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.site-nav__group {
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  padding: var(--s-5) var(--s-4);
  margin-top: var(--s-7);
}
.site-footer .wrap {
  padding: 0;
  display: flex;
  gap: var(--s-4);
  flex-wrap: wrap;
  justify-content: space-between;
}

/* ---------- Кнопки ---------- */
.btn {
  --btn-bg: var(--accent);
  --btn-fg: var(--on-accent);
  --btn-bd: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: 0 18px;
  font-family: var(--font-head);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--btn-bg);
  color: var(--btn-fg);
  border: 1px solid var(--btn-bd);
  border-radius: var(--r-1);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background var(--t-press) var(--ease-out),
    color var(--t-press) var(--ease-out),
    border-color var(--t-press) var(--ease-out),
    transform var(--t-press) var(--ease-out);
}
.btn:hover {
  text-decoration: none;
}
.btn:active {
  transform: scale(0.97);
}
.btn[disabled],
.btn.is-disabled {
  background: var(--c-tint2);
  color: var(--c-faint);
  border-color: var(--border);
  cursor: not-allowed;
  transform: none;
}
.btn--secondary {
  --btn-bg: var(--secondary);
  --btn-fg: var(--on-secondary);
}
.btn--white {
  --btn-bg: var(--surface);
  --btn-fg: var(--muted);
  --btn-bd: var(--border);
}
.btn--ghost {
  --btn-bg: transparent;
  --btn-fg: var(--muted);
  --btn-bd: var(--border);
}
.btn--ghost {
  border-style: dashed;
  text-transform: none;
  font-family: var(--font-body);
  letter-spacing: 0.01em;
}
.btn--danger {
  --btn-bg: var(--c-danger-solid);
  --btn-fg: #fff;
}
.btn--excel {
  --btn-bg: var(--c-excel);
  --btn-fg: #fff;
}
.btn--excel-outline {
  --btn-bg: var(--surface);
  --btn-fg: var(--c-excel);
  --btn-bd: var(--c-excel);
}
.btn--icon {
  width: 48px;
  padding: 0;
}
.btn--sm {
  min-height: 48px;
  padding: 0 12px;
  font-size: 12px;
}
.btn--lg {
  min-height: 56px;
  padding: 0 28px;
  font-size: 14px;
}
.btn--block {
  width: 100%;
}
@media (hover: hover) and (pointer: fine) {
  .btn--secondary:hover,
  .btn--white:hover,
  .btn--ghost:hover,
  .btn--excel-outline:hover {
    --btn-bg: var(--accent);
    --btn-fg: var(--on-accent);
    --btn-bd: var(--accent);
  }
  .btn:hover {
    background: var(--btn-bg);
    filter: none;
  }
  .btn--secondary:hover {
    background: var(--accent);
  }
  .btn--excel:hover {
    --btn-bg: var(--c-excel-press);
    background: var(--c-excel-press);
  }
  .btn:not(.btn--secondary):not(.btn--white):not(.btn--ghost):not(.btn--danger):not(
      .btn--excel
    ):not(.btn--excel-outline):hover {
    background: var(--accent-press);
  }
}
.btn__spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
}
.btn.is-loading .btn__spinner {
  animation: tat-spin 0.7s linear infinite;
}
.btn.is-loading {
  pointer-events: none;
  opacity: 0.85;
}

/* ---------- Формы ---------- */
.field {
  display: block;
  margin: 0 0 var(--s-3);
}
/* Группа полей (переключатели, связанные поля): без рамки браузера, подпись — как у поля. */
fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}
legend {
  padding: 0;
}
label,
.label {
  display: block;
  font-family: var(--font-head);
  font-size: 13px;
  color: var(--heading);
  margin: 0 0 var(--s-1);
}
.hint {
  color: var(--muted);
  font-size: 12px;
  margin: var(--s-1) 0 0;
}
input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  transition:
    border-color var(--t-press) var(--ease-out),
    box-shadow var(--t-press) var(--ease-out);
}
textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 92, 57, 0.18);
}
input[aria-invalid='true'],
select[aria-invalid='true'],
textarea[aria-invalid='true'] {
  border-color: var(--c-err);
}
input::placeholder,
textarea::placeholder {
  color: var(--c-faint);
}
.field-error {
  color: var(--c-err);
  font-size: 13px;
  margin: var(--s-1) 0 0;
}
.check {
  display: flex;
  gap: var(--s-2);
  min-height: 48px;
  align-items: center;
}
.check input[type='checkbox'],
.check input[type='radio'] {
  width: 20px;
  height: 20px;
  min-height: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
  margin-top: 2px;
}
.check span {
  color: var(--text);
}

/* «Разделы меню» в админ-группе сервиса */
.section-toggles {
  list-style: none;
  margin: 0;
  padding: 0;
}
.section-toggle {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  border-bottom: 1px solid var(--border);
}
.section-toggle:last-child {
  border-bottom: 0;
}
.section-toggle .check .icon {
  color: var(--muted);
}

/* нативный select со стрелкой (фолбэк) */
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23ff5c35' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

/* поле с кнопкой показать/скрыть пароль */
.input-affix {
  position: relative;
}
.input-affix input {
  padding-right: 56px;
}
.input-affix__btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  min-height: 48px;
  width: 48px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
}
.input-affix__btn:hover {
  color: var(--accent);
}

/* ---------- Карточки / панели ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--s-5);
  margin: 0 0 var(--s-4);
}
.card > h2:first-child,
.card > h3:first-child {
  margin-top: 0;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
}
.panel__head {
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.panel__body {
  padding: var(--s-5);
}

/* ---------- Бейджи / пилюли ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-1);
  font-family: var(--font-head);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--c-tint2);
  color: var(--heading);
  border: 1px solid var(--border);
}
.badge--accent {
  background: rgba(255, 92, 57, 0.12);
  color: var(--accent-fg);
  border-color: rgba(255, 92, 57, 0.35);
}
.badge--blue {
  background: rgba(47, 29, 170, 0.1);
  color: var(--info-fg);
  border-color: rgba(47, 29, 170, 0.3);
}
.badge--ok {
  background: rgba(47, 143, 87, 0.12);
  color: var(--c-ok);
  border-color: rgba(47, 143, 87, 0.35);
}

/* ---------- Alert / сообщения ---------- */
.alert {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--r-2);
  margin: 0 0 var(--s-3);
  border: 1px solid transparent;
}
.alert svg {
  flex: 0 0 auto;
  margin-top: 2px;
}
.alert--ok {
  background: rgba(47, 143, 87, 0.1);
  color: var(--c-ok);
  border-color: rgba(47, 143, 87, 0.3);
}
.alert--err {
  background: rgba(213, 62, 27, 0.1);
  color: var(--c-err);
  border-color: rgba(213, 62, 27, 0.3);
}
.alert--warn {
  background: rgba(178, 106, 0, 0.1);
  color: var(--c-warn);
  border-color: rgba(178, 106, 0, 0.3);
}
.alert--info {
  background: rgba(47, 29, 170, 0.08);
  color: var(--info-fg);
  border-color: rgba(47, 29, 170, 0.25);
}

/* ---------- Код / результат ---------- */
.result-box {
  background: var(--c-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  padding: var(--s-4);
  overflow-x: auto;
}
.code {
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre;
}

/* ---------- Stat-плитки ---------- */
.stats {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.stat {
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--s-4);
  background: var(--surface);
}
.stat__label {
  color: var(--muted);
  font-size: 13px;
}
.stat__value {
  font-family: var(--font-head);
  font-size: 28px;
  color: var(--heading);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* ---------- Таблицы ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
thead th {
  font-family: var(--font-head);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
  color: var(--muted);
  text-align: left;
  padding: 10px var(--s-3);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  text-align: left;
  padding: 10px var(--s-3);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: var(--c-tint);
}
/* Плотный «cockpit» для админ-таблиц */
.cockpit thead th,
.cockpit tbody td {
  padding: 7px var(--s-3);
}

/* ---------- Иконки ---------- */
.icon {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  display: inline-block;
  vertical-align: middle;
}
.btn .icon {
  width: 16px;
  height: 16px;
}
.btn--lg .icon {
  width: 18px;
  height: 18px;
}

/* ---------- Шапка: навигация / бургер (прогрессивное улучшение) ---------- */
.nav-toggle {
  display: none;
}
.nav-resizer {
  display: none;
}
@media (max-width: 899px) {
  .site-nav__email {
    display: none;
  }
  /* С JS: скрываем нав за бургером, показываем как выпадающую панель */
  html[data-js] .nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    color: var(--accent);
    background: transparent;
    border: 2px solid var(--accent);
    border-radius: var(--r-2);
    cursor: pointer;
  }
  html[data-js] .site-nav {
    position: absolute;
    top: 100%;
    right: 0;
    left: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-2);
    padding: var(--s-3) var(--s-4);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--sh-2);
    z-index: var(--z-dropdown);
  }
  html[data-js] .site-nav.is-open {
    display: flex;
    animation: tat-drop var(--t-drop) var(--ease-out);
  }
  html[data-js] .site-nav .btn {
    justify-content: flex-start;
  }
  .site-nav__user {
    justify-content: space-between;
  }
}
.site-nav__user {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}
.site-nav__logout {
  margin: 0;
}

/* На десктопе все разделы собраны в единой левой навигации. */
@media (min-width: 900px) {
  .has-app-nav[data-nav-width='200'] {
    --sidebar-w: 200px;
  }
  .has-app-nav[data-nav-width='220'] {
    --sidebar-w: 220px;
  }
  .has-app-nav[data-nav-width='240'] {
    --sidebar-w: 240px;
  }
  .has-app-nav[data-nav-width='260'] {
    --sidebar-w: 260px;
  }
  .has-app-nav[data-nav-width='280'] {
    --sidebar-w: 280px;
  }
  .has-app-nav[data-nav-width='300'] {
    --sidebar-w: 300px;
  }
  .has-app-nav[data-nav-width='320'] {
    --sidebar-w: 320px;
  }
  .has-app-nav[data-nav-width='340'] {
    --sidebar-w: 340px;
  }
  .has-app-nav[data-nav-width='360'] {
    --sidebar-w: 360px;
  }
  .has-app-nav[data-nav-width='380'] {
    --sidebar-w: 380px;
  }
  .has-app-nav[data-nav-width='400'] {
    --sidebar-w: 400px;
  }
  .has-app-nav .site-header {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    min-height: 100dvh;
    padding: var(--s-5) var(--s-4);
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    overflow-y: auto;
    border-right: 1px solid var(--border);
    border-bottom: 0;
    transition: width var(--t-press) var(--ease-out);
  }
  .has-app-nav .brand {
    min-height: 48px;
    padding: 0 48px 0 var(--s-2);
  }
  html[data-js] .has-app-nav .nav-toggle {
    position: absolute;
    top: var(--s-5);
    right: var(--s-4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    color: var(--accent);
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--r-2);
    cursor: pointer;
  }
  html[data-js] .has-app-nav .nav-toggle:hover {
    color: var(--accent);
    border-color: var(--accent);
  }
  html[data-js] .has-app-nav .nav-resizer {
    position: fixed;
    top: 0;
    left: calc(var(--sidebar-w) - 24px);
    z-index: calc(var(--z-sticky) + 1);
    display: block;
    width: 48px;
    height: 100dvh;
    padding: 0;
    touch-action: none;
    cursor: ew-resize;
  }
  html[data-js] .has-app-nav .nav-resizer::after {
    position: absolute;
    top: calc(50% - 28px);
    left: 22px;
    width: 4px;
    height: 56px;
    content: '';
    background: var(--border);
    border-radius: var(--r-pill);
  }
  html[data-js] .has-app-nav .nav-resizer:hover::after,
  html[data-js] .has-app-nav .nav-resizer:focus-visible::after,
  html[data-js] .has-app-nav.nav-resizing .nav-resizer::after {
    background: var(--accent);
  }
  .has-app-nav .site-nav {
    flex: 1 0 auto;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-1);
  }
  .has-app-nav .site-nav__user {
    flex-wrap: wrap;
    padding: var(--s-3) var(--s-2) var(--s-4);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--s-2);
  }
  .has-app-nav .site-nav__email {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .has-app-nav .site-nav__group {
    padding: var(--s-4) var(--s-2) var(--s-1);
  }
  .has-app-nav .site-nav .btn {
    justify-content: flex-start;
    border-color: transparent;
    background: transparent;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0.01em;
  }
  .has-app-nav .site-nav .btn:hover {
    background: var(--c-tint);
    color: var(--heading);
  }
  .has-app-nav .site-nav .btn[aria-current='page'] {
    color: var(--nav-active-fg);
    background: var(--nav-active-bg);
    border-color: var(--nav-active-bd);
  }
  .has-app-nav .site-nav__logout {
    margin-top: auto;
    padding-top: var(--s-5);
  }
  .has-app-nav > main.wrap {
    width: auto;
    max-width: none;
    margin-left: var(--sidebar-w);
    margin-right: 0;
    transition: margin-left var(--t-press) var(--ease-out);
  }
  .has-app-nav > .site-footer {
    margin-left: var(--sidebar-w);
    transition: margin-left var(--t-press) var(--ease-out);
  }
  .has-app-nav.nav-resizing .site-header,
  .has-app-nav.nav-resizing > main.wrap,
  .has-app-nav.nav-resizing > .site-footer {
    transition: none;
  }
  html[data-js] .has-app-nav.nav-collapsed .site-header {
    width: 0;
    min-height: 0;
    padding: 0;
    overflow: visible;
    border-right: 0;
  }
  html[data-js] .has-app-nav.nav-collapsed .brand,
  html[data-js] .has-app-nav.nav-collapsed .site-nav,
  html[data-js] .has-app-nav.nav-collapsed .nav-resizer {
    display: none;
  }
  html[data-js] .has-app-nav.nav-collapsed .nav-toggle {
    position: fixed;
    top: var(--s-4);
    right: auto;
    left: var(--s-4);
    box-shadow: var(--sh-2);
  }
  html[data-js] .has-app-nav.nav-collapsed > main.wrap {
    margin-left: 0;
    /* Резервируем левую колонку под фиксированный бургер, чтобы он не перекрывал
       заголовки при прокрутке (не только первый .app-head). */
    padding-left: 64px;
  }
  html[data-js] .has-app-nav.nav-collapsed > .site-footer {
    margin-left: 0;
  }
}

/* ---------- Кастомный дропдаун (клиент строит из <select> в D2) ---------- */
.dropdown {
  position: relative;
}
.dropdown__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  cursor: pointer;
  font: inherit;
  transition:
    border-color var(--t-press) var(--ease-out),
    box-shadow var(--t-press) var(--ease-out);
}
.dropdown__trigger:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(255, 92, 57, 0.18);
}
.dropdown__trigger .icon {
  color: var(--accent);
  transition: transform var(--t-drop) var(--ease-out);
}
.dropdown[data-open] .dropdown__trigger .icon {
  transform: rotate(180deg);
}
.dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: var(--z-dropdown);
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--sh-2);
  max-height: 280px;
  overflow-y: auto;
  transform-origin: top center;
}
.dropdown__menu[hidden] {
  display: none;
}
.dropdown[data-open] .dropdown__menu {
  animation: tat-drop var(--t-drop) var(--ease-out);
}
.dropdown__option {
  padding: 10px 12px;
  border-radius: var(--r-2);
  cursor: pointer;
}
.dropdown__option[aria-selected='true'] {
  color: var(--accent-press);
  font-family: var(--font-head);
}
.dropdown__option.is-active,
.dropdown__option:hover {
  background: var(--c-tint);
}

/* ---------- Модалка (нативный <dialog>) ---------- */
.modal {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: min(92vw, 480px);
  width: 100%;
  color: var(--text);
}
.modal::backdrop {
  background: rgba(17, 21, 79, 0.45);
}
.modal__card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  overflow: hidden;
}
.modal[open] .modal__card {
  animation: tat-modal var(--t-modal) var(--ease-out);
}
.modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.modal__head h3 {
  margin: 0;
}
.modal__close {
  display: inline-flex;
  width: 48px;
  height: 48px;
  padding: 0;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--r-2);
}
.modal__close:hover {
  color: var(--accent);
  background: var(--c-tint);
}
.modal__body {
  padding: var(--s-5);
}
.modal__foot {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--c-tint);
}

/* ---------- Тосты ---------- */
.toast-region {
  position: fixed;
  right: var(--s-4);
  bottom: var(--s-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  max-width: min(92vw, 380px);
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--r-2);
  box-shadow: var(--sh-2);
  animation: tat-toast-in var(--t-drop) var(--ease-out);
}
.toast--ok {
  border-left-color: var(--c-ok);
}
.toast--ok .icon {
  color: var(--c-ok);
}
.toast--err {
  border-left-color: var(--c-err);
}
.toast--err .icon {
  color: var(--c-err);
}
.toast--info {
  border-left-color: var(--secondary);
}
.toast--info .icon {
  color: var(--secondary);
}
.toast.is-leaving {
  animation: tat-toast-out var(--t-drop) var(--ease-in-out) forwards;
}
.toast__body {
  flex: 1;
}
.toast__undo {
  background: transparent;
  border: 0;
  color: var(--link);
  font: inherit;
  font-family: var(--font-head);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  min-height: 48px;
  padding: 2px 8px;
}

/* ---------- Пустое состояние / скелетон ---------- */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-7) var(--s-4);
  color: var(--muted);
  text-align: center;
}
.empty__icon {
  width: 40px;
  height: 40px;
  color: var(--c-faint);
}
.skeleton {
  background: linear-gradient(90deg, var(--c-tint2) 25%, var(--c-tint) 37%, var(--c-tint2) 63%);
  background-size: 400% 100%;
  border-radius: var(--r-2);
  animation: tat-shimmer 1.4s ease infinite;
  min-height: 16px;
}

/* ---------- Мозаика ТАТ (брендовый акцент) ---------- */
.mosaic {
  --sq: 14px;
  height: var(--sq);
  background-image:
    linear-gradient(90deg, var(--accent) 0 var(--sq), transparent var(--sq)),
    linear-gradient(90deg, var(--secondary) 0 var(--sq), transparent var(--sq));
}
.mosaic--bar {
  background-repeat: repeat-x;
  background-size:
    calc(var(--sq) * 3) var(--sq),
    calc(var(--sq) * 5) var(--sq);
  background-position:
    0 0,
    var(--sq) 0;
}

/* ---------- Кубик-загрузчик ТАТ (DaData/DB-операции) ---------- */
.cube-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-6) var(--s-4);
  color: var(--muted);
  text-align: center;
}
.cube-loader__mark {
  width: 44px;
  height: 44px;
}
.cube-loader__label {
  font-family: var(--font-head);
  font-size: 13px;
}
@media (prefers-reduced-motion: no-preference) {
  .cube-loader__mark .logo-mark__sq {
    transform-origin: 50% 50%;
    animation: tat-cube 1.1s var(--ease-in-out) infinite;
  }
  .cube-loader__mark .logo-mark__sq--o2 {
    animation-delay: 0.12s;
  }
  .cube-loader__mark .logo-mark__sq--b1 {
    animation-delay: 0.24s;
  }
  .cube-loader__mark .logo-mark__sq--b2 {
    animation-delay: 0.36s;
  }
}
@keyframes tat-cube {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.82);
  }
  40% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Полноэкранный ТАТ-лоадер для действий без региона-цели (навигация/модалка). */
.cube-overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  background: rgba(17, 21, 79, 0.28);
}
/* Внутри открытой модалки (top layer) крепится абсолютно, поверх её содержимого. */
.cube-overlay--anchored {
  position: absolute;
  z-index: 3;
  background: var(--overlay-bg);
}
:root[data-theme='dark'] .cube-overlay--anchored {
  background: rgba(17, 21, 79, 0.62);
}

/* ---------- Логотип-знак: сборка при загрузке ---------- */
.logo-mark {
  width: 56px;
  height: 56px;
}
.logo-mark__sq {
  transform-origin: 50% 50%;
}
@media (prefers-reduced-motion: no-preference) {
  .logo-mark--animate .logo-mark__sq {
    animation: tat-assemble 520ms var(--ease-out) both;
  }
  .logo-mark--animate .logo-mark__sq--o2 {
    animation-delay: 70ms;
  }
  .logo-mark--animate .logo-mark__sq--b1 {
    animation-delay: 140ms;
  }
  .logo-mark--animate .logo-mark__sq--b2 {
    animation-delay: 210ms;
  }
}

/* ---------- Ссылка с брендовой стрелкой ---------- */
.link-arrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.link-arrow .icon {
  transition: transform var(--t-press) var(--ease-out);
}
@media (hover: hover) {
  .link-arrow:hover .icon {
    transform: translateX(3px);
  }
}

/* ---------- Раскладка: авторизация ---------- */
.main--auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h) - 140px);
  padding: var(--s-6) var(--s-4);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  padding: var(--s-6);
  box-shadow: var(--sh-2);
}
.auth-card__head {
  text-align: center;
  margin-bottom: var(--s-5);
}
.auth-card__head .logo-mark {
  margin: 0 auto var(--s-3);
}
.auth-card__foot {
  margin-top: var(--s-4);
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Раскладка: приложение ---------- */
.app-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  flex-wrap: wrap;
  margin-bottom: var(--s-5);
}
.app-head h1 {
  margin: 0;
}
.app-head h2 {
  margin: 0;
}
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-top: var(--s-4);
  flex-wrap: wrap;
}

/* ---------- Раскладка: админка (shell) ---------- */
.admin {
  display: grid;
  gap: var(--s-5);
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .admin {
    grid-template-columns: 1fr;
    align-items: start;
  }
}
.admin-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--s-1);
}
@media (min-width: 900px) {
  .admin-nav {
    position: sticky;
    top: calc(var(--header-h) + var(--s-4));
    flex-direction: column;
    overflow: visible;
    padding: 0;
  }
}
.admin-nav__link {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  white-space: nowrap;
  padding: 10px 12px;
  border-radius: var(--r-2);
  color: var(--muted);
  font-family: var(--font-head);
  font-size: 13px;
  border: 1px solid transparent;
}
.admin-nav__link:hover {
  color: var(--heading);
  background: var(--c-tint);
  text-decoration: none;
}
.admin-nav__link[aria-current='page'] {
  color: var(--nav-active-fg);
  background: var(--nav-active-bg);
  border-color: var(--nav-active-bd);
}
.admin-nav__link .icon {
  width: 16px;
  height: 16px;
}
.admin-main {
  min-width: 0;
}
.admin-main > h1 {
  margin-top: 0;
}
.inline-form {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  margin: 0;
  flex-wrap: wrap;
}
.inline-form .dropdown {
  min-width: 150px;
}
/* блок кода с кнопкой «копировать» */
.code-scroll {
  position: relative;
}
.code-scroll .code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
}
.code-scroll .result-box {
  padding-top: var(--s-6);
}

/* ---------- Анимации ---------- */
@keyframes tat-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes tat-drop {
  from {
    opacity: 0;
    transform: translateY(-6px) scaleY(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes tat-modal {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes tat-toast-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes tat-toast-out {
  to {
    opacity: 0;
    transform: translateX(16px);
  }
}
@keyframes tat-shimmer {
  to {
    background-position: -400% 0;
  }
}
@keyframes tat-assemble {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes tat-fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: no-preference) {
  .fade-up {
    animation: tat-fade-up 360ms var(--ease-out) both;
  }
}

/* Reduced-motion: гасим всё (должно оставаться последним) */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =================================================================================
   Оболочка портала «ТАТ · Инструменты»
   ================================================================================= */

/* ---------- Логотип (инлайновый SVG, цвета из темы) ---------- */
.logo__blue {
  fill: var(--logo-blue);
}
.logo__orange {
  fill: var(--logo-orange);
}
.brand__logo {
  display: block;
  height: 26px;
  width: auto;
}
.brand {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}
.brand__app {
  font-family: var(--font-head);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  line-height: 1.2;
}

/* ---------- Переключатель сервисов ---------- */
.service-switcher {
  position: relative;
  margin: var(--s-2) 0 var(--s-1);
}
.service-switcher > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 48px;
  padding: 8px 12px;
  color: var(--heading);
  font-family: var(--font-head);
  font-size: 14px;
  background: var(--c-tint);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  cursor: pointer;
  list-style: none;
}
.service-switcher > summary::-webkit-details-marker {
  display: none;
}
.service-switcher > summary::marker {
  content: '';
}
.service-switcher > summary .icon:last-child {
  transition: transform var(--t-press) var(--ease-out);
}
.service-switcher[open] > summary .icon:last-child {
  transform: rotate(180deg);
}
.service-switcher__label {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-width: 0;
}
.service-switcher__label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.service-switcher__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: var(--z-dropdown);
  display: flex;
  flex-direction: column;
  padding: var(--s-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  box-shadow: var(--sh-2);
  animation: tat-drop var(--t-drop) var(--ease-out);
}
.service-switcher__item {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: 0 12px;
  color: var(--text);
  border-radius: var(--r-2);
}
.service-switcher__item:hover {
  background: var(--c-tint);
  color: var(--heading);
  text-decoration: none;
}
.service-switcher__item[aria-current='true'] {
  color: var(--nav-active-fg);
  background: var(--nav-active-bg);
}
.service-switcher__all {
  border-top: 1px solid var(--border);
  margin-top: var(--s-1);
  padding-top: var(--s-1);
}

/* ---------- Блок пользователя и тема ---------- */
.user-card {
  display: grid;
  gap: var(--s-1);
  padding: var(--s-3) var(--s-2);
  border-top: 1px solid var(--border);
  margin-top: var(--s-2);
}
.user-card__name {
  font-family: var(--font-head);
  color: var(--heading);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-card__email {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.theme-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
  margin: var(--s-2) 0 0;
  padding: 2px;
  background: var(--c-tint2);
  border: 1px solid var(--border);
  border-radius: var(--r-2);
}
.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: var(--r-1);
  cursor: pointer;
}
.theme-switch button[aria-pressed='true'] {
  color: var(--heading);
  background: var(--surface);
  box-shadow: var(--sh-1);
}
.theme-switch button:hover {
  color: var(--heading);
}

/* ---------- Пометки в меню ---------- */
.nav-badge {
  margin-left: auto;
  padding: 1px 6px;
  font-family: var(--font-body);
  font-size: 11px;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--r-pill);
}
.site-nav .btn.is-hidden-section {
  opacity: 0.75;
}

/* ---------- Плитки сервисов ---------- */
.tiles {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: 1fr;
  margin: 0;
  padding: 0;
  list-style: none;
}
@media (min-width: 720px) {
  .tiles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (min-width: 1200px) {
  .tiles {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  min-height: 200px;
  padding: var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-3);
  box-shadow: var(--sh-1);
  transition:
    border-color var(--t-press) var(--ease-out),
    box-shadow var(--t-press) var(--ease-out),
    transform var(--t-press) var(--ease-out);
}
.tile__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  color: var(--on-accent);
  background: var(--accent);
  border-radius: var(--r-2);
}
.tile__icon .icon {
  width: 24px;
  height: 24px;
}
.tile__title {
  margin: 0;
  font-size: 20px;
}
.tile__title a {
  color: inherit;
}
.tile__title a::after {
  /* вся плитка кликабельна, но в разметке одна ссылка (доступность) */
  content: '';
  position: absolute;
  inset: 0;
}
.tile__desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.tile__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  flex-wrap: wrap;
  margin-top: auto;
}
.tile__foot form {
  position: relative;
  z-index: 1;
  margin: 0;
}
.tile--granted:hover {
  border-color: var(--accent);
  box-shadow: var(--sh-2);
}
.tile--granted:focus-within {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.tile--granted .tile__title a:focus-visible {
  outline: none;
}
.tile--none .tile__icon,
.tile--requested .tile__icon,
.tile--soon .tile__icon {
  color: var(--muted);
  background: var(--c-tint2);
}
.tile--none,
.tile--requested,
.tile--soon {
  background: var(--c-tint);
  box-shadow: none;
}
.tile--none .tile__title,
.tile--requested .tile__title,
.tile--soon .tile__title {
  color: var(--muted);
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .tile--granted:hover {
    transform: translateY(-2px);
  }
}

/* Кнопка с длинной подписью, которая может переноситься на узких экранах. */
.btn--wrap {
  white-space: normal;
  text-align: left;
  padding-block: 12px;
  height: auto;
}

/* ---------- Страница ошибки ---------- */
.error-page {
  max-width: 560px;
  margin: var(--s-7) auto;
  text-align: left;
}
.error-page__code {
  font-family: var(--font-head);
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---------- Подвал ---------- */
.site-footer__version {
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ---------- Админка: фильтры и карточки данных ---------- */
.filters {
  display: grid;
  gap: var(--s-3);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  margin: 0 0 var(--s-4);
}
.filters .field {
  margin: 0;
}
.filters .actions {
  min-height: 48px;
}
/* Миниатюра (контур зоны и т. п.) в таблице */
img.thumb {
  display: block;
  max-width: none;
  border: 1px solid var(--border);
  border-radius: var(--r-2);
  background: var(--surface);
}
.kv {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--s-2) var(--s-4);
  margin: 0;
}
.kv dt {
  color: var(--muted);
  font-size: 13px;
}
.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
@media (max-width: 599px) {
  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  .kv dd {
    margin-bottom: var(--s-3);
  }
}
details.card > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  cursor: pointer;
}
.inline-form input {
  width: auto;
  min-width: 0;
  flex: 1 1 180px;
}
.stack > .inline-form + .inline-form {
  margin-top: var(--s-2);
}

/* ---------- Подсказка к термину (компонент tooltip) ---------- */
.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tooltip__trigger {
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--secondary);
  background: transparent;
  border: 0;
  cursor: help;
}
.tooltip__trigger .icon {
  width: 16px;
  height: 16px;
}
.tooltip__bubble {
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: var(--z-tooltip);
  display: none;
  width: min(280px, calc(100vw - 32px));
  padding: var(--s-2) var(--s-3);
  color: #fff;
  background: var(--c-navy);
  border-radius: var(--r-2);
  font: 13px/1.45 var(--font-body);
  box-shadow: var(--sh-2);
}
.tooltip[data-open] .tooltip__bubble,
.tooltip:focus-within .tooltip__bubble {
  display: block;
}
