/* 
 * Единый CSS шаблон для админ-страниц Kamaz Centre
 * Версия: 5.1 — Material Design 3 (ozon-exchange look); Celestial opt-in via data-surface="celestial"
 */
@import url('/remos/icon/style.css');
@import url('/admin-ops-theme.css');
@import url('/admin-md3-theme.css?v=5.1');

/*
 * Admin shell скрыт, пока JS не подтвердит staff-сессию (admin-auth-ready).
 * Страницы логина (.login-shell) не затрагиваются.
 */
.admin-container {
  visibility: hidden !important;
}
html.admin-auth-ready .admin-container {
  visibility: visible !important;
}

/* Пока идёт проверка — прячем всё содержимое body (и страницы без .admin-container) */
html.admin-auth-pending {
  background: #e8ecf3 !important;
}
html.admin-auth-pending body {
  background: #e8ecf3 !important;
  overflow: hidden !important;
}
html.admin-auth-pending body > * {
  display: none !important;
}

/* ==================== ROOT VARIABLES ==================== */
:root {
  color-scheme: light;

  /* Корпоративная палитра Kamaz Centre + системный акцент */
  --primary-color: #2275fc;
  --primary-hover: #1a5fd4;
  --primary-light: #4d8ffd;
  --primary-bg: rgba(26, 79, 149, 0.1);
  --ios-blue: #007aff;
  --ios-label: #3c3c43;
  --ios-secondary-label: rgba(60, 60, 67, 0.6);
  --ios-tertiary-label: rgba(60, 60, 67, 0.3);
  
  /* Светлая тема — мягкий «системный» фон */
  --bg-primary: #e8ecf3;
  --bg-secondary: rgba(255, 255, 255, 0.72);
  --bg-accent: rgba(255, 255, 255, 0.45);
  --text-primary: #1c1c1e;
  --text-secondary: var(--ios-secondary-label);
  --text-muted: var(--ios-tertiary-label);
  --border-color: rgba(60, 60, 67, 0.12);
  --border-hover: rgba(60, 60, 67, 0.22);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.12);
  --glass-blur: saturate(180%) blur(22px);
  --glass-bg: rgba(255, 255, 255, 0.55);
  --glass-border: rgba(255, 255, 255, 0.55);
  --success-color: #34c759;
  --warning-color: #ff9500;
  --danger-color: #ff3b30;
  --info-color: #2275fc;
  
  /* Алиасы для совместимости со страницами */
  --card-bg: var(--bg-secondary);
  --text-color: var(--text-primary);
  --secondary-bg: var(--bg-accent);
  
  /* Размеры и отступы (compact) */
  --spacing-xs: 3px;
  --spacing-sm: 5px;
  --spacing-md: 8px;
  --spacing-lg: 12px;
  --spacing-xl: 16px;
  --border-radius-sm: 6px;
  --border-radius-md: 8px;
  --border-radius-lg: 12px;
  --border-radius-xl: 16px;

  /* Breakpoints (mobile-first): xs default 320+, sm 640px, md 768px, lg 1024px, xl 1280px */
  --bp-sm: 640px;
  --bp-md: 768px;
  --bp-lg: 1024px;
  --bp-xl: 1280px;

  /* Typography: fluid scaling */
  --font-size-base: 13px;
  --font-size-sm: 12px;
  --font-size-lg: 15px;
  --line-height-body: 1.45;
  --line-height-tight: 1.3;

  /* Дополнительные переменные */
  --bg-card: var(--bg-secondary);
  --border-color-light: #f1f5f9;
  --font-weight-medium: 500;
  --font-weight-bold: 700;
  --primary-color-light: rgba(26, 79, 149, 0.12);
  --secondary-color: var(--primary-light);
  --border-radius-full: 9999px;

  /* Вертикальный ритм между секциями (особенно внутри .container) */
  --stack-gap: 10px;

  /* Выпадающие панели поверх полупрозрачного сайдбара — только непрозрачный фон */
  --admin-search-popover-bg: #ffffff;
  --admin-search-popover-hover: #eef1f6;
  --admin-search-popover-border: rgba(60, 60, 67, 0.18);
}


/* ==================== DARK THEME ==================== */
[data-theme="dark"] {
  color-scheme: dark;
  --bg-primary: #000000;
  --bg-secondary: rgba(28, 28, 30, 0.76);
  --bg-accent: rgba(44, 44, 46, 0.65);
  --text-primary: #f2f2f7;
  --text-secondary: rgba(235, 235, 245, 0.6);
  --text-muted: rgba(235, 235, 245, 0.3);
  --border-color: rgba(255, 255, 255, 0.12);
  --border-hover: rgba(255, 255, 255, 0.22);
  --primary-bg: rgba(26, 79, 149, 0.35);
  --glass-bg: rgba(28, 28, 30, 0.65);
  --glass-border: rgba(255, 255, 255, 0.08);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 16px 64px rgba(0, 0, 0, 0.55);
  --admin-search-popover-bg: #2c2c2e;
  --admin-search-popover-hover: #3a3a3c;
  --admin-search-popover-border: rgba(255, 255, 255, 0.14);
}

/* ==================== BASE STYLES ==================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-primary);
  background-image:
    radial-gradient(1200px 600px at 20% -10%, rgba(26, 79, 149, 0.14), transparent 55%),
    radial-gradient(900px 500px at 100% 20%, rgba(0, 122, 255, 0.08), transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-size: 1rem;
  line-height: var(--line-height-body);
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(var(--spacing-md), env(safe-area-inset-top))
    max(var(--spacing-md), env(safe-area-inset-right))
    max(var(--spacing-md), env(safe-area-inset-bottom))
    max(var(--spacing-md), env(safe-area-inset-left));
  -webkit-tap-highlight-color: rgba(26, 79, 149, 0.12);
}

[data-theme="dark"] body {
  background-image:
    radial-gradient(1000px 500px at 15% 0%, rgba(26, 79, 149, 0.35), transparent 55%),
    radial-gradient(800px 400px at 95% 15%, rgba(10, 132, 255, 0.12), transparent 45%);
}

/* ==================== LAYOUT ==================== */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.admin-container {
  max-width: 1600px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(260px, 288px) minmax(0, 1fr);
  gap: var(--stack-gap);
  min-height: calc(100dvh - max(32px, env(safe-area-inset-top) + env(safe-area-inset-bottom)));
}

.admin-main {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
}

/* Промежуток задаётся gap у колонки — лишний margin у прямых потомков убираем */
.admin-main > *,
.main-content > * {
  margin-bottom: 0;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
}

/* Контейнер как вертикальный стек — блоки не «слипаются» (парсер, часть отчётов) */
.admin-main > .container:not(.no-stack-gap),
.main-content .container:not(.no-stack-gap) {
  display: flex;
  flex-direction: column;
  gap: var(--stack-gap);
  width: 100%;
  padding-bottom: var(--stack-gap);
}

.admin-main > .container:not(.no-stack-gap) > *,
.main-content .container:not(.no-stack-gap) > * {
  margin-bottom: 0;
}

.main-content .container {
  max-width: 100%;
  padding: 0;
}

.main-content .container:not(.no-stack-gap) {
  padding-left: 0;
  padding-right: 0;
}

@media (max-width: 1024px) {
  .admin-container {
    grid-template-columns: 1fr;
  }
}

/* ==================== SIDEBAR DRAWER (mobile) ==================== */
.sidebar-toggle-btn {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: max(12px, env(safe-area-inset-left));
  z-index: 1001;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  padding: 0;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-primary);
  font-size: 0;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}

.sidebar-toggle-btn svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

@media (max-width: 1024px) {
  .sidebar-toggle-btn {
    display: flex;
  }
  .sidebar-drawer-wrapper {
    position: relative;
  }
  .sidebar-drawer {
    position: fixed;
    top: 0;
    left: 0;
    width: min(300px, 88vw);
    max-width: 88vw;
    height: 100vh;
    height: 100dvh;
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 1002;
    transform: translateX(-100%);
    transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--spacing-lg);
    padding-top: max(60px, calc(env(safe-area-inset-top) + 52px));
    padding-bottom: max(var(--spacing-lg), env(safe-area-inset-bottom));
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
  }
  body.sidebar-open .sidebar-drawer {
    transform: translateX(0);
  }
  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }
  #admin-sidebar-placeholder .sidebar-drawer .admin-sidebar {
    box-shadow: none;
    position: static;
    padding: 0;
  }
  .admin-container {
    padding-top: max(68px, calc(env(safe-area-inset-top) + 56px));
  }
  
  .sidebar-drawer .admin-sidebar {
    padding: 0;
  }
  
  .sidebar-drawer .sidebar-link {
    font-size: 15px;
    padding: 12px 16px;
    min-height: 48px;
  }
}

@media (min-width: 1025px) {
  .sidebar-toggle-btn {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
  .sidebar-drawer {
    position: static !important;
    transform: none !important;
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    box-shadow: none !important;
    overflow: visible !important;
  }
}

/* ==================== HEADER ==================== */
.admin-header {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  padding: 6px 10px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 6px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
}

/* Страница входа (admin-login и др.) */
.container > .header {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-md);
  max-width: 520px;
  margin: 10vh auto 0;
  text-align: center;
}

.container > .header h1 {
  font-size: clamp(1.35rem, 4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--spacing-sm);
}

.container > .header p {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.45;
}

.admin-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: var(--stack-gap);
}

.admin-header h1 {
  color: var(--text-primary);
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  letter-spacing: -0.03em;
  line-height: 1.25;
}

.admin-header p,
.admin-header .admin-page-subtitle,
.admin-page-subtitle {
  display: block;
  margin: 0;
  max-width: 62ch;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
  font-weight: 400;
}

/* ==================== NAVIGATION SIDEBAR ==================== */
.admin-sidebar {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  height: fit-content;
  position: sticky;
  top: max(var(--spacing-md), env(safe-area-inset-top));
}

.sidebar-section {
  margin-bottom: var(--spacing-md);
}

.sidebar-section:last-child {
  margin-bottom: 0;
}

.sidebar-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 8px 10px;
  min-height: 38px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  transition: background 0.2s ease, transform 0.15s ease;
  border: 1px solid transparent;
}

.sidebar-link-label {
  flex: 1;
  min-width: 0;
}

.sidebar-nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  flex-shrink: 0;
  margin-left: auto;
  box-shadow: 0 0 0 2px var(--bg-secondary, #f0f2f5);
}

.sidebar-link.active .sidebar-nav-dot {
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(13, 61, 115, 0.45);
}

.sidebar-nav-dot[hidden] {
  display: none !important;
}

.sidebar-link:hover {
  background: var(--bg-accent);
  border-color: var(--border-color);
}

.sidebar-link:active {
  transform: scale(0.98);
}

.sidebar-link.active {
  background: linear-gradient(135deg, var(--primary-color) 0%, #0d3d73 100%);
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(26, 79, 149, 0.35);
}

/* Подразделы в боковом меню */
.sidebar-subsection {
  margin-bottom: var(--spacing-xs);
}

.sidebar-subsection:last-child {
  margin-bottom: 0;
}

.sidebar-subsection-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-xs);
  width: 100%;
  padding: 6px 8px;
  margin: 0 0 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-subsection-title:hover {
  background: var(--bg-accent);
  color: var(--text-secondary);
}

.sidebar-subsection-title::after {
  content: '▾';
  font-size: 10px;
  opacity: 0.7;
  transition: transform 0.2s ease;
}

.sidebar-subsection.collapsed .sidebar-subsection-title::after {
  transform: rotate(-90deg);
}

.sidebar-subsection-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 4px;
  margin-bottom: 6px;
}

.sidebar-subsection.collapsed .sidebar-subsection-nav {
  display: none;
}

.sidebar-subsection-nav .sidebar-link {
  padding-left: 12px;
  font-size: 12px;
  min-height: 34px;
}

/* Подразделы в меню разделов (admin-menu) */
.menu-subgroup {
  margin-top: 6px;
}

.menu-subgroup:first-child {
  margin-top: 0;
}

.menu-subgroup-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  padding: 4px 8px 2px;
  margin-bottom: 2px;
}

.menu-subgroup.match .menu-subgroup-title {
  color: var(--primary-color);
}

.menu-subgroup-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-subgroup.hidden {
  display: none;
}

/* Глобальный поиск в сайдбаре */
.admin-global-search-section .admin-global-search-heading {
  display: block;
  cursor: default;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
}

.admin-global-search-wrap {
  position: relative;
  z-index: 1;
  isolation: isolate;
}

.admin-global-search-input {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
}

.admin-global-search-results {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 200;
  max-height: min(70vh, 440px);
  overflow-y: auto;
  background: var(--admin-search-popover-bg);
  border: 1px solid var(--admin-search-popover-border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
}

.admin-global-search-group-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  padding: 6px 12px 4px;
}

.admin-global-search-hit {
  display: block;
  padding: 8px 12px;
  text-decoration: none;
  color: var(--text-primary);
  border-top: 1px solid var(--border-color);
  transition: background 0.15s ease;
}

.admin-global-search-group .admin-global-search-hit:first-child {
  border-top: none;
}

.admin-global-search-hit:hover {
  background: var(--admin-search-popover-hover);
}

.admin-global-search-kind {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(26, 79, 149, 0.12);
  color: var(--primary-color);
  margin-bottom: 4px;
}

[data-theme='dark'] .admin-global-search-kind {
  background: rgba(96, 165, 250, 0.15);
  color: #93c5fd;
}

.admin-global-search-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.admin-global-search-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.35;
}

.admin-global-search-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
}

/* ==================== CARDS ==================== */
.admin-card,
.card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  margin-bottom: var(--stack-gap);
}

.card h2 {
  margin-top: 0;
  margin-bottom: var(--spacing-md);
  font-size: 1.1rem;
  color: var(--text-primary);
  font-weight: 600;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-sm);
  padding-bottom: var(--spacing-xs);
  border-bottom: 1px solid var(--border-color);
  gap: var(--spacing-sm);
}
.card-header-light {
  border-bottom-width: 1px;
  border-bottom-color: var(--border-color);
  margin-bottom: var(--spacing-sm);
}
.card-dashboard .card-body {
  padding-top: 0;
}

.card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 5px 12px;
  min-height: 30px;
  min-width: 30px;
  border: none;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  text-decoration: none;
  justify-content: center;
  white-space: nowrap;
  line-height: 1.2;
}

.btn:active {
  transform: scale(0.98);
}

/* Touch-friendly кнопки на мобильных */
@media (hover: none) and (pointer: coarse) {
  .btn {
    min-height: 40px;
    min-width: 40px;
    padding: 8px 14px;
  }
}

.btn-primary {
  background: linear-gradient(180deg, var(--primary-light) 0%, var(--primary-color) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(26, 79, 149, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(180deg, #2d6fc9 0%, var(--primary-hover) 100%);
  box-shadow: 0 4px 16px rgba(26, 79, 149, 0.3);
}

.btn-outline,
.btn-light {
  background: var(--bg-secondary, rgba(255, 255, 255, 0.72));
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}

.btn-outline:hover,
.btn-light:hover {
  border-color: var(--border-hover, var(--primary-color));
  background: var(--bg-accent);
}

.btn-secondary {
  background: var(--bg-accent);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-success {
  background: var(--success-color);
  color: white;
}

.btn-warning {
  background: var(--warning-color);
  color: white;
}

.btn-danger {
  background: var(--danger-color);
  color: white;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 12px;
  min-height: 26px;
  min-width: 26px;
}

.btn-icon {
  padding: 3px 6px;
  min-width: 28px;
  min-height: 26px;
  font-size: 14px;
}

.btn-lg {
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 14px;
}

/* ==================== FORM ELEMENTS ==================== */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-xs);
  margin-bottom: var(--spacing-sm);
}

.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  padding: 5px 10px;
  min-height: 32px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.65);
  color: var(--text-primary);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  line-height: 1.35;
}

[data-theme="dark"] .form-control {
  background: rgba(44, 44, 46, 0.85);
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 4px rgba(26, 79, 149, 0.15);
}

/* Touch-friendly формы на мобильных */
@media (hover: none) and (pointer: coarse) {
  .form-control {
    min-height: 40px;
    font-size: 16px;
    padding: 8px 12px;
  }
  
  select.form-control {
    padding-right: 40px;
  }
}

/* ==================== TABLES ==================== */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--spacing-md);
  border-radius: var(--border-radius-md);
}
.table-responsive table {
  min-width: 600px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.35);
  border-radius: var(--border-radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

[data-theme="dark"] .admin-table {
  background: rgba(28, 28, 30, 0.55);
}

.admin-table th {
  background: var(--bg-accent);
  padding: 5px 8px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--border-color);
  font-size: 11px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.admin-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 12px;
  vertical-align: middle;
}

.admin-table tbody tr:hover {
  background: var(--bg-accent);
}

/* Чекбокс колонка */
.admin-table .checkbox-cell {
  width: 32px;
  text-align: center;
  padding: 4px;
}

/* Кнопки действий в таблицах */
.action-buttons-cell {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.user-info-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-info-cell .user-details {
  min-width: 0;
  overflow: hidden;
}

.user-info-cell .user-contact-line {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Мобильная адаптация таблиц */
@media (max-width: 768px) {
  .table-responsive {
    margin-left: 0;
    margin-right: 0;
    margin-top: var(--spacing-sm);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.2);
  }

  [data-theme='dark'] .table-responsive {
    background: rgba(28, 28, 30, 0.35);
  }
  
  .admin-table th,
  .admin-table td {
    padding: 8px 6px;
    font-size: 12px;
  }
  
  .admin-table th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-accent);
  }
  
  /* Компактный режим для кнопок в таблице */
  .admin-table .btn {
    padding: 4px 6px;
    font-size: 11px;
    min-height: 28px;
    min-width: 28px;
  }
  
  .admin-table .btn-sm {
    padding: 2px 4px;
    font-size: 10px;
    min-height: 24px;
    min-width: 24px;
  }
}

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-primary {
  background: rgba(62, 115, 196, 0.15);
  color: var(--primary-color);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning-color);
}

.badge-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
}

/* ==================== HELP BANNERS ==================== */
.help-banner {
  background: var(--primary-bg);
  border: 1px solid rgba(26, 79, 149, 0.2);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  margin: var(--spacing-md) 0;
}

.help-banner h2,
.help-banner h3 {
  color: var(--primary-color);
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.help-banner ul {
  margin: 4px 0;
  padding-left: 18px;
}

.help-banner li {
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 13px;
  line-height: 1.5;
}

.help-banner p {
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
}

.help-banner strong {
  color: var(--primary-color);
}

/* Info box (информационный блок) */
.info-box {
  background: var(--primary-bg);
  padding: var(--spacing-md);
  border-radius: var(--border-radius-md);
  margin-bottom: var(--spacing-lg);
  border-left: 4px solid var(--primary-color);
}

.info-box strong {
  color: var(--primary-color);
}

/* Help text под полями */
.help-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

/* ==================== STATUS INDICATORS ==================== */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
}

.status-indicator.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-indicator.offline {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.status-indicator.unknown {
  background: var(--bg-accent);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==================== INTEGRATION CARD HEADERS ==================== */
.integration-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-md);
}

.integration-icon {
  font-size: 24px;
  margin-right: 8px;
}

.integration-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==================== TOOLTIPS ==================== */
.tooltip {
  position: relative;
  display: inline-block;
  cursor: help;
}

.tooltip-text {
  visibility: hidden;
  position: absolute;
  z-index: 1000;
  bottom: 125%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-primary);
  color: var(--bg-secondary);
  font-size: 12px;
  padding: var(--spacing-xs) var(--spacing-sm);
  border-radius: var(--border-radius-sm);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s;
  box-shadow: var(--shadow-md);
}

.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--text-primary);
}

.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ==================== THEME SWITCHER ==================== */
.theme-switcher {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: 4px 6px 4px 4px;
  background: rgba(120, 120, 128, 0.16);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 0.2s ease;
  border: 1px solid var(--border-color);
}

.theme-switcher:hover {
  background: var(--border-color);
}

.theme-switcher input[type="checkbox"] {
  display: none;
}

.switch-track {
  width: 51px;
  height: 31px;
  background: rgba(120, 120, 128, 0.36);
  border-radius: 999px;
  position: relative;
  transition: background 0.25s ease;
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 27px;
  height: 27px;
  background: white;
  border-radius: 50%;
  transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.08);
}

input:checked + .switch-track {
  background: var(--primary-color);
}

input:checked + .switch-track .switch-thumb {
  transform: translateX(20px);
}

/* ==================== BUTTON GROUPS ==================== */
.btn-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ==================== MESSAGES ==================== */
.msg {
  padding: 12px;
  border-radius: 10px;
  margin-bottom: 14px;
  display: none;
}

.msg.ok {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.msg.err {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger-color);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* ==================== HINTS ==================== */
.hint {
  font-size: 12px;
  color: #6b7280;
  margin-top: 6px;
}

/* ==================== TABS (iOS segmented control) ==================== */
.tabs {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  padding: 3px;
  border-radius: 11px;
  background: rgba(120, 120, 128, 0.16);
  border: 1px solid var(--border-color);
  max-width: 100%;
}

[data-theme="dark"] .tabs {
  background: rgba(120, 120, 128, 0.24);
}

.tab {
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 9px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  flex: 1 1 auto;
  text-align: center;
}

.tab:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tab.active {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--border-color);
}

[data-theme="dark"] .tab.active {
  background: rgba(58, 58, 60, 0.95);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* Alias used by many pages instead of .tab */
.tab-btn {
  padding: 8px 16px;
  min-height: 36px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  flex: 1 1 auto;
  text-align: center;
}

.tabs .tab-btn {
  border: none;
}

.tab-btn:hover {
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  color: var(--text-primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 0.5px var(--border-color);
  border-color: transparent;
}

[data-theme="dark"] .tab-btn.active {
  background: rgba(58, 58, 60, 0.95);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* Flat pill tabs (when .tabs is a plain flex row without segmented chrome) */
.tabs:not(:has(.tab)):has(.tab-btn) {
  display: flex;
  gap: 8px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}

.tabs:not(:has(.tab)):has(.tab-btn) .tab-btn {
  flex: 0 0 auto;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary, #f3f4f6);
  border-radius: 8px;
}

.tabs:not(:has(.tab)):has(.tab-btn) .tab-btn.active {
  background: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  box-shadow: none;
  backdrop-filter: none;
}

/* ==================== TAB PANELS ==================== */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ==================== TOOLBARS / FILTERS ==================== */
.toolbar,
.admin-toolbar,
.filters-row,
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin-bottom: var(--stack-gap);
}

.toolbar .btn,
.admin-toolbar .btn,
.filters-row .btn,
.filters .btn {
  flex: 0 0 auto;
  align-self: center;
}

.filters .form-group,
.filters-row .form-group {
  margin-bottom: 0;
  min-width: 140px;
}

.filters .form-label,
.filters-row .form-label {
  margin-bottom: 4px;
}

/* ==================== TOGGLES ==================== */
.toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.toggle input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.toggle span {
  font-weight: 500;
  color: var(--text-primary);
}

/* ==================== FORM ROWS ==================== */
.row {
  margin-bottom: 14px;
}

.row label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.row input,
.row select,
.row textarea {
  width: 100%;
  max-width: 520px;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  color: var(--text-primary);
}

/* ==================== GRID LAYOUTS ==================== */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 980px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

/* ==================== UTILITIES ==================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 13px; }
.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.w-full { width: 100%; }
.ml-sm { margin-left: var(--spacing-sm); }

/* Responsive utilities */
.hide-mobile { display: block; }
.show-mobile { display: none; }
.stack-mobile { flex-direction: row; }
.grid-responsive {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--spacing-md);
}

@media (max-width: 1023px) {
  .hide-mobile { display: none !important; }
  .show-mobile { display: block !important; }
  .stack-mobile { flex-direction: column; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
  :root {
    --stack-gap: clamp(22px, 5.5vw, 28px);
  }

  body {
    padding: max(12px, env(safe-area-inset-top))
      max(14px, env(safe-area-inset-right))
      max(16px, env(safe-area-inset-bottom))
      max(14px, env(safe-area-inset-left));
  }
  
  .admin-container {
    grid-template-columns: 1fr;
    gap: var(--stack-gap);
  }
  
  .admin-header {
    padding: 6px 8px;
  }
  
  .admin-header h1 {
    font-size: 1.15rem;
    line-height: 1.25;
  }
  
  .admin-header p,
  .admin-header .admin-page-subtitle {
    display: block;
    font-size: 12px;
  }
  
  .admin-card,
  .card {
    padding: max(var(--spacing-md), 14px) var(--spacing-lg);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(60, 60, 67, 0.08);
  }

  [data-theme='dark'] .admin-card,
  [data-theme='dark'] .card {
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.07);
  }

  .stats-grid {
    gap: var(--stack-gap);
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 158px), 1fr));
  }

  .help-banner {
    margin: var(--spacing-md) 0;
    padding: var(--spacing-md);
  }
  
  .card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
  }
  
  /* Кнопки на мобильных */
  .btn-group {
    flex-direction: column;
    gap: 8px;
  }
  
  .btn-group .btn {
    width: 100%;
  }
  
  /* Формы на мобильных */
  .form-group {
    width: 100%;
    margin-bottom: var(--spacing-sm);
  }
  
  .form-control {
    font-size: 16px; /* Предотвращает zoom на iOS */
    padding: 10px 12px;
  }
  
  .row input,
  .row select,
  .row textarea {
    max-width: 100%;
    font-size: 16px;
  }
  
  .admin-header,
  .admin-sidebar {
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(60, 60, 67, 0.06);
  }

  [data-theme='dark'] .admin-header,
  [data-theme='dark'] .admin-sidebar {
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.06);
  }
  
  /* WCAG AA: secondary text min 14px on mobile */
  .text-muted,
  .text-secondary,
  .form-label,
  .sidebar-title {
    font-size: max(14px, 0.875rem);
  }
  
  /* Вертикальная укладка только там, где это уместно */
  .filters-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
  }
  .filters-row > * {
    width: 100% !important;
  }
  .admin-header .d-flex.justify-between,
  .card-header {
    flex-direction: column;
    align-items: stretch !important;
    gap: var(--spacing-sm);
  }
  .admin-header .d-flex.justify-between > .btn,
  .card-header > .btn {
    width: 100%;
  }
}

@media (max-width: 640px) {
  /* Не сужаем ритм относительно 768px — на узких экранах блоки иначе «слипаются» */
  :root {
    --stack-gap: clamp(22px, 6vw, 30px);
  }

  body {
    padding: max(10px, env(safe-area-inset-top))
      max(12px, env(safe-area-inset-right))
      max(14px, env(safe-area-inset-bottom))
      max(12px, env(safe-area-inset-left));
  }

  .admin-header h1 {
    font-size: 18px;
  }
  
  .admin-header p {
    font-size: 12px;
  }
  
  .card-title {
    font-size: 16px;
  }
  
  .admin-card,
  .card {
    padding: 14px 14px 16px;
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(60, 60, 67, 0.1);
  }

  [data-theme='dark'] .admin-card,
  [data-theme='dark'] .card {
    box-shadow: var(--shadow-sm), 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  
  .btn {
    font-size: 13px;
    padding: 8px 12px;
  }
}

/* ==================== MAIN DASHBOARD (main.html) ==================== */
.page-header {
  margin-bottom: var(--spacing-lg);
}
.page-header h1 {
  font-size: clamp(1.15rem, 3vw, 1.5rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--spacing-xs);
  letter-spacing: -0.02em;
}
.page-header .subtitle {
  font-size: var(--font-size-base);
  color: var(--text-secondary);
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--spacing-md);
}
.stat-card {
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-md);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .stat-card {
  background: rgba(44, 44, 46, 0.55);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-hover);
}
.stat-header {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}
.stat-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}
.stat-icon.bg-blue { background: rgba(62, 115, 196, 0.15); color: var(--primary-color); }
.stat-icon.bg-green { background: rgba(16, 185, 129, 0.15); color: var(--success-color); }
.stat-icon.bg-orange { background: rgba(245, 158, 11, 0.15); color: var(--warning-color); }
.stat-icon.bg-purple { background: rgba(139, 92, 246, 0.15); color: var(--secondary-color); }
.stat-info h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}
.stat-info p {
  font-size: 12px;
  color: var(--text-muted);
}
.stat-value {
  font-size: clamp(1.1rem, 2.5vw, 1.35rem);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* Quick actions grid */
.grid {
  display: grid;
  gap: var(--spacing-sm);
}
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 768px) {
  .md\:grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 480px) {
  .grid-cols-2 { grid-template-columns: 1fr; }
}
.action-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: var(--spacing-md);
  background: rgba(255, 255, 255, 0.38);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  text-decoration: none;
  color: inherit;
  transition: all 0.2s ease;
  min-height: 84px;
}

[data-theme="dark"] .action-card {
  background: rgba(44, 44, 46, 0.5);
}
.action-card:hover {
  border-color: var(--primary-color);
  background: rgba(62, 115, 196, 0.04);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.action-icon {
  font-size: 20px;
  line-height: 1;
}
.action-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}
.action-description {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Card header refinement for main */
.card-header h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* ==================== MODAL OVERLAY ==================== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--spacing-md);
}
.modal[style*="display: flex"] {
  display: flex !important;
}
.modal .modal-content {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 90vw;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  width: 100%;
}
.modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}
.modal .modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal .close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text-muted);
}
.modal .close-btn:hover {
  background: var(--bg-accent);
  color: var(--text-primary);
}
.modal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md) var(--spacing-lg);
}
.modal .detail-row {
  display: flex;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
  border-bottom: 1px solid var(--border-color);
}
.modal .detail-row:last-of-type {
  border-bottom: none;
}
.modal .detail-label {
  flex: 0 0 140px;
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 600;
}
.modal .detail-value {
  flex: 1;
  font-size: 14px;
  color: var(--text-primary);
  word-break: break-word;
}
.modal .actions {
  display: flex;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border-top: 1px solid var(--border-color);
  background: var(--bg-accent);
  flex-shrink: 0;
}

/* Адаптация модалок для мобильных */
@media (max-width: 768px) {
  .modal {
    padding: 0;
    align-items: flex-end;
    padding-bottom: env(safe-area-inset-bottom);
  }
  
  .modal .modal-content {
    max-height: min(92dvh, 95vh);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-width: 100%;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  
  .modal .modal-header {
    padding: 12px 16px;
  }
  
  .modal .modal-header h3 {
    font-size: 16px;
  }
  
  .modal .modal-body {
    padding: 16px;
  }
  
  .modal .detail-row {
    flex-direction: column;
    gap: 4px;
    padding: 10px 0;
  }
  
  .modal .detail-label {
    flex: none;
    font-size: 12px;
  }
  
  .modal .detail-value {
    font-size: 14px;
  }
  
  .modal .actions {
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }
  
  .modal .actions .btn {
    width: 100%;
  }
}

/* ==================== LOADING SPINNER ==================== */
.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
  min-height: 80px;
}
.loading-spinner::after {
  content: '';
  width: 32px;
  height: 32px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spinner-rotate 0.8s linear infinite;
}
@keyframes spinner-rotate {
  to { transform: rotate(360deg); }
}

/* ==================== PAGINATION COMPONENT ==================== */
.pagination-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--bg-secondary);
  border-radius: var(--border-radius-md);
  margin-top: var(--spacing-lg);
  flex-wrap: wrap;
}

.pagination-info {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.pagination-pages {
  font-weight: 500;
  color: var(--text-primary);
  padding: 0 var(--spacing-md);
}

.pagination-size {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: var(--font-size-sm);
  cursor: pointer;
}

@media (max-width: 768px) {
  .pagination-wrapper {
    flex-direction: column;
    gap: var(--spacing-sm);
  }
  
  .pagination-controls {
    width: 100%;
    justify-content: center;
  }
}

/* ==================== BREADCRUMBS COMPONENT ==================== */
.breadcrumbs {
  margin-bottom: var(--spacing-lg);
  padding: var(--spacing-sm) 0;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--spacing-sm);
  list-style: none;
  margin: 0;
  padding: 0;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}

.breadcrumb-item:not(:last-child)::after {
  content: '›';
  margin-left: var(--spacing-sm);
  color: var(--text-muted);
}

.breadcrumb-item a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
  color: var(--primary-hover);
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

/* ==================== SEARCH/FILTER COMPONENT ==================== */
.search-filter-bar {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
}

.search-box {
  display: flex;
  gap: var(--spacing-sm);
  align-items: center;
}

.search-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-base);
}

.filter-controls {
  display: flex;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

.filter-input {
  min-width: 150px;
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  font-size: var(--font-size-sm);
}

@media (max-width: 768px) {
  .search-box {
    flex-direction: column;
  }
  
  .search-input,
  .search-box .btn {
    width: 100%;
  }
  
  .filter-input {
    min-width: 100%;
  }
}

/* ==================== TABLE SORT ==================== */
th[data-sortable] {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s;
}

th[data-sortable]:hover {
  background-color: var(--bg-accent);
}

.sort-icon {
  margin-left: var(--spacing-xs);
  font-size: 12px;
  color: var(--text-muted);
}

th[data-sort="asc"] .sort-icon,
th[data-sort="desc"] .sort-icon {
  color: var(--primary-color);
}

/* ==================== CONFIRM DIALOG ==================== */
.confirm-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.2s;
}

.confirm-dialog {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-xl);
  max-width: 500px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}

@media (max-width: 768px) {
  .confirm-dialog-overlay {
    align-items: flex-end;
    padding: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .confirm-dialog {
    width: 100%;
    max-width: none;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
    padding: var(--spacing-lg);
  }
}

.confirm-dialog h3 {
  margin: 0 0 var(--spacing-md) 0;
  color: var(--text-primary);
  font-size: 20px;
}

.confirm-dialog p {
  margin: 0 0 var(--spacing-lg) 0;
  color: var(--text-secondary);
  line-height: 1.5;
}

.confirm-dialog-actions {
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

/* ==================== POLISH (v3.1) ==================== */
::selection {
  background: rgba(26, 79, 149, 0.22);
  color: var(--text-primary);
}

.main-content a:not(.btn):not(.sidebar-link):not(.action-card),
.admin-main a:not(.btn):not(.sidebar-link):not(.action-card) {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.main-content a:not(.btn):not(.sidebar-link):not(.action-card):hover,
.admin-main a:not(.btn):not(.sidebar-link):not(.action-card):hover {
  border-bottom-color: rgba(26, 79, 149, 0.35);
}

:focus-visible {
  outline: 3px solid rgba(26, 79, 149, 0.45);
  outline-offset: 2px;
}

.btn:focus-visible,
.sidebar-link:focus-visible,
.tab:focus-visible {
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.main-content pre,
.main-content code,
.admin-main pre,
.admin-main code {
  font-family: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.9em;
}

.main-content pre,
.admin-main pre {
  padding: var(--spacing-md);
  border-radius: var(--border-radius-sm);
  background: var(--bg-accent);
  border: 1px solid var(--border-color);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

html {
  scrollbar-width: thin;
  scrollbar-color: rgba(26, 79, 149, 0.35) transparent;
}

html::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar,
.sidebar-drawer::-webkit-scrollbar,
.modal .modal-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb,
.sidebar-drawer::-webkit-scrollbar-thumb,
.modal .modal-body::-webkit-scrollbar-thumb {
  background: rgba(26, 79, 149, 0.28);
  border-radius: 8px;
}

html::-webkit-scrollbar-thumb:hover,
.table-responsive::-webkit-scrollbar-thumb:hover,
.sidebar-drawer::-webkit-scrollbar-thumb:hover,
.modal .modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(26, 79, 149, 0.45);
}

[data-theme="dark"] html {
  scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}

[data-theme="dark"] html::-webkit-scrollbar-thumb,
[data-theme="dark"] .table-responsive::-webkit-scrollbar-thumb,
[data-theme="dark"] .sidebar-drawer::-webkit-scrollbar-thumb,
[data-theme="dark"] .modal .modal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
}

img,
video {
  max-width: 100%;
  height: auto;
  border-radius: var(--border-radius-sm);
}

/* ==================== v3.2 — крупные страницы и типографика контента ==================== */
.admin-main .container--readable,
.admin-main.main-content-wide .container {
  max-width: min(1480px, 100%);
}

.admin-main.main-content-wide {
  max-width: min(1480px, 100%);
  width: 100%;
  justify-self: center;
}

.main-content h2,
.admin-main .main-content h2 {
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin: var(--spacing-lg) 0 var(--spacing-sm);
}

.main-content h2:first-child,
.admin-main .main-content h2:first-child {
  margin-top: 0;
}

.admin-section {
  padding-left: var(--spacing-md);
  border-left: 3px solid rgba(26, 79, 149, 0.35);
  margin: var(--spacing-md) 0;
}

.admin-table tbody tr:nth-child(even) {
  background: rgba(26, 79, 149, 0.03);
}

[data-theme="dark"] .admin-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

.admin-table tbody tr {
  transition: background 0.15s ease;
}

.admin-card:hover,
.admin-card:focus-within {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(26, 79, 149, 0.06);
}

[data-theme="dark"] .admin-card:hover,
[data-theme="dark"] .admin-card:focus-within {
  box-shadow: var(--shadow-md), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

/* Таблицы Bootstrap-подобного класса .table внутри админки (crossdata-batch и др.) */
.admin-main table.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-main table.table th,
.admin-main table.table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.admin-main table.table th {
  font-weight: 600;
  text-align: left;
  font-size: 12px;
  color: var(--text-secondary);
}

.admin-main table.table tbody tr:hover {
  background: rgba(26, 79, 149, 0.04);
}

[data-theme="dark"] .admin-main table.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ==================== Admin list kit — Stripe/Linear liquid SaaS ==================== */
/* Scoped tokens: white surfaces, soft blue, no muddy grey-on-grey */
.admin-list-page {
  --list-ink: #0f172a;
  --list-muted: #64748b;
  --list-line: rgba(15, 23, 42, 0.08);
  --list-soft: #f1f5f9;
  --list-surface: #ffffff;
  --list-accent: #1A4F95;
  --list-accent-soft: rgba(26, 79, 149, 0.1);
  --list-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 24px rgba(15, 23, 42, 0.06);
  --list-radius: 14px;

  display: flex;
  flex-direction: column;
  gap: 18px;
  color: var(--list-ink);
  max-width: 100%;
}

/* Soft canvas behind list pages (overrides Celestial #f3f4f6 mud) */
html[data-surface="celestial"] body.admin-celestial-active:has(.admin-list-page),
html[data-surface="celestial"] body.admin-celestial-active:has(.admin-list-page) .content-wrapper {
  background:
    radial-gradient(1200px 480px at 12% -10%, rgba(26, 79, 149, 0.07), transparent 55%),
    radial-gradient(900px 420px at 92% 0%, rgba(14, 165, 233, 0.05), transparent 50%),
    #f8fafc !important;
}

.admin-list-page .status-checks-hidden,
.admin-list-page #statusChecks {
  display: none !important;
}

.admin-list-page .admin-list-title {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--list-ink);
  line-height: 1.2;
}

.admin-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--list-radius);
  box-shadow: var(--list-shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.admin-list-toolbar__period {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 3px;
  background: var(--list-soft);
  border-radius: 10px;
}

.admin-list-period-label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: var(--list-surface);
  color: var(--list-ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.admin-list-toolbar__period .btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  border: 0 !important;
  background: transparent !important;
  color: var(--list-muted) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.admin-list-toolbar__period .btn:hover {
  background: rgba(255, 255, 255, 0.85) !important;
  color: var(--list-ink) !important;
}

.admin-status-pills {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 3px;
  background: var(--list-soft);
  border-radius: 10px;
}

.admin-status-pill {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--list-muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.2;
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.admin-status-pill:hover {
  color: var(--list-ink);
  background: rgba(255, 255, 255, 0.7);
}

.admin-status-pill.is-active {
  background: var(--list-surface);
  color: var(--list-accent);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(26, 79, 149, 0.12);
}

.admin-status-pill__count {
  margin-left: 4px;
  color: #94a3b8;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.admin-status-pill.is-active .admin-status-pill__count {
  color: var(--list-accent);
}

.admin-list-toolbar__actions {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}

.admin-list-toolbar__actions .btn {
  min-height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 10px;
  letter-spacing: -0.01em;
}

.admin-list-toolbar__actions .btn-outline,
.admin-list-toolbar__actions .btn-secondary {
  background: var(--list-surface) !important;
  border: 1px solid var(--list-line) !important;
  color: var(--list-ink) !important;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03) !important;
  backdrop-filter: none !important;
}

.admin-list-toolbar__actions .btn-outline:hover,
.admin-list-toolbar__actions .btn-secondary:hover {
  background: #f8fafc !important;
  border-color: rgba(26, 79, 149, 0.25) !important;
  color: var(--list-accent) !important;
}

.admin-list-toolbar__actions .btn-primary {
  background: linear-gradient(180deg, #3e73c4 0%, #1A4F95 100%) !important;
  border: 0 !important;
  color: #fff !important;
  box-shadow: 0 4px 14px rgba(26, 79, 149, 0.35) !important;
}

.admin-list-toolbar__actions .btn-primary:hover {
  filter: brightness(1.04);
}

.admin-filter-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1040;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}

.admin-filter-drawer-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.admin-filter-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 100vw);
  height: 100vh;
  z-index: 1050;
  background: rgba(255, 255, 255, 0.92);
  border-left: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: -12px 0 40px rgba(15, 23, 42, 0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.admin-filter-drawer.is-open {
  transform: translateX(0);
}

.admin-filter-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--list-line);
  flex-shrink: 0;
}

.admin-filter-drawer__title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--list-ink);
}

.admin-filter-drawer__close {
  appearance: none;
  border: 0;
  background: var(--list-soft);
  color: var(--list-muted);
  font-size: 20px;
  line-height: 1;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  cursor: pointer;
}

.admin-filter-drawer__close:hover {
  background: var(--list-accent-soft);
  color: var(--list-accent);
}

.admin-filter-drawer__body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.admin-filter-drawer__body .form-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--list-muted);
  margin-bottom: 6px;
}

.admin-filter-drawer__body .form-control {
  height: 38px;
  font-size: 13px;
  border-radius: 10px;
  border: 1px solid var(--list-line);
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

.admin-filter-drawer__body .form-control:focus {
  border-color: rgba(26, 79, 149, 0.45);
  box-shadow: 0 0 0 3px var(--list-accent-soft);
  outline: none;
}

.admin-filter-drawer__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.admin-filter-drawer__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--list-line);
  background: rgba(248, 250, 252, 0.85);
  flex-shrink: 0;
}

.admin-filter-drawer__footer .btn {
  min-height: 36px;
  border-radius: 10px;
  font-size: 13px;
}

.admin-list-table-card {
  background: var(--list-surface);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--list-radius);
  padding: 6px 0 10px;
  box-shadow: var(--list-shadow);
  overflow: hidden;
}

.admin-list-table-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px 10px;
  margin: 0;
  border: 0;
  background: transparent;
}

.admin-list-table-card .card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--list-ink);
}

.admin-list-table-meta {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--list-muted);
}

.admin-list-table-meta strong {
  color: var(--list-ink);
  font-weight: 600;
}

.admin-list-table-meta .form-control {
  border-radius: 8px;
  border: 1px solid var(--list-line);
  background: #fff;
}

.admin-list-page .admin-table {
  background: transparent;
  box-shadow: none;
  border: 0;
  border-radius: 0;
}

.admin-list-page .admin-table th {
  background: transparent;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--list-line);
  padding: 12px 18px;
}

.admin-list-page .admin-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  font-size: 13px;
  color: var(--list-ink);
  background: transparent;
}

.admin-list-page .admin-table tbody tr:nth-child(even) {
  background: transparent;
}

.admin-list-page .admin-table tbody tr:hover {
  background: linear-gradient(90deg, rgba(26, 79, 149, 0.04), rgba(26, 79, 149, 0.02));
}

[data-theme="dark"] .admin-list-page {
  --list-ink: #f1f5f9;
  --list-muted: #94a3b8;
  --list-line: rgba(255, 255, 255, 0.1);
  --list-soft: rgba(255, 255, 255, 0.06);
  --list-surface: rgba(30, 34, 53, 0.92);
  --list-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .admin-list-page .admin-table td {
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] .admin-list-page .admin-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.admin-filter-btn-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--list-accent, #1A4F95);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.admin-filter-btn-badge:empty,
.admin-filter-btn-badge[hidden] {
  display: none;
}

@media (max-width: 1100px) {
  .admin-list-toolbar__actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .admin-status-pills {
    width: 100%;
    order: 3;
  }
}

/* ==================== Designer normalize v4.5 ==================== */
/* Generic pagination used by many pages as .pagination */
.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination button,
.pagination .btn {
  min-height: 32px;
  padding: 4px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-secondary, #fff);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.pagination button:hover:not(:disabled),
.pagination .btn:hover:not(:disabled) {
  border-color: var(--primary-color);
  background: var(--primary-bg, rgba(34, 117, 252, 0.08));
}

.pagination button:disabled,
.pagination .btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Form rhythm */
.form-group {
  margin-bottom: var(--spacing-md, 8px);
}

.form-label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-control {
  min-height: 36px;
}

/* Empty / help surfaces */
.admin-empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.admin-empty-state strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text-primary);
  font-size: 14px;
}

.help-banner {
  width: 100%;
  box-sizing: border-box;
}

.help-banner h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
}

.help-banner ul {
  margin: 0;
  padding-left: 18px;
}

.help-banner li {
  margin-bottom: 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Dangerous confirm should look secondary until confirmed */
.btn-danger-outline {
  background: transparent;
  color: var(--danger-color, #ff3b30);
  border: 1px solid rgba(255, 59, 48, 0.35);
}

.btn-danger-outline:hover {
  background: rgba(255, 59, 48, 0.08);
}

/* Soften emoji-only visual noise in headers when present */
.admin-header h1 {
  font-variant-emoji: text;
}

/* Integration card headers used across ops pages */
.integration-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 12px;
  margin-bottom: 12px;
}

.integration-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.integration-title h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.integration-icon {
  font-size: 16px;
  line-height: 1;
}

/* ==================== NOTIFICATION BELL / ЦЕНТР УВЕДОМЛЕНИЙ ==================== */
.admin-notif {
  position: relative;
  display: inline-flex;
}

.admin-notif-btn {
  position: relative;
}

.admin-notif-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger-color, #ff3b30);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--glass-bg, #fff);
}

.admin-notif-btn.has-unread .material-symbols-outlined,
.admin-notif-btn.has-unread .typcn {
  color: var(--primary-color);
}

.admin-notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, 92vw);
  max-height: min(72vh, 540px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--admin-search-popover-bg, #fff);
  border: 1px solid var(--admin-search-popover-border, rgba(60, 60, 67, 0.18));
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 1200;
}

.admin-notif-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
}

.admin-notif-readall {
  border: 0;
  background: transparent;
  color: var(--primary-color);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}

.admin-notif-readall:hover {
  background: var(--primary-bg);
}

.admin-notif-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.admin-notif-item {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  text-decoration: none;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  transition: background 0.15s ease;
}

.admin-notif-item:last-child {
  border-bottom: none;
}

.admin-notif-item:hover {
  background: var(--admin-search-popover-hover, #eef1f6);
}

.admin-notif-item.is-new {
  background: rgba(34, 117, 252, 0.06);
}

.admin-notif-ic {
  width: 34px;
  height: 34px;
  min-width: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--nic, var(--primary-color));
  background: rgba(34, 117, 252, 0.12);
  background: color-mix(in srgb, var(--nic, #2275fc) 14%, transparent);
}

.admin-notif-ic .material-symbols-outlined {
  font-size: 18px;
}

.admin-notif-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.admin-notif-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
}

.admin-notif-sub {
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-notif-time {
  font-size: 11px;
  color: var(--text-muted);
}

.admin-notif-empty {
  padding: 22px 14px;
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-notif-foot {
  display: block;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-color);
  text-decoration: none;
  border-top: 1px solid var(--border-color);
}

.admin-notif-foot:hover {
  background: var(--primary-bg);
}

@media (max-width: 640px) {
  .admin-notif-panel {
    position: fixed;
    top: auto;
    right: 8px;
    left: 8px;
    width: auto;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-height: 70vh;
  }
}

/* ============================================================
 * V5.1 POLISH — коммерческая отделка (аддитивно, только визуал)
 * Кнопки/бейджи/таблицы/фокус. Размеры и отступы не трогаем.
 * ============================================================ */

/* --- Кнопки: единый мягкий подъём при наведении --- */
.btn {
  position: relative;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0) scale(0.98);
}
.btn:disabled,
.btn[disabled],
.btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* Тонкий верхний блик на «сплошных» цветных кнопках — премиальный вид */
.btn-primary,
.btn-success,
.btn-warning,
.btn-danger {
  border: 1px solid rgba(0, 0, 0, 0.06);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0));
}

/* Градиенты статусных кнопок в качество .btn-primary */
.btn-success {
  background-color: var(--success-color);
  background-image: linear-gradient(180deg, #56d477 0%, #2fb350 100%);
  box-shadow: 0 2px 8px rgba(52, 199, 89, 0.28);
}
.btn-success:hover {
  background-image: linear-gradient(180deg, #45cc69 0%, #27a244 100%);
  box-shadow: 0 4px 16px rgba(52, 199, 89, 0.34);
}
.btn-warning {
  background-color: var(--warning-color);
  background-image: linear-gradient(180deg, #ffab33 0%, #f08c00 100%);
  box-shadow: 0 2px 8px rgba(255, 149, 0, 0.28);
}
.btn-warning:hover {
  background-image: linear-gradient(180deg, #ff9f1a 0%, #e07f00 100%);
  box-shadow: 0 4px 16px rgba(255, 149, 0, 0.34);
}
.btn-danger {
  background-color: var(--danger-color);
  background-image: linear-gradient(180deg, #ff5b52 0%, #e5342a 100%);
  box-shadow: 0 2px 8px rgba(255, 59, 48, 0.28);
}
.btn-danger:hover {
  background-image: linear-gradient(180deg, #ff473d 0%, #d62a20 100%);
  box-shadow: 0 4px 16px rgba(255, 59, 48, 0.34);
}

/* Вторичные/контурные — чуть заметнее при наведении */
.btn-outline:hover,
.btn-light:hover,
.btn-secondary:hover {
  box-shadow: var(--shadow-md);
}

/* --- Бейджи: тонкая рамка для чёткости на стекле --- */
.badge {
  border: 1px solid rgba(0, 0, 0, 0.04);
}
.badge-primary {
  border-color: rgba(34, 117, 252, 0.22);
}
.badge-success {
  border-color: rgba(52, 199, 89, 0.28);
}
.badge-warning {
  border-color: rgba(255, 149, 0, 0.28);
}
.badge-danger {
  border-color: rgba(255, 59, 48, 0.28);
}

/* --- Таблицы: липкая шапка + мягкая зебра --- */
.admin-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  backdrop-filter: saturate(140%) blur(6px);
  -webkit-backdrop-filter: saturate(140%) blur(6px);
}
.admin-table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.014);
}
[data-theme="dark"] .admin-table tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}
.admin-table tbody tr {
  transition: background 0.14s ease;
}

/* --- Карточки: чуть глубже покой, плавный отклик --- */
.admin-card,
.card {
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

/* --- Фокус на инпутах кнопочного вида --- */
.form-control:hover:not(:focus) {
  border-color: var(--border-hover);
}