/* ========== CSS Variables - Dark Theme (Default) ========== */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #263348;
  --bg-input: #0f172a;
  --border-color: #334155;
  --border-light: #475569;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #6366f1;
  --accent-primary-hover: #818cf8;
  --accent-secondary: #8b5cf6;
  --accent-success: #22c55e;
  --accent-warning: #f59e0b;
  --accent-danger: #ef4444;
  --accent-info: #06b6d4;
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-success: linear-gradient(135deg, #22c55e, #16a34a);
  --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
  --gradient-info: linear-gradient(135deg, #06b6d4, #0891b2);
  --sidebar-width: 260px;
  --topbar-height: 64px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
  --sidebar-bg: #1e293b;
  --sidebar-hover: rgba(99, 102, 241, 0.1);
  --sidebar-active-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
  --topbar-bg: #1e293b;
  --table-row-hover: rgba(99,102,241,0.05);
  --table-border: rgba(51,65,85,0.5);
  --code-bg: #0d1117;
  --code-color: #e6edf3;
  --modal-overlay: rgba(0,0,0,0.6);
  --card-footer-bg: rgba(0,0,0,0.1);
  --scrollbar-track: #0f172a;
  --scrollbar-thumb: #334155;
  --scrollbar-thumb-hover: #475569;
}

/* ========== CSS Variables - Light Theme ========== */
[data-theme="light"] {
  --bg-primary: #f0f4f8;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --bg-input: #f8fafc;
  --border-color: #e2e8f0;
  --border-light: #cbd5e1;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-primary: #6366f1;
  --accent-primary-hover: #4f46e5;
  --accent-secondary: #8b5cf6;
  --accent-success: #16a34a;
  --accent-warning: #d97706;
  --accent-danger: #dc2626;
  --accent-info: #0891b2;
  --gradient-primary: linear-gradient(135deg, #6366f1, #8b5cf6);
  --gradient-success: linear-gradient(135deg, #22c55e, #16a34a);
  --gradient-danger: linear-gradient(135deg, #ef4444, #dc2626);
  --gradient-warning: linear-gradient(135deg, #f59e0b, #d97706);
  --gradient-info: linear-gradient(135deg, #06b6d4, #0891b2);
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
  --sidebar-bg: #ffffff;
  --sidebar-hover: rgba(99, 102, 241, 0.06);
  --sidebar-active-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
  --topbar-bg: rgba(255,255,255,0.85);
  --table-row-hover: rgba(99,102,241,0.04);
  --table-border: #f1f5f9;
  --code-bg: #f8fafc;
  --code-color: #334155;
  --modal-overlay: rgba(0,0,0,0.3);
  --card-footer-bg: #f8fafc;
  --scrollbar-track: #f1f5f9;
  --scrollbar-thumb: #cbd5e1;
  --scrollbar-thumb-hover: #94a3b8;
}

/* ========== Reset & Base ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.3s ease, color 0.3s ease;
}

[data-theme="light"] body {
  background: linear-gradient(180deg, #ffffff 0%, #e8f0f8 50%, #dbe9f4 100%);
  background-attachment: fixed;
}

a { color: var(--accent-primary-hover); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-primary); }

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); }

/* ========== Layout ========== */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease, background-color 0.3s ease;
}

[data-theme="light"] .sidebar {
  box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-brand {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .brand-icon {
  width: 40px;
  height: 40px;
  background: var(--gradient-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.sidebar-brand .brand-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.nav-section {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 16px 12px 8px;
  margin-top: 4px;
}

.nav-item {
  list-style: none;
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--gradient-primary);
  color: white;
  box-shadow: var(--sidebar-active-shadow);
}

.nav-link i { width: 20px; text-align: center; font-size: 15px; }

/* Main Content */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background-color 0.3s ease;
}

[data-theme="light"] .topbar {
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.topbar-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

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

/* ========== Theme Toggle Button ========== */
.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.theme-toggle:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(99,102,241,0.08);
  transform: rotate(15deg);
}

.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  position: absolute;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode: show sun icon (to switch to light) */
.theme-toggle .icon-sun {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

.theme-toggle .icon-moon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}

/* Light mode: show moon icon (to switch to dark) */
[data-theme="light"] .theme-toggle .icon-sun {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}

[data-theme="light"] .theme-toggle .icon-moon {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] .theme-toggle {
  background: #ffffff;
  border-color: #e2e8f0;
  color: #6366f1;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

[data-theme="light"] .theme-toggle:hover {
  background: rgba(99,102,241,0.06);
  border-color: var(--accent-primary);
  box-shadow: 0 2px 8px rgba(99,102,241,0.15);
}

/* ========== User Menu ========== */
.user-menu {
  position: relative;
  cursor: pointer;
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--gradient-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: white;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  display: none;
  overflow: hidden;
  z-index: 200;
}

[data-theme="light"] .user-dropdown {
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.user-dropdown.show { display: block; }

.user-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.user-dropdown-header .name { font-weight: 600; font-size: 14px; }
.user-dropdown-header .email { font-size: 12px; color: var(--text-muted); }

.user-dropdown a, .user-dropdown button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-secondary);
  width: 100%;
  border: none;
  background: none;
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
}

.user-dropdown a:hover, .user-dropdown button:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.user-dropdown .text-danger:hover { color: var(--accent-danger) !important; }

/* Content Area */
.content-area {
  flex: 1;
  padding: 24px;
}

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

[data-theme="light"] .card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
}

.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--card-footer-bg);
}

/* ========== Stat Cards ========== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

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

[data-theme="light"] .stat-card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.stat-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.primary { background: rgba(99,102,241,0.15); color: var(--accent-primary); }
.stat-icon.success { background: rgba(34,197,94,0.15); color: var(--accent-success); }
.stat-icon.warning { background: rgba(245,158,11,0.15); color: var(--accent-warning); }
.stat-icon.danger { background: rgba(239,68,68,0.15); color: var(--accent-danger); }
.stat-icon.info { background: rgba(6,182,212,0.15); color: var(--accent-info); }

[data-theme="light"] .stat-icon.primary { background: rgba(99,102,241,0.1); }
[data-theme="light"] .stat-icon.success { background: rgba(34,197,94,0.1); }
[data-theme="light"] .stat-icon.warning { background: rgba(245,158,11,0.1); }
[data-theme="light"] .stat-icon.danger { background: rgba(239,68,68,0.1); }
[data-theme="light"] .stat-icon.info { background: rgba(6,182,212,0.1); }

.stat-value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ========== Tables ========== */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

[data-theme="light"] table th {
  background: #f8fafc;
}

table td {
  padding: 12px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--table-border);
  vertical-align: middle;
}

table tbody tr { transition: var(--transition); }
table tbody tr:hover { background: var(--table-row-hover); }
table tbody tr:last-child td { border-bottom: none; }

/* ========== Badges ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,0.15); color: var(--accent-success); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--accent-danger); }
.badge-warning { background: rgba(245,158,11,0.15); color: var(--accent-warning); }
.badge-info { background: rgba(6,182,212,0.15); color: var(--accent-info); }
.badge-secondary { background: rgba(100,116,139,0.15); color: var(--text-muted); }
.badge-primary { background: rgba(99,102,241,0.15); color: var(--accent-primary); }

[data-theme="light"] .badge-success { background: rgba(34,197,94,0.1); }
[data-theme="light"] .badge-danger { background: rgba(239,68,68,0.1); }
[data-theme="light"] .badge-warning { background: rgba(245,158,11,0.1); }
[data-theme="light"] .badge-info { background: rgba(6,182,212,0.1); }
[data-theme="light"] .badge-secondary { background: rgba(100,116,139,0.08); }
[data-theme="light"] .badge-primary { background: rgba(99,102,241,0.1); }

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.5;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: var(--gradient-primary);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}
.btn-primary:hover { box-shadow: 0 4px 12px rgba(99,102,241,0.4); color: white; }

.btn-success {
  background: var(--gradient-success);
  color: white;
  border: none;
}

.btn-danger {
  background: var(--gradient-danger);
  color: white;
  border: none;
}

.btn-warning {
  background: var(--gradient-warning);
  color: white;
  border: none;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}
.btn-outline:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(99,102,241,0.1);
}

[data-theme="light"] .btn-outline {
  background: #ffffff;
}

[data-theme="light"] .btn-outline:hover {
  background: rgba(99,102,241,0.06);
}

.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-icon { padding: 8px; width: 36px; height: 36px; justify-content: center; }
.btn-icon.btn-sm { width: 30px; height: 30px; padding: 4px; }

/* ========== Forms ========== */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}

[data-theme="light"] .form-control:focus,
[data-theme="light"] .form-select:focus {
  box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

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

textarea.form-control { min-height: 100px; resize: vertical; font-family: 'JetBrains Mono', 'Fira Code', monospace; }

/* Number input - custom spinner */
input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.number-input-wrapper {
  position: relative;
  display: flex;
  align-items: stretch;
}

.number-input-wrapper .form-control {
  padding-right: 40px;
}

.number-input-wrapper .number-btns {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 32px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-color);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  overflow: hidden;
}

.number-input-wrapper .number-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 10px;
  padding: 0;
  transition: var(--transition);
}

.number-input-wrapper .number-btn:hover {
  background: rgba(99,102,241,0.1);
  color: var(--accent-primary);
}

.number-input-wrapper .number-btn:first-child {
  border-bottom: 1px solid var(--border-color);
}

.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ========== Alerts ========== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.alert-success {
  background: rgba(34,197,94,0.1);
  border: 1px solid rgba(34,197,94,0.3);
  color: var(--accent-success);
}

.alert-danger {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--accent-danger);
}

.alert-warning {
  background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--accent-warning);
}

.alert-info {
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.3);
  color: var(--accent-info);
}

.alert .close-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 18px;
  opacity: 0.7;
}

.alert .close-btn:hover { opacity: 1; }

/* ========== Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 700px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

[data-theme="light"] .modal {
  box-shadow: 0 16px 48px rgba(0,0,0,0.15);
}

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

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

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ========== Code/Output ========== */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 13px;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--code-color);
  max-height: 500px;
  overflow-y: auto;
}

/* ========== Pagination ========== */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin-top: 16px;
  justify-content: center;
}

.pagination a, .pagination span {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  transition: var(--transition);
}

[data-theme="light"] .pagination a,
[data-theme="light"] .pagination span {
  background: #ffffff;
}

.pagination a:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: rgba(99,102,241,0.1);
}

.pagination .active {
  background: var(--gradient-primary);
  color: white;
  border-color: transparent;
}

/* ========== Tabs ========== */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  gap: 4px;
}

.tab-link {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab-link:hover { color: var(--text-primary); }
.tab-link.active {
  color: var(--accent-primary);
  border-bottom-color: var(--accent-primary);
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========== Empty State ========== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 15px; margin-top: 8px; }

/* ========== Grid Helpers ========== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.ml-auto { margin-left: auto; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--accent-success); }
.text-danger { color: var(--accent-danger); }
.text-warning { color: var(--accent-warning); }
.text-sm { font-size: 13px; }
.font-mono { font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full { width: 100%; }

/* ========== Script Card ========== */
.script-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

[data-theme="light"] .script-card {
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.script-card:hover {
  border-color: var(--accent-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.script-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.script-card-icon {
  width: 44px;
  height: 44px;
  background: rgba(99,102,241,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent-primary);
  flex-shrink: 0;
}

[data-theme="light"] .script-card-icon {
  background: rgba(99,102,241,0.08);
}

.script-card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.script-card-desc {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.script-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

/* ========== Account Card ========== */
.account-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  overflow: hidden;
}

.account-card-header {
  padding: 10px 16px;
  background: rgba(99,102,241,0.05);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.account-card-body { padding: 12px 16px; }

/* ========== Toggle Switch ========== */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  cursor: pointer;
  display: inline-block;
  vertical-align: middle;
}

.toggle input { display: none; }

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #475569;
  border: 1px solid #64748b;
  border-radius: 12px;
  transition: var(--transition);
}

[data-theme="light"] .toggle-slider {
  background: #cbd5e1;
  border-color: #94a3b8;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  top: 2px;
  left: 2px;
  transition: var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ========== Auth Pages ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-primary);
  padding: 20px;
  transition: background 0.3s ease;
}

[data-theme="light"] .auth-page {
  background: linear-gradient(180deg, #ffffff 0%, #e8f0f8 50%, #dbe9f4 100%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

[data-theme="light"] .auth-card {
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}

.auth-header {
  padding: 32px 32px 0;
  text-align: center;
}

.auth-header .logo {
  width: 56px;
  height: 56px;
  background: var(--gradient-primary);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin-bottom: 16px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.auth-header p { color: var(--text-muted); font-size: 14px; }

.auth-body { padding: 32px; }
.auth-footer {
  padding: 0 32px 32px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

/* Auth page theme toggle */
.auth-theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

/* ========== Responsive ========== */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .mobile-toggle { display: block; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .content-area { padding: 16px; }
  .modal { width: 95%; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar-title { font-size: 15px; }
}

/* ========== Animation ========== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease; }

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

.spin { animation: spin 1s linear infinite; }

/* ========== Loading ========== */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========== Theme transition smoothing ========== */
.theme-transitioning,
.theme-transitioning *,
.theme-transitioning *::before,
.theme-transitioning *::after {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease !important;
}
