/* ════════════════════════════════════════════════════
   AdMatrix — Design System
   ════════════════════════════════════════════════════ */

:root {
  --bg-primary: #0b0f1a;
  --bg-secondary: #111827;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);

  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --sidebar-w: 240px;
  --topbar-h: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.2);
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ════════════════════════════════════════════════════
   LIGHT THEME
   ════════════════════════════════════════════════════ */
[data-theme="light"] {
  --bg-primary: #f1f5f9;
  --bg-secondary: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --border: rgba(15, 23, 42, 0.1);
  --border-focus: rgba(99, 102, 241, 0.5);

  --accent: #6366f1;
  --accent-light: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.2);
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #2563eb;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;

  --shadow: 0 4px 24px rgba(15, 23, 42, 0.1);
  --shadow-sm: 0 2px 12px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ─── UTILITIES ─────────────────────────────────── */
.text-center {
  text-align: center;
}

.text-muted {
  color: var(--text-muted);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

.text-danger {
  color: var(--danger);
}

.text-info {
  color: var(--info);
}

/* ─── SCROLLBAR ──────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ─── PAGES ──────────────────────────────────────── */
.page {
  display: none;
}

.page.active {
  display: flex;
}

/* ════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════ */
#login-page {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 20% 50%, #1e1b4b 0%, #0b0f1a 60%),
    radial-gradient(ellipse at 80% 20%, #1e3a5f 0%, transparent 50%);
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: float 8s ease-in-out infinite;
}

.orb-1 {
  width: 400px;
  height: 400px;
  background: rgba(99, 102, 241, 0.2);
  top: -100px;
  left: -100px;
  animation-delay: 0s;
}

.orb-2 {
  width: 300px;
  height: 300px;
  background: rgba(16, 185, 129, 0.15);
  bottom: -50px;
  right: 10%;
  animation-delay: -3s;
}

.orb-3 {
  width: 200px;
  height: 200px;
  background: rgba(245, 158, 11, 0.1);
  top: 40%;
  right: -50px;
  animation-delay: -6s;
}

@keyframes float {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-30px) scale(1.05);
  }
}

.login-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.glass-card {
  background: rgba(17, 24, 39, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card {
  padding: 40px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  font-size: 48px;
  line-height: 1;
  margin-bottom: 8px;
  display: block;
  filter: drop-shadow(0 0 16px rgba(99, 102, 241, 0.5));
}

.logo-text {
  font-size: 28px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #6366f1, #10b981);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}

.logo-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 12px;
  font-size: 16px;
  z-index: 1;
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  padding: 11px 12px 11px 40px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.input-wrap input:focus {
  border-color: var(--border-focus);
  background: rgba(99, 102, 241, 0.08);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

input,
select,
textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  padding: 10px 12px;
  transition: var(--transition);
  outline: none;
  width: 100%;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  background: rgba(99, 102, 241, 0.06);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}

select option {
  background: var(--bg-secondary);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

.error-msg {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.login-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ─── BUTTONS ─────────────────────────────────────── */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 20px var(--accent-glow);
  filter: brightness(1.1);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-full {
  width: 100%;
  justify-content: center;
  padding: 13px;
  font-size: 15px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
  font-size: 14px;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.btn-icon.danger:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ════════════════════════════════════════════════════
   APP LAYOUT
   ════════════════════════════════════════════════════ */
#app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* ─── SIDEBAR ─────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: rgba(11, 15, 26, 0.95);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  backdrop-filter: blur(20px);
}

.sidebar-header {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon-sm {
  font-size: 22px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section {
  margin-bottom: 8px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  padding: 4px 12px 8px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: var(--transition);
  position: relative;
  font-size: 13.5px;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(99, 102, 241, 0.15);
  color: var(--accent-light);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-icon {
  font-size: 16px;
}

.nav-label {
  flex: 1;
}

.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  animation: pulse 2s infinite;
}

@keyframes pulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
  }

  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
  }
}

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  font-size: 11px;
  color: var(--accent-light);
  font-weight: 500;
}

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 16px;
  transition: var(--transition);
  flex-shrink: 0;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

/* ─── MAIN CONTENT ────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
}

.topbar {
  height: var(--topbar-h);
  background: rgba(11, 15, 26, 0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-title {
  font-size: 18px;
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.date-range-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.date-input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  width: 140px;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  font-size: 20px;
}

/* ─── CONTENT PAGES ───────────────────────────────── */
.content-page {
  display: none;
  padding: 24px;
  flex-direction: column;
  gap: 24px;
}

.content-page.active {
  display: flex;
}

.page-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.search-wrap {
  flex: 1;
  max-width: 400px;
}

.search-input {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 9px 14px;
  width: 100%;
  font-size: 14px;
}

.filter-select {
  min-width: 200px;
  padding: 9px 14px;
}

/* ─── STAT CARDS ──────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  cursor: default;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 60%, rgba(255, 255, 255, 0.02));
  pointer-events: none;
}

.stat-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.stat-card.alert-card:hover {
  border-color: rgba(239, 68, 68, 0.3);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.5px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 500;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ─── CHARTS ROW ──────────────────────────────────── */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
}

.chart-card {
  padding: 20px;
}

.chart-card canvas {
  max-height: 200px;
}

.chart-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.chart-header h3 {
  margin-bottom: 0;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.chart-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 15px;
}

/* ─── CARD ─────────────────────────────────────────── */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 15px;
  font-weight: 600;
}

/* ─── TABLES ──────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.02);
}

.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-primary);
}

/* ─── STATUS BADGES ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  gap: 4px;
}

.badge-active {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-paused {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-suspended {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-admin {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

.badge-editor {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-viewer {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.2);
}

.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-critical {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-resolved {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* ─── PROGRESS BAR ────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease;
}

.progress-ok {
  background: var(--success);
}

.progress-warn {
  background: var(--warning);
}

.progress-crit {
  background: var(--danger);
}

.progress-pct {
  font-size: 12px;
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

/* ─── PLATFORMS GRID ─────────────────────────────── */
.platforms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.platform-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  transition: var(--transition);
  cursor: default;
}

.platform-card:hover {
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.12);
}

.platform-card .p-icon {
  font-size: 36px;
  margin-bottom: 10px;
  display: block;
}

.platform-card .p-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── MODALS ──────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: var(--transition);
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

.modal form {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

/* ─── TOAST ───────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(30, 40, 60, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  max-width: 320px;
  backdrop-filter: blur(12px);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
}

.toast.warn {
  border-color: rgba(245, 158, 11, 0.4);
}

/* ─── LOADING ─────────────────────────────────────── */
.loading-spin {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ─── RESPONSIVE ──────────────────────────────────── */
@media (max-width: 1024px) {
  .charts-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0, 0, 0, 0.5);
  }

  .main-content {
    margin-left: 0;
  }

  .mobile-menu-btn {
    display: block;
  }

  .topbar-right {
    gap: 8px;
  }

  .date-range-wrap {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .content-page {
    padding: 16px;
  }

  .topbar {
    padding: 0 16px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 24px;
  }
}

/* ════════════════════════════════════════════════════
   SPREADSHEET PAGE
   ════════════════════════════════════════════════════ */

.sheet-tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sheet-tabs-left {
  display: flex;
  gap: 4px;
}

.sheet-tabs-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sheet-tab-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 18px;
  transition: var(--transition);
}

.sheet-tab-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: var(--text-primary);
}

.sheet-tab-btn.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--accent-light);
}

.dirty-badge {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fbbf24;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  animation: pulse 2s infinite;
}

.sheet-filterbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  flex-wrap: wrap;
}

.sheet-filterbar input,
.sheet-filterbar select {
  width: auto;
}

.sheet-import-label {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.sheet-card {
  overflow: hidden;
}

.sheet-scroll {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 62vh;
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}

.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(15, 20, 35, 0.97);
  backdrop-filter: blur(8px);
  text-align: left;
  padding: 10px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  user-select: none;
}

.sheet-table thead th.th-num {
  width: 44px;
  text-align: center;
}

.sheet-table thead th.th-action {
  width: 40px;
  text-align: center;
}

.sheet-table tbody tr {
  transition: background 0.1s;
}

.sheet-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

.sheet-table tbody tr.row-dirty {
  background: rgba(245, 158, 11, 0.07);
  box-shadow: inset 3px 0 0 var(--warning);
}

.sheet-table tbody tr.row-new {
  background: rgba(16, 185, 129, 0.07);
  box-shadow: inset 3px 0 0 var(--success);
}

.sheet-table tbody td {
  padding: 3px 4px;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.sheet-table tbody td.td-num {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  padding: 4px 0;
  user-select: none;
}

.cell-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  padding: 5px 6px;
  outline: none;
  min-height: 28px;
  transition: border-color 0.15s, background 0.15s;
}

.cell-input:hover:not(:focus) {
  border-color: rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.04);
}

.cell-input:focus {
  border-color: var(--accent);
  background: rgba(99, 102, 241, 0.1);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

input.cell-input[type="number"] {
  text-align: right;
}

input.cell-input[type="date"] {
  min-width: 110px;
  cursor: pointer;
}

.btn-del-row {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  display: block;
  margin: 0 auto;
  transition: var(--transition);
}

.btn-del-row:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.sheet-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  gap: 12px;
  background: rgba(255, 255, 255, 0.02);
  flex-wrap: wrap;
}

.sheet-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-muted);
}

.page-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 5px 14px;
  font-size: 13px;
  transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ════════════════════════════════════════════════════
   ACCOUNTS PAGE — 广告余额一览（分组）
   ════════════════════════════════════════════════════ */

.acct-group {
  margin-bottom: 20px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

/* 组标题行 */
.acct-group-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.acct-group-header:hover {
  background: rgba(99, 102, 241, 0.14);
}

.acct-group-opener {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 80px;
}

.acct-group-type {
  font-size: 12px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 10px;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.acct-group-meta {
  display: flex;
  gap: 20px;
  margin-left: auto;
  align-items: center;
  flex-wrap: wrap;
}

.acct-group-meta span {
  font-size: 12px;
  color: var(--text-muted);
}

.acct-group-meta b {
  color: var(--text-primary);
  font-weight: 600;
}

.acct-group-toggle {
  color: var(--text-muted);
  font-size: 13px;
  transition: transform 0.2s;
}

.acct-group-toggle.collapsed {
  transform: rotate(-90deg);
}

/* 组内表格 */
.acct-group-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.01);
}

.acct-group-table th {
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.acct-group-table td {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.acct-group-table tr:last-child td {
  border-bottom: none;
}

.acct-group-table tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

/* 状态 badge */
.status-running {
  color: #10b981;
}

.status-paused {
  color: #f59e0b;
}

.status-stopped {
  color: #ef4444;
}

/* 汇总行 */
.acct-group-sum td {
  background: rgba(99, 102, 241, 0.06);
  font-weight: 600;
  color: var(--text-primary);
  border-top: 1px solid var(--border);
}

/* ════════════════════════════════════════════════════
   THEME TOGGLE BUTTON
   ════════════════════════════════════════════════════ */
.theme-toggle-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 6px 11px;
  font-size: 16px;
  line-height: 1;
  transition: var(--transition);
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.4);
  color: var(--accent);
  transform: rotate(15deg) scale(1.1);
}

/* ════════════════════════════════════════════════════
   LIGHT THEME — Element Overrides
   (CSS variables alone cannot override hardcoded values)
   ════════════════════════════════════════════════════ */

/* ── Global ── */
[data-theme="light"] body {
  background: var(--bg-primary);
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.16);
}

[data-theme="light"] ::-webkit-scrollbar-thumb:hover {
  background: rgba(15, 23, 42, 0.28);
}

/* ── Login Page ── */
[data-theme="light"] #login-page {
  background:
    radial-gradient(ellipse at 20% 50%, #e0e7ff 0%, #f1f5f9 55%),
    radial-gradient(ellipse at 80% 20%, #dbeafe 0%, transparent 50%);
}

[data-theme="light"] .login-orb.orb-1 {
  background: rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .login-orb.orb-2 {
  background: rgba(16, 185, 129, 0.12);
}

[data-theme="light"] .login-orb.orb-3 {
  background: rgba(245, 158, 11, 0.10);
}

[data-theme="light"] .glass-card {
  background: rgba(255, 255, 255, 0.92);
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .login-card {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(99, 102, 241, 0.15);
}

[data-theme="light"] .logo-text {
  background: linear-gradient(135deg, #4f46e5, #6366f1, #059669);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .input-wrap input {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.14);
}

[data-theme="light"] .input-wrap input:focus {
  background: rgba(99, 102, 241, 0.05);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* ── Inputs (global) ── */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.14);
  color: var(--text-primary);
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

[data-theme="light"] select option {
  background: #ffffff;
  color: #0f172a;
}

/* ── Sidebar ── */
[data-theme="light"] .sidebar {
  background: rgba(255, 255, 255, 0.98);
  border-right-color: rgba(15, 23, 42, 0.1);
  box-shadow: 2px 0 16px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .sidebar-header {
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sidebar-footer {
  border-top-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sidebar-title {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

[data-theme="light"] .nav-item {
  color: var(--text-secondary);
}

[data-theme="light"] .nav-item:hover {
  background: rgba(99, 102, 241, 0.07);
  color: var(--text-primary);
}

[data-theme="light"] .nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--accent);
}

[data-theme="light"] .nav-section-label {
  color: var(--text-muted);
}

[data-theme="light"] .user-role-badge {
  color: var(--accent);
}

[data-theme="light"] .btn-logout {
  border-color: rgba(15, 23, 42, 0.15);
  color: var(--text-muted);
}

[data-theme="light"] .btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(220, 38, 38, 0.06);
}

/* ── Topbar ── */
[data-theme="light"] .topbar {
  background: rgba(255, 255, 255, 0.94);
  border-bottom-color: rgba(15, 23, 42, 0.09);
  box-shadow: 0 1px 8px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .date-input {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.13);
}

[data-theme="light"] .search-input {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.13);
}

/* ── Buttons ── */
[data-theme="light"] .btn-secondary {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.13);
  color: var(--text-secondary);
}

[data-theme="light"] .btn-secondary:hover {
  background: rgba(15, 23, 42, 0.11);
  color: var(--text-primary);
}

[data-theme="light"] .btn-icon {
  color: var(--text-muted);
}

[data-theme="light"] .btn-icon:hover {
  background: rgba(15, 23, 42, 0.07);
  color: var(--text-primary);
}

[data-theme="light"] .btn-icon.danger:hover {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.07);
}

/* ── Stat Cards ── */
[data-theme="light"] .stat-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .stat-card::after {
  background: linear-gradient(135deg, transparent 60%, rgba(15, 23, 42, 0.015));
}

[data-theme="light"] .stat-card:hover {
  background: #fafcff;
  border-color: rgba(99, 102, 241, 0.2);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.12);
}

/* ── Chart Cards ── */
[data-theme="light"] .chart-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
}

/* ── Tables ── */
[data-theme="light"] .data-table thead th {
  background: #f8fafc;
  border-bottom-color: rgba(15, 23, 42, 0.1);
  color: var(--text-muted);
}

[data-theme="light"] .data-table tbody td {
  border-bottom-color: rgba(15, 23, 42, 0.06);
  color: var(--text-secondary);
}

[data-theme="light"] .data-table tbody tr:hover td {
  background: rgba(99, 102, 241, 0.04);
  color: var(--text-primary);
}

/* ── Card Header ── */
[data-theme="light"] .card-header {
  border-bottom-color: rgba(15, 23, 42, 0.09);
}

/* ── Platforms Grid ── */
[data-theme="light"] .platform-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.09);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .platform-card:hover {
  background: #fafcff;
  border-color: rgba(99, 102, 241, 0.3);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.1);
}

/* ── Modals ── */
[data-theme="light"] .modal-overlay {
  background: rgba(15, 23, 42, 0.5);
}

[data-theme="light"] .modal-header {
  border-bottom-color: rgba(15, 23, 42, 0.09);
}

[data-theme="light"] .modal-actions {
  border-top-color: rgba(15, 23, 42, 0.09);
}

[data-theme="light"] .modal-close:hover {
  background: rgba(15, 23, 42, 0.07);
  color: var(--text-primary);
}

[data-theme="light"] .role-desc {
  background: #f8fafc !important;
  border-color: rgba(15, 23, 42, 0.09) !important;
}

/* ── Toast ── */
[data-theme="light"] .toast {
  background: rgba(255, 255, 255, 0.97);
  border-color: rgba(15, 23, 42, 0.15);
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(15, 23, 42, 0.15);
}

[data-theme="light"] .toast.success {
  border-color: rgba(5, 150, 105, 0.4);
}

[data-theme="light"] .toast.error {
  border-color: rgba(220, 38, 38, 0.4);
}

[data-theme="light"] .toast.warn {
  border-color: rgba(217, 119, 6, 0.4);
}

/* ── Spreadsheet ── */
[data-theme="light"] .sheet-tab-btn {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.12);
  color: var(--text-muted);
}

[data-theme="light"] .sheet-tab-btn:hover {
  background: rgba(15, 23, 42, 0.09);
  color: var(--text-primary);
}

[data-theme="light"] .sheet-tab-btn.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.35);
  color: var(--accent);
}

[data-theme="light"] .sheet-filterbar {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(15, 23, 42, 0.09);
}

[data-theme="light"] .sheet-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .sheet-table thead th {
  background: rgba(248, 250, 252, 0.98);
  border-bottom-color: rgba(15, 23, 42, 0.12);
  color: var(--text-muted);
  backdrop-filter: none;
}

[data-theme="light"] .sheet-table tbody td {
  border-bottom-color: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .sheet-table tbody tr:hover {
  background: rgba(99, 102, 241, 0.04);
}

[data-theme="light"] .sheet-table tbody tr.row-dirty {
  background: rgba(217, 119, 6, 0.07);
  box-shadow: inset 3px 0 0 var(--warning);
}

[data-theme="light"] .sheet-table tbody tr.row-new {
  background: rgba(5, 150, 105, 0.07);
  box-shadow: inset 3px 0 0 var(--success);
}

[data-theme="light"] .cell-input {
  background: transparent;
  color: var(--text-primary);
  border-color: transparent;
}

[data-theme="light"] .cell-input:hover:not(:focus) {
  border-color: rgba(15, 23, 42, 0.18);
  background: rgba(15, 23, 42, 0.03);
}

[data-theme="light"] .cell-input:focus {
  background: rgba(99, 102, 241, 0.07);
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.12);
}

[data-theme="light"] .btn-del-row {
  color: var(--text-muted);
}

[data-theme="light"] .btn-del-row:hover {
  color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
}

[data-theme="light"] .sheet-footer {
  background: rgba(248, 250, 252, 0.9);
  border-top-color: rgba(15, 23, 42, 0.09);
}

[data-theme="light"] .page-btn {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.13);
  color: var(--text-secondary);
}

[data-theme="light"] .page-btn:hover:not(:disabled) {
  background: rgba(15, 23, 42, 0.1);
  color: var(--text-primary);
}

/* ── Accounts Groups ── */
[data-theme="light"] .acct-group {
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .acct-group-header {
  background: rgba(99, 102, 241, 0.06);
  border-bottom-color: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .acct-group-header:hover {
  background: rgba(99, 102, 241, 0.11);
}

[data-theme="light"] .acct-group-type {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .acct-group-table th {
  background: rgba(15, 23, 42, 0.03);
  border-bottom-color: rgba(15, 23, 42, 0.09);
  color: var(--text-muted);
}

[data-theme="light"] .acct-group-table td {
  border-bottom-color: rgba(15, 23, 42, 0.05);
}

[data-theme="light"] .acct-group-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

[data-theme="light"] .acct-group-sum td {
  background: rgba(99, 102, 241, 0.06);
  border-top-color: rgba(15, 23, 42, 0.1);
}

/* ── Error msg ── */
[data-theme="light"] .error-msg {
  background: rgba(220, 38, 38, 0.07);
  border-color: rgba(220, 38, 38, 0.25);
  color: #b91c1c;
}