:root[data-theme='dark'] {
  --blue-100: #1f2858;
  --bg: #0f152f;
  --surface: #171f3f;
  --surface-soft: #1d264c;
  --text: #eef3ff;
  --muted: #a9b4d8;
  --border: #2b376d;
  --shadow: 0 18px 42px rgba(5, 10, 28, 0.38);
}

:root[data-theme='dark'] body {
  background: linear-gradient(180deg, #0e142b 0%, #121938 100%);
}

:root[data-theme='dark'] .panel,
:root[data-theme='dark'] select,
:root[data-theme='dark'] input[type='date'],
:root[data-theme='dark'] .button,
:root[data-theme='dark'] .stuck-item,
:root[data-theme='dark'] .empty,
:root[data-theme='dark'] .stat-box {
  color: var(--text);
}

:root[data-theme='dark'] .main,
:root[data-theme='dark'] .page-subtitle,
:root[data-theme='dark'] .panel__hint,
:root[data-theme='dark'] .control,
:root[data-theme='dark'] .topbar__user-meta span,
:root[data-theme='dark'] .admin-card__header p,
:root[data-theme='dark'] .admin-meta,
:root[data-theme='dark'] .admin-hint,
:root[data-theme='dark'] .auth-field,
:root[data-theme='dark'] .auth-card__text,
:root[data-theme='dark'] .brand--dark .brand__subtitle {
  color: var(--muted);
}

:root[data-theme='dark'] .attention-badge,
:root[data-theme='dark'] .attention-item {
  background: #241f34;
  border-color: #4a3557;
}

:root[data-theme='dark'] th,
:root[data-theme='dark'] td {
  border-bottom-color: var(--border);
}

:root[data-theme='dark'] .is-selected-row td {
  background: #233164;
}

:root[data-theme='dark'] .auth-shell {
  background: linear-gradient(180deg, rgba(13, 18, 40, 0.96), rgba(10, 15, 34, 0.98));
}

:root[data-theme='dark'] .auth-card,
:root[data-theme='dark'] .admin-card,
:root[data-theme='dark'] .topbar__user {
  background: #171f3f;
  border-color: rgba(103, 127, 240, 0.22);
  box-shadow: 0 24px 60px rgba(5, 10, 28, 0.42);
}

:root[data-theme='dark'] .auth-card__forms,
:root[data-theme='dark'] .admin-card {
  color: var(--text);
}

:root[data-theme='dark'] .auth-tabs,
:root[data-theme='dark'] .auth-tab,
:root[data-theme='dark'] .auth-field input,
:root[data-theme='dark'] .auth-field select,
:root[data-theme='dark'] .admin-field input,
:root[data-theme='dark'] .admin-field select,
:root[data-theme='dark'] .admin-grid input,
:root[data-theme='dark'] .admin-grid select,
:root[data-theme='dark'] #modelBaseUrl,
:root[data-theme='dark'] #modelApiKey,
:root[data-theme='dark'] #modelName,
:root[data-theme='dark'] #modelProvider {
  background: #202a54;
  border-color: #31407f;
  color: var(--text);
}

:root[data-theme='dark'] .auth-tab--active {
  background: #4156da;
  color: #fff;
  box-shadow: 0 10px 24px rgba(39, 67, 196, 0.26);
}

:root[data-theme='dark'] .topbar__user {
  background: rgba(23, 31, 63, 0.82);
}

:root[data-theme='dark'] .button:not(.button--primary),
:root[data-theme='dark'] .theme-toggle {
  background: #171f3f;
  border-color: #31407f;
  color: var(--text);
}

:root[data-theme='dark'] .button-link {
  background: rgba(255, 255, 255, 0.02);
  border-color: #31407f;
  color: var(--text);
}

:root[data-theme='dark'] .button-link--subtle {
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(103, 127, 240, 0.3);
  color: rgba(238, 243, 255, 0.82);
}

:root[data-theme='dark'] .button-link:hover {
  border-color: #586fdc;
  color: #dfe7ff;
}

:root[data-theme='dark'] .button-link--subtle:hover {
  background: rgba(103, 127, 240, 0.12);
}

:root[data-theme='dark'] .stuck-item__ai-note {
  background: rgba(103, 127, 240, 0.12);
  color: #c7d3ff;
}

:root[data-theme='dark'] .ai-verdict-badge--success {
  background: rgba(47, 191, 113, 0.14);
  border-color: rgba(47, 191, 113, 0.26);
  color: #7fe0a8;
}

:root[data-theme='dark'] .ai-verdict-badge--warning {
  background: rgba(226, 167, 47, 0.14);
  border-color: rgba(226, 167, 47, 0.26);
  color: #ffd880;
}

:root[data-theme='dark'] .ai-verdict-badge--danger {
  background: rgba(227, 77, 77, 0.14);
  border-color: rgba(227, 77, 77, 0.26);
  color: #ff9b9b;
}

:root[data-theme='dark'] .ai-verdict-badge--neutral {
  background: rgba(103, 127, 240, 0.12);
  border-color: rgba(103, 127, 240, 0.28);
  color: #c7d3ff;
}

:root[data-theme='dark'] .button:hover:not(.button--primary) {
  border-color: #586fdc;
}

:root[data-theme='dark'] .admin-backdrop {
  background: rgba(3, 6, 18, 0.66);
}

:root[data-theme='dark'] .manager-spotlight-card,
:root[data-theme='dark'] .sla-spotlight-card,
:root[data-theme='dark'] .attention-spotlight-card {
  background: linear-gradient(180deg, #202a54 0%, #1a244a 100%);
  border-color: #31407f;
  color: var(--text);
}

:root[data-theme='dark'] .funnel-stage-card {
  background: linear-gradient(180deg, #202a54 0%, #1a244a 100%);
  border-color: #31407f;
  color: var(--text);
}

:root[data-theme='dark'] .manager-spotlight-card__meta,
:root[data-theme='dark'] .funnel-stage-card__meta,
:root[data-theme='dark'] .sla-spotlight-card__label,
:root[data-theme='dark'] .sla-spotlight-card__meta,
:root[data-theme='dark'] .attention-spotlight-card__label,
:root[data-theme='dark'] .attention-spotlight-card__meta {
  color: var(--muted);
}

:root[data-theme='dark'] .discipline-card.is-active {
  background: linear-gradient(180deg, #202a54 0%, #1a244a 100%);
  border-color: #586fdc;
  color: var(--text);
}

:root[data-theme='dark'] .discipline-card.is-active .discipline-card__meta {
  color: var(--muted);
}

.theme-toggle {
  min-width: 148px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, transform 160ms ease;
}

.button-link:hover {
  border-color: var(--blue-600);
  color: var(--blue-600);
  transform: translateY(-1px);
}

.button-link--subtle {
  background: transparent;
  border-color: color-mix(in srgb, var(--border) 84%, transparent);
  color: color-mix(in srgb, var(--text) 88%, var(--muted));
}

.button-link--subtle:hover {
  background: color-mix(in srgb, var(--surface-soft) 68%, transparent);
}

/* ── Сайт ЛК — тёмная тема ── */
:root[data-theme='dark'] .kpi-card { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
:root[data-theme='dark'] .kpi-card__value { color: #f1f5f9; }
:root[data-theme='dark'] .kpi-card__label { color: rgba(255,255,255,0.5); }
:root[data-theme='dark'] .kpi-card--won .kpi-card__value { color: #4ade80; }
:root[data-theme='dark'] .kpi-card--lost .kpi-card__value { color: #f87171; }
:root[data-theme='dark'] .kpi-card--active .kpi-card__value { color: #60a5fa; }
:root[data-theme='dark'] .kpi-card--revenue .kpi-card__value { color: #a78bfa; }
:root[data-theme='dark'] .kpi-card--conv .kpi-card__value { color: #facc15; }
:root[data-theme='dark'] .timing-card { background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.08); }
:root[data-theme='dark'] .timing-card__value { color: #f1f5f9; }
:root[data-theme='dark'] .timing-card__label { color: rgba(255,255,255,0.5); }
:root[data-theme='dark'] .timing-card__norm { color: rgba(255,255,255,0.3); }
:root[data-theme='dark'] .data-table th { color: rgba(255,255,255,0.4); border-color: rgba(255,255,255,0.08); }
:root[data-theme='dark'] .data-table td { color: #e2e8f0; border-color: rgba(255,255,255,0.05); }
:root[data-theme='dark'] .data-table tr:hover td { background: rgba(255,255,255,0.03); }
:root[data-theme='dark'] .empty-state { color: rgba(255,255,255,0.3); }
:root[data-theme='dark'] .period-btn { border-color: rgba(255,255,255,0.12); color: rgba(255,255,255,0.4); }
:root[data-theme='dark'] .period-btn:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.7); }
:root[data-theme='dark'] .period-btn--active { background: rgba(99,102,241,0.2); border-color: rgba(99,102,241,0.5); color: #a5b4fc; }
:root[data-theme='dark'] .warn-text { color: #fbbf24 !important; }
