/* ─── Artha - Smart Finance Agent Stylesheet ─────────────────────────────── */

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --secondary: #10b981;
  --secondary-light: #34d399;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --bg: #0b0f1a;
  --bg-card: #161e2e;
  --bg-card2: #1f2937;
  --bg-surface: rgba(31, 41, 55, 0.7);
  --text: #f9fafb;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  --sidebar-w: 260px;
  
  /* Premium Tokens */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  --glass: blur(12px) saturate(180%);
  --radius-lg: 20px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

html, body {
  width: 100%;
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
  min-height: 100vh;
}

html[dir="rtl"] body {
  font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-card);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.global-mobile-nav-toggle,
.sidebar-close,
.sidebar-overlay {
  display: none;
}

.global-mobile-nav-toggle {
  position: fixed;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 220;
  width: 50px;
  height: 50px;
  border-radius: 16px;
  border: 1px solid rgba(129, 140, 248, 0.16);
  background: linear-gradient(180deg, rgba(22, 30, 46, 0.94), rgba(15, 23, 42, 0.98));
  color: var(--text);
  box-shadow: 0 12px 24px rgba(2, 6, 23, 0.34);
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.global-mobile-nav-toggle:hover,
.global-mobile-nav-toggle:active {
  transform: translateY(-1px);
  box-shadow: 0 16px 28px rgba(2, 6, 23, 0.42);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 1));
}

.sidebar-close {
  margin-left: auto;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(31, 41, 55, 0.88);
  color: var(--text);
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.68);
  z-index: 180;
}

.sidebar-brand {
  padding: 2rem 1.5rem;
  display: flex; align-items: center; gap: 12px;
}
.sidebar-brand .logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.sidebar-brand span {
  font-size: 1.15rem; font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.02em;
}

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  cursor: pointer;
  border: none; background: transparent; width: 100%;
  position: relative;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}
.nav-item.active {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-light);
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 20%; bottom: 20%;
  width: 3px;
  background: var(--primary);
  border-radius: 0 4px 4px 0;
}
.nav-item .icon { font-size: 1.25rem; width: 24px; text-align: center; }

.sidebar-footer {
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border);
}
.user-info {
  display: flex; align-items: center; gap: 12px;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--bg-card2);
  border: 1px solid var(--border);
}
.user-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: white; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.user-name { font-size: 0.85rem; font-weight: 600; color: var(--text); }
.user-currency { font-size: 0.75rem; color: var(--text-muted); }

/* ─── Main Content ────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  max-width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  padding: 1.5rem 2rem;
  overflow-x: clip;
}

html[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--border);
}

html[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-w);
}

html[dir="rtl"] .nav-item.active::before {
  left: auto;
  right: 0;
  border-radius: 4px 0 0 4px;
}

html[dir="rtl"] .sidebar-brand,
html[dir="rtl"] .nav-item,
html[dir="rtl"] .user-info,
html[dir="rtl"] .page-header,
html[dir="rtl"] .topbar,
html[dir="rtl"] .table-header,
html[dir="rtl"] .modal-header,
html[dir="rtl"] .modal-footer {
  direction: rtl;
}

html[dir="rtl"] .page-title,
html[dir="rtl"] .page-subtitle,
html[dir="rtl"] .card-title,
html[dir="rtl"] .card-sub,
html[dir="rtl"] .chart-title,
html[dir="rtl"] .form-label,
html[dir="rtl"] .asset-name,
html[dir="rtl"] .asset-symbol,
html[dir="rtl"] .sub-name,
html[dir="rtl"] .sub-meta,
html[dir="rtl"] .table-title,
html[dir="rtl"] th,
html[dir="rtl"] td {
  text-align: right;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap; gap: 1rem;
}
.page-title { font-size: 1.5rem; font-weight: 700; }
.page-subtitle { font-size: 0.875rem; color: var(--text-muted); margin-top: 2px; }

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-title {
  font-size: 0.75rem; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 0.75rem;
}
.card-value {
  font-size: 1.85rem; font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: var(--text);
}
.card-sub { font-size: 0.85rem; color: var(--text-dim); margin-top: 8px; font-weight: 500; }
.card-icon {
  font-size: 1.5rem;
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-light);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1.25rem;
  box-shadow: var(--shadow);
}
.stat-card .left { flex: 1; }
.stat-card .card-value { font-size: 1.6rem; }

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.metric-card .card-value {
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.metric-card::after {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 4px;
}
.metric-card.income::after { background: linear-gradient(90deg, var(--secondary), var(--secondary-light)); }
.metric-card.expense::after { background: linear-gradient(90deg, var(--danger), #ff6b6b); }
.metric-card.cash::after { background: linear-gradient(90deg, #14b8a6, #2dd4bf); }
.metric-card.portfolio::after { background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.metric-card.total-assets::after { background: linear-gradient(90deg, #38bdf8, #818cf8); }
.metric-card.subscription::after { background: linear-gradient(90deg, var(--warning), #fbbf24); }

/* ─── Grid Layouts ────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stats-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.finance-stats { margin-top: 1rem; }
.charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  align-items: start;
}
.content-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.charts-grid > *,
.content-grid > *,
.two-col > *,
.three-col > * { min-width: 0; }

/* ─── Charts ──────────────────────────────────────────────────────────────── */
.chart-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
}
.dashboard-chart { min-height: 360px; display: flex; flex-direction: column; }
.chart-canvas { position: relative; height: 280px; }
.chart-empty {
  flex: 1;
  min-height: 280px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}
.chart-title {
  font-size: 0.875rem; font-weight: 600;
  margin-bottom: 1rem; color: var(--text-muted);
}
canvas { display: block; max-width: 100%; }
#chart-allocation {
  width: 100% !important;
  height: 320px !important;
}

/* ─── Tables ──────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-header {
  padding: 1.25rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap; gap: 1rem;
}
.table-title { font-size: 1rem; font-weight: 700; color: var(--text); }

table {
  width: 100%; border-collapse: collapse;
}
th {
  padding: 1rem 1.5rem;
  font-size: 0.7rem; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(255, 255, 255, 0.02);
  text-align: left;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 1.15rem 1.5rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255, 255, 255, 0.02); }

/* ─── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.02em;
}
.badge-income { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.badge-expense { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.badge-transfer { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.badge-success { background: rgba(16, 185, 129, 0.12); color: #34d399; }
.badge-danger { background: rgba(239, 68, 68, 0.12); color: #f87171; }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: #fbbf24; }
.badge-info { background: rgba(59, 130, 246, 0.12); color: #60a5fa; }
.badge-primary { background: rgba(99, 102, 241, 0.12); color: #818cf8; }
.badge-secondary { background: rgba(156, 163, 175, 0.12); color: #9ca3af; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  font-family: inherit;
}
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { 
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); 
  color: white;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover:not(:disabled) { 
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary { 
  background: var(--bg-card2); 
  color: var(--text); 
  border: 1px solid var(--border); 
}
.btn-secondary:hover:not(:disabled) { background: var(--border); border-color: var(--text-dim); }

.btn-success { background: var(--secondary); color: white; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.2); }
.btn-danger { background: var(--danger); color: white; box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-sm { padding: 0.45rem 0.9rem; font-size: 0.8rem; border-radius: var(--radius-sm); }
.btn-icon { padding: 0.5rem; border-radius: var(--radius-sm); width: 36px; height: 36px; }
.btn-ghost { background: transparent; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, 0.05); color: var(--text); }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; }
.form-control, .form-select {
  width: 100%;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
  color: var(--text);
  font-size: 0.875rem;
  transition: border-color 0.2s;
  outline: none;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--text-muted); }
.form-select option { background: var(--bg-card); color: var(--text); }
textarea.form-control { resize: vertical; min-height: 80px; }
.input-group {
  display: flex; gap: 8px;
}
.input-group .form-control { flex: 1; }
.input-addon {
  background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 0.75rem;
  display: flex; align-items: center;
  color: var(--text-muted); font-size: 0.875rem;
}

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; visibility: hidden;
  transition: all 0.2s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.5rem;
  transform: translateY(-20px);
  transition: transform 0.2s;
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close {
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; font-size: 1.25rem; line-height: 1;
  padding: 4px; border-radius: 6px;
  transition: color 0.2s;
}
.modal-close:hover { color: var(--text); }
.modal-footer {
  display: flex; gap: 0.75rem; justify-content: flex-end;
  margin-top: 1.25rem; padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ─── Auth Page ───────────────────────────────────────────────────────────── */
.auth-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.1), transparent),
              radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent),
              var(--bg);
  padding: 1.5rem;
}
.auth-box {
  background: var(--bg-card);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 2.5rem;
  width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  text-align: center; margin-bottom: 2rem;
}
.auth-logo .icon {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 32px; margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.25);
}
.auth-logo h1 {
  font-size: 1.75rem; font-weight: 800;
  background: linear-gradient(135deg, #fff, var(--primary-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}
.auth-logo p { font-size: 0.9rem; color: var(--text-dim); }
.auth-tabs {
  display: flex; background: var(--bg-card2);
  border-radius: 14px; padding: 5px;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}
.auth-tab {
  flex: 1; padding: 0.75rem; border-radius: 10px;
  text-align: center; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; color: var(--text-dim);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); border: none; background: none;
}
.auth-tab.active { background: var(--primary); color: white; box-shadow: var(--shadow); }

/* ─── Portfolio Cards ─────────────────────────────────────────────────────── */
.asset-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  transition: border-color 0.2s, transform 0.2s;
}
.asset-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.asset-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 1rem;
}
.asset-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
}
.asset-name { font-weight: 600; font-size: 0.95rem; }
.asset-symbol { font-size: 0.75rem; color: var(--text-muted); }
.asset-values { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.asset-val-label { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 2px; }
.asset-val { font-size: 0.9rem; font-weight: 600; }
.pnl-positive { color: var(--secondary); }
.pnl-negative { color: var(--danger); }
.pnl-bar {
  height: 4px; border-radius: 2px;
  background: var(--border); overflow: hidden; margin-top: 0.5rem;
}
.pnl-bar-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.5s ease;
}

/* ─── Subscription Card ───────────────────────────────────────────────────── */
.sub-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.sub-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: rgba(99, 102, 241, 0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.sub-info { flex: 1; min-width: 0; }
.sub-name { font-weight: 600; font-size: 0.9rem; }
.sub-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.sub-amount { text-align: right; }
.sub-amount .amount { font-weight: 700; }
.sub-amount .cycle { font-size: 0.7rem; color: var(--text-muted); }

/* ─── AI Page ─────────────────────────────────────────────────────────────── */
.ai-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
.upload-area {
  border: 2px dashed var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.upload-text { font-size: 0.9rem; color: var(--text-muted); }
.ai-result {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  font-size: 0.85rem;
}
.ai-result-item { display: flex; justify-content: space-between; padding: 0.35rem 0; }
.ai-result-label { color: var(--text-muted); }
.ai-result-value { font-weight: 600; }

/* ─── Progress ────────────────────────────────────────────────────────────── */
.progress-bar-wrapper {
  background: var(--bg-card2);
  border-radius: 10px; height: 8px; overflow: hidden; margin-top: 0.5rem;
}
.progress-bar-fill {
  height: 100%; border-radius: 10px;
  transition: width 0.8s ease;
}

/* ─── Topbar ──────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.topbar-left h2 { font-size: 1.3rem; font-weight: 700; }
.topbar-left p { font-size: 0.8rem; color: var(--text-muted); }
.topbar-actions { margin-left: auto; }

/* ─── Loading ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton {
  background: linear-gradient(90deg, var(--bg-card2) 25%, var(--border) 50%, var(--bg-card2) 75%);
  background-size: 200% 100%;
  animation: skeleton 1.5s infinite;
  border-radius: 8px;
}
@keyframes skeleton { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ─── Upcoming ────────────────────────────────────────────────────────────── */
.upcoming-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}
.upcoming-item:last-child { border-bottom: none; }

/* ─── Filters ─────────────────────────────────────────────────────────────── */
.filter-bar {
  display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center;
}
.filter-btn {
  padding: 0.4rem 0.9rem;
  border-radius: 20px;
  font-size: 0.8rem; font-weight: 500;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
}
.filter-btn:hover, .filter-btn.active {
  background: rgba(99, 102, 241, 0.2);
  border-color: var(--primary);
  color: var(--primary);
}

/* ─── Pager ───────────────────────────────────────────────────────────────── */
.pagination {
  display: flex; gap: 4px; align-items: center; justify-content: center;
  padding: 1rem;
}
.page-btn {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  background: var(--bg-card2);
  border: 1px solid var(--border);
  color: var(--text);
  transition: all 0.2s;
}
.page-btn:hover, .page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ─── Empty State ─────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 1rem;
}
.empty-state .icon { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.85rem; color: var(--text-muted); }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body.sidebar-open {
    overflow: hidden;
  }
  body.sidebar-open .global-mobile-nav-toggle {
    display: none !important;
  }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; width: 100%; max-width: 100%; padding: 4.85rem 1rem 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .content-grid, .two-col { grid-template-columns: 1fr; }
  .ai-container { grid-template-columns: 1fr; }
  .topbar-actions { margin-left: 0; width: 100%; }
  .chart-canvas, .chart-empty { min-height: 240px; height: 240px; }
  .global-mobile-nav-toggle,
  .sidebar-close,
  .sidebar-overlay.open {
    display: flex !important;
  }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr; }
  .three-col { grid-template-columns: 1fr; }
  #chart-allocation { height: 240px !important; }
  .topbar-actions .btn { flex: 1; }
}

/* ─── Toasts ─────────────────────────────────────────────────────────────── */
.toast-container {
  position: fixed; top: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.75rem;
  z-index: 10000;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex; align-items: center; gap: 12px;
  min-width: 250px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--glass);
  -webkit-backdrop-filter: var(--glass);
  animation: toastIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}
.toast-icon { font-size: 1.1rem; }
.toast-message { font-size: 0.875rem; font-weight: 500; }
.toast-success { border-left: 4px solid var(--secondary); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast.fade-out { opacity: 0; transform: translateX(20px); transition: all 0.4s; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.text-success { color: var(--secondary-light) !important; }
.text-danger { color: #ff6b6b !important; }
.text-muted { color: var(--text-dim) !important; }
.text-dim { color: var(--text-dim) !important; }
.text-primary { color: var(--primary-light) !important; }
.text-warning { color: var(--warning) !important; }
.fw-bold { font-weight: 800; }
.fw-semibold { font-weight: 600; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1.25rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 900px) {
  html[dir="rtl"] .main-content {
    margin-right: 0;
  }
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }
  html[dir="rtl"] .sidebar.open {
    transform: translateX(0);
  }
  html[dir="rtl"] .global-mobile-nav-toggle {
    left: auto;
    right: 1rem;
  }
  html[dir="rtl"] .sidebar-close {
    margin-left: 0;
    margin-right: auto;
  }
}
