/* FLEX — neon cyan on dark navy (default brand theme) */
[data-theme="flex"],
html:not([data-theme]) {
  --bg-primary: #0a0e14;
  --bg-secondary: #0f141c;
  --bg-tertiary: #151b26;
  --bg-hover: #1a2230;
  --border-color: rgba(0, 229, 255, 0.08);
  --border-light: rgba(0, 229, 255, 0.16);
  --text-primary: #e8f4ff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #00e5ff;
  --accent-secondary: #a0ffff;
  --accent-glow: rgba(0, 229, 255, 0.35);
  --danger: #00bcd4;
  --btn-text: #0a0e14;
  --flex-logo-url: url('../assets/flex-logo.svg');
}

[data-theme="flex"] .main-content::after,
html:not([data-theme]) .main-content::after {
  background: var(--flex-logo-url) no-repeat center / contain;
  opacity: 0.035;
  filter: none;
}

/* ── Vector logo + glitch (без PNG-квадрата) ── */
.flex-logo-host {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.flex-logo-host--lg {
  width: 88px;
  height: 88px;
  margin-bottom: 6px;
  animation: flexLogoFloat 8s ease-in-out infinite;
}

.flex-logo-host--sm {
  width: 40px;
  height: 40px;
}

.flex-logo-host--xs {
  width: 36px;
  height: 36px;
}

/* Точечное свечение — только вокруг иконки, не квадратом */
.flex-logo-host::before {
  content: '';
  position: absolute;
  width: 70%;
  height: 70%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    rgba(0, 229, 255, 0.35) 0%,
    rgba(0, 229, 255, 0.08) 45%,
    transparent 72%
  );
  animation: flexLogoGlow 4.2s ease-in-out infinite;
  pointer-events: none;
}

.flex-logo-mark,
.flex-logo-host img,
.flex-logo-host .login-logo-image,
.flex-logo-host .logo-image,
.flex-logo-host .topbar-logo {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: transparent !important;
  mix-blend-mode: normal;
  filter: drop-shadow(0 0 4px rgba(0, 229, 255, 0.65))
    drop-shadow(0 0 14px rgba(0, 229, 255, 0.28));
  animation: flexLogoGlitchMain 6s ease-in-out infinite;
  will-change: transform, opacity;
}

/* Ghost cyan */
.flex-logo-host::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--flex-logo-url) center / contain no-repeat;
  opacity: 0;
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.8));
  animation: flexLogoGhostCyan 6s steps(1) infinite;
}

.flex-logo-host--lg .flex-logo-split {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--flex-logo-url) center / contain no-repeat;
  opacity: 0;
  pointer-events: none;
  filter: hue-rotate(155deg) brightness(1.25);
  animation: flexLogoGhostMagenta 6s steps(1) infinite;
}

.flex-logo-host--lg .flex-logo-scanlines {
  position: absolute;
  inset: 5%;
  z-index: 4;
  pointer-events: none;
  opacity: 0;
  border-radius: 50%;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 229, 255, 0.04) 2px,
    rgba(0, 229, 255, 0.04) 4px
  );
  animation: flexScanFlicker 6s steps(1) infinite;
}

/* Login title — часть бренда, не отдельная картинка */
.login-header h1,
.logo-text {
  text-shadow:
    0 0 12px rgba(0, 229, 255, 0.45),
    0 0 28px rgba(0, 229, 255, 0.15);
  letter-spacing: 0.28em;
}

@keyframes flexLogoGlow {
  0%, 100% { opacity: 0.55; transform: scale(0.96); }
  50% { opacity: 1; transform: scale(1.05); }
}

@keyframes flexLogoGlitchMain {
  0%, 86%, 100% {
    transform: translate(0, 0);
    opacity: 1;
    clip-path: inset(0 0 0 0);
  }
  87% {
    transform: translate(-2px, 1px);
    opacity: 0.5;
    clip-path: inset(10% 0 52% 0);
  }
  88% {
    transform: translate(3px, -1px);
    opacity: 0.72;
    clip-path: inset(42% 0 18% 0);
  }
  89% {
    transform: translate(-1px, 2px);
    opacity: 0.38;
  }
  90% {
    transform: translate(2px, 0);
    opacity: 0.82;
    clip-path: inset(58% 0 0 0);
  }
  91% { transform: translate(0, 0); opacity: 1; }
  94%, 95% {
    transform: translate(1px, -1px);
    opacity: 0.9;
  }
}

@keyframes flexLogoGhostCyan {
  0%, 85%, 100% { opacity: 0; transform: translate(0, 0); }
  86% { opacity: 0.5; transform: translate(4px, -2px); }
  87% { opacity: 0; transform: translate(-3px, 2px); }
  88% { opacity: 0.42; transform: translate(-4px, -1px); }
  90% { opacity: 0.32; transform: translate(2px, 1px); }
  91% { opacity: 0; }
}

@keyframes flexLogoGhostMagenta {
  0%, 85%, 100% { opacity: 0; transform: translate(0, 0); }
  86% { opacity: 0.38; transform: translate(-4px, 2px); }
  88% { opacity: 0.45; transform: translate(4px, 1px); }
  90% { opacity: 0.28; transform: translate(-2px, -1px); }
  91% { opacity: 0; }
}

@keyframes flexLogoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes flexScanFlicker {
  0%, 84%, 100% { opacity: 0; }
  85%, 86% { opacity: 0.55; }
  88%, 89% { opacity: 0.4; }
  90% { opacity: 0; }
}

/* Light content cards */
/* Light content cards — переопределяем переменные текста внутри карточек */
[data-theme="flex"] .stat-card,
[data-theme="flex"] .device-card,
[data-theme="flex"] .settings-card,
[data-theme="flex"] .detail-section,
[data-theme="flex"] .table-container,
[data-theme="flex"] .tabs-container,
[data-theme="flex"] .empty-activity,
[data-theme="flex"] .empty-state-card,
html:not([data-theme]) .stat-card,
html:not([data-theme]) .device-card,
html:not([data-theme]) .settings-card,
html:not([data-theme]) .detail-section,
html:not([data-theme]) .table-container,
html:not([data-theme]) .tabs-container,
html:not([data-theme]) .empty-activity,
html:not([data-theme]) .empty-state-card {
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --border-light: #cbd5e1;
  --bg-tertiary: #e8eef5;
  --bg-secondary: #ffffff;
  --bg-hover: #e2e8f0;
}

[data-theme="flex"] .stat-card,
[data-theme="flex"] .device-card,
[data-theme="flex"] .settings-card,
[data-theme="flex"] .detail-section,
[data-theme="flex"] .table-container,
[data-theme="flex"] .tabs-container,
[data-theme="flex"] .empty-activity,
[data-theme="flex"] .empty-state-card,
html:not([data-theme]) .stat-card,
html:not([data-theme]) .device-card,
html:not([data-theme]) .settings-card,
html:not([data-theme]) .detail-section,
html:not([data-theme]) .table-container,
html:not([data-theme]) .tabs-container,
html:not([data-theme]) .empty-activity,
html:not([data-theme]) .empty-state-card {
  background: #f4f7fb;
  color: #0f172a;
  border-color: #e2e8f0;
}

[data-theme="flex"] .detail-section .detail-sms-form input,
[data-theme="flex"] .detail-section .detail-sms-form textarea,
[data-theme="flex"] .detail-section .detail-sms-form select,
html:not([data-theme]) .detail-section .detail-sms-form input,
html:not([data-theme]) .detail-section .detail-sms-form textarea,
html:not([data-theme]) .detail-section .detail-sms-form select {
  background: #ffffff;
  border-color: #cbd5e1;
  color: #0f172a;
}

[data-theme="flex"] .detail-section .detail-sms-form input::placeholder,
[data-theme="flex"] .detail-section .detail-sms-form textarea::placeholder,
html:not([data-theme]) .detail-section .detail-sms-form input::placeholder,
html:not([data-theme]) .detail-section .detail-sms-form textarea::placeholder {
  color: #94a3b8;
}

[data-theme="flex"] .detail-section label,
html:not([data-theme]) .detail-section label {
  color: #475569;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

[data-theme="flex"] .stat-value,
[data-theme="flex"] .stat-label,
[data-theme="flex"] .device-card-header .device-id,
[data-theme="flex"] .device-info-item .info-value,
[data-theme="flex"] .settings-card-header h3,
html:not([data-theme]) .stat-value,
html:not([data-theme]) .stat-label,
html:not([data-theme]) .device-card-header .device-id,
html:not([data-theme]) .device-info-item .info-value,
html:not([data-theme]) .settings-card-header h3 {
  color: #0f172a;
}

[data-theme="flex"] .device-info-item .info-label,
[data-theme="flex"] .settings-card-desc,
html:not([data-theme]) .device-info-item .info-label,
html:not([data-theme]) .settings-card-desc {
  color: #475569;
}

[data-theme="flex"] .data-table th,
html:not([data-theme]) .data-table th {
  background: #e8eef5;
  color: #334155;
}

[data-theme="flex"] .login-card,
html:not([data-theme]) .login-card {
  background: #0f141c;
  border-color: rgba(0, 229, 255, 0.12);
  box-shadow: 0 0 48px rgba(0, 229, 255, 0.04), 0 24px 48px rgba(0, 0, 0, 0.45);
}

[data-theme="flex"] .nav-item.active,
html:not([data-theme]) .nav-item.active {
  color: #0a0e14;
}

[data-theme="flex"] .logo-fallback,
html:not([data-theme]) .logo-fallback {
  background: linear-gradient(135deg, #00e5ff, #0066aa) !important;
  color: #0a0e14 !important;
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

@media (prefers-reduced-motion: reduce) {
  .flex-logo-host::before,
  .flex-logo-host::after,
  .flex-logo-mark,
  .flex-logo-host img,
  .flex-logo-split,
  .flex-logo-scanlines,
  .flex-logo-host--lg {
    animation: none !important;
  }
}
