/* ============================================================
   Cortex AI AI Marketing Platform - Dark Theme Stylesheet
   ============================================================ */

/* ---------- CSS Variables ---------- */
:root {
  --bg-body: #0f0f1a;
  --bg-sidebar: #12122a;
  --bg-card: #1a1a2e;
  --bg-input: #16162e;
  --bg-hover: #222244;
  --bg-modal-overlay: rgba(0, 0, 0, 0.65);
  --border: #2a2a4a;
  --border-focus: #667eea;
  --accent: #667eea;
  --accent-end: #764ba2;
  --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --text: #e0e0e0;
  --text-secondary: #888;
  --text-muted: #555;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.15);
  --warning: #eab308;
  --warning-bg: rgba(234, 179, 8, 0.15);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.15);
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 8px 25px rgba(102, 126, 234, 0.12);
  --transition: 0.2s ease;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-body);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.85; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }

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

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex; flex-direction: column;
  min-height: 100vh;
}
.header {
  position: sticky; top: 0;
  height: var(--header-height);
  background: rgba(15, 15, 26, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 30px;
  z-index: 90;
}
.content {
  padding: 30px;
  flex: 1;
  animation: fadeIn 0.3s ease;
}

/* ---------- Sidebar ---------- */
.sidebar-logo {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 36px; height: 36px;
  background: var(--accent-gradient);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: #fff;
}
.sidebar-logo .logo-text {
  font-size: 18px; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav .nav-section {
  padding: 8px 24px 4px;
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-muted);
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 24px;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
}
.nav-link:hover {
  color: var(--text);
  background: rgba(102, 126, 234, 0.06);
}
.nav-link.active {
  color: var(--accent);
  background: rgba(102, 126, 234, 0.1);
  border-left-color: var(--accent);
}
.nav-link .nav-icon { font-size: 16px; width: 20px; text-align: center; }
.nav-link .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  min-width: 18px; text-align: center;
}
.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
}

/* ---------- Header ---------- */
.header-left { display: flex; align-items: center; gap: 16px; }
.header-title { font-size: 16px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 16px; }
.hamburger {
  display: none;
  background: none; border: none;
  color: var(--text); font-size: 22px;
  padding: 11px;
  min-width: 44px; min-height: 44px;
}
.header-notification {
  position: relative;
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 18px;
  padding: 10px;
  min-width: 44px; min-height: 44px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.header-notification:hover { color: var(--text); background: var(--bg-hover); }
.header-notification .notif-badge {
  position: absolute; top: 0; right: 0;
  background: var(--danger);
  color: #fff;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.header-user {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; padding: 6px 10px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  position: relative;
}
.header-user:hover { background: var(--bg-hover); }
.header-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
}
.header-user-name { font-size: 13px; font-weight: 500; }
.header-user-dropdown {
  display: none;
  position: absolute; top: 100%; right: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-width: 180px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 200;
  overflow: hidden;
}
.header-user-dropdown.open { display: block; }
.dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  min-height: 44px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}
.dropdown-item:hover { background: var(--bg-hover); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: box-shadow var(--transition), border-color var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); border-color: rgba(102, 126, 234, 0.2); }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 15px; font-weight: 600; }
.card-subtitle { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

/* ---------- Stat Cards ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-hover); border-color: rgba(102, 126, 234, 0.2); }
.stat-card .stat-label {
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .stat-change {
  font-size: 12px; margin-top: 6px;
  display: flex; align-items: center; gap: 4px;
}
.stat-card .stat-change.positive { color: var(--success); }
.stat-card .stat-change.negative { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrapper { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(42, 42, 74, 0.5);
  vertical-align: middle;
}
tbody tr { transition: background var(--transition); }
tbody tr:nth-child(even) { background: rgba(26, 26, 46, 0.4); }
tbody tr:hover { background: rgba(102, 126, 234, 0.05); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px;
  min-height: 40px;
  font-size: 13px; font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-sm { padding: 8px 14px; font-size: 12px; border-radius: 6px; min-height: 36px; }
.btn-lg { padding: 14px 28px; font-size: 15px; min-height: 48px; }
.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
  box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}
.btn-primary:hover { box-shadow: 0 4px 16px rgba(102, 126, 234, 0.45); transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }
.btn-success {
  background: var(--success);
  color: #fff;
}
.btn-success:hover { background: #16a34a; }
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 10px;
}
.btn-ghost:hover { color: var(--text); background: var(--bg-hover); }
.btn-icon {
  width: 34px; height: 34px;
  padding: 0; border-radius: var(--radius-sm);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn-group { display: flex; gap: 8px; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23888' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-select option { background: var(--bg-card); color: var(--text); }
.form-error { font-size: 11px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px; accent-color: var(--accent);
}

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px;
  font-size: 11px; font-weight: 600;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-active, .badge-connected { background: var(--success-bg); color: var(--success); }
.badge-paused, .badge-pending { background: var(--warning-bg); color: var(--warning); }
.badge-draft, .badge-disconnected { background: rgba(85, 85, 85, 0.2); color: var(--text-secondary); }
.badge-error { background: var(--danger-bg); color: var(--danger); }
.badge-completed { background: var(--info-bg); color: var(--info); }
.badge-running { background: rgba(102, 126, 234, 0.15); color: var(--accent); }

/* ---------- Modals ---------- */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: var(--bg-modal-overlay);
  z-index: 500;
  align-items: center; justify-content: center;
  animation: fadeIn 0.2s ease;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 90%; max-width: 560px;
  max-height: 85vh; overflow-y: auto;
  animation: slideUp 0.3s ease;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none;
  color: var(--text-secondary);
  font-size: 20px;
  padding: 4px;
  cursor: pointer;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ---------- Toasts ---------- */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 10px;
  max-width: 380px;
}
.toast {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  animation: slideInRight 0.3s ease;
  font-size: 13px;
  border-left: 3px solid var(--accent);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-info { border-left-color: var(--info); }
.toast-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info .toast-icon { color: var(--info); }
.toast-content { flex: 1; }
.toast-dismiss {
  background: none; border: none;
  color: var(--text-muted); font-size: 14px;
  cursor: pointer; flex-shrink: 0;
}
.toast.removing { animation: slideOutRight 0.3s ease forwards; }

/* ---------- Activity Feed ---------- */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42, 42, 74, 0.4);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: rgba(102, 126, 234, 0.12);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.activity-text { font-size: 13px; flex: 1; }
.activity-text strong { color: var(--text); font-weight: 600; }
.activity-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Platform Cards ---------- */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.platform-card {
  text-align: center;
  padding: 28px 20px;
}
.platform-card .platform-icon {
  font-size: 36px;
  margin-bottom: 12px;
}
.platform-card .platform-name {
  font-size: 16px; font-weight: 600;
  margin-bottom: 8px;
}
.platform-card .platform-status { margin-bottom: 16px; }

/* ---------- Agent Cards ---------- */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}
.agent-card { position: relative; }
.agent-card .agent-icon {
  font-size: 28px;
  margin-bottom: 12px;
}
.agent-card .agent-name {
  font-size: 15px; font-weight: 600;
  margin-bottom: 4px;
}
.agent-card .agent-desc {
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 16px;
}
.agent-card .agent-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-muted);
  margin-bottom: 16px;
}

/* ---------- Chart Placeholders (legacy, replaced by Chart.js containers below) ---------- */
.chart-placeholder {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
.chart-placeholder .chart-ph-icon { font-size: 40px; margin-bottom: 8px; opacity: 0.4; }

/* ---------- Alerts List ---------- */
.alert-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}
.alert-item.alert-warning { background: var(--warning-bg); color: var(--warning); }
.alert-item.alert-danger { background: var(--danger-bg); color: var(--danger); }
.alert-item.alert-info { background: var(--info-bg); color: var(--info); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex; gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab-btn {
  padding: 10px 20px;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Budget Overview ---------- */
.budget-bars .budget-bar-item { margin-bottom: 16px; }
.budget-bar-item .budget-bar-label {
  display: flex; justify-content: space-between;
  font-size: 12px; margin-bottom: 6px;
}
.budget-bar-item .budget-bar-track {
  height: 8px; background: var(--bg-input);
  border-radius: 4px; overflow: hidden;
}
.budget-bar-item .budget-bar-fill {
  height: 100%; border-radius: 4px;
  background: var(--accent-gradient);
  transition: width 0.5s ease;
}
.budget-bar-item .budget-bar-fill.warning { background: var(--warning); }
.budget-bar-item .budget-bar-fill.danger { background: var(--danger); }

/* ---------- Settings / Profile ---------- */
.settings-section { max-width: 640px; }
.plan-card {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-color: rgba(102, 126, 234, 0.3);
}
.plan-card .plan-name {
  font-size: 22px; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Quick Actions ---------- */
.quick-actions {
  display: flex; gap: 12px; flex-wrap: wrap;
}

/* ---------- Date Range ---------- */
.date-range {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.date-range .form-input { width: auto; max-width: 160px; }

/* ---------- Section Headers ---------- */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.section-title { font-size: 20px; font-weight: 700; }

/* ---------- Empty State ---------- */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; opacity: 0.3; }
.empty-state p { font-size: 14px; margin-bottom: 16px; }

/* ---------- Loading Spinner ---------- */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

/* ---------- Page Sections ---------- */
.page-section { display: none; }
.page-section.active { display: block; animation: fadeIn 0.3s ease; }

/* ---------- Grid Layouts ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(100px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(100px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Login Page ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.login-header {
  text-align: center;
  padding: 32px 24px 20px;
}
.login-header .logo-icon {
  width: 52px; height: 52px;
  background: var(--accent-gradient);
  border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff;
  margin-bottom: 16px;
}
.login-header h1 {
  font-size: 24px; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-header p {
  font-size: 13px; color: var(--text-secondary);
  margin-top: 4px;
}
.login-body { padding: 8px 32px 32px; box-sizing: border-box; }
.login-tabs {
  display: flex; margin-bottom: 24px;
}
.login-tab {
  flex: 1;
  padding: 12px;
  min-height: 44px;
  text-align: center;
  font-size: 13px; font-weight: 600;
  color: var(--text-secondary);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.login-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.login-form { display: none; }
.login-form.active { display: block; animation: fadeIn 0.3s ease; }
.login-footer {
  text-align: center;
  padding: 0 32px 24px;
  font-size: 12px;
  color: var(--text-muted);
}
.login-footer a { color: var(--accent); }
.login-forgot {
  text-align: right;
  margin-bottom: 16px;
}
.login-forgot a { font-size: 12px; color: var(--text-secondary); }
.login-forgot a:hover { color: var(--accent); }

/* Google Sign-In Button */
.google-signin-wrap { margin-bottom: 16px; }
.google-signin-btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 14px;
  min-height: 48px;
  background: #fff; color: #333;
  border: 1px solid #dadce0; border-radius: 8px;
  font-size: 15px; font-weight: 500;
  text-decoration: none;
  transition: box-shadow 0.2s, background 0.2s;
}
.google-signin-btn:hover { box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); }

/* Login Divider */
.login-divider {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px;
}
.login-divider-line { flex: 1; height: 1px; background: rgba(255, 255, 255, 0.15); }
.login-divider-text { color: rgba(255, 255, 255, 0.4); font-size: 13px; }
.login-submit { width: 100%; margin-top: 8px; }

/* ---------- Chart Containers (Chart.js) ---------- */
.chart-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  min-height: 280px;
  position: relative;
  animation: chartFadeIn 0.5s ease;
}
.chart-container .chart-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.chart-container .chart-title {
  font-size: 14px; font-weight: 600; color: var(--text);
}
.chart-container .chart-subtitle {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.chart-container canvas {
  max-height: 300px;
}

/* ---------- Gauge (Budget Utilization) ---------- */
.gauge {
  position: relative;
  width: 80px; height: 80px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto;
}
.gauge::before {
  content: '';
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    var(--accent) 0%,
    var(--accent) var(--gauge-pct, 0%),
    var(--bg-input) var(--gauge-pct, 0%),
    var(--bg-input) 100%
  );
  mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #fff calc(100% - 7px));
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 8px), #fff calc(100% - 7px));
}
.gauge.gauge-warning::before {
  background: conic-gradient(
    var(--warning) 0%,
    var(--warning) var(--gauge-pct, 0%),
    var(--bg-input) var(--gauge-pct, 0%),
    var(--bg-input) 100%
  );
}
.gauge.gauge-danger::before {
  background: conic-gradient(
    var(--danger) 0%,
    var(--danger) var(--gauge-pct, 0%),
    var(--bg-input) var(--gauge-pct, 0%),
    var(--bg-input) 100%
  );
}
.gauge .gauge-value {
  font-size: 14px; font-weight: 700; color: var(--text);
  z-index: 1;
}

/* ---------- Live Log Viewer ---------- */
.live-log {
  background: #0d0d1a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  max-height: 400px;
  overflow-y: auto;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
  scroll-behavior: smooth;
}
.live-log .log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(42, 42, 74, 0.25);
  display: flex; gap: 8px;
  animation: logSlideIn 0.3s ease;
}
.live-log .log-entry:last-child { border-bottom: none; }
.live-log .log-timestamp {
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.live-log .log-agent {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.live-log .log-message { color: var(--text); flex: 1; }
.live-log .log-entry.log-error .log-message { color: var(--danger); }
.live-log .log-entry.log-success .log-message { color: var(--success); }
.live-log .log-entry.log-warning .log-message { color: var(--warning); }

/* ---------- Sparkline (Stat Card Mini Charts) ---------- */
.sparkline {
  width: 100%;
  height: 40px;
  margin-top: 8px;
  position: relative;
}
.sparkline canvas {
  width: 100% !important;
  height: 40px !important;
}

/* ---------- Date Picker ---------- */
.date-picker {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
}
.date-picker input[type="date"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  padding: 6px 10px;
  font-family: inherit;
}
.date-picker input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}
.date-picker .date-separator {
  color: var(--text-muted); font-size: 12px;
}

/* ---------- Progress Bar ---------- */
.progress-bar {
  position: relative;
  height: 10px;
  background: var(--bg-input);
  border-radius: 5px;
  overflow: hidden;
  margin: 6px 0;
}
.progress-bar .progress-fill {
  height: 100%;
  border-radius: 5px;
  background: var(--accent-gradient);
  transition: width 0.6s ease;
  position: relative;
}
.progress-bar .progress-fill.warning {
  background: linear-gradient(135deg, var(--warning) 0%, #f59e0b 100%);
}
.progress-bar .progress-fill.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #f87171 100%);
}
.progress-bar-label {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--text-secondary);
  margin-bottom: 4px;
}
.progress-bar-label .progress-pct {
  font-weight: 600; color: var(--text);
}

/* ---------- Alert Cards ---------- */
.alert-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex; align-items: flex-start; gap: 12px;
  animation: chartFadeIn 0.4s ease;
}
.alert-card.alert-warning {
  border-left: 3px solid var(--warning);
  background: rgba(234, 179, 8, 0.04);
}
.alert-card.alert-critical {
  border-left: 3px solid var(--danger);
  background: rgba(239, 68, 68, 0.04);
}
.alert-card.alert-info {
  border-left: 3px solid var(--info);
  background: rgba(59, 130, 246, 0.04);
}
.alert-card .alert-icon {
  font-size: 18px; flex-shrink: 0; margin-top: 1px;
}
.alert-card.alert-warning .alert-icon { color: var(--warning); }
.alert-card.alert-critical .alert-icon { color: var(--danger); }
.alert-card.alert-info .alert-icon { color: var(--info); }
.alert-card .alert-content { flex: 1; }
.alert-card .alert-title {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin-bottom: 2px;
}
.alert-card .alert-message {
  font-size: 12px; color: var(--text-secondary);
}
.alert-card .alert-time {
  font-size: 11px; color: var(--text-muted); margin-top: 4px;
}

/* ---------- Real-Time Badge (Pulsing Dot) ---------- */
.real-time-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600;
  color: var(--success);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.real-time-badge::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

/* ---------- Budget Utilization Row ---------- */
.budget-util-row {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42, 42, 74, 0.4);
}
.budget-util-row:last-child { border-bottom: none; }
.budget-util-info { flex: 1; min-width: 0; }
.budget-util-info .budget-campaign-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.budget-util-info .budget-spend-label {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}
.budget-util-bar { flex: 2; }

/* ---------- Chart Section Full Width ---------- */
.chart-full {
  grid-column: 1 / -1;
}

/* ---------- Animations (Charts/Monitoring) ---------- */
@keyframes chartFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}
@keyframes logSlideIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── MOBILE RESPONSIVE ─── */

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
}
.sidebar-overlay.open { display: block; }

/* Table responsive wrapper */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- Tablet (768px - 1024px) ---------- */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  :root { --sidebar-width: 200px; }
  .main-wrapper { margin-left: 200px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-container { min-height: 240px; }
  .chart-container canvas { max-height: 260px; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .agents-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  table { font-size: 12px; }
  thead th { padding: 10px 12px; font-size: 10px; }
  tbody td { padding: 10px 12px; }
  .content { padding: 24px 20px; }
  .section-header { flex-wrap: wrap; }
}

/* ---------- Mobile (< 768px) ---------- */
@media (max-width: 768px) {
  /* Sidebar: hidden by default, slides in as overlay */
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    z-index: 1000;
    transition: transform 0.3s ease;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.5);
  }

  /* Main wrapper full width */
  .main-wrapper { margin-left: 0; }

  /* Header: full width, show hamburger */
  .header {
    padding: 0 12px;
  }
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .header-user-name { display: none; }
  .header-title { font-size: 14px; }

  /* Form inputs: touch-friendly */
  .form-input, .form-select, .form-textarea { padding: 12px 14px; min-height: 44px; font-size: 14px; }
  .form-check input[type="checkbox"] { width: 20px; height: 20px; }

  /* Login page mobile */
  .login-header { padding: 24px 20px 16px; }
  .login-header .logo-icon { width: 44px; height: 44px; font-size: 20px; }
  .login-header h1 { font-size: 20px; }
  .login-body { padding: 8px 20px 24px; }
  .login-footer { padding: 0 20px 20px; }
  .login-tab { padding: 12px 8px; font-size: 12px; }
  .login-forgot a { padding: 8px 0; display: inline-block; }

  /* Content */
  .content { padding: 15px; }

  /* Stat cards: 1 per row */
  .stats-grid { grid-template-columns: 1fr; }

  /* Tables: horizontal scroll */
  table { font-size: 12px; }
  thead th { padding: 8px 10px; font-size: 10px; }
  tbody td { padding: 8px 10px; }

  /* Charts: full width, reduced height */
  .chart-container { min-height: 220px; padding: 16px; }
  .chart-container canvas { max-height: 200px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  /* Modals: full width with margin */
  .modal { width: calc(100% - 20px); max-width: none; margin: 10px; }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-footer { padding: 12px 16px; flex-wrap: wrap; }
  .modal-footer .btn { flex: 1; min-width: 120px; }

  /* Forms: full width */
  .form-row { grid-template-columns: 1fr; }
  .form-input, .form-select, .form-textarea { width: 100%; }

  /* Buttons: full width in forms */
  .modal-footer .btn { width: 100%; }

  /* Platform cards: 1 per row */
  .platform-grid { grid-template-columns: 1fr; }

  /* Agent cards: 1 per row */
  .agents-grid { grid-template-columns: 1fr; }

  /* Budget progress bars: full width */
  .budget-util-row { flex-direction: column; gap: 8px; }
  .budget-util-bar { width: 100%; }
  .budget-bars .budget-bar-item { margin-bottom: 12px; }

  /* Quick actions: vertical stack */
  .quick-actions { flex-direction: column; }
  .quick-actions .btn { width: 100%; }

  /* Date picker: full width */
  .date-picker { width: 100%; flex-wrap: wrap; }
  .date-picker input[type="date"] { flex: 1; min-width: 0; }
  .date-range { flex-wrap: wrap; width: 100%; }
  .date-range .form-input { width: 100%; }

  /* Approval cards: stack vertically */
  .activity-item { flex-wrap: wrap; }

  /* Settings: single column */
  .settings-section { max-width: 100%; }

  /* Font sizes: slightly smaller */
  .section-title { font-size: 18px; }
  .card-title { font-size: 14px; }
  .stat-card .stat-value { font-size: 24px; }
  .stat-card .stat-label { font-size: 11px; }

  /* Toast: full width at top */
  .toast-container {
    top: 10px; right: 10px; left: 10px;
    max-width: none;
  }
  .toast { font-size: 12px; }

  /* Live log */
  .live-log { max-height: 250px; font-size: 11px; padding: 10px; }

  /* Tabs */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 10px 14px; font-size: 12px; white-space: nowrap; min-height: 44px; }

  /* Section header */
  .section-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .section-header .btn-group { width: 100%; }
  .section-header .btn-group .btn { flex: 1; }

  /* Card header */
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* Alert cards */
  .alert-card { padding: 12px 14px; }

  /* Gauge */
  .gauge { width: 60px; height: 60px; }
  .gauge .gauge-value { font-size: 12px; }

  /* Toast below header */
  .toast-container { top: calc(var(--header-height) + 10px); }

  /* Live log */
  .live-log { max-height: 200px; }

  /* Modal close button */
  .modal-close { min-width: 44px; min-height: 44px; padding: 8px; }
}

/* ---------- Small Mobile (< 480px) ---------- */
@media (max-width: 480px) {
  /* Header */
  .header { height: 50px; padding: 0 8px; }
  :root { --header-height: 50px; }
  .header-title { font-size: 13px; }
  .header-right { gap: 4px; }
  .header-notification { font-size: 16px; padding: 8px; }
  .header-avatar { width: 28px; height: 28px; font-size: 11px; }

  /* Stat cards: compact */
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 10px; }
  .stat-card .stat-change { font-size: 11px; }
  .sparkline { height: 30px; }
  .sparkline canvas { height: 30px !important; }

  /* All spacing reduced */
  .content { padding: 10px; }
  .stats-grid { gap: 10px; margin-bottom: 16px; }
  .card { padding: 14px; }
  .card-header { margin-bottom: 12px; }

  /* Long text handling */
  .activity-text { word-break: break-word; }
  .budget-util-info .budget-campaign-name {
    white-space: normal;
    word-break: break-word;
  }
  td { word-break: break-word; }

  /* Sidebar narrower on very small screens */
  .sidebar { width: 240px; }
  .sidebar-logo { padding: 14px 16px; }
  .sidebar-logo .logo-text { font-size: 16px; }
  .nav-link { padding: 8px 16px; font-size: 12px; }
  .sidebar-nav .nav-section { padding: 6px 16px 4px; font-size: 9px; }

  /* Platform cards compact */
  .platform-card { padding: 16px 12px; }
  .platform-card .platform-icon { font-size: 28px; }
  .platform-card .platform-name { font-size: 14px; }

  /* Agent cards compact */
  .agent-card .agent-icon { font-size: 22px; margin-bottom: 8px; }
  .agent-card .agent-name { font-size: 13px; }
  .agent-card .agent-desc { font-size: 11px; margin-bottom: 10px; }

  /* Buttons - maintain touch-friendly sizes */
  .btn { padding: 10px 14px; font-size: 12px; min-height: 40px; }
  .btn-sm { padding: 8px 12px; font-size: 11px; min-height: 36px; }
  .btn-lg { padding: 12px 20px; font-size: 13px; min-height: 44px; }
  .btn-group { flex-wrap: wrap; }

  /* Modal */
  .modal { margin: 5px; width: calc(100% - 10px); }
  .modal-header h3 { font-size: 14px; }

  /* Chart */
  .chart-container { padding: 12px; min-height: 180px; }
  .chart-container .chart-title { font-size: 12px; }
  .chart-container canvas { max-height: 160px; }

  /* Tabs */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tab-btn { padding: 8px 10px; font-size: 11px; min-height: 40px; }

  /* Plan card in settings */
  .plan-card .plan-name { font-size: 18px; }

  /* Login compact */
  .login-header { padding: 20px 16px 12px; }
  .login-header .logo-icon { width: 40px; height: 40px; font-size: 18px; }
  .login-header h1 { font-size: 18px; }
  .login-body { padding: 4px 16px 20px; }
  .login-footer { padding: 0 16px 16px; }

  /* Live log compact */
  .live-log { max-height: 150px; font-size: 10px; }

  /* Gauge compact */
  .gauge { width: 50px; height: 50px; }
  .gauge .gauge-value { font-size: 10px; }

  /* Chart compact */
  .chart-container canvas { max-height: 140px; }
}

/* ---------- Very Small Mobile (< 360px) ---------- */
@media (max-width: 360px) {
  .sidebar { width: 220px; }
  .content { padding: 8px; }
  .stats-grid { gap: 8px; }
  .card { padding: 12px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .stat-value { font-size: 18px; }
  .modal { margin: 4px; width: calc(100% - 8px); }
  .modal-header h3 { font-size: 13px; }
  .header-title { font-size: 12px; }
  .login-body { padding: 4px 12px 16px; }
  .login-footer { padding: 0 12px 12px; }
}

/* ---------- Accessibility: Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Modal Large ---------- */
.modal-lg { max-width: 800px; }
@media (max-width: 768px) { .modal-lg { max-width: none; } }

/* Report mini stat cards */
.stat-card-mini {
  padding: 12px;
  background: var(--bg-elevated);
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-card-mini .stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}
.stat-card-mini .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
