/* ============================================================
   apps-ds — дизайн-система для панелей и приложений
   Эталон: интерфейс Яндекс.Метрики (замеры: research/metrika-extract.md)
   Подключение: <link rel="stylesheet" href="ds.css"> + Inter с Google Fonts
   Все классы с префиксом .ds- ; токены — CSS-переменные --ds-*
   ============================================================ */

/* ------------------------------------------------------------
   1. ТОКЕНЫ
   ------------------------------------------------------------ */
:root {
  /* Шрифт. YS Text проприетарный — подхватится, если стоит локально; иначе Inter */
  --ds-font: "YS Text", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;

  /* Серые — полупрозрачные синеватые, как у Метрики (живут на любом фоне) */
  --ds-gray-010: rgba(202, 214, 238, .10);
  --ds-gray-015: rgba(176, 189, 214, .15);   /* фон вторичных контролов */
  --ds-gray-020: rgba(176, 189, 214, .20);   /* hover контролов */
  --ds-gray-030: rgba(165, 177, 202, .30);   /* рамки-кольца, сетка графиков, тени */
  --ds-gray-040: rgba(134, 148, 176, .40);
  --ds-gray-050: rgba(71, 90, 128, .50);     /* плейсхолдеры, disabled-текст */
  --ds-gray-060: rgba(26, 43, 77, .60);      /* вторичный текст */
  --ds-gray-070: rgba(26, 43, 77, .73);
  --ds-gray-080: #1e242e;                    /* основной текст */
  --ds-gray-090: #121725;
  --ds-gray-030-solid: #d9dee9;

  /* Поверхности */
  --ds-bg: #eff2f7;            /* фон страницы */
  --ds-surface: #ffffff;       /* карточки */
  --ds-surface-muted: #f6f8fb; /* итоговая строка, выделенная область */
  --ds-line: #eff2f7;          /* разделители в таблицах и списках */

  /* Акцент и семантика */
  --ds-accent: #7a45e5;
  --ds-accent-010: rgba(122, 69, 229, .10);
  --ds-accent-020: rgba(122, 69, 229, .20);
  --ds-accent-030: rgba(122, 69, 229, .30);
  --ds-accent-060: rgba(122, 69, 229, .60);
  --ds-accent-hover: #6c3bd0;
  --ds-accent-active: #5f32bb;
  --ds-green: #33b343;
  --ds-green-020: rgba(51, 179, 67, .25);
  --ds-red: #dd0000;
  --ds-red-020: rgba(221, 0, 0, .20);
  --ds-blue: #498bff;
  --ds-orange: #ff8200;
  --ds-yellow: #ffdd57;
  --ds-pink: #ff326e;

  /* Палитра серий графиков */
  --ds-chart-1: #7a45e5;
  --ds-chart-2: #ff3399;
  --ds-chart-3: #0fbda0;
  --ds-chart-4: #498bff;
  --ds-chart-5: #ff8200;
  --ds-chart-6: #ffd21f;

  /* Геометрия */
  --ds-r-card: 20px;
  --ds-r-ctl: 12px;
  --ds-r-sm: 10px;
  --ds-r-xs: 6px;
  --ds-h-ctl: 36px;
  --ds-h-sm: 32px;
  --ds-sidebar-w: 200px;
  --ds-topbar-h: 68px;
  --ds-gap: 16px;            /* между карточками */
  --ds-card-pad: 28px 36px;  /* широкая карточка */
  --ds-card-pad-sm: 20px 28px;

  /* Тени — только у всплывающих слоёв */
  --ds-shadow-pop: 0 0 3px var(--ds-gray-030), 0 10px 40px var(--ds-gray-030);
  --ds-ring: inset 0 0 0 1px var(--ds-gray-030);
  --ds-ring-focus: 0 0 0 2px var(--ds-accent-030);

  --ds-t: .15s ease;
}

/* ------------------------------------------------------------
   2. БАЗА
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body.ds-body, .ds-root {
  margin: 0;
  font: 400 14px/20px var(--ds-font);
  color: var(--ds-gray-080);
  background: var(--ds-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
/* сбросы через :where() — нулевая специфичность, чтобы не перебивать модификаторы компонентов */
:where(.ds-root, .ds-body) :where(a) { color: inherit; text-decoration: none; }
:where(.ds-root, .ds-body) :where(button, input, select, textarea) { font: inherit; color: inherit; }
:where(.ds-root, .ds-body) :where(svg) { display: block; }

/* Типографика */
.ds-h1 { margin: 0; font-size: 28px; line-height: 36px; font-weight: 500; }
.ds-h2 { margin: 32px 0 16px; font-size: 24px; line-height: 32px; font-weight: 500; }
.ds-h3 { margin: 0; font-size: 18px; line-height: 24px; font-weight: 500; }
.ds-title { margin: 0; font-size: 16px; line-height: 20px; font-weight: 400; } /* заголовок виджета */
.ds-num { font-size: 28px; line-height: 32px; font-weight: 400; }               /* большая цифра */
.ds-num--lg { font-size: 40px; line-height: 44px; }
.ds-muted { color: var(--ds-gray-060); }
.ds-small { font-size: 12px; line-height: 16px; }
.ds-label { display: block; margin-bottom: 6px; color: var(--ds-gray-060); }
.ds-link { color: var(--ds-gray-060); transition: color var(--ds-t); }
.ds-link:hover { color: var(--ds-gray-080); }
.ds-link--accent { color: var(--ds-accent); }
.ds-link--accent:hover { color: var(--ds-accent-hover); }
.ds-tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------
   3. КАРКАС ПРИЛОЖЕНИЯ
   ------------------------------------------------------------ */
.ds-app { display: grid; grid-template-columns: var(--ds-sidebar-w) 1fr; min-height: 100vh; }
.ds-app--nosidebar { grid-template-columns: 1fr; }

.ds-topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  height: var(--ds-topbar-h); padding: 0 16px;
}
.ds-logo { display: flex; align-items: center; gap: 8px; font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; margin-right: 24px; }
.ds-logo__mark { width: 32px; height: 32px; border-radius: 50%; background: var(--ds-accent); }
.ds-topbar__spacer { flex: 1; }
.ds-topbar .ds-link { padding: 0 8px; }

.ds-sidebar {
  padding: 0 12px 24px;
  /* Сайдбар закреплён: при прокрутке контента меню остаётся на месте */
  position: sticky; top: var(--ds-topbar-h); align-self: start;
  max-height: calc(100vh - var(--ds-topbar-h)); overflow-y: auto;
}
.ds-app--notop .ds-sidebar { top: 0; max-height: 100vh; }
.ds-nav { display: flex; flex-direction: column; }
.ds-nav__group + .ds-nav__group { margin-top: 16px; }
.ds-nav__item {
  display: flex; align-items: center; gap: 8px;
  height: var(--ds-h-ctl); padding: 8px 12px; border-radius: var(--ds-r-ctl);
  color: var(--ds-gray-060); font-weight: 500; cursor: pointer;
  transition: background var(--ds-t), color var(--ds-t);
}
.ds-nav__item:hover { background: var(--ds-gray-015); }
.ds-nav__item--active { background: var(--ds-surface); color: var(--ds-gray-080); }
.ds-nav__item svg { width: 16px; height: 16px; flex: none; fill: currentColor; }
.ds-nav__dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--ds-accent); box-shadow: 0 0 0 3px var(--ds-accent-020); }
.ds-sidebar__foot { margin-top: auto; }

.ds-main { min-width: 0; padding: 0 16px 48px; }
.ds-app--nosidebar .ds-main { max-width: 1280px; margin: 0 auto; width: 100%; }

/* Шапка страницы — карточка с заголовком и контролами */
.ds-page-head { background: var(--ds-surface); border-radius: var(--ds-r-card); padding: 24px 36px; }
.ds-page-head__row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ds-page-head__row + .ds-page-head__row { margin-top: 16px; }
.ds-page-head__spacer { flex: 1; }

/* Липкая панель контролов */
.ds-sticky { position: sticky; top: 0; z-index: 10; background: var(--ds-surface); }

/* ------------------------------------------------------------
   4. КАРТОЧКИ И СЕТКА
   ------------------------------------------------------------ */
.ds-card {
  background: var(--ds-surface); border-radius: var(--ds-r-card);
  padding: var(--ds-card-pad); min-width: 0;
}
.ds-card--sm { padding: var(--ds-card-pad-sm); }
.ds-card--flush { padding: 0; overflow: hidden; } /* для таблиц и списков на всю ширину */
.ds-card__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.ds-card__head .ds-title { flex: 1; }
.ds-card__sub { color: var(--ds-gray-060); margin-top: 4px; }
.ds-card__actions { display: flex; gap: 8px; margin-left: auto; }

.ds-grid { display: grid; gap: var(--ds-gap); grid-template-columns: repeat(12, minmax(0, 1fr)); }
.ds-grid > * { grid-column: span 12; }
.ds-col-6 { grid-column: span 6 !important; }
.ds-col-4 { grid-column: span 4 !important; }
.ds-col-3 { grid-column: span 3 !important; }
.ds-col-8 { grid-column: span 8 !important; }
@media (max-width: 960px) { .ds-col-6, .ds-col-4, .ds-col-3, .ds-col-8 { grid-column: span 12 !important; } }
.ds-stack { display: flex; flex-direction: column; gap: var(--ds-gap); }
.ds-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Фактоид: заголовок + большая цифра + дельта + спарклайн */
.ds-factoid { display: flex; flex-direction: column; gap: 12px; }
.ds-factoid__value { display: flex; align-items: baseline; gap: 10px; }
.ds-factoid__spark { height: 32px; flex: 1; min-width: 80px; }

/* Дельта */
.ds-delta { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.ds-delta::before { content: ""; width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; }
.ds-delta--up { color: var(--ds-green); }
.ds-delta--up::before { border-bottom: 8px solid currentColor; }
.ds-delta--down { color: var(--ds-red); }
.ds-delta--down::before { border-top: 8px solid currentColor; }
.ds-delta--flat { color: var(--ds-gray-060); }
.ds-delta--flat::before { width: 6px; height: 6px; border: 0; background: currentColor; transform: rotate(45deg); }

/* ------------------------------------------------------------
   5. КНОПКИ
   ------------------------------------------------------------ */
.ds-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--ds-h-ctl); padding: 8px 16px; border: 0; border-radius: var(--ds-r-ctl);
  background: var(--ds-gray-015); color: var(--ds-gray-080);
  font: inherit; white-space: nowrap; cursor: pointer; user-select: none;
  transition: background var(--ds-t), color var(--ds-t), box-shadow var(--ds-t);
}
.ds-btn:hover { background: var(--ds-gray-020); }
.ds-btn:active { background: var(--ds-gray-030); }
.ds-btn:focus-visible { outline: 0; box-shadow: var(--ds-ring-focus); }
.ds-btn:disabled { opacity: .5; cursor: default; pointer-events: none; }
.ds-btn svg { width: 16px; height: 16px; fill: currentColor; flex: none; }
.ds-btn--icon-left { padding-left: 10px; }   /* иконка слева — паддинг уже */
.ds-btn--icon-right { padding-right: 10px; } /* шеврон справа */

.ds-btn--primary { background: var(--ds-accent); color: #fff; }
.ds-btn--primary:hover { background: var(--ds-accent-hover); }
.ds-btn--primary:active { background: var(--ds-accent-active); }

.ds-btn--tint { background: var(--ds-accent-020); color: var(--ds-accent); font-weight: 500; }
.ds-btn--tint:hover { background: var(--ds-accent-030); }

.ds-btn--outline { background: transparent; box-shadow: var(--ds-ring); }
.ds-btn--outline:hover { background: var(--ds-gray-010); }
.ds-btn--outline:focus-visible { box-shadow: var(--ds-ring), var(--ds-ring-focus); }

.ds-btn--ghost { background: transparent; color: var(--ds-gray-060); }
.ds-btn--ghost:hover { background: var(--ds-gray-015); color: var(--ds-gray-080); }

.ds-btn--danger { background: var(--ds-red); color: #fff; }
.ds-btn--danger:hover { background: #c40000; }

.ds-btn--sm { height: var(--ds-h-sm); padding: 6px 12px; border-radius: var(--ds-r-sm); }
.ds-btn--icon { width: var(--ds-h-ctl); padding: 0; }
.ds-btn--icon.ds-btn--sm { width: var(--ds-h-sm); }
.ds-btn--circle { width: var(--ds-h-ctl); padding: 0; border-radius: 50%; background: var(--ds-surface); box-shadow: var(--ds-ring); }
.ds-btn--circle:hover { background: var(--ds-surface-muted); }
.ds-btn--white { background: var(--ds-surface); }
.ds-btn--white:hover { background: var(--ds-surface-muted); }

/* Шеврон для селектов/дропдаунов */
.ds-chev { width: 16px; height: 16px; }
.ds-btn[aria-expanded="true"] { background: var(--ds-gray-030); }

/* Сегмент-контрол (Сегодня / Вчера / Неделя) */
.ds-seg { display: inline-flex; padding: 2px; height: var(--ds-h-ctl); border-radius: var(--ds-r-ctl); background: var(--ds-gray-015); }
.ds-seg__item {
  display: inline-flex; align-items: center; padding: 0 14px; border: 0; border-radius: var(--ds-r-ctl);
  background: transparent; color: var(--ds-gray-080); font: inherit; cursor: pointer;
  transition: background var(--ds-t);
}
.ds-seg__item:hover { background: var(--ds-gray-015); }
.ds-seg__item--active, .ds-seg__item[aria-pressed="true"] { background: var(--ds-surface); }
.ds-seg--sm { height: var(--ds-h-sm); }
.ds-seg--sm .ds-seg__item { padding: 0 10px; border-radius: var(--ds-r-sm); }

/* Чипы и теги */
.ds-chip {            /* фильтр: «Группировка • Интервал дат» */
  display: inline-flex; align-items: center; gap: 6px; height: var(--ds-h-ctl); padding: 8px 16px;
  border-radius: var(--ds-r-ctl); box-shadow: var(--ds-ring); background: transparent; cursor: pointer;
}
.ds-chip:hover { background: var(--ds-gray-010); }
.ds-chip__key { color: var(--ds-gray-060); }
.ds-chip__key::after { content: " • "; }
.ds-tag {             /* выделенная сущность: «Визиты», «Люди» */
  display: inline-flex; align-items: center; gap: 6px; height: var(--ds-h-sm); padding: 6px 12px;
  border-radius: var(--ds-r-ctl); border: 1px solid var(--ds-accent-020); color: var(--ds-accent); background: var(--ds-surface);
}
.ds-tag svg { width: 14px; height: 14px; fill: currentColor; }
.ds-tag--gray { border-color: var(--ds-gray-030); color: var(--ds-gray-080); }
.ds-tag--green { border-color: var(--ds-green-020); color: var(--ds-green); }
.ds-tag--red { border-color: var(--ds-red-020); color: var(--ds-red); }

/* Бейдж-счётчик */
.ds-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; line-height: 1; font-weight: 500; background: var(--ds-accent); color: #fff; }
.ds-badge--soft { background: var(--ds-accent-020); color: var(--ds-accent); }
.ds-badge--gray { background: var(--ds-gray-020); color: var(--ds-gray-070); }
.ds-badge--green { background: var(--ds-green); }
.ds-badge--red { background: var(--ds-red); }

/* Статус-точка */
.ds-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ds-gray-040); vertical-align: middle; }
.ds-dot--green { background: var(--ds-green); } .ds-dot--red { background: var(--ds-red); } .ds-dot--accent { background: var(--ds-accent); } .ds-dot--orange { background: var(--ds-orange); }

/* ------------------------------------------------------------
   6. ФОРМЫ
   ------------------------------------------------------------ */
.ds-input, .ds-select, .ds-textarea {
  display: block; width: 100%; height: var(--ds-h-ctl); padding: 8px 12px;
  border: 0; border-radius: var(--ds-r-ctl); background: var(--ds-surface);
  box-shadow: var(--ds-ring); font: inherit; color: var(--ds-gray-080); outline: 0;
  transition: box-shadow var(--ds-t), background var(--ds-t);
}
.ds-input::placeholder, .ds-textarea::placeholder { color: var(--ds-gray-050); }
.ds-input:hover, .ds-select:hover, .ds-textarea:hover { box-shadow: inset 0 0 0 1px var(--ds-gray-040); }
.ds-input:focus, .ds-select:focus, .ds-textarea:focus { box-shadow: inset 0 0 0 1px var(--ds-accent-060), var(--ds-ring-focus); }
.ds-input--fill { background: var(--ds-gray-015); box-shadow: none; }
.ds-input--fill:hover { background: var(--ds-gray-020); box-shadow: none; }
.ds-input--fill:focus { background: var(--ds-surface); box-shadow: inset 0 0 0 1px var(--ds-accent-060), var(--ds-ring-focus); }
.ds-input--sm { height: var(--ds-h-sm); padding: 6px 10px; border-radius: var(--ds-r-sm); }
.ds-textarea { height: auto; min-height: 96px; resize: vertical; line-height: 20px; }
.ds-select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%231e242e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.ds-input-wrap { position: relative; }
.ds-input-wrap > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; fill: var(--ds-gray-060); pointer-events: none; }
.ds-input-wrap > .ds-input { padding-left: 36px; }
.ds-field { display: flex; flex-direction: column; gap: 6px; }
.ds-field__hint { color: var(--ds-gray-060); font-size: 12px; line-height: 16px; }
.ds-field__error { color: var(--ds-red); font-size: 12px; line-height: 16px; }
.ds-field--error .ds-input { box-shadow: inset 0 0 0 1px var(--ds-red); }
.ds-form-row { display: grid; grid-template-columns: 200px 1fr; gap: 12px 24px; align-items: start; }
.ds-form-row > label:first-child { padding-top: 8px; }

/* Чекбокс / радио */
.ds-check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.ds-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.ds-check__box {
  width: 16px; height: 16px; border-radius: 4px; flex: none;
  box-shadow: inset 0 0 0 1.5px var(--ds-gray-040); background: var(--ds-surface);
  transition: background var(--ds-t), box-shadow var(--ds-t); position: relative;
}
.ds-check input:checked + .ds-check__box { background: var(--ds-accent); box-shadow: none; }
.ds-check input:checked + .ds-check__box::after {
  content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.ds-check input:focus-visible + .ds-check__box { box-shadow: var(--ds-ring-focus); }
.ds-check--radio .ds-check__box { border-radius: 50%; }
.ds-check--radio input:checked + .ds-check__box { background: var(--ds-surface); box-shadow: inset 0 0 0 5px var(--ds-accent); }
.ds-check--radio input:checked + .ds-check__box::after { display: none; }
/* цветной чекбокс легенды графика: задать --c */
.ds-check--legend input:checked + .ds-check__box { background: var(--c, var(--ds-accent)); }

/* Переключатель */
.ds-switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.ds-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.ds-switch__track { width: 36px; height: 20px; border-radius: 10px; background: var(--ds-gray-040); position: relative; transition: background var(--ds-t); flex: none; }
.ds-switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform var(--ds-t); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.ds-switch input:checked + .ds-switch__track { background: var(--ds-accent); }
.ds-switch input:checked + .ds-switch__track::after { transform: translateX(16px); }
.ds-switch input:focus-visible + .ds-switch__track { box-shadow: var(--ds-ring-focus); }

/* ------------------------------------------------------------
   7. ТАБЛИЦА И СПИСКИ
   ------------------------------------------------------------ */
.ds-table-wrap { overflow-x: auto; }
.ds-table { width: 100%; border-collapse: collapse; border-spacing: 0; }
.ds-table th, .ds-table td { height: 56px; padding: 8px 16px; text-align: left; vertical-align: middle; border-top: 1px solid var(--ds-line); }
.ds-table th { font-weight: 400; color: var(--ds-gray-060); border-top: 0; vertical-align: bottom; }
.ds-table th:first-child, .ds-table td:first-child { padding-left: 36px; }
.ds-table th:last-child, .ds-table td:last-child { padding-right: 36px; }
.ds-table .ds-num-cell, .ds-table th.ds-num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.ds-table--dividers td + td, .ds-table--dividers th + th { border-left: 1px solid var(--ds-line); }
.ds-table tbody tr:hover td { background: var(--ds-gray-010); }
.ds-table .ds-tr-total td { background: var(--ds-surface-muted); }
.ds-table .ds-sub { display: block; font-size: 12px; line-height: 16px; color: var(--ds-gray-060); margin-top: 2px; }
.ds-table--compact th, .ds-table--compact td { height: 44px; padding: 6px 12px; }
.ds-table--compact th:first-child, .ds-table--compact td:first-child { padding-left: 28px; }
.ds-table--compact th:last-child, .ds-table--compact td:last-child { padding-right: 28px; }
.ds-sort { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.ds-sort::after { content: "↓"; opacity: .6; }
.ds-sort--up::after { content: "↑"; }
.ds-toolbar { display: flex; align-items: center; gap: 12px; padding: 20px 36px; }
.ds-toolbar__spacer { flex: 1; }
.ds-table-wrap + .ds-toolbar, .ds-toolbar + .ds-table-wrap { border-top: 1px solid var(--ds-line); }

/* Список строк (как список целей) */
.ds-list { margin: 0; padding: 0; list-style: none; }
.ds-list__item { display: flex; align-items: center; gap: 24px; min-height: 57px; padding: 16px 36px; border-top: 1px solid var(--ds-line); transition: background var(--ds-t); }
.ds-list__item:first-child { border-top: 0; }
.ds-list__item:hover { background: var(--ds-gray-010); }
.ds-list__title { font-size: 18px; line-height: 24px; font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-list__meta { color: var(--ds-gray-060); white-space: nowrap; }
.ds-list__actions { display: flex; gap: 4px; margin-left: auto; opacity: .55; transition: opacity var(--ds-t); }
.ds-list__item:hover .ds-list__actions { opacity: 1; }

/* Ключ-значение */
.ds-kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; }
.ds-kv dt { color: var(--ds-gray-060); margin: 0; }
.ds-kv dd { margin: 0; }

/* ------------------------------------------------------------
   8. ВСПЛЫВАЮЩИЕ СЛОИ
   ------------------------------------------------------------ */
.ds-popup { background: var(--ds-surface); border-radius: var(--ds-r-ctl); box-shadow: var(--ds-shadow-pop); padding: 6px; min-width: 200px; }
.ds-menu { margin: 0; padding: 0; list-style: none; }
.ds-menu__item { display: flex; align-items: center; gap: 8px; height: var(--ds-h-ctl); padding: 8px 12px; border-radius: var(--ds-r-sm); cursor: pointer; white-space: nowrap; transition: background var(--ds-t); }
.ds-menu__item:hover { background: var(--ds-gray-015); }
.ds-menu__item--active { background: var(--ds-accent-010); color: var(--ds-accent); }
.ds-menu__item svg { width: 16px; height: 16px; fill: currentColor; }
.ds-menu__sep { height: 1px; margin: 6px 0; background: var(--ds-line); }
.ds-menu__title { padding: 8px 12px 4px; font-size: 12px; line-height: 16px; color: var(--ds-gray-060); }

.ds-tooltip { display: inline-block; padding: 6px 10px; border-radius: var(--ds-r-sm); background: var(--ds-gray-090); color: #fff; font-size: 12px; line-height: 16px; white-space: nowrap; }

.ds-modal-backdrop { position: fixed; inset: 0; background: rgba(26, 43, 77, .4); display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 100; }
.ds-modal { width: 100%; max-width: 560px; background: var(--ds-surface); border-radius: var(--ds-r-card); box-shadow: var(--ds-shadow-pop); padding: 28px 36px; }
.ds-modal__head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.ds-modal__head .ds-h3 { flex: 1; font-size: 20px; line-height: 28px; }
.ds-modal__foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 24px; }

.ds-toast { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--ds-r-ctl); background: var(--ds-gray-090); color: #fff; box-shadow: var(--ds-shadow-pop); }

/* Уведомление в потоке */
.ds-note { display: flex; gap: 10px; padding: 12px 16px; border-radius: var(--ds-r-ctl); background: var(--ds-accent-010); color: var(--ds-gray-080); }
.ds-note--warn { background: rgba(255, 130, 0, .12); }
.ds-note--error { background: rgba(221, 0, 0, .08); }
.ds-note--ok { background: rgba(51, 179, 67, .12); }

/* ------------------------------------------------------------
   9. ПРОЧЕЕ
   ------------------------------------------------------------ */
.ds-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--ds-surface); box-shadow: var(--ds-ring); display: inline-flex; align-items: center; justify-content: center; font-weight: 500; color: var(--ds-gray-070); overflow: hidden; }
.ds-avatar img { width: 100%; height: 100%; object-fit: cover; }

.ds-progress { height: 6px; border-radius: 3px; background: var(--ds-gray-020); overflow: hidden; }
.ds-progress > span { display: block; height: 100%; border-radius: 3px; background: var(--ds-accent); transition: width .35s ease; }
.ds-progress--green > span { background: var(--ds-green); }

.ds-skel { display: inline-block; height: 20px; border-radius: 6px; background: linear-gradient(90deg, var(--ds-gray-015) 25%, var(--ds-gray-030) 37%, var(--ds-gray-015) 63%); background-size: 400% 100%; animation: ds-skel 1.4s ease infinite; }
@keyframes ds-skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.ds-empty { padding: 48px 24px; text-align: center; color: var(--ds-gray-060); }
.ds-empty__title { font-size: 18px; line-height: 24px; font-weight: 500; color: var(--ds-gray-080); margin-bottom: 4px; }

.ds-divider { height: 1px; background: var(--ds-line); margin: 20px 0; }
.ds-sep-v { width: 1px; height: 20px; background: var(--ds-gray-030); }

.ds-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--ds-line); }
.ds-tab { padding: 10px 12px; margin-bottom: -1px; color: var(--ds-gray-060); border-bottom: 2px solid transparent; cursor: pointer; font-weight: 500; transition: color var(--ds-t); }
.ds-tab:hover { color: var(--ds-gray-080); }
.ds-tab--active { color: var(--ds-gray-080); border-bottom-color: var(--ds-accent); }

.ds-legend { display: flex; gap: 20px; flex-wrap: wrap; }
.ds-legend__value { font-weight: 500; margin-left: 4px; }

/* Появление блока */
.ds-fade-in { animation: ds-fade .3s ease both; }
@keyframes ds-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Утилиты */
.ds-flex { display: flex; } .ds-ac { align-items: center; } .ds-jb { justify-content: space-between; }
.ds-g8 { gap: 8px; } .ds-g12 { gap: 12px; } .ds-g16 { gap: 16px; }
.ds-mt8 { margin-top: 8px; } .ds-mt16 { margin-top: 16px; } .ds-mt24 { margin-top: 24px; }
.ds-w100 { width: 100%; } .ds-right { text-align: right; } .ds-nowrap { white-space: nowrap; }
.ds-hide { display: none !important; }

@media (max-width: 900px) {
  .ds-app { grid-template-columns: 1fr; }
  .ds-sidebar { display: none; }
  .ds-card, .ds-page-head { padding: 20px; }
  .ds-table th:first-child, .ds-table td:first-child, .ds-list__item { padding-left: 20px; }
  .ds-table th:last-child, .ds-table td:last-child { padding-right: 20px; }
  .ds-toolbar { padding: 16px 20px; }
  .ds-form-row { grid-template-columns: 1fr; }
  .ds-form-row > label:first-child { padding-top: 0; }
}
