/* ── Theme: Light ── */
html[data-theme="light"] {
  --bg: #eef1f6;
  --bg-2: #e2e7ef;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --surface2: #f3f5f9;
  --surface-hover: #e8ecf3;
  --border: rgba(15, 23, 42, 0.1);
  --border-light: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-2: #1d4ed8;
  --accent-bright: #3b82f6;
  --accent-glow: rgba(37, 99, 235, 0.18);
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.12);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.1);
  --purple: #7c3aed;
  --shadow: 0 8px 32px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 12px rgba(15, 23, 42, 0.06);
  --input-bg: #ffffff;
}

html[data-theme="light"] .panel-body {
  background:
    radial-gradient(ellipse 80% 60% at 10% -10%, rgba(37, 99, 235, 0.08), transparent 50%),
    radial-gradient(ellipse 60% 50% at 90% 100%, rgba(124, 58, 237, 0.06), transparent 50%),
    var(--bg);
}

html[data-theme="light"] .login-page {
  background:
    radial-gradient(ellipse 70% 50% at 50% -20%, rgba(37, 99, 235, 0.12), transparent 60%),
    var(--bg);
}

html[data-theme="light"] .sidebar {
  background: var(--surface-solid);
  border-right-color: var(--border);
}

html[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.85);
  border-bottom-color: var(--border);
}

html[data-theme="light"] .user-avatar {
  color: #fff;
}

/* ── Theme: Matrix (NITRO) ── */
html[data-theme="matrix"] {
  --bg: #000000;
  --bg-2: #000000;
  --surface: #000000;
  --surface-solid: #000000;
  --surface2: #030803;
  --surface-hover: #071207;
  --border: rgba(0, 255, 65, 0.28);
  --border-light: rgba(0, 255, 65, 0.65);
  --text: #00ff41;
  --text-muted: #008f24;
  --accent: #00ff41;
  --accent-2: #00cc33;
  --accent-bright: #39ff14;
  --accent-glow: rgba(0, 255, 65, 0.35);
  --green: #00ff41;
  --green-dim: rgba(0, 255, 65, 0.08);
  --red: #ff2222;
  --red-dim: rgba(255, 34, 34, 0.12);
  --purple: #00ff41;
  --orange: #00ff41;
  --cyan: #00ff41;
  --radius: 0;
  --radius-sm: 0;
  --shadow: 0 0 18px rgba(0, 255, 65, 0.14);
  --shadow-sm: 0 0 10px rgba(0, 255, 65, 0.1);
  --input-bg: #030803;
}

html[data-theme="matrix"] body,
html[data-theme="matrix"] .panel-body {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  background: transparent !important;
  color: var(--text);
}

/* Matrix rain — на весь экран, под всем UI */
html[data-theme="matrix"] .matrix-bg {
  display: block !important;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  background: #000;
  pointer-events: none;
}

html[data-theme="matrix"] .panel-layout,
html[data-theme="matrix"] .login-page,
html[data-theme="matrix"] .theme-switcher-login {
  position: relative;
  z-index: 1;
}

html[data-theme="matrix"] .panel-layout,
html[data-theme="matrix"] .main-wrap,
html[data-theme="matrix"] .panel-content,
html[data-theme="matrix"] .page,
html[data-theme="matrix"] .page.active,
html[data-theme="matrix"] .page-workspace,
html[data-theme="matrix"] .workspace-panel,
html[data-theme="matrix"] .workspace-top {
  background: transparent !important;
}

html[data-theme="matrix"] .sidebar {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-right: 1px solid var(--border-light);
  box-shadow: none;
}

html[data-theme="matrix"] .topbar {
  background: rgba(0, 0, 0, 0.58);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-bottom: 1px solid var(--border-light);
}

html[data-theme="matrix"] .user-chip {
  background: rgba(0, 0, 0, 0.55);
}

html[data-theme="matrix"] .sidebar-brand {
  border-bottom-color: var(--border);
}

html[data-theme="matrix"] .brand-name {
  color: #00ff41;
  text-shadow: 0 0 12px rgba(0, 255, 65, 0.45);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.82rem;
}

html[data-theme="matrix"] .brand-ver {
  color: #008f24;
  opacity: 1;
  letter-spacing: 0.14em;
}

html[data-theme="matrix"] .brand-icon img {
  border-radius: 0;
  filter: hue-rotate(85deg) saturate(2) brightness(1.1);
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.3);
}

html[data-theme="matrix"] .nav-group {
  color: #008f24;
  opacity: 1;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 0.62rem;
}

html[data-theme="matrix"] .nav-group::before {
  content: '# ';
}

html[data-theme="matrix"] .sidebar-link {
  border-radius: 0;
  color: #008f24;
  border-left: 2px solid transparent;
}

html[data-theme="matrix"] .sidebar-link:hover {
  background: rgba(0, 255, 65, 0.06);
  color: #00ff41;
  border-left-color: rgba(0, 255, 65, 0.35);
}

html[data-theme="matrix"] .sidebar-link.active {
  background: rgba(0, 255, 65, 0.1);
  color: #00ff41;
  border-left: 2px solid #00ff41;
  box-shadow: inset 0 0 20px rgba(0, 255, 65, 0.08);
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.35);
}

html[data-theme="matrix"] .sidebar-link.active svg {
  stroke: #00ff41;
  filter: drop-shadow(0 0 4px rgba(0, 255, 65, 0.5));
}

html[data-theme="matrix"] .topbar {
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 0 rgba(0, 255, 65, 0.06);
}

html[data-theme="matrix"] .topbar-search {
  background: #000;
  border: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.08);
}

html[data-theme="matrix"] .topbar-search:focus-within {
  border-color: #00ff41;
  box-shadow: 0 0 16px rgba(0, 255, 65, 0.22);
}

html[data-theme="matrix"] .toolbar-search {
  color: #00ff41;
}

html[data-theme="matrix"] .toolbar-search::placeholder {
  color: #006b1a;
}

html[data-theme="matrix"] .topbar-search svg {
  stroke: #008f24;
}

html[data-theme="matrix"] .user-chip {
  background: #000;
  border: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: 0 0 10px rgba(0, 255, 65, 0.1);
}

html[data-theme="matrix"] .user-avatar {
  background: #000;
  border: 1px solid #00ff41;
  border-radius: 0;
  color: #00ff41;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.25);
}

html[data-theme="matrix"] .header-user {
  color: #00ff41;
  text-shadow: 0 0 6px rgba(0, 255, 65, 0.3);
}

html[data-theme="matrix"] .btn-icon {
  background: #000;
  border: 1px solid var(--border-light);
  border-radius: 0;
  color: #008f24;
}

html[data-theme="matrix"] .btn-icon:hover {
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}

html[data-theme="matrix"] .panel-content {
  background: transparent;
}

html[data-theme="matrix"] .page-head {
  position: relative;
  z-index: 1;
}

html[data-theme="matrix"] .card,
html[data-theme="matrix"] .stat-card,
html[data-theme="matrix"] .home-profile,
html[data-theme="matrix"] .platform-section,
html[data-theme="matrix"] .table-wrap,
html[data-theme="matrix"] .settings-block {
  background: rgba(0, 0, 0, 0.72) !important;
  background-image: none !important;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow:
    0 0 0 1px rgba(0, 255, 65, 0.06),
    0 0 20px rgba(0, 0, 0, 0.9);
}

html[data-theme="matrix"] .home-profile {
  border-color: var(--border-light) !important;
}

html[data-theme="matrix"] .panel-body .input-dark,
html[data-theme="matrix"] .panel-body input[type="text"],
html[data-theme="matrix"] .panel-body input[type="password"],
html[data-theme="matrix"] .panel-body input[type="number"],
html[data-theme="matrix"] .panel-body input[type="email"],
html[data-theme="matrix"] .panel-body textarea,
html[data-theme="matrix"] .panel-body select {
  background: #020402 !important;
  color: #00ff41 !important;
  border: 1px solid rgba(0, 255, 65, 0.45) !important;
  border-radius: 0;
}

html[data-theme="matrix"] .panel-body input::placeholder,
html[data-theme="matrix"] .panel-body textarea::placeholder {
  color: #006b1a !important;
}

html[data-theme="matrix"] .page h1 {
  color: #00ff41;
  text-shadow: 0 0 20px rgba(0, 255, 65, 0.35);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 1.35rem;
}

html[data-theme="matrix"] .page h1::before {
  content: '> ';
  color: #008f24;
}

html[data-theme="matrix"] .page .subtitle {
  color: #008f24;
}

html[data-theme="matrix"] .page .subtitle::before {
  content: '# ';
}

html[data-theme="matrix"] .card:hover,
html[data-theme="matrix"] .stat-card:hover {
  transform: none;
  box-shadow:
    0 0 0 1px rgba(0, 255, 65, 0.2),
    0 0 28px rgba(0, 255, 65, 0.16);
}

html[data-theme="matrix"] .home-label,
html[data-theme="matrix"] .block-title,
html[data-theme="matrix"] .platform-section-title {
  color: #008f24;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

html[data-theme="matrix"] .home-label::before,
html[data-theme="matrix"] .block-title::before {
  content: '# ';
}

html[data-theme="matrix"] .home-value,
html[data-theme="matrix"] .home-balance {
  color: #00ff41;
  text-shadow: 0 0 10px rgba(0, 255, 65, 0.35);
}

html[data-theme="matrix"] .platform-section-title {
  color: #00ff41;
  text-shadow: 0 0 8px rgba(0, 255, 65, 0.25);
}

html[data-theme="matrix"] .platform-section-title::before {
  background: #00ff41 !important;
  box-shadow: 0 0 8px rgba(0, 255, 65, 0.5);
}

html[data-theme="matrix"] .tool-btn {
  background: #000;
  border: 1px solid rgba(0, 255, 65, 0.45);
  border-radius: 0;
  color: #008f24;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

html[data-theme="matrix"] .tool-btn:hover {
  background: rgba(0, 255, 65, 0.08);
  border-color: #00ff41;
  color: #00ff41;
  box-shadow: 0 0 14px rgba(0, 255, 65, 0.18);
}

html[data-theme="matrix"] .platform-disabled .tool-btn {
  opacity: 0.35;
  border-color: rgba(0, 255, 65, 0.15);
}

html[data-theme="matrix"] .platform-maintenance,
html[data-theme="matrix"] .sidebar-maintenance-badge {
  color: #ff2222;
  background: rgba(255, 34, 34, 0.08);
  border-color: rgba(255, 34, 34, 0.45);
  border-radius: 0;
  text-transform: uppercase;
  font-size: 0.62rem;
}

html[data-theme="matrix"] .btn-accent {
  background: transparent;
  border: 1px solid #00ff41;
  color: #00ff41;
  border-radius: 0;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  box-shadow: 0 0 14px rgba(0, 255, 65, 0.2);
}

html[data-theme="matrix"] .btn-accent::before {
  content: '> ';
}

html[data-theme="matrix"] .btn-accent:hover {
  background: rgba(0, 255, 65, 0.1);
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.35);
}

html[data-theme="matrix"] .btn-secondary {
  background: #000;
  border: 1px solid rgba(0, 255, 65, 0.4);
  color: #008f24;
  border-radius: 0;
}

html[data-theme="matrix"] .btn-secondary:hover {
  border-color: #00ff41;
  color: #00ff41;
}

html[data-theme="matrix"] .input-dark,
html[data-theme="matrix"] textarea.input-dark,
html[data-theme="matrix"] select.input-dark {
  background: #000;
  color: #00ff41;
  border: 1px solid rgba(0, 255, 65, 0.45);
  border-radius: 0;
}

html[data-theme="matrix"] .input-dark::placeholder {
  color: #006b1a;
}

html[data-theme="matrix"] .modal-box,
html[data-theme="matrix"] .workspace-panel,
html[data-theme="matrix"] .settings-panel,
html[data-theme="matrix"] .global-search-results,
html[data-theme="matrix"] .theme-switcher-menu {
  background: #000;
  backdrop-filter: none;
  border: 1px solid var(--border-light);
  border-radius: 0;
  box-shadow: 0 0 30px rgba(0, 255, 65, 0.15);
}

html[data-theme="matrix"] table th {
  color: #008f24;
  border-color: var(--border);
  text-transform: uppercase;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
}

html[data-theme="matrix"] table td {
  border-color: rgba(0, 255, 65, 0.12);
  color: #00cc33;
}

html[data-theme="matrix"] .tg-sub-timer {
  color: #00ff41;
  border: 1px solid rgba(0, 255, 65, 0.35);
  background: #000;
  border-radius: 0;
}

html[data-theme="matrix"] .toast {
  background: #000;
  border: 1px solid var(--border-light);
  color: #00ff41;
  border-radius: 0;
  box-shadow: 0 0 20px rgba(0, 255, 65, 0.2);
}

/* Matrix login (NITRO style) */
html[data-theme="matrix"] .login-page {
  background: transparent;
}

html[data-theme="matrix"] .login-card {
  background: rgba(0, 0, 0, 0.96);
  backdrop-filter: none;
  border: 1px solid #00ff41;
  border-radius: 0;
  box-shadow:
    0 0 0 1px rgba(0, 255, 65, 0.15),
    0 0 40px rgba(0, 255, 65, 0.2),
    inset 0 0 60px rgba(0, 255, 65, 0.03);
  font-family: 'JetBrains Mono', monospace;
  position: relative;
  z-index: 2;
}

html[data-theme="matrix"] .login-card::before {
  display: none;
}

html[data-theme="matrix"] .login-card::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 255, 65, 0.015) 2px,
    rgba(0, 255, 65, 0.015) 4px
  );
}

html[data-theme="matrix"] .login-logo-icon {
  filter: hue-rotate(85deg) saturate(2.5) brightness(1.2);
  border-radius: 0;
}

html[data-theme="matrix"] .login-logo-name,
html[data-theme="matrix"] .login-card h1 {
  color: #00ff41;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 0 0 16px rgba(0, 255, 65, 0.4);
}

html[data-theme="matrix"] .login-card h1 {
  font-size: 1.1rem;
}

html[data-theme="matrix"] .login-card h1::before {
  content: '> ';
}

/* Login: matrix vs default branding */
.login-brand-matrix,
.login-title-matrix,
.login-sub-matrix,
.btn-login-matrix,
.login-field-label,
.login-hint {
  display: none;
}

html[data-theme="matrix"] .login-brand-default,
html[data-theme="matrix"] .login-title-default,
html[data-theme="matrix"] .login-sub-default,
html[data-theme="matrix"] .btn-login-default {
  display: none;
}

html[data-theme="matrix"] .login-brand-matrix,
html[data-theme="matrix"] .login-title-matrix,
html[data-theme="matrix"] .login-sub-matrix,
html[data-theme="matrix"] .btn-login-matrix,
html[data-theme="matrix"] .login-field-label,
html[data-theme="matrix"] .login-hint {
  display: block;
}

html[data-theme="matrix"] .btn-login-matrix {
  display: inline;
}

html[data-theme="matrix"] .login-field-label {
  color: #00ff41;
  font-size: 0.72rem;
  margin: 12px 0 4px;
  text-transform: lowercase;
}

html[data-theme="matrix"] .login-sub-matrix::before {
  content: '> ';
}

html[data-theme="matrix"] .login-hint::before {
  content: '> ';
}

html[data-theme="matrix"] .login-hint {
  color: #00b32d;
  font-size: 0.72rem;
  margin-top: 16px;
  font-family: 'JetBrains Mono', monospace;
}

html[data-theme="matrix"] .btn-login::after {
  content: '_';
  animation: matrix-cursor 1s step-end infinite;
}

html[data-theme="matrix"] .login-logo-name,
html[data-theme="matrix"] .login-title-matrix {
  color: #00ff41;
  font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

html[data-theme="matrix"] .login-logo-text .login-logo-ver,
html[data-theme="matrix"] .login-logo-text .login-brand-matrix + .login-brand-matrix,
html[data-theme="matrix"] .login-logo-ver.login-brand-matrix {
  color: #00b32d;
}

html[data-theme="matrix"] #loginForm input {
  background: #e8f5e9;
  color: #000;
  border: 1px solid #bbb;
  border-radius: 0;
  font-family: 'JetBrains Mono', monospace;
}

html[data-theme="matrix"] #loginForm input::placeholder {
  color: #666;
}

html[data-theme="matrix"] .btn-login {
  background: transparent;
  border: 1px solid #00ff41;
  color: #00ff41;
  border-radius: 0;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

html[data-theme="matrix"] .btn-login::before {
  content: '> ';
}

html[data-theme="matrix"] .login-error {
  background: rgba(255, 0, 0, 0.15);
  border: 1px solid #ff3333;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

html[data-theme="matrix"] .login-error::before {
  content: '[ERROR] ';
  color: #ff3333;
}

@keyframes matrix-cursor {
  50% { opacity: 0; }
}

/* Matrix rain canvas */
.matrix-bg {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* ── Theme switcher UI ── */
.theme-switcher {
  position: relative;
}

.theme-switcher-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-switcher-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  padding: 6px;
  background: var(--surface-solid);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 200;
}

.theme-switcher-menu[hidden] {
  display: none;
}

.theme-switcher-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}

.theme-switcher-item:hover {
  background: var(--surface-hover);
}

.theme-switcher-item.is-active {
  background: rgba(74, 158, 255, 0.12);
  color: var(--accent);
}

html[data-theme="matrix"] .theme-switcher-item.is-active {
  background: rgba(0, 255, 65, 0.12);
}

.theme-switcher-icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  font-size: 0.95rem;
}

.theme-switcher-login {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
}

.theme-switcher-login .theme-switcher-menu {
  right: 0;
}
