.theme-icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-icon-moon {
  display: block;
}

html[data-theme="light"] .theme-icon-sun,
html:not([data-theme]) .theme-icon-sun {
  display: block;
}

html[data-theme="light"] .theme-icon-moon,
html:not([data-theme]) .theme-icon-moon {
  display: none;
}

html,
body {
  background: var(--color-surface);
  color: var(--color-text);
  transition: background-color 0.2s ease, color 0.2s ease;
}

.main-content,
.page-body {
  background: var(--color-surface);
}

.card,
.login-card {
  background: var(--color-card-bg);
}

.form-input,
.form-select,
.form-textarea {
  background: var(--color-input-bg);
  color: var(--color-text);
  border-color: var(--color-border);
}

.data-table th {
  background: var(--color-surface);
}

.data-table tr:hover td {
  background: var(--color-hover);
}

/* ── Telegram night dark mode ── */

html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .app-layout,
html[data-theme="dark"] .main-content,
html[data-theme="dark"] .page-body {
  background: var(--color-bg);
  color: var(--color-text-primary);
}

html[data-theme="dark"] .sidebar {
  background: var(--color-sidebar-bg);
  border-left-color: rgba(255, 255, 255, 0.05);
  box-shadow: none;
}

html[data-theme="dark"] .sidebar-brand,
html[data-theme="dark"] .sidebar-footer {
  border-color: rgba(255, 255, 255, 0.05);
  background: var(--color-sidebar-bg);
}

html[data-theme="dark"] .sidebar-brand-text h1 {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .sidebar-nav-link {
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .sidebar-nav-link:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--color-text-primary);
}

html[data-theme="dark"] .sidebar-nav-link.active,
html[data-theme="dark"] .sidebar-nav a.active {
  background: rgba(42, 171, 238, 0.16);
  color: #6AB3F3;
  box-shadow: inset 3px 0 0 #2AABEE;
}

html[data-theme="dark"] .sidebar-nav-link.active .nav-icon {
  color: #6AB3F3;
}

html[data-theme="dark"] .sidebar-child-link {
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .sidebar-child-link:hover,
html[data-theme="dark"] .sidebar-child-link.active {
  color: #6AB3F3;
  background: rgba(42, 171, 238, 0.1);
}

html[data-theme="dark"] .sidebar-child-group {
  color: var(--color-text-muted);
}

html[data-theme="dark"] .sidebar-children {
  border-right-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .sidebar-user-card {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .sidebar-user-avatar {
  background: rgba(42, 171, 238, 0.2);
  color: #6AB3F3;
}

html[data-theme="dark"] .sidebar-user-meta .user-name {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .sidebar-logout {
  color: var(--color-text-tertiary);
  border-color: rgba(255, 255, 255, 0.08);
  background: transparent;
}

html[data-theme="dark"] .sidebar-logout:hover {
  color: #EF5350;
  border-color: rgba(229, 57, 53, 0.35);
  background: rgba(229, 57, 53, 0.1);
}

html[data-theme="dark"] .page-header-unified h2 {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .page-header-unified .page-subtitle {
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .admin-header {
  background: var(--color-header-bg);
  border-bottom-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .admin-header-date {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .admin-header-user {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--color-text-primary);
}

html[data-theme="dark"] .admin-header-user:hover,
html[data-theme="dark"] .admin-header-user-menu:hover .admin-header-user,
html[data-theme="dark"] .admin-header-user-menu:focus-within .admin-header-user {
  background: rgba(42, 171, 238, 0.12);
  border-color: rgba(42, 171, 238, 0.35);
  color: #6AB3F3;
}

html[data-theme="dark"] .admin-header-user-dropdown {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

html[data-theme="dark"] .admin-header-logout:hover {
  background: rgba(229, 57, 53, 0.12);
}

html[data-theme="dark"] .theme-toggle,
html[data-theme="dark"] .mobile-menu-btn {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--color-text-secondary);
}

html[data-theme="dark"] .theme-toggle:hover,
html[data-theme="dark"] .mobile-menu-btn:hover {
  background: rgba(42, 171, 238, 0.12);
  border-color: rgba(42, 171, 238, 0.35);
  color: #6AB3F3;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .kpi-card-modern,
html[data-theme="dark"] .bi-kpi-card,
html[data-theme="dark"] .dash-panel,
html[data-theme="dark"] .insight-card-modern {
  background: var(--color-card-bg);
  border-color: rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

html[data-theme="dark"] .chart-card-header,
html[data-theme="dark"] .dash-panel__header {
  background: #1C2733;
  border-bottom-color: rgba(255, 255, 255, 0.05);
  color: var(--color-text-primary);
}

html[data-theme="dark"] .dash-panel__title {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .dash-panel__hint,
html[data-theme="dark"] .dash-empty,
html[data-theme="dark"] .kpi-label,
html[data-theme="dark"] .kpi-subtext {
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .kpi-value,
html[data-theme="dark"] .dash-action-card__label,
html[data-theme="dark"] .dash-action-count {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .dash-period-range {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.06);
  color: var(--color-text-secondary);
}

html[data-theme="dark"] .dash-period-range__label {
  color: var(--color-text-primary);
}

html[data-theme="dark"] .dash-period-range__dates {
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .dash-period-tab {
  background: var(--color-surface-elevated);
  border-color: rgba(255, 255, 255, 0.08);
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .dash-period-tab:hover {
  border-color: rgba(42, 171, 238, 0.4);
  color: #6AB3F3;
  background: rgba(42, 171, 238, 0.08);
}

html[data-theme="dark"] .dash-period-tab.is-active {
  background: #2AABEE;
  border-color: #2AABEE;
  color: #FFFFFF;
  box-shadow: 0 2px 10px rgba(42, 171, 238, 0.28);
}

html[data-theme="dark"] .dash-action-card {
  background: #1C2733;
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .dash-action-card:hover {
  border-color: rgba(42, 171, 238, 0.4);
  background: rgba(42, 171, 238, 0.08);
  box-shadow: none;
}

html[data-theme="dark"] .dash-action-card.urgency-high {
  border-color: rgba(229, 57, 53, 0.35);
  background: rgba(229, 57, 53, 0.08);
}

html[data-theme="dark"] .dash-action-card.urgency-medium {
  border-color: rgba(240, 160, 32, 0.35);
  background: rgba(240, 160, 32, 0.08);
}

html[data-theme="dark"] .dash-tier-legend__item {
  background: #1C2733;
  border-color: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .dash-tier-legend__item:hover {
  background: rgba(42, 171, 238, 0.1);
  border-color: rgba(42, 171, 238, 0.28);
}

html[data-theme="dark"] .dash-tier-bar__track {
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .bi-insight-hero,
html[data-theme="dark"] .bi-insight-hero-info {
  background: rgba(42, 171, 238, 0.08);
  border-color: rgba(42, 171, 238, 0.28);
}

html[data-theme="dark"] .bi-insight-hero-warning {
  background: rgba(240, 160, 32, 0.08);
  border-color: rgba(240, 160, 32, 0.3);
}

html[data-theme="dark"] .bi-insight-hero-critical {
  background: rgba(229, 57, 53, 0.08);
  border-color: rgba(229, 57, 53, 0.3);
}

html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .form-textarea {
  background: var(--color-input-bg);
  color: var(--color-text-primary);
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .form-input:focus,
html[data-theme="dark"] .form-select:focus,
html[data-theme="dark"] .form-textarea:focus {
  border-color: #2AABEE;
  box-shadow: 0 0 0 4px rgba(42, 171, 238, 0.2);
  background: #242F3D;
}

html[data-theme="dark"] .form-input::placeholder {
  color: var(--color-text-muted);
}

html[data-theme="dark"] .data-table th {
  background: #1C2733;
  color: var(--color-text-tertiary);
  border-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .data-table td {
  border-color: rgba(255, 255, 255, 0.04);
  color: var(--color-text-secondary);
}

html[data-theme="dark"] .data-table tr:hover td {
  background: rgba(255, 255, 255, 0.03);
}

html[data-theme="dark"] .btn-primary {
  background: #2AABEE;
  border-color: #2AABEE;
  color: #fff;
}

html[data-theme="dark"] .btn-primary:hover {
  background: #229ED9;
  border-color: #229ED9;
}

html[data-theme="dark"] .btn-secondary {
  background: transparent;
  border-color: rgba(42, 171, 238, 0.45);
  color: #6AB3F3;
}

html[data-theme="dark"] .btn-secondary:hover {
  background: rgba(42, 171, 238, 0.12);
  border-color: #2AABEE;
  color: #8FC7F7;
}

html[data-theme="dark"] .login-page {
  background: var(--color-bg);
}

html[data-theme="dark"] .login-card {
  background: var(--color-card-bg);
  border-color: var(--color-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .login-card__product {
  color: var(--color-text-tertiary);
}

html[data-theme="dark"] .badge-vip { background: rgba(240, 160, 32, 0.18); color: #FFD180; }
html[data-theme="dark"] .badge-gold { background: rgba(240, 160, 32, 0.16); color: #FFE082; }
html[data-theme="dark"] .badge-silver { background: rgba(255, 255, 255, 0.08); color: #CFD8DC; }
html[data-theme="dark"] .badge-bronze { background: rgba(191, 110, 58, 0.2); color: #FFCC80; }
html[data-theme="dark"] .badge-newcomer { background: rgba(42, 171, 238, 0.18); color: #90CAF9; }
html[data-theme="dark"] .badge-at_risk { background: rgba(229, 57, 53, 0.18); color: #EF9A9A; }
html[data-theme="dark"] .badge-filter-product { background: rgba(126, 87, 194, 0.22); color: #D1C4E9; }
html[data-theme="dark"] .badge-filter-customer { background: rgba(0, 172, 193, 0.18); color: #80DEEA; }
html[data-theme="dark"] .profile-pill--product { background: rgba(126, 87, 194, 0.22); color: #D1C4E9; }
html[data-theme="dark"] .profile-pill--customer { background: rgba(0, 172, 193, 0.18); color: #80DEEA; }
html[data-theme="dark"] .profile-pill--tag { background: rgba(42, 171, 238, 0.18); color: #90CAF9; }
html[data-theme="dark"] .badge-tag-auto { background: rgba(76, 175, 80, 0.18); color: #A5D6A7; }

html[data-theme="dark"] .toast {
  background: #232E3C;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  color: var(--color-text-primary);
}

html[data-theme="dark"] .toast-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .dash-floating-tip {
  background: #2B3748;
  color: #F5F5F5;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] .insight-card.warning { border-right-color: var(--color-warning); }
html[data-theme="dark"] .insight-card.critical { border-right-color: var(--color-danger); }

html[data-theme="dark"] .wf-node {
  background: var(--color-card-bg);
}

html[data-theme="dark"] .activity-timeline-item {
  border-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .activity-timeline-title {
  color: var(--color-text-secondary);
}

html[data-theme="dark"] .activity-timeline-date {
  color: var(--color-text-muted);
}

html[data-theme="dark"] .alert {
  border-color: rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .alert-info {
  background: rgba(42, 171, 238, 0.1);
  color: #B3E5FC;
}

.login-theme-toggle {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 300;
}
