/* =========================================================================
   photo.belles.kz — ui.css: общие компоненты (P17, из лаборатории design-lab/photo/ui.css): кнопки, поля, бейджи, чипы, вкладки,
   меню, диалог подтверждения, тосты, баннеры, пустые состояния, скелетоны, dl, пагинация (вид center).
   Перенос (P17): варианты лаборатории сняты под выбор владельца 07.11 скриптом — выбранный вариант остаётся правилом,
   префикс варианта на <html> заменён на html:root… той же специфичности (каскад не меняется), невыбранные удалены;
   повторы правил одного селектора сведены, где это не меняет каскад. Равенство вычисленных стилей с лабораторией проверено
   на 52 экранах × 1440/390. Мозаика getty — только с JS (:where(.js)), «Сетка» — html[data-feed-view="grid"] и без JS.
   ========================================================================= */
/* ---------- База ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh; background: var(--canvas); color: var(--text);
  font: var(--fw-regular) var(--fs-md)/var(--lh) var(--font);
  font-feature-settings: var(--font-features);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3 { letter-spacing: var(--tracking-head); line-height: var(--lh-tight); text-wrap: balance; font-weight: var(--fw-semibold); }
a { color: var(--accent-ui); text-decoration-thickness: 1px; text-underline-offset: 3px; }
::selection { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--text); }
:focus { outline: none; }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--r-sm); }
.tnum, td.num, .num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-ctl); text-decoration: none; }
.skip-link:focus { top: 12px; }
[hidden] { display: none !important; }

/* Тонкие скроллбары в цвет темы */
* { scrollbar-width: thin; scrollbar-color: #d4d4d8 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 10px; border: 3px solid transparent; background-clip: content-box; }

/* Иконки: SVG-спрайт, currentColor */
.ic { width: 20px; height: 20px; flex: none; color: currentColor; }
.ic--sm { width: 16px; height: 16px; }
.ic--lg { width: 24px; height: 24px; }
.ic--xl { width: 32px; height: 32px; }
/* иконки — спрайт Hugeicons витрины (обводка) */
.ic use { pointer-events: none; }

/* Аватар */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  background: var(--brand-soft); color: var(--brand); font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.avatar--lg { width: 64px; height: 64px; font-size: var(--fs-lg); }
.avatar--ink { background: var(--neutral-bg); color: var(--neutral); }

/* Страница */
.page { flex: 1; padding: var(--s-2) var(--page-pad) var(--s-12); }
.page__inner { max-width: var(--content-max); margin: 0 auto; display: grid; gap: var(--stack); min-width: 0; }
.page__inner > * { min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; padding-top: var(--s-4); }
.page-head__title { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.page-head h1 { font-size: var(--fs-xl); }
.page-head__sub { color: var(--text-2); font-size: var(--fs-sm); margin-top: 4px; }
.page-head__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-size: var(--fs-sm); font-weight: var(--fw-medium); min-height: 32px; }
.back-link:hover { color: var(--text); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-3); flex-wrap: wrap; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--text); text-decoration: underline; }

.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: var(--z-overlay); opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease-out); }
.overlay.is-open { opacity: 1; pointer-events: auto; }

/* ---------- Кнопки ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-line: var(--line); --btn-bg-hover: var(--surface-hover); --btn-bg-press: var(--surface-press);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--ctl-h); padding: 0 var(--s-4); border-radius: var(--r-ctl);
  border: 1px solid var(--btn-line); background: var(--btn-bg); color: var(--btn-fg);
  font-weight: var(--fw-medium); font-size: var(--fs-md); line-height: 1; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-xs); user-select: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1);
}
.btn:hover { background: var(--btn-bg-hover); }
.btn:active:not(:disabled):not(.is-loading) { background: var(--btn-bg-press); transform: scale(.98); }
.btn:focus-visible { border-radius: var(--r-ctl); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn .ic { width: 18px; height: 18px; }
.btn--primary { --btn-bg: var(--primary-bg); --btn-fg: var(--primary-fg); --btn-line: transparent; --btn-bg-hover: var(--primary-bg-hover); --btn-bg-press: var(--primary-bg-press); box-shadow: var(--shadow-sm); }
.btn--ink { --btn-bg: var(--ink); --btn-fg: #fff; --btn-line: transparent; --btn-bg-hover: var(--ink-hover); --btn-bg-press: var(--ink-press); }
.btn--danger { --btn-bg: var(--danger-solid); --btn-fg: #fff; --btn-line: transparent; --btn-bg-hover: var(--danger-solid-hover); --btn-bg-press: #8e1b13; }
.btn--danger-soft { --btn-fg: var(--danger); --btn-bg-hover: var(--danger-bg); }
.btn--ghost { --btn-bg: transparent; --btn-line: transparent; --btn-fg: var(--text-2); box-shadow: none; }
.btn--ghost:hover { color: var(--text); }
.btn--sm { height: var(--ctl-h-sm); padding: 0 var(--s-3); font-size: var(--fs-sm); gap: 6px; }
.btn--lg { height: 48px; padding: 0 var(--s-6); font-size: var(--fs-md); }
.btn--block { width: 100%; }
.btn--icon { width: var(--ctl-h); padding: 0; }
.btn--icon.btn--sm { width: var(--ctl-h-sm); }
/* кнопка с загрузкой: спиннер внутри, текст «Сохраняю…», повторное нажатие заблокировано */
.btn.is-loading { pointer-events: none; cursor: progress; }
.btn.is-loading > .ic { display: none; } /* витрина: иконка не занимает место рядом со спиннером */
.btn__spinner { display: none; }
.btn.is-loading .btn__spinner { display: block; }
.btn-group { display: inline-flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
@media (max-width: 767px) { .btn--icon { width: var(--tap); } .btn--sm { min-height: 40px; } }

.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; opacity: .9; animation: spin .7s linear infinite; flex: none; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }

/* Ссылка-кнопка */
.link-btn { border: 0; background: none; padding: 0; color: var(--accent-ui); font-weight: var(--fw-medium); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link-btn:hover { text-decoration-thickness: 2px; }

/* ---------- Формы ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field__label { font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); display: flex; align-items: center; gap: 6px; }
.field__req { color: var(--danger); }
.field__opt { color: var(--text-3); font-weight: var(--fw-regular); }
.field__hint { font-size: var(--fs-sm); color: var(--text-3); }
.field__error { font-size: var(--fs-sm); color: var(--danger); display: flex; gap: 6px; align-items: flex-start; }
.field__error .ic { width: 16px; height: 16px; margin-top: 2px; }
.field__count { font-size: var(--fs-xs); color: var(--text-3); margin-left: auto; font-variant-numeric: tabular-nums; }
.input, .select, .textarea {
  width: 100%; height: var(--ctl-h); padding: 0 var(--s-3); border: 1px solid var(--line-input); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text); font-size: var(--fs-md);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: #6b6b73; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--accent-ui); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-ui) 18%, transparent); border-radius: var(--r-ctl); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly] { background: var(--surface-2); color: var(--text-2); border-color: var(--line); cursor: not-allowed; }
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.textarea { height: auto; min-height: 112px; padding: 10px var(--s-3); line-height: var(--lh); resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2352525b' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .ic { position: absolute; left: 12px; color: var(--text-3); pointer-events: none; }
.input-group > .ic + .input { padding-left: 38px; }
.input-group__suffix { position: absolute; right: 12px; color: var(--text-3); font-size: var(--fs-sm); pointer-events: none; }
.input-group__suffix ~ .input, .input-group .input:has(+ .input-group__suffix) { padding-right: 40px; }
.input-group__btn { position: absolute; right: 4px; }
.input--num { font-variant-numeric: tabular-nums; text-align: right; }
.form-grid { display: grid; gap: var(--s-5) var(--s-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 767px) { .form-grid { grid-template-columns: minmax(0, 1fr); } .input, .select, .textarea { font-size: 16px; } }

/* Чекбокс/радио/переключатель */
.check { display: inline-flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: var(--fs-md); line-height: 1.4; min-height: 24px; }
.check input { appearance: none; margin: 1px 0 0; flex: none; width: 20px; height: 20px; border: 1.5px solid var(--line-input); border-radius: var(--r-xs); background: var(--surface) center/14px no-repeat; transition: background-color var(--dur-1), border-color var(--dur-1); cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background-color: var(--accent-ui); border-color: var(--accent-ui); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E"); }
.check input[type="radio"]:checked { background-image: radial-gradient(circle, #fff 0 3.5px, transparent 4px); }
.check input:indeterminate { background-color: var(--accent-ui); border-color: var(--accent-ui); background-image: linear-gradient(#fff, #fff); background-size: 10px 2px; }
.check input:focus-visible { box-shadow: var(--focus-ring); }
.check__text small { display: block; color: var(--text-3); font-size: var(--fs-sm); margin-top: 2px; }
/* зона нажатия чекбокса в таблице ≥ 40px */
.check--cell { padding: 10px; margin: -10px; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 32px; }
.switch input { appearance: none; margin: 0; width: 40px; height: 24px; border-radius: 999px; background: #d4d4d8; position: relative; cursor: pointer; transition: background-color var(--dur-2) var(--ease-out); flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .2); transition: translate var(--dur-3) var(--ease-spring); }
.switch input:checked { background: var(--accent-ui); }
.switch input:checked::after { translate: 16px 0; }
.switch input:focus-visible { box-shadow: var(--focus-ring); }

/* ---------- Карточки и секции ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); box-shadow: var(--shadow-xs); min-width: 0; }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--card-pad); border-bottom: 1px solid var(--line-soft); min-height: 60px; flex-wrap: wrap; }
.card__head--plain { border-bottom: 0; padding-bottom: 0; }
.card__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--s-2); }
.card__sub { color: var(--text-3); font-size: var(--fs-sm); margin-top: 2px; }
.card__body { padding: var(--card-pad); }
.card__foot { padding: var(--s-3) var(--card-pad); border-top: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
/* секция формы как в ref-3: описание слева, поля справа */
.fsec { display: grid; grid-template-columns: minmax(0, 280px) minmax(0, 1fr); gap: var(--s-8); padding: var(--s-6) 0; border-top: 1px solid var(--line); }
.fsec:first-child { border-top: 0; padding-top: 0; }
.fsec__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.fsec__desc { color: var(--text-2); font-size: var(--fs-sm); margin-top: 6px; max-width: 32ch; }
@media (max-width: 1023px) { .fsec { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); } }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--stack); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--stack); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--stack); align-items: start; }
@media (max-width: 1199px) { .split { grid-template-columns: minmax(0, 1fr); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--s-3) var(--s-6); font-size: var(--fs-md); margin: 0; }
.dl dt { color: var(--text-2); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 767px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: var(--s-3); } }

/* ---------- Бейджи / статусы / чипы ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); white-space: nowrap; line-height: 1;
  background: var(--neutral-bg); color: var(--neutral); border: 1px solid var(--neutral-line);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--plain::before { display: none; }
.badge--success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.badge--warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.badge--danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.badge--info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge--violet { background: var(--violet-bg); color: var(--violet); border-color: var(--violet-line); }
.badge--brand { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-line); }
.badge .ic { width: 14px; height: 14px; }
.badge:has(.ic)::before { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium);
  white-space: nowrap; transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1);
}
button.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip[aria-pressed="true"], .chip.is-on { border-color: var(--selected-line); background: var(--selected-bg); color: var(--text); }
.chip--dashed { border-style: dashed; }
.chip__x { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: -6px; border: 0; background: none; border-radius: 50%; color: var(--text-3); padding: 0; }
.chip__x:hover { background: var(--surface-press); color: var(--text); }
.chip__x .ic { width: 14px; height: 14px; }
.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; align-items: center; }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: var(--r-sm); background: var(--surface-sunken); color: var(--text-2); font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: var(--fs-xs); font-weight: var(--fw-semibold); padding: 2px 6px; border-radius: var(--r-sm); font-variant-numeric: tabular-nums; }
.delta--up { color: var(--success); background: var(--success-bg); }
.delta--down { color: var(--danger); background: var(--danger-bg); }
.delta .ic { width: 12px; height: 12px; }

/* ---------- Вкладки и сегмент-контрол ---------- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative; display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 var(--s-3);
  border: 0; background: none; color: var(--text-2); font-weight: var(--fw-medium); white-space: nowrap; text-decoration: none;
}
.tab:hover { color: var(--text); }
.tab::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--accent-ui); transform: scaleX(0); transition: transform var(--dur-2) var(--ease-out); }
.tab[aria-selected="true"], .tab[aria-current="page"] { color: var(--text); }
.tab[aria-selected="true"]::after, .tab[aria-current="page"]::after { transform: scaleX(1); }
.tab__count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--r-pill); background: var(--surface-sunken); color: var(--text-2); font-size: var(--fs-xs); display: inline-grid; place-items: center; font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] .tab__count { background: var(--ink); color: #fff; }
html:root .tab[aria-selected="true"] .tab__count { background: var(--brand); }
.seg { display: inline-flex; padding: 3px; background: var(--surface-sunken); border-radius: calc(var(--r-ctl) + 2px); gap: 2px; }
.seg__btn {
  display: inline-flex; align-items: center; gap: 6px; height: calc(var(--ctl-h) - 6px); padding: 0 var(--s-3); border: 0; border-radius: var(--r-ctl);
  background: transparent; color: var(--text-2); font-weight: var(--fw-medium); font-size: var(--fs-sm);
  transition: background-color var(--dur-2) var(--ease-out), color var(--dur-2), box-shadow var(--dur-2);
}
.seg__btn:hover { color: var(--text); }
.seg__btn[aria-pressed="true"], .seg__btn[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.seg__btn .ic { width: 18px; height: 18px; }

/* ---------- Панель инструментов списка ---------- */
.toolbar { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-3) var(--card-pad); border-bottom: 1px solid var(--line-soft); }
.toolbar__search { flex: 1 1 260px; max-width: 360px; }
.toolbar__spacer { flex: 1; }
@media (max-width: 767px) { .toolbar__search { max-width: none; flex-basis: 100%; } .toolbar .seg { margin-left: auto; } }
/* панель выделения (заменяет тулбар при ≥1 выбранном) */
.bulkbar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-2) var(--card-pad); min-height: 57px;
  background: var(--selected-bg); border-bottom: 1px solid var(--selected-line);
}
.bulkbar__count { font-weight: var(--fw-semibold); margin-right: var(--s-2); font-variant-numeric: tabular-nums; }
@media (max-width: 767px) {
  .bulkbar { position: fixed; left: 8px; right: 8px; bottom: 8px; z-index: var(--z-sticky); border: 1px solid var(--selected-line); border-radius: var(--r-lg); box-shadow: var(--shadow-lg); background: var(--surface); padding: var(--s-2) var(--s-3); }
}

/* ---------- Таблица (как ref-1) ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); }
.table th {
  position: sticky; top: 0; z-index: 1; height: 44px; padding: 0 var(--s-3); text-align: left; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2); font-weight: var(--fw-medium); font-size: var(--fs-sm); border-bottom: 1px solid var(--line);
}
.table th:first-child, .table td:first-child { padding-left: var(--card-pad); }
.table th:last-child, .table td:last-child { padding-right: var(--card-pad); }
.table td { height: var(--row-h); padding: 6px var(--s-3); border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background-color var(--dur-1) var(--ease-out); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-selected { background: var(--selected-bg); }
.table tbody tr[data-href] { cursor: pointer; }
.table .num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-check { width: 44px; }
.table .col-actions { width: 56px; text-align: right; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; border: 0; background: none; padding: 0; color: inherit; font: inherit; height: 32px; }
.th-sort:hover { color: var(--text); }
.th-sort .ic { width: 14px; height: 14px; opacity: .5; }
.th-sort[aria-sort] .ic { opacity: 1; }
.cell-main { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.cell-main__text { min-width: 0; }
.cell-title { font-weight: var(--fw-medium); color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 44ch; }
a.cell-title:hover { text-decoration: underline; }
.cell-sub { font-size: var(--fs-sm); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 48ch; }
.thumb { width: 48px; height: 48px; border-radius: var(--r-sm); object-fit: cover; background: var(--skeleton); flex: none; border: 1px solid var(--line-soft); }
.thumb--sm { width: 36px; height: 36px; }
.thumb--empty { display: grid; place-items: center; color: var(--text-3); }

/* Таблица → карточки на мобильной */
@media (max-width: 767px) {
  .table--stack thead { display: none; }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; }
  .table--stack tr { position: relative; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line-soft); }
  .table--stack td { height: auto; padding: 2px 0 !important; border: 0; }
  .table--stack td[data-label]:not(.td-main)::before { content: attr(data-label) " · "; color: var(--text-3); font-size: var(--fs-sm); }
  .table--stack td.num { text-align: left; }
  .table--stack .col-check { position: absolute; left: auto; right: 56px; top: 14px; width: auto; }
  .table--stack .col-actions { position: absolute; right: 8px; top: 8px; width: auto; }
  .table--stack .td-main { padding-right: 88px !important; margin-bottom: 6px; }
  .table--stack .cell-title { white-space: normal; max-width: none; }
  .table--stack .td-inline { display: inline-block; width: auto; margin-right: var(--s-3); }
}

/* ---------- Сетка карточек (как Яндекс Диск / ref-1) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--s-4); padding: var(--card-pad); }

.tile {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card);
  overflow: hidden; transition: border-color var(--dur-2) var(--ease-out), box-shadow var(--dur-2) var(--ease-out), translate var(--dur-2) var(--ease-out);
}
.tile:hover { box-shadow: var(--shadow-md); border-color: #d4d4d8; }
.tile.is-selected { border-color: var(--accent-ui); box-shadow: 0 0 0 1px var(--accent-ui); }
.tile__media { position: relative; aspect-ratio: 4 / 3; background: var(--skeleton); overflow: hidden; display: block; }
.tile__media img { width: 100%; height: 100%; object-fit: cover; transition: scale var(--dur-4) var(--ease-out); }
.tile:hover .tile__media img { scale: 1.03; }
.tile__check { position: absolute; top: 8px; left: 8px; z-index: 2; width: 36px; height: 36px; display: grid; place-items: center; border-radius: var(--r-sm); background: rgb(255 255 255 / .92); box-shadow: var(--shadow-xs); }
.tile__check .check input { margin: 0; }
.tile__menu { position: absolute; top: 8px; right: 8px; z-index: 2; }
.tile__menu .btn { background: rgb(255 255 255 / .92); width: 36px; height: 36px; }
.tile__badges { position: absolute; left: 8px; bottom: 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.tile__count { position: absolute; right: 8px; bottom: 8px; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; height: 24px; border-radius: var(--r-pill); background: rgb(24 24 27 / .72); color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }
.tile__count .ic { width: 14px; height: 14px; }
.tile__body { padding: var(--s-3) var(--s-3) var(--s-3); display: grid; gap: 4px; }
.tile__title { font-weight: var(--fw-semibold); color: var(--text); text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.tile__title::after { content: ""; position: absolute; inset: 0; z-index: 1; } /* вся карточка кликабельна */
.tile__meta { font-size: var(--fs-sm); color: var(--text-3); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tile__foot { margin-top: 4px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
@media (max-width: 767px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); padding: var(--s-3); } .tile__body { padding: var(--s-2) var(--s-3) var(--s-3); } }

/* ---------- Пагинация (пилюли, как ref-1) ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--card-pad); border-top: 1px solid var(--line-soft); }
.pager__info { color: var(--text-3); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.pager__pages { display: flex; gap: 6px; align-items: center; }
.pager__btn {
  min-width: 36px; height: 36px; padding: 0 10px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; color: var(--text-2); font-size: var(--fs-sm); font-weight: var(--fw-medium); text-decoration: none; font-variant-numeric: tabular-nums;
  transition: background-color var(--dur-1), border-color var(--dur-1);
}
.pager__btn:hover { background: var(--surface-hover); color: var(--text); }
.pager__btn[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.pager__btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.pager__gap { color: var(--text-3); padding: 0 2px; }
@media (max-width: 767px) { .pager { justify-content: center; } .pager__info { width: 100%; text-align: center; } .pager__btn { min-width: 44px; height: 44px; } .pager__btn--far { display: none; } }

/* ---------- Выпадающее меню (popover) ---------- */
.menu {
  position: fixed; z-index: var(--z-popover); min-width: 220px; max-width: 320px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl); box-shadow: var(--shadow-lg);
  display: grid; gap: 1px;
}
.menu[hidden] { display: none; }
.menu__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: calc(var(--r-ctl) - 3px);
  background: none; color: var(--text); text-align: left; text-decoration: none; font-size: var(--fs-md);
}
.menu__item .ic { color: var(--text-3); width: 18px; height: 18px; }
.menu__item:hover, .menu__item:focus-visible { background: var(--surface-hover); box-shadow: none; }
.menu__item--danger { color: var(--danger); }
.menu__item--danger .ic { color: var(--danger); }
.menu__item[aria-disabled="true"] { color: var(--text-3); pointer-events: none; }
.menu__sep { height: 1px; background: var(--line-soft); margin: 4px 0; }
.menu__label { padding: 6px 10px 4px; font-size: var(--fs-xs); color: var(--text-3); font-weight: var(--fw-medium); }
@media (max-width: 767px) { .menu__item { min-height: 48px; } }

/* ---------- Модальное окно (<dialog>) ---------- */
.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 0; border: 0; border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden;
}
.modal--sm { width: min(440px, calc(100vw - 32px)); }
.modal--lg { width: min(760px, calc(100vw - 32px)); }
.modal::backdrop { background: var(--overlay); }
.modal__form { display: flex; flex-direction: column; max-height: inherit; }
.modal__head { display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-5) var(--s-6) var(--s-2); }
.modal__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); flex: 1; line-height: 1.35; }
.modal__icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--neutral-bg); color: var(--neutral); }
.modal__icon--danger { background: var(--danger-bg); color: var(--danger); }
.modal__icon--warning { background: var(--warning-bg); color: var(--warning); }
.modal__body { padding: var(--s-2) var(--s-6) var(--s-5); overflow-y: auto; color: var(--text-2); display: grid; gap: var(--s-4); }
.modal__foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-6); background: var(--surface-2); border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
@media (max-width: 767px) {
  .modal, .modal--sm, .modal--lg { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 92dvh; }
  .modal__foot { flex-direction: column-reverse; padding-bottom: max(var(--s-4), env(safe-area-inset-bottom)); }
  .modal__foot .btn { width: 100%; height: 48px; }
  .modal__head, .modal__body { padding-left: var(--s-4); padding-right: var(--s-4); }
}

/* ---------- Тосты ---------- */
.toasts { position: fixed; z-index: var(--z-toast); right: 24px; bottom: 24px; display: grid; gap: var(--s-2); width: min(400px, calc(100vw - 32px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s-3); padding: 14px var(--s-4);
  background: var(--ink); color: #fff; border-radius: var(--r-ctl); box-shadow: var(--shadow-lg); font-size: var(--fs-md);
}
.toast .ic { margin-top: 1px; }
.toast--success .ic { color: #6ce9a6; }
.toast--danger .ic { color: #fda29b; }
.toast__text { flex: 1; min-width: 0; line-height: 1.4; }
.toast__action { border: 0; background: none; color: #fff; font-weight: var(--fw-semibold); text-decoration: underline; text-underline-offset: 3px; padding: 0; min-height: 24px; }
.toast__close { border: 0; background: none; color: rgb(255 255 255 / .7); padding: 0; width: 24px; height: 24px; display: grid; place-items: center; margin: -2px -4px 0 0; }
.toast__close:hover { color: #fff; }
@media (max-width: 767px) { .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; } }

/* ---------- Баннеры ---------- */
.banner { display: flex; gap: var(--s-3); align-items: flex-start; padding: 14px var(--s-4); border-radius: var(--r-ctl); border: 1px solid var(--info-line); background: var(--info-bg); color: var(--text); }
.banner > .ic { color: var(--info); margin-top: 1px; }
.banner__title { font-weight: var(--fw-semibold); }
.banner__text { color: var(--text-2); font-size: var(--fs-sm); margin-top: 2px; }
.banner__body { flex: 1; min-width: 0; }
.banner__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; margin-top: var(--s-2); }
.banner--warning { border-color: var(--warning-line); background: var(--warning-bg); } .banner--warning > .ic { color: var(--warning); }
.banner--danger { border-color: var(--danger-line); background: var(--danger-bg); } .banner--danger > .ic { color: var(--danger); }
.banner--success { border-color: var(--success-line); background: var(--success-bg); } .banner--success > .ic { color: var(--success); }
.banner--neutral { border-color: var(--line); background: var(--surface-2); } .banner--neutral > .ic { color: var(--text-2); }
.banner--lock { border-color: var(--line); background: var(--surface); box-shadow: var(--shadow-xs); } .banner--lock > .ic { color: var(--text); }

/* ---------- Пустое состояние / ошибка ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: var(--s-3); padding: var(--s-12) var(--s-6); }
.empty__art { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-sunken); color: var(--text-2); margin-bottom: var(--s-1); }
.empty__art .ic { width: 28px; height: 28px; }
.empty__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
.empty__text { color: var(--text-2); max-width: 44ch; }
.empty__actions { display: flex; gap: var(--s-2); flex-wrap: wrap; justify-content: center; margin-top: var(--s-2); }
.empty--error .empty__art { background: var(--danger-bg); color: var(--danger); }

/* ---------- Скелетоны ---------- */
.sk { display: block; background: var(--skeleton); border-radius: var(--r-sm); position: relative; overflow: hidden; }
.sk::after { content: ""; position: absolute; inset: 0; translate: -100% 0; background: linear-gradient(90deg, transparent, var(--skeleton-hi), transparent); animation: shimmer 1.4s var(--ease-in-out) infinite; }
.sk--text { height: 12px; border-radius: 6px; }
.sk--title { height: 20px; width: 40%; border-radius: 6px; }
.sk--thumb { width: 48px; height: 48px; }
.sk--media { aspect-ratio: 4 / 3; border-radius: 0; }
.sk--circle { border-radius: 50%; }
.sk--btn { height: var(--ctl-h); width: 140px; border-radius: var(--r-ctl); }
.sk-row { display: flex; align-items: center; gap: var(--s-3); height: var(--row-h); padding: 0 var(--card-pad); border-bottom: 1px solid var(--line-soft); }
.sk-stack { display: grid; gap: 8px; flex: 1; }

/* ---------- Прогресс ---------- */
.progress { height: 6px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.progress__bar { height: 100%; width: 100%; border-radius: inherit; background: var(--accent-ui); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform var(--dur-3) var(--ease-out); }
.progress--success .progress__bar { background: var(--success); }
.progress--danger .progress__bar { background: var(--danger); }
.progress--sm { height: 4px; }
/* индикатор перехода между страницами */
.nav-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: var(--z-toast); pointer-events: none; }
.nav-progress__bar { height: 100%; background: var(--accent-ui); transform-origin: left; transform: scaleX(0); opacity: 0; }

.footnote { font-size: var(--fs-sm); color: var(--text-3); }

/* ---------- Вход и страницы ошибок (без каркаса) ---------- */
.solo { min-height: 100dvh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.solo__card { width: min(420px, 100%); padding: var(--s-8); display: grid; gap: var(--s-6); }
.solo__logo { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-size: var(--fs-sm); }
.solo__logo img { height: 28px; width: auto; }
.solo__title { font-size: var(--fs-xl); }
.solo__sub { color: var(--text-2); margin-top: 6px; }
.solo__foot { color: var(--text-3); font-size: var(--fs-sm); text-align: center; }
.err-code { font-size: 4.5rem; font-weight: var(--fw-bold); letter-spacing: -.04em; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 767px) { .solo__card { padding: var(--s-6) var(--s-5); } .solo { align-items: start; padding-top: 10vh; } }

/* ---------- Общие поправки (из лаборатории админки) ---------- */
.input-group:has(> .ic) .input { padding-left: 38px; }
@media (max-width: 767px) {
  .btn--sm { height: 44px; min-height: 44px; }
  .btn--icon.btn--sm { width: 44px; height: 44px; }
  .chip__x { width: 44px; height: 44px; margin: -10px -14px -10px -8px; }
  .toast__close { width: 44px; height: 44px; margin: -12px -12px -12px 0; }
}

.tab:focus-visible, .menu__item:focus-visible, .seg__btn:focus-visible, .pager__btn:focus-visible { box-shadow: none; outline: 2px solid var(--accent-ui); outline-offset: -2px; }

/* 1. Вкладки: линия только у активной */
.tab::after { transform: scaleX(0); }
.tab[aria-current="location"] { color: var(--text); }
.tab[aria-current="location"]::after { transform: scaleX(1); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-gutter: stable; scroll-padding-top: calc(var(--topbar-h) + 16px); scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
html[data-motion="off"] { scroll-behavior: auto; }

/* 5. Строки списков — различимые: заметнее разделители, больше воздуха, подсветка при наведении */
:root { --row-h: 60px; --line-row: #e4e4e7; --row-hover: #f4f4f5; }

.table td { border-bottom-color: var(--line-row); padding-top: 10px; padding-bottom: 10px; }
.table tbody tr:hover { background: var(--row-hover); }
.table tbody tr.group-row:hover { background: transparent; }

/* каждая строка — отдельная карточка */

@media (max-width: 767px) {
  .table--stack tr { border-bottom-color: var(--line-row); padding-top: var(--s-4); padding-bottom: var(--s-4); }

}

/* 6. Пагинация: одна разметка UI.pager(), три вида (alt-pagination) */
.pager { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; padding: var(--s-3) var(--card-pad); border-top: 1px solid var(--line-row); }
.pager__info { color: var(--text-2); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.pager__info b { color: var(--text); font-weight: var(--fw-semibold); }
.pager__per { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-2); }
.select--sm { height: 32px; width: auto; padding: 0 30px 0 10px; font-size: var(--fs-sm); background-position: right 8px center; }
.pager__pages { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.pager__more { display: none; }

/* center: пилюли по центру, под ними — сколько показано */
html:root .pager { flex-direction: column-reverse; gap: var(--s-2); }
html:root .pager__pages { margin: 0; }
html:root .pager__per { display: none; }
html:root .pager__info { font-size: var(--fs-xs); color: var(--text-3); }
/* more: «Показать ещё N» во всю ширину + мелкие номера */

@media (max-width: 767px) {
  .pager, html:root .pager { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .pager__pages, html:root .pager__pages { margin: 0; justify-content: center; }
  .pager__info { text-align: center; }
  .pager__per { justify-content: center; }
  .select--sm { height: 44px; }

}

/* раунд 2: прокручиваемые ряды — позиционированный контейнер, чтобы .sr-only внутри не расширял страницу на мобильной */
.tabs, .chips { position: relative; }
