/* ═══════════════════════════════════════════════════════════════
   Quantum AI — Enterprise Theme v3
   Premium dark-sidebar glassmorphism design system
   Professional, information-dense, highly functional
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ─ Brand ─ */
  --brand-primary: #6366f1;
  --brand-primary-hover: #4f46e5;
  --brand-primary-light: #eef2ff;
  --brand-primary-rgb: 99, 102, 241;
  --brand-secondary: #8b5cf6;
  --brand-secondary-hover: #7c3aed;
  --brand-accent: #06b6d4;

  /* ─ Surfaces ─ */
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #0b0e1a;
  --bg-sidebar-hover: rgba(255,255,255,0.05);
  --bg-sidebar-active: rgba(99, 102, 241, 0.14);
  --bg-input: #ffffff;
  --bg-overlay: rgba(15, 23, 42, 0.65);
  --bg-subtle: #f8fafc;
  --bg-raised: #ffffff;

  /* ─ Text ─ */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;
  --text-sidebar: rgba(255,255,255,0.50);
  --text-sidebar-active: #ffffff;

  /* ─ Borders ─ */
  --border-color: #e2e8f0;
  --border-light: #f1f5f9;
  --border-focus: var(--brand-primary);
  --border-radius: 10px;
  --border-radius-lg: 14px;
  --border-radius-xl: 20px;

  /* ─ Status ─ */
  --color-success: #10b981;
  --color-success-light: #ecfdf5;
  --color-warning: #f59e0b;
  --color-warning-light: #fffbeb;
  --color-danger: #ef4444;
  --color-danger-light: #fef2f2;
  --color-info: #3b82f6;
  --color-info-light: #eff6ff;

  /* ─ Shadows ─ */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.03);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04), 0 1px 3px rgba(0,0,0,0.03);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.06), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.1), 0 4px 12px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.12);
  --shadow-glow: 0 0 24px rgba(99,102,241,0.12);
  --shadow-card: 0 1px 3px rgba(0,0,0,0.04), 0 0 0 1px rgba(0,0,0,0.02);
  --shadow-card-hover: 0 8px 24px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);

  /* ─ Layout ─ */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --header-height: 56px;

  /* ─ Transitions ─ */
  --transition-fast: 120ms ease;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ════════════════════════════════════════════════════
   RESET & BASE
   ════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--brand-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--brand-primary-hover); }
img { max-width: 100%; display: block; }
::selection { background: rgba(var(--brand-primary-rgb), 0.15); color: var(--text-primary); }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.10); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.18); }
.app-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); }
.app-sidebar::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }

/* ════════════════════════════════════════════════════
   TYPOGRAPHY
   ════════════════════════════════════════════════════ */
h1, h2, h3, h4, h5, h6 { font-weight: 600; line-height: 1.3; color: var(--text-primary); letter-spacing: -0.02em; }
h1 { font-size: 1.65rem; font-weight: 700; }
h2 { font-size: 1.35rem; font-weight: 700; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-danger { color: var(--color-danger); }

/* ════════════════════════════════════════════════════
   LAYOUT — App Shell
   ════════════════════════════════════════════════════ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── SIDEBAR ─────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  background-image: linear-gradient(180deg, rgba(99,102,241,0.03) 0%, transparent 40%);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: width var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.app-sidebar.collapsed { width: var(--sidebar-collapsed); }

/* ── MAIN AREA ───────────────────────────────────── */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

.app-sidebar.collapsed ~ .app-main { margin-left: var(--sidebar-collapsed); }

/* ── HEADER ──────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  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;
}

/* ── CONTENT ─────────────────────────────────────── */
.app-content {
  flex: 1;
  padding: 24px;
  max-width: 1440px;
}

/* ════════════════════════════════════════════════════
   SIDEBAR — Components
   ════════════════════════════════════════════════════ */
.sidebar-brand {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  min-height: 56px;
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: contain;
}

.sidebar-brand-name {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-inverse);
  white-space: nowrap;
  overflow: hidden;
  letter-spacing: -0.01em;
}

.sidebar-logo-default {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(var(--brand-primary-rgb), 0.4);
  flex-shrink: 0;
}

.collapsed .sidebar-brand-name { display: none; }

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
}

.nav-section-label {
  font-size: 0.64rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.22);
  padding: 18px 12px 6px;
  font-weight: 700;
}

.collapsed .nav-section-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-sidebar);
  cursor: pointer;
  transition: all 150ms ease;
  margin-bottom: 1px;
  font-size: 0.86rem;
  white-space: nowrap;
  position: relative;
  font-weight: 400;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: rgba(255,255,255,0.82);
}

.nav-item.active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--brand-primary);
  border-radius: 0 4px 4px 0;
}

.nav-item .nav-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-item .nav-label { overflow: hidden; }
.collapsed .nav-label { display: none; }

.nav-item .nav-badge {
  margin-left: auto;
  background: var(--brand-primary);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.collapsed .nav-badge { display: none; }

.sidebar-footer {
  padding: 10px;
  border-top: 1px solid rgba(255,255,255,0.05);
}

.sidebar-footer .nav-item { color: rgba(255,255,255,0.35); }
.sidebar-footer .nav-item:hover { color: rgba(255,255,255,0.7); background: rgba(239,68,68,0.08); }

/* ════════════════════════════════════════════════════
   CARDS
   ════════════════════════════════════════════════════ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-card-hover);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h4 { font-size: 0.92rem; font-weight: 600; }

.card-body { padding: 20px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  background: var(--bg-subtle);
  border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* ════════════════════════════════════════════════════
   STAT / KPI CARDS
   ════════════════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--brand-primary-rgb), 0.03), transparent 70%);
  transform: translate(30%, -30%);
  pointer-events: none;
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}

.stat-icon.primary { background: var(--brand-primary-light); color: var(--brand-primary); }
.stat-icon.success { background: var(--color-success-light); color: var(--color-success); }
.stat-icon.warning { background: var(--color-warning-light); color: var(--color-warning); }
.stat-icon.danger  { background: var(--color-danger-light);  color: var(--color-danger);  }
.stat-icon.info    { background: var(--color-info-light);    color: var(--color-info);    }

.stat-info { flex: 1; min-width: 0; }

.stat-label {
  font-size: 0.76rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-change {
  font-size: 0.72rem;
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 100px;
  font-weight: 600;
}

.stat-change.up { color: var(--color-success); background: var(--color-success-light); }
.stat-change.down { color: var(--color-danger); background: var(--color-danger-light); }

/* ════════════════════════════════════════════════════
   BUTTONS
   ════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0;
  line-height: 1.4;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(var(--brand-primary-rgb), 0.25);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(var(--brand-primary-rgb), 0.35);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(var(--brand-primary-rgb), 0.2);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
  box-shadow: 0 2px 6px rgba(239,68,68,0.2);
}

.btn-danger:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-success {
  background: var(--color-success);
  color: #fff;
  border-color: var(--color-success);
  box-shadow: 0 2px 6px rgba(16,185,129,0.2);
}

.btn-success:hover:not(:disabled) { filter: brightness(1.1); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 6px 10px;
}

.btn-ghost:hover { color: var(--text-primary); background: var(--bg-subtle); border-radius: 8px; }

.btn-outline-primary {
  background: transparent;
  color: var(--brand-primary);
  border: 1.5px solid var(--brand-primary);
}

.btn-outline-primary:hover:not(:disabled) {
  background: var(--brand-primary-light);
}

.btn-sm { padding: 5px 12px; font-size: 0.78rem; border-radius: 7px; }
.btn-lg { padding: 11px 24px; font-size: 0.92rem; border-radius: 10px; }
.btn-icon { padding: 7px; }
.btn-group { display: flex; gap: 8px; }

/* ════════════════════════════════════════════════════
   FORM CONTROLS
   ════════════════════════════════════════════════════ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
  letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.86rem;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-input);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.08);
}

.form-input::placeholder { color: var(--text-muted); }
.form-textarea { min-height: 90px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 0.72rem; color: var(--color-danger); margin-top: 4px; }

/* ════════════════════════════════════════════════════
   DATA TABLES
   ════════════════════════════════════════════════════ */
.data-table-wrap {
  overflow-x: auto;
  border-radius: var(--border-radius-lg);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.data-table th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 16px;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 100ms ease;
}

.data-table tbody tr:hover {
  background: rgba(var(--brand-primary-rgb), 0.02);
}

.data-table tbody tr:last-child td { border-bottom: none; }

/* Alternating rows for density */
.data-table.striped tbody tr:nth-child(even) { background: var(--bg-subtle); }
.data-table.striped tbody tr:nth-child(even):hover { background: rgba(var(--brand-primary-rgb), 0.04); }

.table-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

/* ════════════════════════════════════════════════════
   PAGINATION
   ════════════════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.pagination-controls { display: flex; align-items: center; gap: 3px; }

.pagination-btn {
  padding: 5px 10px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.78rem;
  transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text-primary); }
.pagination-btn.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.pagination-btn:disabled { opacity: 0.35; cursor: default; }

/* ════════════════════════════════════════════════════
   BADGES
   ════════════════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.015em;
}

.badge-primary { background: var(--brand-primary-light); color: var(--brand-primary); }
.badge-success { background: var(--color-success-light); color: #059669; }
.badge-warning { background: var(--color-warning-light); color: #d97706; }
.badge-danger  { background: var(--color-danger-light);  color: #dc2626; }
.badge-info    { background: var(--color-info-light);    color: #2563eb; }
.badge-muted   { background: var(--bg-subtle); color: var(--text-muted); }

/* Dot badges */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* ════════════════════════════════════════════════════
   MODAL
   ════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition);
}

.modal-overlay.open { opacity: 1; visibility: visible; }

.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-xl);
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(12px) scale(0.97);
  transition: transform var(--transition);
  border: 1px solid var(--border-color);
}

.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 { font-size: 1.05rem; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modal-close:hover { background: var(--bg-subtle); color: var(--text-primary); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-subtle);
  border-radius: 0 0 var(--border-radius-xl) var(--border-radius-xl);
}

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }

/* ════════════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  margin-bottom: 20px;
}

.tab-btn {
  padding: 9px 16px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

/* ════════════════════════════════════════════════════
   TOAST / NOTIFICATIONS
   ════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 280px;
  max-width: 400px;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.84rem;
}

.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error   { border-left: 3px solid var(--color-danger); }
.toast.toast-warning { border-left: 3px solid var(--color-warning); }
.toast.toast-info    { border-left: 3px solid var(--color-info); }

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px;
  font-size: 0.85rem;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ════════════════════════════════════════════════════
   EMPTY STATE
   ════════════════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 2.8rem;
  margin-bottom: 16px;
  opacity: 0.25;
  filter: grayscale(1);
}

.empty-state h3 { color: var(--text-primary); margin-bottom: 6px; font-size: 1.05rem; }
.empty-state p { max-width: 360px; margin: 0 auto 20px; font-size: 0.84rem; color: var(--text-secondary); }

/* ════════════════════════════════════════════════════
   LOADING / SPINNER / SKELETON
   ════════════════════════════════════════════════════ */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--brand-primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-lg { width: 32px; height: 32px; border-width: 3px; }

.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 56px 20px;
  flex-direction: column;
  gap: 12px;
  color: var(--text-muted);
  font-size: 0.82rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8ecf1 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 6px;
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ════════════════════════════════════════════════════
   SEARCH
   ════════════════════════════════════════════════════ */
.search-box { position: relative; }

.search-box .search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 0.85rem;
}

.search-box .form-input {
  padding-left: 36px;
  background: var(--bg-subtle);
  border-color: transparent;
  border-radius: 8px;
}

.search-box .form-input:focus {
  background: var(--bg-card);
  border-color: var(--brand-primary);
}

/* ════════════════════════════════════════════════════
   DROPDOWN
   ════════════════════════════════════════════════════ */
.dropdown { position: relative; display: inline-block; }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all var(--transition);
  padding: 4px;
}

.dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown-item {
  padding: 7px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
  border-radius: 6px;
}

.dropdown-item:hover { background: var(--bg-subtle); color: var(--text-primary); }
.dropdown-divider { border-top: 1px solid var(--border-light); margin: 4px 0; }

/* ════════════════════════════════════════════════════
   HEADER — Components
   ════════════════════════════════════════════════════ */
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-mobile-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 5px;
  border-radius: 7px;
  transition: all var(--transition-fast);
}

.header-mobile-btn:hover { background: var(--bg-subtle); color: var(--text-primary); }

.header-tenant {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 3px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.header-user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 3px;
  background: none;
  border: 1px solid transparent;
  border-radius: 40px;
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--text-secondary);
}

.header-user-btn:hover {
  background: var(--bg-subtle);
  border-color: var(--border-color);
}

.header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.header-user-info { display: flex; flex-direction: column; text-align: left; }
.header-user-name { font-size: 0.82rem; font-weight: 500; color: var(--text-primary); line-height: 1.2; }

/* ════════════════════════════════════════════════════
   VIEW HEADER / TOOLBAR
   ════════════════════════════════════════════════════ */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.view-title h2 { margin-bottom: 2px; font-size: 1.3rem; }
.view-title p { font-size: 0.82rem; color: var(--text-secondary); }

/* ════════════════════════════════════════════════════
   FILTERS BAR
   ════════════════════════════════════════════════════ */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 5px 14px;
  border: 1px solid var(--border-color);
  border-radius: 100px;
  font-size: 0.78rem;
  cursor: pointer;
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all 150ms ease;
  font-family: inherit;
  font-weight: 500;
}

.filter-chip:hover { border-color: var(--brand-primary); color: var(--brand-primary); }

.filter-chip.active {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(var(--brand-primary-rgb), 0.25);
  font-weight: 600;
}

/* ════════════════════════════════════════════════════
   PROGRESS BAR
   ════════════════════════════════════════════════════ */
.progress-bar {
  height: 5px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 3px;
  transition: width var(--transition-slow);
}

/* ════════════════════════════════════════════════════
   CHART CONTAINER
   ════════════════════════════════════════════════════ */
.chart-container { position: relative; width: 100%; height: 300px; }

/* ════════════════════════════════════════════════════
   TOGGLE SWITCH
   ════════════════════════════════════════════════════ */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 20px;
  transition: 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider { background: var(--brand-primary); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ════════════════════════════════════════════════════
   ALERT / INFO BOX
   ════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  font-size: 0.84rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
}

.alert-info    { background: var(--color-info-light);    color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: var(--color-success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--color-warning-light); color: #92400e; border: 1px solid #fde68a; }
.alert-danger  { background: var(--color-danger-light);  color: #991b1b; border: 1px solid #fecaca; }

/* ════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════ */
.mobile-menu-btn { display: none; }
.sidebar-overlay { display: none; }

@media (max-width: 1024px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    z-index: 200;
  }

  .app-sidebar.mobile-open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .mobile-menu-btn { display: flex; }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 150;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
  }

  .sidebar-overlay.show { opacity: 1; visibility: visible; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .modal { width: 95%; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .app-content { padding: 14px; }
  .app-header { padding: 0 14px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .btn-group { flex-wrap: wrap; }
  .card-body { padding: 14px; }
  .card-header { padding: 14px 16px; }
  .pagination { flex-direction: column; gap: 8px; }
  .search-box { display: none; }
  .header-tenant { display: none; }
  .header-user-info { display: none; }
  .view-title h2 { font-size: 1.1rem; }
  .stat-value { font-size: 1.25rem; }
  .tabs { overflow-x: auto; }
  .tab-btn { font-size: 0.78rem; padding: 8px 12px; }
}

@media (max-width: 420px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: #080b16;
  position: relative;
  overflow: hidden;
}

/* Ambient light effects */
.login-page::before {
  content: '';
  position: absolute;
  width: 800px;
  height: 800px;
  background: radial-gradient(circle, rgba(99,102,241,0.10), transparent 66%);
  top: -350px;
  right: -250px;
  pointer-events: none;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  background: radial-gradient(circle, rgba(139,92,246,0.07), transparent 66%);
  bottom: -250px;
  left: -200px;
  pointer-events: none;
}

.login-card {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(40px) saturate(150%);
  -webkit-backdrop-filter: blur(40px) saturate(150%);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 24px;
  box-shadow: 0 32px 80px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.04);
  width: 100%;
  max-width: 400px;
  padding: 40px 36px;
  position: relative;
  z-index: 1;
}

.login-card .form-label { color: rgba(255,255,255,0.55); font-size: 0.75rem; font-weight: 500; }

.login-card .form-input {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.88rem;
}

.login-card .form-input::placeholder { color: rgba(255,255,255,0.25); }

.login-card .form-input:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(var(--brand-primary-rgb), 0.12);
  background: rgba(255,255,255,0.07);
}

.login-card a { color: rgba(var(--brand-primary-rgb), 0.8); }
.login-card a:hover { color: var(--brand-primary); }

.login-card .btn-primary {
  width: 100%;
  padding: 11px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 10px;
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-brand h1 {
  font-size: 1.45rem;
  margin-bottom: 4px;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-brand p {
  color: rgba(255,255,255,0.35);
  font-size: 0.84rem;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.72rem;
  color: rgba(255,255,255,0.2);
}

.login-footer a { color: rgba(255,255,255,0.35); }
.login-footer a:hover { color: rgba(255,255,255,0.6); }

.login-error {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: var(--border-radius);
  font-size: 0.82rem;
  margin-bottom: 16px;
  display: none;
  border: 1px solid rgba(239, 68, 68, 0.15);
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 20px 0;
  color: rgba(255,255,255,0.25);
  font-size: 0.78rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.06);
}

/* ════════════════════════════════════════════════════
   UTILITIES
   ════════════════════════════════════════════════════ */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-20 { padding: 20px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.82rem; }
.text-base { font-size: 0.92rem; }
.text-lg { font-size: 1.1rem; }
.rounded { border-radius: var(--border-radius); }
.rounded-lg { border-radius: var(--border-radius-lg); }
.border { border: 1px solid var(--border-color); }
.overflow-hidden { overflow: hidden; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.opacity-50 { opacity: 0.5; }
.opacity-75 { opacity: 0.75; }

/* ════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.animate-fade-in { animation: fadeIn 0.3s ease both; }
.animate-slide-up { animation: slideUp 0.35s ease both; }

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 50ms; }
.stagger > *:nth-child(3) { animation-delay: 100ms; }
.stagger > *:nth-child(4) { animation-delay: 150ms; }
.stagger > *:nth-child(5) { animation-delay: 200ms; }
.stagger > *:nth-child(6) { animation-delay: 250ms; }

/* ════════════════════════════════════════════════════
   PRINT
   ════════════════════════════════════════════════════ */
@media print {
  .app-sidebar, .app-header, .btn, .toast-container, .modal-overlay, .sidebar-overlay { display: none !important; }
  .app-main { margin-left: 0 !important; }
  .app-content { padding: 0 !important; max-width: 100% !important; }
  .card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  body { background: #fff; }
}
