/* =========================================================================
   design-system.css — дизайн-система ОМК-Строй (редизайн v2)
   -------------------------------------------------------------------------
   22 секции спеки редизайна. ТЁМНАЯ тема — основная (:root + [data-theme="dark"]),
   светлая — [data-theme="light"].

   НОВЫЕ ТОКЕНЫ (primary):
     --bg-base/surface/elevated/overlay/highlight  — фоны
     --text-primary/secondary/muted/inverse        — текст
     --accent-blue/green/orange/red/purple/yellow + --accent-*-bg  — акценты
     --status-success/warning/error/info/neutral + --status-*-bg   — статусы
     --border-subtle/default/strong/focus           — границы
     --radius-xs/sm/md/lg/xl/full                   — скругления
     --transition-fast/normal/slow                  — анимации
     --space-1..12, --text-xs..2xl, --font-body/mono, --shadow-*,
     --sidebar-*, --topbar-*

   ОБРАТНАЯ СОВМЕСТИМОСТЬ (АЛИАСЫ): старые имена токенов и компонентные классы,
   от которых зависят 27 шаблонов и 11 page-CSS, определены ниже как алиасы на
   новые токены / дублирующие селекторы. Поэтому текущие страницы продолжают
   работать без правок, а новые шаблоны могут использовать новый нейминг.
   Старые алиасы токенов: --color-text/-muted/-faint, --color-surface[-2/-offset/-rgb],
   --color-border, --color-divider, --color-primary[-hover/-light/-text],
   --color-success/warning/error/info[/-light], --bg-primary/secondary/tertiary/card/
   card-hover/input, --border-muted, --accent-primary[-hover]/secondary/success/
   warning/danger/orange, --transition[-slow], --sidebar-item-active-bg/-hover-bg/
   -group-label, --space-16.
   Старые классы: .card*, .data-table, .table-responsive, .badge-* (все старые
   варианты), .btn-table-*, .form-control, .progress-fill.warning/.danger/.success,
   .kpi-card.alert/.warn/.ok, .alert-banner, .modal* (display-toggle), .toast*,
   .empty-state, .page-header/-title/-subtitle/-actions, .tabs/.tab-btn, .pagination*,
   .sidebar-link/.nav-badge/.sidebar-user/.user-avatar/...  — сохранены.
   Подключается ПОСЛЕ base.css.
   ========================================================================= */

/* ====================== СЕКЦИЯ 1: ИМПОРТ ШРИФТОВ ======================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, monospace;
}

/* ====================== СЕКЦИЯ 2: ТОКЕНЫ — ТЁМНАЯ ТЕМА ================== */
:root,
[data-theme="dark"] {
  /* Фоны */
  --bg-base:     #0f1117;
  --bg-surface:  #161b27;
  --bg-elevated: #1e2535;
  --bg-overlay:  #252d3d;
  --bg-highlight: #2d3650;

  /* Сайдбар (остаётся тёмным в обеих темах) */
  --sidebar-bg:          #0d1117;
  --sidebar-border:      rgba(255, 255, 255, 0.06);
  --sidebar-item-hover:  rgba(255, 255, 255, 0.05);
  --sidebar-item-active: rgba(99, 179, 237, 0.12);
  --sidebar-text:        #8892a4;
  --sidebar-text-active: #e2e8f0;
  --sidebar-accent:       #63b3ed;
  --sidebar-width:        240px;

  /* Топбар */
  --topbar-bg:     #0d1117;
  --topbar-border: rgba(255, 255, 255, 0.06);
  --topbar-height:  56px;

  /* Текст */
  --text-primary: #e2e8f0;
  --text-secondary: #8892a4;
  --text-muted:    #4a5568;
  --text-inverse:  #0f1117;

  /* Акценты (цвет + фон) */
  --accent-blue:    #63b3ed; --accent-blue-bg:    rgba(99, 179, 237, 0.10);
  --accent-green:   #68d391; --accent-green-bg:   rgba(104, 211, 145, 0.10);
  --accent-orange:  #f6ad55; --accent-orange-bg:  rgba(246, 173, 85, 0.10);
  --accent-red:     #fc8181; --accent-red-bg:     rgba(252, 129, 129, 0.10);
  --accent-purple:  #b794f4; --accent-purple-bg:  rgba(183, 148, 244, 0.10);
  --accent-yellow:  #f6e05e; --accent-yellow-bg:  rgba(246, 224, 94, 0.10);

  /* Статусы (цвет + фон) */
  --status-success: #68d391; --status-success-bg: rgba(104, 211, 145, 0.12);
  --status-warning: #f6ad55; --status-warning-bg: rgba(246, 173, 85, 0.12);
  --status-error:   #fc8181; --status-error-bg:   rgba(252, 129, 129, 0.12);
  --status-info:    #63b3ed; --status-info-bg:    rgba(99, 179, 237, 0.12);
  --status-neutral: #8892a4; --status-neutral-bg: rgba(136, 146, 164, 0.12);

  /* Границы */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --border-focus:  #63b3ed;

  /* Тени */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);

  /* Скругления */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Отступы */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  /* Шрифты */
  --text-xs:  11px;
  --text-sm:  13px;
  --text-base: 14px;
  --text-md:  15px;
  --text-lg:  17px;
  --text-xl:  20px;
  --text-2xl: 24px;

  /* Анимации */
  --transition-fast:   120ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-normal: 200ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow:   350ms cubic-bezier(0.16, 1, 0.3, 1);

  /* ----------------------- АЛИАСЫ СТАРЫХ ИМЁН ------------------------- */
  /* Фоны/поверхности */
  --bg-primary:    var(--bg-base);
  --bg-secondary:  var(--bg-surface);
  --bg-tertiary:   var(--bg-elevated);
  --bg-card:       var(--bg-surface);
  --bg-card-hover: var(--bg-highlight);
  --bg-input:      var(--bg-elevated);
  --color-bg:              var(--bg-base);
  --color-surface:         var(--bg-surface);
  --color-surface-rgb:     22, 27, 39;              /* #161b27 — для rgba() */
  --color-surface-2:       var(--bg-elevated);
  --color-surface-offset:  var(--bg-overlay);
  /* Границы */
  --color-border:  var(--border-default);
  --color-divider: var(--border-subtle);
  --border-muted:  var(--border-subtle);
  /* Текст */
  --color-text:        var(--text-primary);
  --color-text-muted:  var(--text-secondary);
  --color-text-faint:  var(--text-muted);
  /* Сайдбар (алиасы под старые имена) */
  --sidebar-item-active-bg: var(--sidebar-item-active);
  --sidebar-item-hover-bg:   var(--sidebar-item-hover);
  --sidebar-group-label:     var(--sidebar-text);
  /* Акцент-бренд (бывшая бирюза → теперь accent-blue) */
  --color-primary:       var(--accent-blue);
  --color-primary-hover: var(--accent-blue);
  --color-primary-light: var(--accent-blue-bg);
  --color-primary-text:  var(--accent-blue);
  /* Акценты (старые имена → новые) */
  --accent-primary:        var(--accent-blue);
  --accent-primary-hover:  var(--accent-blue);
  --accent-secondary:      var(--accent-blue);
  --accent-success: var(--status-success);
  --accent-warning: var(--status-warning);
  --accent-danger:  var(--status-error);
  /* Статусы (старые имена) */
  --color-success:       var(--status-success); --color-success-light: var(--status-success-bg);
  --color-warning:       var(--status-warning); --color-warning-light: var(--status-warning-bg);
  --color-error:         var(--status-error);   --color-error-light:   var(--status-error-bg);
  --color-info:          var(--status-info);    --color-info-light:    var(--status-info-bg);
  /* Переход (старый plain --transition) */
  --transition: var(--transition-normal);
}

/* ====================== СЕКЦИЯ 3: ТОКЕНЫ — СВЕТЛАЯ ТЕМА ================ */
[data-theme="light"] {
  /* Фоны */
  --bg-base:     #f0f2f5;
  --bg-surface:  #ffffff;
  --bg-elevated: #f8f9fc;
  --bg-overlay:  #ffffff;
  --bg-highlight: #eef2ff;

  /* Сайдбар (ОСТАЁТСЯ ТЁМНЫМ в светлой теме) */
  --sidebar-bg:          #1e2a3a;
  --sidebar-border:      rgba(255, 255, 255, 0.06);
  --sidebar-item-hover:  rgba(255, 255, 255, 0.05);
  --sidebar-item-active: rgba(99, 179, 237, 0.18);
  --sidebar-text:        #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-accent:      #63b3ed;

  /* Топбар */
  --topbar-bg:     #ffffff;
  --topbar-border: rgba(0, 0, 0, 0.08);

  /* Текст */
  --text-primary:  #1a202c;
  --text-secondary: #4a5568;
  --text-muted:    #a0aec0;
  --text-inverse:  #0f1117;

  /* Акценты (более насыщенные для светлого фона) */
  --accent-blue:    #3182ce; --accent-blue-bg:    rgba(49, 130, 206, 0.10);
  --accent-green:   #38a169; --accent-green-bg:   rgba(56, 161, 105, 0.10);
  --accent-orange:  #dd6b20; --accent-orange-bg:  rgba(221, 107, 32, 0.10);
  --accent-red:     #e53e3e; --accent-red-bg:     rgba(229, 62, 62, 0.10);
  --accent-purple:  #6b46c1; --accent-purple-bg:  rgba(107, 70, 193, 0.10);
  --accent-yellow:  #d69e2e; --accent-yellow-bg:  rgba(214, 158, 46, 0.10);

  /* Статусы (насыщенные) */
  --status-success: #38a169; --status-success-bg: rgba(56, 161, 105, 0.12);
  --status-warning: #dd6b20; --status-warning-bg: rgba(221, 107, 32, 0.12);
  --status-error:   #e53e3e; --status-error-bg:   rgba(229, 62, 62, 0.12);
  --status-info:    #3182ce; --status-info-bg:    rgba(49, 130, 206, 0.12);
  --status-neutral: #a0aec0; --status-neutral-bg: rgba(160, 174, 192, 0.12);

  /* Границы */
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-default: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);
  --border-focus:  #3182ce;

  /* Тени (мягче) */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.10);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);

  /* Светлые алиасы поверхностей (rgb) */
  --color-surface-rgb: 255, 255, 255;
}

/* ====================== СЕКЦИЯ 4: BASE RESET ========================== */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; color: var(--text-primary); }
p { margin: 0; }
a { color: var(--accent-blue); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-blue); text-decoration: underline; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }

/* ====================== СЕКЦИЯ 5: APP SHELL LAYOUT ==================== */
.app-shell { display: flex; min-height: 100vh; }

/* ====================== СЕКЦИЯ 6: SIDEBAR ============================= */
/* Каркас .sidebar (position/width/height/z-index/flex-column) объявлен в base.css;
   здесь — оформление по новым токенам. Класс .sidebar-link (используется текущим
   sidebar.html) сохранён ниже как alias-стиль. */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform var(--transition-normal);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-height);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--sidebar-border);
  text-decoration: none;
  color: var(--sidebar-text-active);
  flex-shrink: 0;
}
.sidebar-logo:hover { color: var(--sidebar-text-active); text-decoration: none; }

.sidebar-logo-icon {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-blue);
  color: var(--text-inverse);
  border-radius: var(--radius-md);
  font-weight: 700;
  flex-shrink: 0;
}
.sidebar-logo-text {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--sidebar-text-active);
  white-space: nowrap;
}
/* Старое имя (текущий sidebar.html) — alias. */
.sidebar-logo-name {
  font-size: var(--text-base);
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  padding: var(--space-2) 0;
}
.sidebar-nav::-webkit-scrollbar { display: none; }

.sidebar-group-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
  opacity: 0.6;
  padding: var(--space-4) var(--space-4) var(--space-1);
}
/* Старое имя. */
.sidebar-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--sidebar-group-label);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: var(--space-4) var(--space-4) var(--space-1);
}
.sidebar-section + .sidebar-section { margin-top: var(--space-2); }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 7px var(--space-4);
  color: var(--sidebar-text);
  font-size: var(--text-sm);
  font-weight: 450;
  text-decoration: none;
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-active);
  text-decoration: none;
}
.sidebar-item.active {
  background: var(--sidebar-item-active);
  color: var(--sidebar-accent);
  font-weight: 500;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--sidebar-accent);
}
.sidebar-item svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; opacity: 0.7; }

/* Старое имя (текущий sidebar.html использует .sidebar-link). Дублирует .sidebar-item. */
.sidebar-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 8px var(--space-4);
  text-decoration: none; color: var(--sidebar-text);
  font-size: var(--text-sm); font-weight: 450;
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-link:hover { background: var(--sidebar-item-hover); color: var(--sidebar-text-active); text-decoration: none; }
.sidebar-link.active { background: var(--sidebar-item-active); color: var(--sidebar-text-active); font-weight: 500; }
.sidebar-link.active::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--accent-blue);
}
.sidebar-link svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; opacity: 0.7; }
.sidebar-link.active svg, .sidebar-link:hover svg { opacity: 1; }
.sidebar-link > span:first-of-type {
  flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.sidebar-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 700;
  font-family: var(--font-mono);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: var(--accent-red);
  flex-shrink: 0;
}
.sidebar-badge.warning { background: var(--accent-orange); }
.sidebar-badge.info { background: var(--accent-blue); }

/* Старое имя бейджа навигации. */
.nav-badge {
  font-size: 10px; font-weight: 700; font-family: var(--font-mono);
  padding: 1px 6px; border-radius: var(--radius-full);
  min-width: 18px; text-align: center; line-height: 16px; color: #fff;
  background: var(--accent-red); flex-shrink: 0;
}
.nav-badge.info    { background: var(--accent-blue); }
.nav-badge.warning { background: var(--accent-orange); }
.nav-badge.danger  { background: var(--accent-red); }
.nav-badge.is-zero { display: none; }
.nav-badge.nav-beta {
  background: rgba(255, 255, 255, 0.1); color: var(--sidebar-text);
  font-weight: 600; font-family: var(--font-body); margin-left: auto;
}

.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  border-top: 1px solid var(--sidebar-border);
  padding: var(--space-3) var(--space-4);
  display: flex; align-items: center; gap: var(--space-2);
}
.sidebar-avatar {
  width: 32px; height: 32px;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
  color: var(--text-inverse);
  font-size: var(--text-xs);
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
/* Старые имена профиля (sidebar-user / user-avatar / user-info / ...). */
.sidebar-user {
  display: flex; align-items: center; gap: var(--space-3);
  flex: 1; min-width: 0;
  padding: var(--space-1); border-radius: var(--radius-md);
  text-decoration: none; color: inherit;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-user:hover { background: var(--sidebar-item-hover); color: inherit; text-decoration: none; }
.user-avatar {
  width: 30px; height: 30px; border-radius: var(--radius-full);
  background: var(--accent-blue); color: #fff;
  font-size: var(--text-xs); font-weight: 700;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.user-name { font-size: var(--text-xs); font-weight: 600; color: var(--sidebar-text-active); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--sidebar-group-label); }
.sidebar-logout {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--sidebar-group-label); padding: var(--space-1);
  border-radius: var(--radius-md); flex-shrink: 0;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.sidebar-logout svg { width: 16px; height: 16px; stroke: currentColor; }
.sidebar-logout:hover { color: var(--accent-red); background: var(--sidebar-item-hover); }

/* Карточка профиля внизу сайдбара (базовый footer нового дизайна).
   Аватар-картинка (base64 data URL) вписывается в круг, бейдж 2FA — рядом с именем. */
.sidebar-avatar img { width: 100%; height: 100%; border-radius: var(--radius-full); object-fit: cover; display: block; }
.sidebar-user.active { background: var(--sidebar-item-active); }
.sidebar-2fa-badge { width: 13px; height: 13px; color: var(--accent-green); vertical-align: middle; margin-left: 4px; stroke: currentColor; }
.sidebar-logout-link {
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--sidebar-group-label); padding: var(--space-1);
  border-radius: var(--radius-md); flex-shrink: 0; text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.sidebar-logout-link svg { width: 16px; height: 16px; stroke: currentColor; }
.sidebar-logout-link:hover { color: var(--accent-red); background: var(--sidebar-item-hover); }

/* ====================== СЕКЦИЯ 7: TOPBAR ============================= */
.topbar {
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  flex-shrink: 0;
}
.topbar-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 6px var(--space-3);
  width: 220px;
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal), width var(--transition-normal);
}
.topbar-search input {
  background: none; border: none; outline: none; color: var(--text-primary);
  font-size: var(--text-sm); width: 100%; font-family: var(--font-body);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search svg { width: 15px; height: 15px; stroke: var(--text-secondary); flex-shrink: 0; }
.topbar-search:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-bg);
  width: 280px;
}
.topbar-btn {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.topbar-btn:hover { background: var(--bg-highlight); color: var(--text-primary); }
.topbar-btn svg { width: 17px; height: 17px; stroke: currentColor; }
.topbar-notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: var(--radius-full);
  background: var(--accent-red);
}

/* ====================== СЕКЦИЯ 8: PAGE CONTENT ======================== */
.main-area {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.page-content {
  flex: 1;
  padding: var(--space-6);
  min-width: 0;
}
.page-title { font-size: var(--text-xl); font-weight: 700; color: var(--text-primary); }
.page-subtitle { font-size: var(--text-sm); color: var(--text-secondary); margin-top: var(--space-1); }

/* Заголовок страницы (R9 глобальный fallback — сохранён). */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap;
}
.page-actions { display: flex; gap: var(--space-2); flex-shrink: 0; flex-wrap: wrap; }

/* ====================== СЕКЦИЯ 9: KPI КАРТОЧКИ ======================= */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--space-4);
}
.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal), transform var(--transition-normal);
}
.kpi-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.kpi-card.alert-red    { border-color: rgba(252, 129, 129, 0.3); }
.kpi-card.alert-orange { border-color: rgba(246, 173, 85, 0.3); }
/* Старые модификаторы (alias). */
.kpi-card.alert { border-left: 3px solid var(--accent-red); }
.kpi-card.warn  { border-left: 3px solid var(--accent-orange); }
.kpi-card.ok    { border-left: 3px solid var(--accent-green); }

.kpi-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  flex-shrink: 0;
}
.kpi-icon.blue   { background: var(--accent-blue-bg);   color: var(--accent-blue); }
.kpi-icon.green  { background: var(--accent-green-bg);  color: var(--accent-green); }
.kpi-icon.orange { background: var(--accent-orange-bg); color: var(--accent-orange); }
.kpi-icon.red    { background: var(--accent-red-bg);    color: var(--accent-red); }
.kpi-icon.purple { background: var(--accent-purple-bg); color: var(--accent-purple); }
.kpi-icon svg { width: 20px; height: 20px; stroke: currentColor; }

.kpi-value {
  font-size: var(--text-2xl);
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-2);
}
.kpi-sub { font-size: var(--text-xs); color: var(--text-secondary); margin-top: var(--space-1); }
.kpi-sub.up   { color: var(--accent-green); }
.kpi-sub.down { color: var(--accent-red); }

/* ====================== СЕКЦИЯ 10: ТАБЛИЦЫ ============================ */
.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-default);
  -webkit-overflow-scrolling: touch;
}
.table-container > table,
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}
thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-default);
}
thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}
tbody tr:hover { background: var(--bg-elevated); }
tbody tr:last-child { border-bottom: none; }
tbody td {
  padding: var(--space-3) var(--space-4);
  vertical-align: middle;
  color: var(--text-primary);
}
td.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
td.amount { font-family: var(--font-mono); font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
td.amount.positive { color: var(--status-success); }
td.amount.negative { color: var(--status-error); }

/* Старый компонент .data-table (используется шаблонами) — сохранён. */
.data-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.data-table thead th {
  padding: 10px 14px; text-align: left; color: var(--text-secondary);
  font-weight: 500; font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 1px solid var(--border-default);
  white-space: nowrap; background: var(--bg-elevated);
}
.data-table tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle; color: var(--text-primary);
}
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover td { background: var(--bg-elevated); }
.data-table tr:last-child td { border-bottom: none; }
.data-table .num, .data-table .mono {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: var(--text-sm);
}
.data-table .amount { font-family: var(--font-mono); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.data-table .amount-negative { color: var(--accent-red); }
.data-table .amount-positive { color: var(--accent-green); }
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive .data-table { min-width: 700px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ====================== СЕКЦИЯ 11: БЕЙДЖИ ============================= */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}
.badge.success { background: var(--status-success-bg); color: var(--status-success); }
.badge.warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge.error   { background: var(--status-error-bg);   color: var(--status-error); }
.badge.info    { background: var(--status-info-bg);    color: var(--status-info); }
.badge.neutral { background: var(--status-neutral-bg); color: var(--status-neutral); }
.badge.blue    { background: var(--accent-blue-bg);    color: var(--accent-blue); }
.badge.purple  { background: var(--accent-purple-bg);  color: var(--accent-purple); }

/* Старые варианты (используются в page-CSS и шаблонах) — сохранены как alias. */
.badge-success { background: var(--status-success-bg); color: var(--status-success); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-danger  { background: var(--status-error-bg);   color: var(--status-error); }
.badge-error    { background: var(--status-error-bg);   color: var(--status-error); }
.badge-info    { background: var(--status-info-bg);    color: var(--status-info); }
.badge-orange  { background: var(--accent-orange-bg);  color: var(--accent-orange); }
.badge-muted   { background: var(--status-neutral-bg);  color: var(--status-secondary); }
.badge-neutral { background: var(--status-neutral-bg);  color: var(--status-secondary); }
.badge-primary { background: var(--accent-blue-bg);     color: var(--accent-blue); }
.badge-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: var(--radius-full); background: currentColor; margin-right: var(--space-1);
}

/* ====================== СЕКЦИЯ 12: КНОПКИ ============================= */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1.4;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
}
.btn:active { transform: translateY(0.5px); }
.btn svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }
.btn.is-loading { cursor: wait; opacity: 0.85; }

.btn-primary {
  background: var(--accent-blue);
  color: var(--text-inverse);
  border-color: var(--accent-blue);
}
.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 0 0 3px var(--accent-blue-bg);
  text-decoration: none;
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}
.btn-secondary:hover { border-color: var(--border-focus); background: var(--bg-highlight); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--bg-elevated); color: var(--text-primary); text-decoration: none; }
.btn-danger {
  background: var(--accent-red-bg);
  color: var(--accent-red);
  border: 1px solid transparent;
}
.btn-danger:hover { background: var(--accent-red); color: #fff; text-decoration: none; }

.btn-sm  { padding: 4px 10px; font-size: var(--text-xs); }
.btn-lg  { padding: 10px 20px; font-size: var(--text-base); }
.btn-icon { padding: 7px; width: 34px; height: 34px; justify-content: center; }

/* Кнопки действий в таблицах (R8) — сохранены. */
.table-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn-table {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px;
  font-size: var(--text-xs); line-height: 1.4; font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
.btn-table:hover { background: var(--bg-overlay); color: var(--text-primary); text-decoration: none; }
.btn-table svg { width: 13px; height: 13px; stroke: currentColor; flex-shrink: 0; }
.btn-table-primary { border-color: var(--accent-blue); background: var(--accent-blue); color: var(--text-inverse); }
.btn-table-primary:hover { filter: brightness(1.1); color: var(--text-inverse); }
.btn-table-secondary { border-color: var(--border-default); background: transparent; color: var(--text-secondary); }
.btn-table-secondary:hover { background: var(--bg-overlay); color: var(--text-primary); }
.btn-table-danger { border-color: transparent; background: transparent; color: var(--accent-red); }
.btn-table-danger:hover { background: var(--accent-red-bg); }

/* ====================== СЕКЦИЯ 13: ФОРМЫ ============================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
.form-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 500;
}
.form-label.required::after { content: ' *'; color: var(--accent-red); }
/* Старый вариант маркера обязательности. */
.form-label .req { color: var(--accent-red); margin-left: 2px; }

.form-control,
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 8px var(--space-3);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}
.form-input::placeholder,
.form-textarea::placeholder,
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-blue-bg);
}
select.form-control, select.form-select { cursor: pointer; }
.form-textarea { resize: vertical; min-height: 80px; }

.form-hint { font-size: var(--text-xs); color: var(--text-muted); }
.form-error, .form-error-msg { font-size: var(--text-xs); color: var(--accent-red); }
.form-row { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.form-row > .form-group { flex: 1 1 200px; margin-bottom: 0; }

/* ====================== СЕКЦИЯ 14: ПРОГРЕСС-БАР ======================= */
.progress-bar {
  height: 4px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent-blue);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.progress-fill.blue   { background: var(--accent-blue); }
.progress-fill.green  { background: var(--accent-green); }
.progress-fill.orange { background: var(--accent-orange); }
.progress-fill.red    { background: var(--accent-red); }
/* Старые варианты. */
.progress-fill.warning { background: var(--accent-orange); }
.progress-fill.danger  { background: var(--accent-red); }
.progress-fill.success { background: var(--accent-green); }
.progress-fill.full    { background: var(--accent-green); }

/* ====================== СЕКЦИЯ 15: МОДАЛЬНЫЕ ОКНА ===================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal), visibility var(--transition-normal);
}
.modal-backdrop.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}
.modal {
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96);
  transition: transform var(--transition-normal);
  padding: var(--space-6);
}
.modal-backdrop.active .modal { transform: scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-5);
}
.modal-title { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.modal-close {
  color: var(--text-secondary); cursor: pointer; padding: var(--space-1);
  background: none; border: none; display: inline-flex;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { margin-bottom: var(--space-5); }
.modal-footer {
  display: flex; gap: var(--space-2); justify-content: flex-end;
  margin-top: var(--space-5); padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

/* ====================== СЕКЦИЯ 16: TOAST УВЕДОМЛЕНИЯ ================== */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  min-width: 300px;
  max-width: 420px;
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  pointer-events: all;
  animation: toastIn var(--transition-slow) both;
}
.toast.success, .toast-success { border-left: 3px solid var(--status-success); }
.toast.error,   .toast-error   { border-left: 3px solid var(--status-error); }
.toast.warning, .toast-warning { border-left: 3px solid var(--status-warning); }
.toast.info,    .toast-info     { border-left: 3px solid var(--status-info); }
.toast span { flex: 1; color: var(--text-primary); }
.toast svg { flex-shrink: 0; width: 18px; height: 18px; }
.toast button {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); margin-left: auto; flex-shrink: 0;
  display: inline-flex; padding: 0;
}
.toast button:hover { color: var(--text-primary); }
/* Старое поведение visible (используется showToast в base.html). */
.toast { transform: translateX(calc(100% + 24px)); opacity: 0; transition: all var(--transition-slow); }
.toast.visible { transform: translateX(0); opacity: 1; }

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 200ms ease; transform: none; }
}

/* ====================== СЕКЦИЯ 17: TABS =============================== */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: 3px;
}
.tab {
  padding: 6px var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tab:hover { color: var(--text-primary); }
.tab.active { background: var(--bg-surface); color: var(--text-primary); box-shadow: var(--shadow-sm); }

/* Старый компонент .tabs/.tab-btn (нижнее подчёркивание, используется admin/salary). */
.tabs.tab-underline,
.tabs.is-underline {
  display: flex; gap: var(--space-1); background: transparent; border-radius: 0; padding: 0;
  border-bottom: 1px solid var(--border-default); margin-bottom: var(--space-5);
  overflow-x: auto;
}
.tab-btn {
  padding: var(--space-2) var(--space-4); font-size: var(--text-sm); font-weight: 500;
  color: var(--text-secondary); background: none; border: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color var(--transition-fast);
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }

/* ====================== СЕКЦИЯ 18: EMPTY STATE ======================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--text-secondary);
  gap: var(--space-3);
}
.empty-state-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.empty-state-icon svg { width: 24px; height: 24px; stroke: currentColor; }
.empty-state h3 { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.empty-state p { font-size: var(--text-sm); color: var(--text-secondary); max-width: 36ch; }

/* ====================== СЕКЦИЯ 19: SKELETON LOADER ==================== */
@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-elevated) 25%,
    var(--bg-highlight) 50%,
    var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-md);
}
.skeleton-text {
  height: 12px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-sm);
}
.skeleton-title { height: 20px; width: 60%; margin-bottom: var(--space-3); }
.skeleton-row { height: 40px; margin-bottom: var(--space-2); }

/* ====================== СЕКЦИЯ 20: ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ ================== */
.theme-switcher {
  display: flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: 3px;
  gap: 2px;
}
.theme-option {
  padding: 4px var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.theme-option:hover { color: var(--text-primary); }
.theme-option.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ====================== СЕКЦИЯ 21: МОБИЛЬНАЯ АДАПТАЦИЯ ================= */
/* Внимание: drawer-режим сайдбара требует кнопки-переключателя + JS, которая
   добавляет/убирает класс .mobile-open на .sidebar (шаблон base.html/sidebar.html).
   Без неё сайдбар скрыт на ≤768px. */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-search, .topbar-date { display: none; }
}

/* ====================== СЕКЦИЯ 22: УТИЛИТЫ ============================= */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.w-full { width: 100%; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-muted { color: var(--text-secondary); }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.divider { height: 1px; background: var(--border-subtle); margin: var(--space-4) 0; border: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: var(--space-4); }

@media (max-width: 768px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ====================== СОХРАНЁННЫЕ ГЛОБАЛЬНЫЕ ПРАВИЛА ================= */
/* Баннеры-уведомления (используются page-CSS). */
.alert-banner {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-md);
  font-size: var(--text-sm);
}
.alert-banner.info    { background: var(--status-info-bg);    color: var(--status-info); }
.alert-banner.warning { background: var(--status-warning-bg); color: var(--status-warning); }
.alert-banner.error   { background: var(--status-error-bg);   color: var(--status-error); }
.alert-banner.success { background: var(--status-success-bg); color: var(--status-success); }
.alert-banner .alert-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 1px; }
.alert-banner .alert-title { font-weight: 600; margin-bottom: 2px; }

/* Карточка (используется всеми шаблонами <div class="card">). */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: box-shadow var(--transition-normal), border-color var(--transition-normal);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); gap: var(--space-3); }
.card-title { font-size: var(--text-md); font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: var(--text-sm); color: var(--text-secondary); }
.card-body { margin-top: var(--space-2); }
.card-footer { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--border-subtle); }

/* Пагинация (используется page-CSS, напр. upd.css). */
.pagination { display: flex; align-items: center; gap: 4px; }
.page-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: 500;
  border: 1px solid var(--border-default); background: var(--bg-surface);
  color: var(--text-secondary); cursor: pointer; padding: 0 8px;
  transition: all var(--transition-fast);
}
.page-btn:hover { border-color: var(--border-focus); color: var(--accent-blue); }
.page-btn.active { background: var(--accent-blue); color: #fff; border-color: var(--accent-blue); }
.page-btn:disabled { opacity: 0.4; cursor: default; }
.page-btn:disabled:hover { border-color: var(--border-default); color: var(--text-secondary); }
.page-ellipsis { color: var(--text-muted); padding: 0 4px; }

/* Breakpoint-переопределения раскладки (R9, десктоп — no-op). */
@media (max-width: 1199px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }
  .page-header .btn { width: 100%; justify-content: center; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; justify-content: center; }
  .card { padding: var(--space-3); }
  .modal { padding: var(--space-4); }
  .data-table thead th, .data-table tbody td { padding: var(--space-2) 10px; }
  .empty-state { padding: var(--space-5) var(--space-3); }
  .kpi-grid { grid-template-columns: 1fr; }
}

/* ====================== ПОДДЕРЖКА base_new.html (v2) =================== */
/* Аддитивные под-классы для нового базового шаблона. Новые имена — старые
   страницы их не используют, поэтому добавление ничего не ломает. */
.sidebar-item-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-logo-sub {
  font-size: var(--text-xs);
  font-weight: 400;
  color: var(--sidebar-text);
  white-space: nowrap;
}
.sidebar-group + .sidebar-group { margin-top: var(--space-2); }
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.sidebar-user-name {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--sidebar-text-active);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role { font-size: 10px; color: var(--sidebar-text); }

.topbar-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.topbar-date {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.toast-icon { flex-shrink: 0; display: flex; align-items: center; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); }
.toast-msg { font-size: var(--text-sm); color: var(--text-secondary); }

/* Служебные утилиты. */
.fade-in { animation: fadeIn var(--transition-slow) both; }
.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;
}

/* Анимации (имена countUp / fadeIn используются в .kpi-value / .fade-in;
   @keyframes объявлены здесь, чтобы быть самодостаточным. */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes countUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}