/* ============================================
   BankSys Theme - Main Styles
   Supports RTL & LTR | Dark Fintech Theme
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  /* Brand palette */
  --brand-50:  #eef4ff;
  --brand-100: #d9e6ff;
  --brand-200: #bcd3ff;
  --brand-300: #8eb6ff;
  --brand-400: #598dff;
  --brand-500: #3366ff;
  --brand-600: #1f47f5;
  --brand-700: #1736e1;
  --brand-800: #1a2fb6;
  --brand-900: #1c2e8f;

  --accent-cyan:   #22d3ee;
  --accent-violet: #a855f7;
  --accent-emerald:#10b981;
  --accent-amber:  #f59e0b;
  --accent-rose:   #f43f5e;

  /* Surfaces (dark) */
  --bg-0: #070b18;
  --bg-1: #0c1226;
  --bg-2: #111a35;
  --bg-3: #18224a;
  --bg-glass: rgba(20, 30, 60, 0.55);
  --bg-glass-strong: rgba(20, 30, 60, 0.78);
  --border: rgba(120, 150, 220, 0.16);
  --border-strong: rgba(120, 150, 220, 0.32);

  /* Text */
  --text-1: #f2f6ff;
  --text-2: #b8c4e6;
  --text-3: #7a86b0;
  --text-muted: #5a6690;

  /* Status */
  --success: #10b981;
  --warning: #f59e0b;
  --danger:  #f43f5e;
  --info:    #3366ff;

  /* Gradients */
  --grad-brand: linear-gradient(135deg, #3366ff 0%, #a855f7 100%);
  --grad-cyan:  linear-gradient(135deg, #22d3ee 0%, #3366ff 100%);
  --grad-emerald: linear-gradient(135deg, #10b981 0%, #22d3ee 100%);
  --grad-amber: linear-gradient(135deg, #f59e0b 0%, #f43f5e 100%);
  --grad-rose:  linear-gradient(135deg, #f43f5e 0%, #a855f7 100%);
  --grad-bg:    radial-gradient(1200px 800px at 80% -10%, rgba(168,85,247,0.18), transparent 60%),
                radial-gradient(900px 700px at -10% 110%, rgba(51,102,255,0.18), transparent 60%),
                linear-gradient(180deg, #070b18 0%, #0c1226 100%);

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow:    0 8px 24px rgba(0,0,0,0.35);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.45);
  --shadow-glow: 0 0 40px rgba(51,102,255,0.35);

  /* Radii */
  --r-sm: 8px;
  --r:    14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --sidebar-w: 264px;
  --header-h: 72px;

  /* Fonts */
  --font-ar: 'Tajawal', 'Cairo', system-ui, sans-serif;
  --font-en: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --transition: 220ms cubic-bezier(.4,.0,.2,1);
  --transition-slow: 600ms cubic-bezier(.4,.0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-ar);
  background: var(--bg-0);
  color: var(--text-1);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

[dir="ltr"] body { font-family: var(--font-en); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
ul, ol { list-style: none; }

::selection { background: rgba(51,102,255,0.4); color: #fff; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,150,220,0.25); border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,150,220,0.45); background-clip: padding-box; }

/* ---------- Typography ---------- */
h1,h2,h3,h4,h5 { line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; }
.text-muted { color: var(--text-3); }
.text-grad { background: var(--grad-brand); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* ---------- Layout helpers ---------- */
.container { width: min(1200px, 100% - 2*var(--sp-6)); margin-inline: auto; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }
.grid { display: grid; }
.hidden { display: none !important; }
.text-center { text-align: center; }
.w-full { width: 100%; }
.relative { position: relative; }

/* ---------- Glass card ---------- */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.card {
  background: linear-gradient(180deg, rgba(24,34,74,0.6), rgba(12,18,38,0.6));
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  padding: 12px 22px;
  border-radius: var(--r-pill);
  font-weight: 600; font-size: 0.95rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  white-space: nowrap; user-select: none;
  position: relative; overflow: hidden;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 8px 24px rgba(51,102,255,0.35);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 12px 32px rgba(51,102,255,0.5); transform: translateY(-1px); }

.btn-ghost {
  background: rgba(120,150,220,0.08); color: var(--text-1);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: rgba(120,150,220,0.16); border-color: var(--border-strong); }

.btn-cyan { background: var(--grad-cyan); color: #06121f; box-shadow: 0 8px 24px rgba(34,211,238,0.3); }
.btn-cyan:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 12px 32px rgba(34,211,238,0.45); }

.btn-emerald { background: var(--grad-emerald); color: #051a14; box-shadow: 0 8px 24px rgba(16,185,129,0.3); }
.btn-emerald:hover:not(:disabled) { transform: translateY(-1px); }

.btn-lg { padding: 16px 32px; font-size: 1.05rem; }
.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-block { width: 100%; }

/* shine sweep on hover */
.btn-primary::after, .btn-cyan::after, .btn-emerald::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255,255,255,0.25) 50%, transparent 70%);
  transform: translateX(-120%);
  transition: transform 700ms ease;
}
.btn-primary:hover::after, .btn-cyan:hover::after, .btn-emerald:hover::after { transform: translateX(120%); }

/* ---------- Inputs ---------- */
.field { display: flex; flex-direction: column; gap: var(--sp-2); }
.label { font-size: 0.85rem; color: var(--text-2); font-weight: 500; }
.input, .select {
  width: 100%; padding: 14px 16px;
  background: rgba(7,11,24,0.6);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-1); font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}
.input::placeholder { color: var(--text-muted); }
.input:focus, .select:focus {
  outline: none; border-color: var(--brand-400);
  box-shadow: 0 0 0 4px rgba(51,102,255,0.18);
  background: rgba(7,11,24,0.85);
}
.input-icon { position: relative; }
.input-icon .icon {
  position: absolute; top: 50%; transform: translateY(-50%);
  inset-inline-start: 14px; color: var(--text-3); pointer-events: none;
  display: grid; place-items: center; width: 22px; height: 22px;
}
.input-icon .input { padding-inline-start: 46px; }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: 0.78rem; font-weight: 600;
  background: rgba(120,150,220,0.12); border: 1px solid var(--border);
  color: var(--text-2);
}
.badge-success { background: rgba(16,185,129,0.15); border-color: rgba(16,185,129,0.4); color: #34d399; }
.badge-warning { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.4); color: #fbbf24; }
.badge-danger  { background: rgba(244,63,94,0.15); border-color: rgba(244,63,94,0.4); color: #fb7185; }
.badge-info    { background: rgba(51,102,255,0.15); border-color: rgba(51,102,255,0.4); color: #7c9cff; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ---------- Login page ---------- */
.auth {
  min-height: 100vh; display: grid; place-items: center;
  background: var(--grad-bg); position: relative; overflow: hidden;
  padding: var(--sp-6);
}
#particles { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.auth-card {
  position: relative; z-index: 2;
  width: min(440px, 100%);
  padding: var(--sp-10);
  border-radius: var(--r-xl);
}
.auth-logo {
  display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-8);
}
.auth-logo .logo-mark {
  width: 48px; height: 48px; border-radius: 14px;
  background: var(--grad-brand); display: grid; place-items: center;
  box-shadow: var(--shadow-glow);
}
.auth-logo .logo-mark svg { width: 26px; height: 26px; color: #fff; }
.auth-title { margin-bottom: var(--sp-2); }
.auth-sub { color: var(--text-3); margin-bottom: var(--sp-8); font-size: 0.95rem; }
.auth-foot { margin-top: var(--sp-6); text-align: center; color: var(--text-3); font-size: 0.85rem; }

/* ---------- App shell (dashboard) ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  background: var(--grad-bg);
}
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: rgba(7,11,24,0.7);
  backdrop-filter: blur(18px);
  border-inline-end: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: var(--sp-6);
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); margin-bottom: var(--sp-8); }
.brand .logo-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: var(--grad-brand); display: grid; place-items: center;
  box-shadow: var(--shadow-glow);
}
.brand .logo-mark svg { width: 22px; height: 22px; color: #fff; }
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-sub { font-size: 0.72rem; color: var(--text-3); }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-section-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); padding: var(--sp-4) var(--sp-3) var(--sp-2); }
.nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 11px 14px; border-radius: var(--r);
  color: var(--text-2); font-weight: 500; font-size: 0.92rem;
  transition: background var(--transition), color var(--transition);
  position: relative;
}
.nav-item:hover { background: rgba(120,150,220,0.08); color: var(--text-1); }
.nav-item.active { background: rgba(51,102,255,0.16); color: #fff; }
.nav-item.active::before {
  content: ""; position: absolute; inset-inline-start: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 999px; background: var(--grad-brand);
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item .nav-badge { margin-inline-start: auto; }

.sidebar-foot { padding-top: var(--sp-4); border-top: 1px solid var(--border); }
.user-mini { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad-cyan); display: grid; place-items: center;
  font-weight: 700; color: #06121f; flex-shrink: 0;
}
.user-name { font-size: 0.88rem; font-weight: 600; }
.user-role { font-size: 0.74rem; color: var(--text-3); }

/* ---------- Main area ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--sp-4);
  padding: 0 var(--sp-6);
  background: rgba(7,11,24,0.6);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.topbar .page-title { font-size: 1.1rem; font-weight: 700; }
.topbar .page-sub { font-size: 0.8rem; color: var(--text-3); }
.topbar-spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; color: var(--text-2);
  background: rgba(120,150,220,0.06); border: 1px solid var(--border);
  transition: all var(--transition);
}
.icon-btn:hover { background: rgba(120,150,220,0.14); color: var(--text-1); }
.icon-btn svg { width: 20px; height: 20px; }

.content { padding: var(--sp-6); flex: 1; min-width: 0; }
.content-inner { width: min(1100px, 100%); margin-inline: auto; }

/* ---------- Stepper ---------- */
.stepper {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-6);
  margin-bottom: var(--sp-6);
  overflow-x: auto;
}
.step {
  display: flex; align-items: center; gap: var(--sp-3); flex-shrink: 0;
}
.step-num {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 0.9rem;
  background: rgba(120,150,220,0.1); border: 1px solid var(--border);
  color: var(--text-3); transition: all var(--transition-slow);
}
.step-label { font-size: 0.85rem; color: var(--text-3); font-weight: 500; white-space: nowrap; }
.step.active .step-num { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: var(--shadow-glow); }
.step.active .step-label { color: var(--text-1); }
.step.done .step-num { background: var(--grad-emerald); color: #051a14; border-color: transparent; }
.step.done .step-label { color: var(--text-2); }
.step-line { flex: 1; height: 2px; min-width: 28px; background: var(--border); border-radius: 999px; position: relative; overflow: hidden; }
.step-line.done { background: var(--grad-emerald); }
.step-line.active::after {
  content: ""; position: absolute; inset: 0;
  background: var(--grad-brand);
  animation: lineFill 1.2s ease forwards;
}

/* ---------- Panels (step content) ---------- */
.panel { display: none; animation: fadeUp 500ms ease both; }
.panel.active { display: block; }
.panel-head { margin-bottom: var(--sp-6); }
.panel-head h2 { margin-bottom: var(--sp-2); }
.panel-head p { color: var(--text-3); }

/* ---------- AI processing overlay ---------- */
.ai-processing {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--sp-12) var(--sp-6);
  min-height: 320px;
}
.ai-orb {
  width: 120px; height: 120px; position: relative; margin-bottom: var(--sp-6);
  display: grid; place-items: center;
}
.ai-orb-core {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--grad-brand);
  box-shadow: 0 0 40px rgba(51,102,255,0.7), 0 0 80px rgba(168,85,247,0.4);
  animation: orbPulse 2s ease-in-out infinite;
}
.ai-orb-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid transparent;
}
.ai-orb-ring.r1 { border-top-color: var(--brand-400); animation: spin 2.2s linear infinite; }
.ai-orb-ring.r2 { inset: 12px; border-inline-end-color: var(--accent-violet); animation: spin 1.6s linear infinite reverse; }
.ai-orb-ring.r3 { inset: 24px; border-bottom-color: var(--accent-cyan); animation: spin 1.1s linear infinite; }

.ai-title { font-size: 1.15rem; font-weight: 700; margin-bottom: var(--sp-2); }
.ai-status { color: var(--text-2); font-size: 0.95rem; min-height: 1.4em; }
.ai-status .cursor { display: inline-block; width: 8px; height: 1em; background: var(--brand-400); margin-inline-start: 2px; animation: blink 1s steps(2) infinite; vertical-align: text-bottom; }
.ai-progress {
  width: min(360px, 80vw); height: 6px; border-radius: 999px;
  background: rgba(120,150,220,0.15); margin-top: var(--sp-6); overflow: hidden;
}
.ai-progress-bar { height: 100%; width: 0%; background: var(--grad-brand); border-radius: 999px; transition: width 400ms ease; }
.ai-steps-log {
  margin-top: var(--sp-6); width: min(480px, 90vw);
  text-align: start; font-family: var(--font-mono); font-size: 0.8rem;
  color: var(--text-3); max-height: 140px; overflow: hidden;
}
.ai-steps-log .log-line { padding: 2px 0; opacity: 0; animation: fadeUp 300ms ease forwards; }
.ai-steps-log .log-line .ok { color: var(--success); }
.ai-steps-log .log-line .arr { color: var(--brand-400); }

/* ---------- OTP ---------- */
.otp-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--sp-6); }
.otp-inputs { display: flex; gap: var(--sp-3); justify-content: center; }
.otp-cell {
  width: 56px; height: 64px; text-align: center;
  font-size: 1.6rem; font-weight: 700;
  background: rgba(7,11,24,0.7); border: 1px solid var(--border);
  border-radius: var(--r); color: var(--text-1);
  transition: all var(--transition);
}
.otp-cell:focus { outline: none; border-color: var(--brand-400); box-shadow: 0 0 0 4px rgba(51,102,255,0.2); transform: translateY(-2px); }
.otp-cell.filled { border-color: var(--brand-500); background: rgba(51,102,255,0.1); }
.otp-cell.error { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(244,63,94,0.18); animation: shake 400ms; }
.otp-cell.success { border-color: var(--success); background: rgba(16,185,129,0.12); }

/* ---------- Stats / KPI ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.stat {
  padding: var(--sp-5); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(24,34,74,0.55), rgba(12,18,38,0.55));
  border: 1px solid var(--border); position: relative; overflow: hidden;
}
.stat::before {
  content: ""; position: absolute; inset-block-start: 0; inset-inline-end: 0;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--grad-brand); filter: blur(40px); opacity: 0.25;
}
.stat-icon {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  margin-bottom: var(--sp-3); color: #fff;
}
.stat-icon.brand { background: var(--grad-brand); }
.stat-icon.cyan { background: var(--grad-cyan); }
.stat-icon.emerald { background: var(--grad-emerald); }
.stat-icon.amber { background: var(--grad-amber); }
.stat-icon svg { width: 22px; height: 22px; }
.stat-label { font-size: 0.82rem; color: var(--text-3); margin-bottom: 4px; }
.stat-value { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-delta { font-size: 0.78rem; margin-top: 4px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* ---------- Account cards ---------- */
.accounts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--sp-5); }
.account-card {
  padding: var(--sp-6); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(24,34,74,0.6), rgba(12,18,38,0.6));
  border: 1px solid var(--border); position: relative; overflow: hidden;
  transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
  animation: fadeUp 500ms ease both;
}
.account-card:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.account-card::after {
  content: ""; position: absolute; inset-block-start: -40px; inset-inline-end: -40px;
  width: 140px; height: 140px; border-radius: 50%;
  background: var(--grad-brand); filter: blur(50px); opacity: 0.18;
}
.ac-head { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-5); position: relative; z-index: 1; }
.bank-logo {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 800; font-size: 1.1rem; color: #fff; flex-shrink: 0;
}
.ac-bank { font-weight: 700; font-size: 1rem; }
.ac-iban { font-size: 0.78rem; color: var(--text-3); font-family: var(--font-mono); }
.ac-type { margin-inline-start: auto; }
.ac-rows { display: flex; flex-direction: column; gap: var(--sp-3); position: relative; z-index: 1; }
.ac-row { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) 0; border-bottom: 1px dashed var(--border); }
.ac-row:last-child { border-bottom: none; }
.ac-row .lbl { font-size: 0.85rem; color: var(--text-3); display: flex; align-items: center; gap: 8px; }
.ac-row .val { font-weight: 700; font-size: 1.05rem; }
.ac-row .val.pos { color: var(--success); }
.ac-row .val.neg { color: var(--danger); }
.ac-net {
  margin-top: var(--sp-4); padding: var(--sp-4); border-radius: var(--r);
  background: rgba(51,102,255,0.1); border: 1px solid rgba(51,102,255,0.25);
  display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1;
}
.ac-net .lbl { font-size: 0.85rem; color: var(--text-2); font-weight: 600; }
.ac-net .val { font-size: 1.3rem; font-weight: 800; }

/* ---------- Analysis ---------- */
.analysis-summary {
  padding: var(--sp-8); border-radius: var(--r-xl); margin-bottom: var(--sp-6);
  background: linear-gradient(135deg, rgba(51,102,255,0.15), rgba(168,85,247,0.12));
  border: 1px solid rgba(51,102,255,0.3);
  position: relative; overflow: hidden;
}
.analysis-summary::before {
  content: ""; position: absolute; inset-block-start: -60px; inset-inline-end: -60px;
  width: 220px; height: 220px; border-radius: 50%;
  background: var(--grad-brand); filter: blur(80px); opacity: 0.3;
}
.analysis-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--sp-4); position: relative; z-index: 1; }
.analysis-item { text-align: center; }
.analysis-item .v { font-size: 1.8rem; font-weight: 800; }
.analysis-item .l { font-size: 0.82rem; color: var(--text-2); margin-top: 4px; }

/* bar chart */
.chart { display: flex; align-items: flex-end; gap: var(--sp-3); height: 180px; padding: var(--sp-5); }
.chart-bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: var(--sp-2); height: 100%; justify-content: flex-end; }
.chart-bar .bar {
  width: 100%; max-width: 48px; border-radius: 8px 8px 0 0;
  background: var(--grad-brand); position: relative; min-height: 4px;
  animation: barGrow 800ms cubic-bezier(.2,.8,.2,1) both;
}
.chart-bar .bar.income { background: var(--grad-emerald); }
.chart-bar .bar.expense { background: var(--grad-rose); }
.chart-bar .lbl { font-size: 0.72rem; color: var(--text-3); }

/* ---------- Financing plans ---------- */
.plans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--sp-5); }
.plan-card {
  padding: var(--sp-6); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(24,34,74,0.6), rgba(12,18,38,0.6));
  border: 1px solid var(--border); position: relative; overflow: hidden;
  transition: all var(--transition); animation: fadeUp 500ms ease both;
}
.plan-card:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
.plan-card.featured { border-color: rgba(51,102,255,0.5); }
.plan-card.featured::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(51,102,255,0.08), transparent 50%);
  pointer-events: none;
}
.plan-badge {
  position: absolute; inset-block-start: var(--sp-4); inset-inline-end: var(--sp-4);
  font-size: 0.7rem; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--grad-brand); color: #fff;
}
.plan-provider { display: flex; align-items: center; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.plan-name { font-weight: 700; font-size: 1.05rem; }
.plan-type { font-size: 0.78rem; color: var(--text-3); }
.plan-amount { font-size: 1.9rem; font-weight: 800; margin-bottom: 4px; }
.plan-amount small { font-size: 0.85rem; font-weight: 500; color: var(--text-3); }
.plan-rate { color: var(--success); font-weight: 600; font-size: 0.9rem; margin-bottom: var(--sp-4); }
.plan-features { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.plan-feature { display: flex; align-items: center; gap: var(--sp-2); font-size: 0.88rem; color: var(--text-2); }
.plan-feature svg { width: 18px; height: 18px; color: var(--success); flex-shrink: 0; }

/* plan detail rows (amount / rate / term / installment) */
.plan-details {
  display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3);
  margin-bottom: var(--sp-5); position: relative; z-index: 1;
}
.plan-detail {
  padding: var(--sp-3); border-radius: var(--r-sm);
  background: rgba(7,11,24,0.45); border: 1px solid var(--border);
}
.plan-detail .lbl { font-size: 0.72rem; color: var(--text-3); margin-bottom: 2px; }
.plan-detail .val { font-weight: 700; font-size: 0.98rem; }
.plan-detail.highlight { background: rgba(16,185,129,0.1); border-color: rgba(16,185,129,0.35); }
.plan-detail.highlight .val { color: var(--success); }
.plan-monthly-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-4); border-radius: var(--r);
  background: linear-gradient(135deg, rgba(51,102,255,0.12), rgba(168,85,247,0.08));
  border: 1px solid rgba(51,102,255,0.25);
  margin-bottom: var(--sp-4); position: relative; z-index: 1;
}
.plan-monthly-row .lbl { font-size: 0.82rem; color: var(--text-2); font-weight: 600; }
.plan-monthly-row .val { font-size: 1.5rem; font-weight: 800; }
.plan-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: var(--sp-3); position: relative; z-index: 1; }
.plan-tag {
  font-size: 0.7rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.plan-tag.best-monthly { background: rgba(16,185,129,0.18); color: var(--success); border: 1px solid rgba(16,185,129,0.4); }
.plan-tag.best-rate { background: rgba(51,102,255,0.18); color: var(--brand-400); border: 1px solid rgba(51,102,255,0.4); }

/* sort buttons active state */
.sort-btn.active { background: rgba(51,102,255,0.18); color: #fff; border-color: rgba(51,102,255,0.4); }
#plansViewToggle .btn.active { background: rgba(51,102,255,0.18); color: #fff; border-color: rgba(51,102,255,0.4); }

/* comparison table */
.cmp-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 760px; }
.cmp-table th, .cmp-table td {
  padding: 14px 16px; text-align: start;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.cmp-table th {
  font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3); font-weight: 600; background: rgba(7,11,24,0.4);
  position: sticky; top: 0;
}
.cmp-table tbody tr { transition: background var(--transition); }
.cmp-table tbody tr:hover { background: rgba(120,150,220,0.06); }
.cmp-table tbody tr.best { background: rgba(16,185,129,0.08); }
.cmp-table tbody tr.best:hover { background: rgba(16,185,129,0.14); }
.cmp-table .bank-cell { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.cmp-table .bank-cell .bl { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 0.8rem; flex-shrink: 0; }
.cmp-table .num { font-family: var(--font-mono); font-weight: 600; }
.cmp-table .num.pos { color: var(--success); }
.cmp-table .num.neg { color: var(--danger); }
.cmp-table .tag-mini { font-size: 0.66rem; padding: 2px 6px; border-radius: 999px; margin-inline-start: 6px; }
.cmp-table .tag-mini.best-m { background: rgba(16,185,129,0.2); color: var(--success); }
.cmp-table .tag-mini.best-r { background: rgba(51,102,255,0.2); color: var(--brand-400); }
.cmp-table .row-action { padding: 6px 14px; font-size: 0.8rem; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; inset-block-end: var(--sp-6); inset-inline-end: var(--sp-6); z-index: 100; display: flex; flex-direction: column; gap: var(--sp-3); }
.toast {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-5); border-radius: var(--r);
  background: var(--bg-glass-strong); backdrop-filter: blur(16px);
  border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  min-width: 280px; animation: toastIn 400ms cubic-bezier(.2,.8,.2,1) both;
}
.toast.out { animation: toastOut 300ms ease forwards; }
.toast .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0; }
.toast.success .ico { background: rgba(16,185,129,0.2); color: var(--success); }
.toast.error .ico { background: rgba(244,63,94,0.2); color: var(--danger); }
.toast.info .ico { background: rgba(51,102,255,0.2); color: var(--brand-400); }
.toast .msg { font-size: 0.9rem; }

/* ---------- Direction toggle ---------- */
.dir-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(120,150,220,0.08); border: 1px solid var(--border);
  font-size: 0.8rem; font-weight: 600; color: var(--text-2);
  transition: all var(--transition);
}
.dir-toggle:hover { background: rgba(120,150,220,0.16); color: var(--text-1); }
.dir-toggle svg { width: 16px; height: 16px; }

/* ---------- Misc utilities ---------- */
.divider { height: 1px; background: var(--border); margin: var(--sp-6) 0; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); } .mt-8 { margin-top: var(--sp-8); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); } .mb-6 { margin-bottom: var(--sp-6); } .mb-8 { margin-bottom: var(--sp-8); }

/* ---------- Responsive ---------- */

/* Large tablets and small desktops */
@media (max-width: 1200px) {
  .content-inner { width: 100%; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
  .accounts-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .plans-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

/* Tablets */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; --header-h: 60px; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0;
    width: 280px; transform: translateX(-100%);
    transition: transform var(--transition);
    z-index: 100;
  }
  [dir="rtl"] .sidebar { transform: translateX(100%); inset-inline-start: auto; inset-inline-end: 0; }
  .sidebar.open { transform: translateX(0) !important; }
  .menu-btn { display: grid !important; }
  .stepper { padding: var(--sp-4); }
  .step-label { display: none; }
  .content { padding: var(--sp-4); }
  .topbar { padding: 0 var(--sp-4); height: var(--header-h); }
  .topbar .page-title { font-size: 1rem; }
  .topbar .page-sub { font-size: 0.72rem; }
  .dir-toggle span { display: none; }
  .dir-toggle { padding: 8px; }
  .dir-toggle svg { width: 18px; height: 18px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: var(--sp-3); }
  .stat { padding: var(--sp-4); }
  .stat-value { font-size: 1.3rem; }
  .accounts-grid { grid-template-columns: 1fr; }
  .plans-grid { grid-template-columns: 1fr; }
  .plan-details { grid-template-columns: 1fr 1fr; }
  .analysis-grid { grid-template-columns: repeat(2, 1fr); }
  .cmp-table { font-size: 0.82rem; }
  .cmp-table th, .cmp-table td { padding: 10px 8px; }
  h1 { font-size: 1.6rem; }
  h2 { font-size: 1.3rem; }
  .btn { padding: 10px 18px; font-size: 0.88rem; }
  .btn-lg { padding: 14px 24px; font-size: 0.95rem; }
  .card { border-radius: var(--r); }
}

/* Mobile phones */
@media (max-width: 560px) {
  :root { --sp-6: 16px; --sp-8: 20px; --sp-10: 24px; }
  .content { padding: var(--sp-3); }
  .content-inner { width: 100%; }
  .otp-cell { width: 40px; height: 48px; font-size: 1.2rem; }
  .otp-inputs { gap: var(--sp-2); flex-wrap: wrap; }
  .auth-card { padding: var(--sp-6); }
  .stats-grid { grid-template-columns: 1fr; }
  .stat-value { font-size: 1.2rem; }
  .stat-icon { width: 36px; height: 36px; }
  .plan-details { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr 1fr; }
  .analysis-item .v { font-size: 1.4rem; }
  .chart { height: 140px; padding: var(--sp-3); gap: var(--sp-2); }
  .topbar { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .topbar .page-sub { display: none; }
  .sidebar { width: 260px; padding: var(--sp-4); }
  .brand-name { font-size: 1rem; }
  .nav-item { padding: 10px 12px; font-size: 0.88rem; }
  .btn { padding: 10px 16px; font-size: 0.85rem; width: auto; }
  .btn-block { width: 100%; }
  .btn-lg { padding: 12px 20px; font-size: 0.9rem; }
  .input, .select { padding: 12px 14px; font-size: 0.95rem; }
  h1 { font-size: 1.4rem; }
  h2 { font-size: 1.15rem; }
  h3 { font-size: 1.05rem; }
  .card { padding: var(--sp-4) !important; }
  .analysis-summary { padding: var(--sp-5); }
  .plan-card { padding: var(--sp-4); }
  .account-card { padding: var(--sp-4); }
  .stepper { padding: var(--sp-3); gap: var(--sp-1); }
  .step-num { width: 30px; height: 30px; font-size: 0.8rem; }
  .step-line { min-width: 20px; }
  .ai-orb { width: 90px; height: 90px; }
  .ai-orb-core { width: 44px; height: 44px; }
  .toast-wrap { inset-block-end: var(--sp-3); inset-inline-end: var(--sp-3); inset-inline-start: var(--sp-3); }
  .toast { min-width: auto; width: 100%; }
  .cmp-table { min-width: 500px; font-size: 0.78rem; }
  .login-demo { font-size: 0.75rem; }
  .login-demo .row { font-size: 0.75rem; }
}

/* Very small phones */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
  .otp-cell { width: 34px; height: 42px; font-size: 1rem; }
  .btn { padding: 8px 14px; font-size: 0.82rem; }
  .topbar .page-title { font-size: 0.9rem; }
  .nav-item { padding: 8px 10px; font-size: 0.82rem; }
  .nav-item svg { width: 18px; height: 18px; }
  .brand .logo-mark { width: 34px; height: 34px; }
  .brand .logo-mark svg { width: 18px; height: 18px; }
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

.menu-btn { display: none; }

/* RTL arrow icon flip for forward buttons */
[dir='rtl'] .btn-primary svg,
[dir='rtl'] .btn-cyan svg,
[dir='rtl'] .btn-emerald svg {
  transform: scaleX(-1);
}

