/* ═══════════════════════════════════════════════════════════════
   FLIXABLE THEME — TOKENS
   Static design tokens: spacing · radius · motion · fonts
   + Bridge: maps app_settings variables → DS token names
   ═══════════════════════════════════════════════════════════════ */

/* ─── FONTS ─────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ─── SPACING SCALE (4px base) ───────────────────────────────── */
:root {
  --space-0:  0;
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;
}

/* ─── RADIUS ─────────────────────────────────────────────────── */
/* --radius injected by app_settings (default 14px)             */
:root {
  --r-xs:   6px;
  --r-sm:   10px;
  --r:      var(--radius, 14px);
  --r-lg:   20px;
  --r-xl:   28px;
  --r-full: 999px;
}

/* ─── MOTION ─────────────────────────────────────────────────── */
:root {
  --ease-out:    cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast:    140ms;
  --dur:         220ms;
  --dur-slow:    420ms;
}

/* ─── FONT FAMILIES ──────────────────────────────────────────── */
/* --font injected by app_settings                               */
:root {
  --font-base: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}
/* Default font — app_settings <style> will override if admin changed it */
:root {
  --font: var(--font-base);
}

/* ─── SEMANTIC COLORS (fixed — not in app_settings) ─────────── */
:root {
  --success: oklch(0.70 0.16 150);
  --danger:  oklch(0.62 0.22 25);
  --warning: oklch(0.80 0.16 80);
  --info:    oklch(0.65 0.18 245);

  --success-soft: oklch(0.70 0.16 150 / 0.12);
  --danger-soft:  oklch(0.62 0.22 25  / 0.12);
  --warning-soft: oklch(0.80 0.16 80  / 0.12);
  --info-soft:    oklch(0.65 0.18 245 / 0.12);
}

/* ─── BRIDGE: app_settings → DS tokens ─────────────────────────
   app_settings blade <style> injects into :root:
     --color-primary, --color-primary-rgb
     --radius, --button-radius, --card-shadow, --font
   Per dark/light (via data-theme on <html>):
     --color-bg, --color-bg-soft, --color-surface
     --color-text, --color-muted, --color-border
     --sidebar-bg, --sidebar-text, --sidebar-muted, --sidebar-border
     --sidebar-hover-bg, --sidebar-active-bg, --sidebar-active-text
   ─────────────────────────────────────────────────────────────── */
:root {
  /* Primary */
  --primary:        var(--color-primary,     #FFB703);
  --primary-rgb:    var(--color-primary-rgb, 255,183,3);
  --primary-soft:   rgba(var(--primary-rgb), 0.12);
  --primary-ring:   rgba(var(--primary-rgb), 0.28);
  --primary-strong: color-mix(in srgb, var(--primary) 82%, black);
  --primary-fg:     #000;

  /* Primary alpha helpers — fix circular refs in old CSS */
  --color-primary-alpha-05:  rgba(var(--primary-rgb), 0.05);
  --color-primary-alpha-1:   rgba(var(--primary-rgb), 0.10);
  --color-primary-alpha-15:  rgba(var(--primary-rgb), 0.15);
  --color-primary-alpha-2:   rgba(var(--primary-rgb), 0.20);
  --color-primary-alpha-25:  rgba(var(--primary-rgb), 0.25);
  --color-primary-alpha-3:   rgba(var(--primary-rgb), 0.30);

  /* Derived radius */
  --r:    var(--radius, 14px);
  --r-sm: calc(var(--radius, 14px) * 0.72);

  /* Focus ring */
  --focus-ring: 0 0 0 3px var(--primary-ring);

  /* Shadows */
  --shadow-sm:   0 1px 2px rgba(0,0,0,.30);
  --shadow:      var(--card-shadow, 0 4px 16px rgba(0,0,0,.35));
  --shadow-lg:   0 16px 40px rgba(0,0,0,.50);
  --shadow-glow: 0 0 32px rgba(var(--primary-rgb), 0.18);

  /* Scrim */
  --scrim: rgba(0,0,0,.65);

  /* LTR/RTL */
  --ltr-end: right;

  /* backward compat: neutral-rgb = white in dark (default) */
  --neutral-rgb: 255,255,255;
}
html[data-theme="light"] { --neutral-rgb: 0,0,0; }
html[dir="rtl"] { --ltr-end: left; }
html[dir="ltr"] { --ltr-end: right; }

/* ═══════════════════════════════════════════════════════════════
   FLIXABLE THEME — DARK MODE
   Maps --color-* (from app_settings) → DS surface/text tokens
   app_settings sets --color-bg, --color-surface, etc. per theme
   ═══════════════════════════════════════════════════════════════ */

:root,
[data-theme="dark"] {
  color-scheme: dark;

  /* Backgrounds & Surfaces */
  --bg:        var(--color-bg,      oklch(0.16 0.012 265));
  --bg-soft:   var(--color-bg-soft, oklch(0.19 0.012 265));
  --surface:   var(--color-surface, oklch(0.22 0.012 265));
  --surface-2: color-mix(in srgb, var(--surface) 70%, white 30%);
  --surface-3: color-mix(in srgb, var(--surface) 55%, white 45%);

  /* Borders */
  --border:        var(--color-border, rgba(255,255,255,.08));
  --border-strong: color-mix(in srgb, var(--border) 100%, white 40%);

  /* Text */
  --text:       var(--color-text,  oklch(0.97 0.005 80));
  --text-muted: var(--color-muted, oklch(0.65 0.012 265));
  --text-dim:   color-mix(in srgb, var(--text-muted) 60%, var(--bg));

  /* Shadows (darker in dark mode) */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow:    0 4px 16px rgba(0,0,0,.40);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.55);

  /* Sidebar */
  --side-bg:          var(--sidebar-bg,         oklch(0.13 0.012 265));
  --side-text:        var(--sidebar-text,        var(--text));
  --side-muted:       var(--sidebar-muted,       var(--text-muted));
  --side-border:      var(--sidebar-border,      var(--border));
  --side-hover-bg:    var(--sidebar-hover-bg,    var(--surface-2));
  --side-active-bg:   var(--sidebar-active-bg,   var(--primary-soft));
  --side-active-text: var(--sidebar-active-text, var(--primary));
}

/* ═══════════════════════════════════════════════════════════════
   FLIXABLE THEME — LIGHT MODE
   Maps --color-* (from app_settings) → DS surface/text tokens
   ═══════════════════════════════════════════════════════════════ */

[data-theme="light"] {
  color-scheme: light;

  /* Backgrounds & Surfaces */
  --bg:        var(--color-bg,      oklch(0.99 0.003 80));
  --bg-soft:   var(--color-bg-soft, oklch(0.97 0.004 80));
  --surface:   var(--color-surface, oklch(1 0 0));
  --surface-2: color-mix(in srgb, var(--surface) 92%, black 8%);
  --surface-3: color-mix(in srgb, var(--surface) 84%, black 16%);

  /* Borders */
  --border:        var(--color-border, rgba(0,0,0,.08));
  --border-strong: color-mix(in srgb, var(--border) 100%, black 30%);

  /* Text */
  --text:       var(--color-text,  oklch(0.18 0.012 265));
  --text-muted: var(--color-muted, oklch(0.50 0.014 265));
  --text-dim:   color-mix(in srgb, var(--text-muted) 60%, var(--bg));

  /* Shadows (softer in light mode) */
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 4px 16px rgba(15,23,42,.10);
  --shadow-lg: 0 16px 40px rgba(15,23,42,.14);

  /* Sidebar */
  --side-bg:          var(--sidebar-bg,         oklch(0.97 0.004 80));
  --side-text:        var(--sidebar-text,        var(--text));
  --side-muted:       var(--sidebar-muted,       var(--text-muted));
  --side-border:      var(--sidebar-border,      var(--border));
  --side-hover-bg:    var(--sidebar-hover-bg,    var(--surface-2));
  --side-active-bg:   var(--sidebar-active-bg,   var(--primary-soft));
  --side-active-text: var(--sidebar-active-text, var(--primary));

  /* Amber/warning badge needs darker text in light mode */
  --warning-text-light: oklch(0.45 0.15 75);
}

/* Amber primary needs white fg in light mode for contrast */
[data-theme="light"] {
  --primary-fg: #fff;
}
[data-theme="light"][data-variant="1"] {
  --primary-fg: #fff;
}

/* ═══════════════════════════════════════════════════════════════
   FLIXABLE THEME — LAYOUT
   Dashboard shell · Sidebar · Topbar · Main content grid
   Compatible with existing #sidebar, .layout, .topbar blade HTML
   ═══════════════════════════════════════════════════════════════ */

/* ─── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes stagger-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fade-in {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes slide-in-start {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ─── APP SHELL ─────────────────────────────────────────────── */
/*  Sidebar is position:fixed so grid would double-offset main.
    Use plain block + margin-inline-start on .dash-main instead. */
.dash {
  min-height: 100vh;
  --side-w: 256px;
  position: relative;
}
.dash[data-side="collapsed"] { --side-w: 76px; }

/* ─── SIDEBAR ───────────────────────────────────────────────── */
.side {
  background: var(--side-bg, var(--surface));
  border-inline-end: 1px solid var(--side-border, var(--border-strong));
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  height: 100vh;
  width: var(--side-w, 256px);
  display: flex; flex-direction: column;
  padding: var(--space-5) 0;
  z-index: 30; overflow: hidden;
  transition: width var(--dur) var(--ease-out);
}
.dash-main {
  display: flex; flex-direction: column; min-width: 0; min-height: 100vh;
  margin-inline-start: var(--side-w, 256px);
  transition: margin-inline-start var(--dur) var(--ease-out);
}

/* ── Collapsed: explicit fallback (CSS var may not cascade to fixed) ── */
.dash[data-side="collapsed"] .side,
#sidebar.collapsed {
  width: 76px !important;
}
/* Sibling selector: sidebar.collapsed → shift main content */
#sidebar.collapsed ~ .dash-main,
.dash[data-side="collapsed"] .dash-main {
  margin-inline-start: 76px !important;
}

/* Collapsed state — hide text labels */
.dash[data-side="collapsed"] .side-logo-text,
.dash[data-side="collapsed"] .side-nav-label,
.dash[data-side="collapsed"] .side-item-text,
.dash[data-side="collapsed"] .side-item-badge,
.dash[data-side="collapsed"] .side-user-info,
#sidebar.collapsed .side-logo-text,
#sidebar.collapsed .side-nav-label,
#sidebar.collapsed .side-item-text,
#sidebar.collapsed .side-item-badge,
#sidebar.collapsed .side-user-info { opacity: 0; pointer-events: none; width: 0; overflow: hidden; flex-shrink: 0; }

/* Collapsed: center items & head */
.dash[data-side="collapsed"] .side-item,
#sidebar.collapsed .side-item { justify-content: center; padding: 10px; }
.dash[data-side="collapsed"] .side-head,
#sidebar.collapsed .side-head { justify-content: center; padding: 0 var(--space-2); }
.dash[data-side="collapsed"] .side-logo,
#sidebar.collapsed .side-logo { justify-content: center; }
.dash[data-side="collapsed"] .side-user,
#sidebar.collapsed .side-user { justify-content: center; }
.dash[data-side="collapsed"] .side-nav-label,
#sidebar.collapsed .side-nav-label { display: none; }
/* Hide collapse btn text hint */
.dash[data-side="collapsed"] .side-collapse-icon { opacity: 0; pointer-events: none; }

/* Logo */
.side-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-4); margin-block-end: var(--space-4);
}
.side-logo { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.side-logo-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--primary); color: var(--primary-fg, #000);
  display: grid; place-items: center;
  font-weight: 800; font-size: 17px; flex-shrink: 0;
  box-shadow: 0 6px 16px var(--primary-soft);
}
.side-logo-text { display: flex; flex-direction: column; white-space: nowrap; overflow: hidden; opacity: 1; transition: opacity var(--dur); }
.side-logo-name { font-weight: 800; font-size: 15px; color: var(--side-text, var(--text)); }
.side-logo-sub  { font-size: 11px; color: var(--side-muted, var(--text-muted)); }

/* Collapse button */
.side-collapse {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface-2); color: var(--text-muted);
  display: grid; place-items: center; cursor: pointer;
  transition: all var(--dur); flex-shrink: 0; border: none;
}
.side-collapse:hover { background: var(--surface-3); color: var(--text); }
/* Collapse chevron: SVG inside .side-collapse rotates on collapse */
.side-collapse svg,
.side-collapse [data-lucide] { font-size: 16px; transition: transform var(--dur); }
/* LTR default: chevrons point left (collapse action) */
html[dir="ltr"] .side-collapse svg { transform: scaleX(1); }
html[dir="ltr"] .dash[data-side="collapsed"] .side-collapse svg,
html[dir="ltr"] #sidebar.collapsed .side-collapse svg { transform: scaleX(-1); }
/* RTL default: chevrons point right (collapse action, already pointing toward sidebar) */
html[dir="rtl"] .side-collapse svg { transform: scaleX(-1); }
html[dir="rtl"] .dash[data-side="collapsed"] .side-collapse svg,
html[dir="rtl"] #sidebar.collapsed .side-collapse svg { transform: scaleX(1); }

/* Nav */
.side-nav { flex: 1; overflow-y: auto; padding: 0 var(--space-3); }
.side-nav::-webkit-scrollbar { width: 4px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }

.side-nav-label {
  font-size: 11px; font-weight: 700;
  color: var(--text-dim); text-transform: uppercase; letter-spacing: .08em;
  padding: var(--space-3) var(--space-3) var(--space-1);
  transition: opacity var(--dur);
}
.side-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3); border-radius: var(--r-sm);
  color: var(--side-muted, var(--text-muted));
  font-size: 14px; font-weight: 500; cursor: pointer;
  transition: color var(--dur), background var(--dur);
  position: relative; margin-block-end: 2px;
  white-space: nowrap; overflow: hidden;
}
.side-item:hover { background: var(--side-hover-bg, var(--surface-2)); color: var(--side-text, var(--text)); }
.side-item.active {
  background: var(--side-active-bg, var(--primary-soft));
  color: var(--side-active-text, var(--primary));
  font-weight: 700;
}
.side-item.active::before {
  content: ''; position: absolute; inset-block: 8px; inset-inline-start: -3px;
  width: 3px; background: var(--side-active-text, var(--primary)); border-radius: 999px;
}
.side-item-icon { width: 20px; height: 20px; display: grid; place-items: center; flex-shrink: 0; }
.side-item-icon [data-lucide] { font-size: 18px; }
.side-item-text { flex: 1; transition: opacity var(--dur); }
.side-item-badge {
  font-size: 11px; font-weight: 700; padding: 2px 7px;
  border-radius: var(--r-full);
  background: var(--primary-soft); color: var(--primary);
  transition: opacity var(--dur);
}

/* User card at bottom */
.side-user {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); margin: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer; transition: background var(--dur);
}
.side-user:hover { background: var(--surface-2); }
.side-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), oklch(0.55 0.16 220));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.side-user-info { flex: 1; min-width: 0; transition: opacity var(--dur); }
.side-user-name { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--side-text, var(--text)); }
.side-user-role { font-size: 11px; color: var(--side-muted, var(--text-muted)); }

/* --- Existing system sidebar (#sidebar) compat --------------- */
#sidebar {
  background: var(--side-bg, var(--surface));
  border-inline-end: 1px solid var(--side-border, var(--border-strong));
  width: var(--sidebar-width, 270px);
  transition: width var(--dur) var(--ease-out), transform var(--dur) var(--ease-out);
}
#sidebar .nav-link {
  color: var(--side-muted, var(--text-muted));
  border-radius: var(--r-sm);
  transition: color var(--dur), background var(--dur);
}
#sidebar .nav-link:hover { background: var(--side-hover-bg); color: var(--side-text, var(--text)); }
#sidebar .nav-link.active {
  background: var(--side-active-bg, var(--primary-soft));
  color: var(--side-active-text, var(--primary));
  font-weight: 700;
}
#sidebar .sidebar-brand .brand-icon {
  background: var(--primary); color: var(--primary-fg, #000);
  box-shadow: 0 6px 16px var(--primary-soft);
}

/* ─── TOPBAR (EXISTING SYSTEM) ──────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-block-end: 1px solid var(--border);
  min-height: 64px;
  display: flex; align-items: center;
  padding: 0 var(--space-5);
  gap: var(--space-4);
}
/* New DS topbar */
.topbar-dash {
  position: sticky; top: 0; z-index: 20;
   backdrop-filter: saturate(160%) blur(20px);
  -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-block-end: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-6); min-height: 68px;
}
.topbar-search {
  flex: 1; max-width: 520px; position: relative;
  display: flex; align-items: center;
}
.topbar-search-input {
  width: 100%; height: 40px;
  padding: 0 var(--space-8) 0 38px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text) !important;
  font-family: var(--font, var(--font-base)); font-size: 14px;
  outline: none; transition: border-color var(--dur), box-shadow var(--dur);
}
html[dir="rtl"] .topbar-search-input { padding: 0 38px 0 var(--space-8); }
.topbar-search-input:focus { border-color: var(--primary) !important; box-shadow: var(--focus-ring) !important; }
.topbar-search-input::placeholder { color: var(--text-dim) !important; }
.topbar-search-icon {
  position: absolute; inset-block-start: 50%; inset-inline-start: 12px;
  transform: translateY(-50%); color: var(--text-muted); pointer-events: none;
  display: flex; align-items: center;
}
html[dir="rtl"] .topbar-search-icon { inset-inline-start: auto; inset-inline-end: 12px; }
.topbar-kbd {
  position: absolute; inset-block-start: 50%; inset-inline-end: 10px;
  transform: translateY(-50%); font-family: var(--font-mono);
  font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 6px;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  pointer-events: none;
}
html[dir="rtl"] .topbar-kbd { inset-inline-end: auto; inset-inline-start: 10px; }
.topbar-actions {
  display: flex; align-items: center; gap: var(--space-2);
  margin-inline-start: auto; flex-shrink: 0;
}
/* Variant picker (topbar) */
.tb-controls { display: flex; align-items: center; gap: var(--space-2); }
.tb-variant-pick {
  display: inline-flex; gap: 3px; background: var(--surface);
  border: 1px solid var(--border); padding: 4px; border-radius: var(--r-full);
}
.tb-variant-swatch { width: 22px; height: 22px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform var(--dur-fast); }
.tb-variant-swatch:hover { transform: scale(1.15); }
.tb-variant-swatch.active { border-color: var(--text); }
.tb-variant-swatch[data-val="1"] { background: oklch(0.78 0.16 75); }
.tb-variant-swatch[data-val="2"] { background: oklch(0.68 0.15 165); }
.tb-variant-swatch[data-val="3"] { background: oklch(0.66 0.20 270); }

/* ─── ICON BUTTON ───────────────────────────────────────────── */
.icon-btn {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); cursor: pointer; flex-shrink: 0;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
  font-size: 16px; line-height: 1; padding: 0; font-family: inherit;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.active, .icon-btn.topbar-sidebar-toggle {
  background: var(--primary-soft) !important;
  border-color: var(--primary-ring) !important;
  color: var(--primary) !important;
}
.icon-btn.topbar-sidebar-toggle:hover {
  background: rgba(var(--primary-rgb), 0.20) !important;
}

/* Theme toggle show/hide icons */
[data-theme="dark"]  .theme-icon-light { display: none; }
[data-theme="light"] .theme-icon-dark  { display: none; }

/* ─── CONTENT AREA ──────────────────────────────────────────── */
/* Also: existing system .layout (uses margin, not padding) ---- */
.layout {
  margin-inline-start: var(--sidebar-width, 270px);
  width: calc(100% - var(--sidebar-width, 270px));
  box-sizing: border-box;
  transition: margin-inline-start var(--dur) var(--ease-out), width var(--dur) var(--ease-out);
}
.sidebar.collapsed ~ .layout {
  margin-inline-start: 80px;
  width: calc(100% - 80px);
}
@media (max-width: 992px) {
  .layout { margin-inline-start: 0 !important; width: 100% !important; }
}

.dash-content {
  padding: var(--space-6); width: 100%; flex: 1;
}
.dash-hero {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: var(--space-6); flex-wrap: wrap; margin-block-end: var(--space-6);
}
.dash-hero h1 {
  font-size: clamp(20px, 3vw, 32px); font-weight: 800;
  letter-spacing: -0.025em; line-height: 1.15;
}
.dash-hero p { color: var(--text-muted); font-size: 14px; margin-block-start: 4px; }

/* ─── KPI GRID ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-block-end: var(--space-6);
  direction: ltr; /* keep card order LTR: Revenue→Tx→Rate→Users */
}
.kpi-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--space-5);
  display: flex; flex-direction: column; gap: var(--space-2);
  transition: border-color var(--dur);
}
.kpi-card:hover { border-color: var(--primary); }
.kpi-label { font-size: 13px; color: var(--text-muted); margin-block-end: 0; }
.kpi-value {
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.025em; font-variant-numeric: tabular-nums;
  line-height: 1.1; margin-block-end: 4px;
}
.kpi-value .cur { font-size: .5em; color: var(--text-muted); font-weight: 700; margin-inline-end: 4px; vertical-align: middle; }
.kpi-value .dec { color: var(--text-muted); font-size: .7em; font-weight: 700; }
.kpi-delta { font-size: 12px; font-weight: 600; }
.kpi-delta.pos { color: var(--success); }
.kpi-delta.neg { color: var(--danger); }

/* ─── DASHBOARD GRID (12 cols) ───────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-4);
  /* Force LTR column flow so col-8 stays on the LEFT and col-4 on the RIGHT
     regardless of the page writing direction (RTL Arabic pages) */
  direction: ltr;
}
.col-3  { grid-column: span 3; }
.col-4  { grid-column: span 4; }
.col-5  { grid-column: span 5; }
.col-6  { grid-column: span 6; }
.col-7  { grid-column: span 7; }
.col-8  { grid-column: span 8; }
.col-9  { grid-column: span 9; }
.col-12 { grid-column: span 12; }

/* Dashboard card — restore RTL for Arabic content inside */
.d-card {
  direction: rtl;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--space-5);
  display: flex; flex-direction: column; min-width: 0; position: relative;
  opacity: 0; transform: translateY(8px);
  animation: stagger-in .5s var(--ease-spring) forwards;
  animation-delay: 240ms;
}
.d-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-block-end: var(--space-4);
}
.d-card-title   { font-size: 15px; font-weight: 700; }
.d-card-sub     { font-size: 12px; color: var(--text-muted); margin-block-start: 2px; }
.d-card-actions { display: flex; align-items: center; gap: var(--space-2); }

/* Chart */
.chart { position: relative; height: 280px; user-select: none; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-axis text { font-family: var(--font-mono); font-size: 10px; fill: var(--text-dim); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 4px 12px var(--primary-soft)); }
.chart-dot  { fill: var(--primary); stroke: var(--surface); stroke-width: 3; }
.chart-crosshair { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0; transition: opacity var(--dur); }
.chart-crosshair.visible { opacity: .5; }
.chart-tooltip {
  position: absolute; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); padding: 8px 12px; box-shadow: var(--shadow);
  pointer-events: none; white-space: nowrap; z-index: 5;
  opacity: 0; transition: opacity var(--dur);
  transform: translateX(-50%) translateY(-100%); margin-block-start: -10px;
}
.chart-tooltip.visible { opacity: 1; }
.chart-tooltip .tt-k { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }
.chart-tooltip .tt-v { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-legend { display: flex; gap: var(--space-4); margin-block-start: var(--space-3); }
.chart-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* Bar list */
.bar-list { display: flex; flex-direction: column; gap: var(--space-3); }
.bar-row { display: grid; grid-template-columns: 24px 1fr auto; gap: var(--space-3); align-items: center; }
.bar-rank { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); font-weight: 700; text-align: center; }
.bar-body { min-width: 0; }
.bar-name { font-size: 13px; font-weight: 600; margin-block-end: 4px; display: flex; justify-content: space-between; gap: var(--space-2); }
.bar-name .v { color: var(--text-muted); font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.bar-track { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill {
  height: 100%;
  background: var(--bar-c, linear-gradient(to var(--ltr-end, right), var(--primary), var(--primary-strong)));
  border-radius: 999px; transition: width 1s var(--ease-out); width: 0;
}
.bar-pct  { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); font-weight: 600; min-width: 38px; text-align: end; }
.bar-flag { width: 26px; height: 20px; border-radius: 4px; display: grid; place-items: center; font-size: 9px; font-weight: 800; color: #fff; flex-shrink: 0; }

/* KYC */
.kyc-list { display: flex; flex-direction: column; gap: var(--space-2); }
.kyc-item {
  display: grid; grid-template-columns: 40px 1fr auto auto;
  gap: var(--space-3); align-items: center; padding: var(--space-3);
  background: var(--bg-soft); border: 1px solid var(--border);
  border-radius: var(--r-sm); transition: border-color var(--dur);
}
.kyc-item:hover { border-color: var(--border-strong); }
.kyc-av { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--primary-soft); color: var(--primary); }
.kyc-name { font-size: 13px; font-weight: 600; }
.kyc-meta { font-size: 11px; color: var(--text-muted); margin-block-start: 2px; }
.kyc-act  { display: flex; gap: 4px; }
.kyc-btn { width: 30px; height: 30px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); color: var(--text-muted); display: grid; place-items: center; cursor: pointer; transition: all var(--dur); }
.kyc-btn:hover { transform: scale(1.05); }
.kyc-btn.approve:hover { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.kyc-btn.reject:hover  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger); }

/* Live feed */
.feed { flex: 1; display: flex; flex-direction: column; gap: 6px; overflow: hidden; position: relative; }
.feed-item {
  display: grid; grid-template-columns: 36px 1fr auto;
  gap: var(--space-3); align-items: center;
  padding: 10px var(--space-3); background: var(--bg-soft);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 13px; transition: background var(--dur);
  animation: feed-in .45s var(--ease-spring);
}
@keyframes feed-in { 0% { opacity: 0; transform: translateY(-12px) scale(.96); } 100% { opacity: 1; transform: translateY(0) scale(1); } }
.feed-item:first-child { border-color: var(--primary); background: var(--primary-soft); animation: feed-in-hl .45s var(--ease-spring), highlight-fade 2.5s ease forwards 0.5s; }
@keyframes feed-in-hl    { 0% { opacity:0; transform:translateY(-16px) scale(.95); } 100% { opacity:1; transform:translateY(0) scale(1); } }
@keyframes highlight-fade { to { border-color: var(--border); background: var(--bg-soft); } }
.feed-ic { width: 32px; height: 32px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 16px; }
.feed-ic.success { background: var(--success-soft); color: var(--success); }
.feed-ic.danger  { background: var(--danger-soft);  color: var(--danger); }
.feed-ic.info    { background: var(--info-soft);    color: var(--info); }
.feed-ic.warning { background: var(--warning-soft); color: var(--warning); }
.feed-name { font-weight: 600; }
.feed-sub  { font-size: 11px; color: var(--text-muted); margin-block-start: 1px; }
.feed-amt  { font-weight: 700; font-variant-numeric: tabular-nums; text-align: end; font-size: 13px; }
.feed-amt.pos { color: var(--success); }
.feed-amt.neg { color: var(--danger); }
.feed-amt small { display: block; font-size: 11px; color: var(--text-muted); font-weight: 600; }
.feed-tps { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-mono); font-size: 11px; margin-inline-start: auto; color: var(--success); }

/* ─── FLOATING ACTION BUTTON ────────────────────────────────── */
.fab {
  position: fixed; inset-block-end: var(--space-6); inset-inline-end: var(--space-6);
  width: 56px; height: 56px; border-radius: var(--r-full);
  background: var(--primary); color: var(--primary-fg, #000);
  display: grid; place-items: center;
  box-shadow: 0 12px 32px var(--primary-ring), var(--shadow-lg);
  cursor: pointer; z-index: 100;
  transition: all var(--dur) var(--ease-spring);
}
.fab:hover { transform: scale(1.1) rotate(45deg); }
.fab [data-lucide] { font-size: 26px; }

/* ─── MOBILE BOTTOM NAV ─────────────────────────────────────── */
.mobile-nav {
  display: none; position: fixed; inset-block-end: 0; inset-inline: 0;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-block-start: 1px solid var(--border);
  padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom, 0));
  justify-content: space-around; z-index: 50;
}
.mobile-nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0; color: var(--text-muted); font-size: 10px; font-weight: 600;
  cursor: pointer; border-radius: var(--r-sm); transition: all var(--dur);
}
.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item [data-lucide] { font-size: 22px; }

/* ─── LAYOUT wrapper (existing system uses .layout) ──────────── */
/* Defined above in CONTENT AREA section — uses margin-inline-start */

/* Page */
#main-content { flex: 1; display: flex; flex-direction: column; }
/* #page = .dash-content (same element) — padding from .dash-content */
@media (max-width: 767px) { #page { padding: var(--space-4) var(--space-3); } }

/* ─── RESPONSIVE ────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .col-3 { grid-column: span 6; }
  .col-4 { grid-column: span 6; }
  .col-5 { grid-column: span 6; }
  .col-7 { grid-column: span 6; }
  .col-8 { grid-column: span 12; }
  .col-9 { grid-column: span 12; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) and (min-width: 721px) {
  /* Tablet: auto-collapse sidebar */
  .dash { --side-w: 76px; }
  .side-logo-text, .side-nav-label, .side-item-text,
  .side-item-badge, .side-user-info, .side-collapse { opacity: 0; pointer-events: none; width: 0; overflow: hidden; }
  .side-item { justify-content: center; padding: 10px; }
  .side-head  { justify-content: center; padding: 0 var(--space-2); }
  .side-logo  { justify-content: center; }
  .side-user  { justify-content: center; padding: 8px; }
  .dash-content { padding: var(--space-4); }
}

@media (max-width: 720px) {
  /* On mobile: sidebar hidden by default, shown as overlay when .show added */
  .side {
    display: flex !important; /* keep flex layout */
    transform: translateX(100%); /* hide off-screen (RTL: right side) */
    transition: transform var(--dur) var(--ease-out), box-shadow var(--dur);
    z-index: 1040;
    box-shadow: none;
  }
  html[dir="ltr"] .side { transform: translateX(-100%); }

  /* Show sidebar overlay */
  #sidebar.show {
    transform: translateX(0) !important;
    box-shadow: var(--shadow-lg) !important;
  }

  /* Main content takes full width on mobile */
  .dash-main { margin-inline-start: 0 !important; }

  .mobile-nav { display: flex; }
  .dash-content { padding: var(--space-4) var(--space-3) calc(var(--space-12) + 60px); }
  .col-3, .col-4, .col-5, .col-6,
  .col-7, .col-8, .col-9 { grid-column: span 12; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { display: none; }
   .fab { inset-block-end: calc(60px + env(safe-area-inset-bottom, 0) + 16px); }
}

@media (max-width: 420px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 24px; }
}

/* ─── EXISTING SYSTEM — SIDEBAR CLASS (DS token overrides) ─── */
/*  The old CSS uses hardcoded colors. We override with tokens.  */
.sidebar {
  background: var(--side-bg, var(--surface)) !important;
  border-inline-end: 1px solid var(--side-border, var(--border)) !important;
  color: var(--side-text, var(--text)) !important;
  scrollbar-color: var(--primary-soft) transparent;
}
.sidebar::-webkit-scrollbar-thumb {
  background: var(--primary-soft) !important;
  border-color: rgba(var(--primary-rgb), 0.2) !important;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(var(--primary-rgb), 0.40) !important;
}

/* Brand */
.brand { display: flex; align-items: center; gap: 10px; padding: 10px 6px; margin-bottom: 8px; }
.brand .logo {
  inline-size: 36px; block-size: 36px; border-radius: 10px;
  background: var(--primary) !important;
  display: grid; place-items: center; color: var(--primary-fg, #000); font-weight: 700; overflow: hidden;
}
.brand .logo.has-image { background: transparent !important; }
.brand .name { font-weight: 700; letter-spacing: .2px; color: var(--side-text, var(--text)); }

/* Menu */
.menu a { color: var(--side-text, var(--text)); }
.menu a:hover { background: var(--side-hover-bg, rgba(255,255,255,.06)); }
.menu .section-title, .menu > .section-title { color: var(--side-muted, var(--text-muted)); }

/* Menu items */
.menu-item { color: var(--side-text, var(--text)); }
.menu-item:hover { background: var(--side-hover-bg, rgba(255,255,255,.08)); }
.menu-item.active {
  background: var(--side-active-bg, var(--primary-soft)) !important;
  color: var(--side-active-text, var(--primary)) !important;
}
.menu-item.active .menu-icon { color: var(--side-active-text, var(--primary)); }
.menu-item.active::before { background: var(--side-active-text, var(--primary)) !important; }

/* Plugin nav */
.plugin-toggle-btn { color: var(--side-text, var(--text)); }
.plugin-toggle-btn:hover { background: var(--side-hover-bg, rgba(255,255,255,.08)); }
.plugin-toggle-btn.active { background: var(--side-active-bg, var(--primary-soft)); color: var(--side-active-text, var(--primary)); }
.plugin-submenu {
  background: rgba(var(--primary-rgb), 0.04);
  display: none; overflow: hidden;
  padding-inline-start: var(--space-2);
  border-radius: var(--r-sm);
}
.plugin-submenu.show { display: block; }
.plugin-item { color: var(--side-muted, var(--text-muted)); }
.plugin-item:hover { background: var(--side-hover-bg, rgba(255,255,255,.08)); color: var(--side-text, var(--text)); }
.plugin-item.active { background: var(--side-active-bg, var(--primary-soft)); color: var(--side-active-text, var(--primary)); }
.sidebar.collapsed .admin-submenu,
.sidebar.collapsed .plugin-submenu {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

/* Topbar DS overrides */
.topbar {
  background: color-mix(in srgb, var(--bg) 75%, transparent) !important;
  border-block-end: 1px solid var(--border) !important;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}
[data-theme="light"] .topbar {
  background: rgba(255,255,255,.8) !important;
}
/* ─── TOPBAR ACTIONS — normalize all Bootstrap btns to icon-btn look ── */
/*  Scoped tightly to .topbar-actions so Bootstrap is not broken globally  */

/* btn-outline-light inside topbar → icon-btn look */
.topbar-actions .btn-outline-light:not(.balance-pill),
.topbar-actions a.btn-outline-light:not(.balance-pill) {
  display: inline-grid !important;
  place-items: center !important;
  width: 36px !important; height: 36px !important;
  border-radius: var(--r-sm) !important;
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  border: 1px solid var(--border) !important;
  padding: 0 !important; font-size: 15px !important; font-weight: 700 !important;
  transition: background var(--dur-fast), color var(--dur-fast) !important;
  line-height: 1 !important;
}
.topbar-actions .btn-outline-light:not(.balance-pill):hover,
.topbar-actions a.btn-outline-light:not(.balance-pill):hover {
  background: var(--surface-3) !important;
  color: var(--text) !important;
  border-color: var(--border-strong) !important;
}
/* Quick actions primary button — keep brand color, just fix size */
.topbar-actions .quick-actions > .btn-primary,
.topbar-actions .btn-primary:not(.w-100) {
  width: 36px !important; height: 36px !important;
  padding: 0 !important; border-radius: var(--r-sm) !important;
  background: var(--primary) !important; color: var(--primary-fg, #000) !important;
  border: none !important; font-size: 16px !important;
}
/* Balance pill — pill-shaped chip showing the balance amount */
.balance-pill {
  height: 36px !important;
  width: auto !important;
  padding: 0 var(--space-3) !important;
  border-radius: var(--r-sm) !important;
  background: var(--surface-2) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
  font-size: 13px !important; font-weight: 700 !important;
  display: inline-flex !important; align-items: center !important; gap: 4px !important;
}
.balance-pill:hover {
  background: var(--surface-3) !important;
  border-color: var(--primary-ring) !important;
}

/* Card surface */
.card-surface {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r);
}
.card-surface:hover { border-color: var(--primary) !important; }

/* Body base */
body {
  background-color: var(--bg, var(--color-bg)) !important;
  color: var(--text, var(--color-text));
  font-family: var(--font, var(--font-base));
}

/* ─── MISSING CLASSES — token overrides ────────────────────── */
/* These already have rules in old CSS; we add DS-token versions */

/* menu-text — inherits color from parent sidebar */
.menu-text { flex: 1; font-size: 0.95rem; font-weight: 500; transition: opacity var(--dur); }
.sidebar.collapsed .menu-text { opacity: 0; width: 0; overflow: hidden; }

/* plugin-section / plugin-arrow */
.plugin-section { position: relative; margin-bottom: 4px; }
.plugin-arrow { margin-inline-start: auto; display: flex; align-items: center; justify-content: center; width: 20px; height: 20px; transition: transform 0.3s ease; }
.plugin-toggle-btn.active .plugin-arrow { transform: rotate(180deg); }

/* admin-main — same as menu-item, inherits active state */
.menu-item.admin-main {}

/* Theme toggle — extends .icon-btn */
.theme-toggle {
  color: var(--text) !important;
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}
[data-theme="light"] .theme-toggle {
  background: rgba(0,0,0,.04) !important;
  border-color: var(--border) !important;
}

/* Topbar search input */
.topbar-search-input { color: var(--text) !important; background: transparent; }
.topbar-search-input::placeholder { color: var(--text-muted); }

/* ─── BOOTSTRAP DROPDOWNS → DS surface look ───────────────────── */
.dropdown-menu {
  background: var(--surface) !important;
  border: 1px solid var(--border-strong) !important;
  box-shadow: var(--shadow-lg) !important;
  border-radius: var(--r) !important;
}
.dropdown-item {
  color: var(--text) !important;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast), color var(--dur-fast);
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--surface-2) !important;
  color: var(--text) !important;
}
.dropdown-item.text-danger:hover { background: var(--danger-soft) !important; color: var(--danger) !important; }
.dropdown-divider { border-color: var(--border) !important; }
.dropdown-header { color: var(--text-muted) !important; font-size: 11px !important; }

/* Profile dropdown */
.profile-dropdown {
  background: var(--surface) !important;
  border-color: var(--border-strong) !important;
  box-shadow: var(--shadow-lg) !important;
  min-width: 260px !important;
}

/* Balance pill */
.balance-pill {
  background: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border) !important;
}

/* Sidebar backdrop */
.sidebar-backdrop {
  position: fixed; inset: 0;
  background: var(--scrim);
  z-index: 1030; display: none;
  transition: opacity var(--dur);
}
body.sidebar-open .sidebar-backdrop { display: block; }

/* ─── BOOTSTRAP CARDS → DS surface ──────────────────────────── */
.card {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow-sm) !important;
  color: var(--text) !important;
}
.card-header {
  background: var(--surface-2) !important;
  border-bottom-color: var(--border) !important;
  font-weight: 700 !important; color: var(--text) !important;
}
.card-footer { background: var(--surface-2) !important; border-top-color: var(--border) !important; }

/* Bootstrap form controls → DS styling */
.form-control, .form-select {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  border-radius: var(--r-sm) !important;
}
.form-control:focus, .form-select:focus {
  background: var(--surface) !important;
  border-color: var(--primary) !important;
  box-shadow: var(--focus-ring) !important;
  color: var(--text) !important;
}
.form-control::placeholder { color: var(--text-dim) !important; }
.form-label { color: var(--text) !important; font-weight: 600; }
.form-text { color: var(--text-muted) !important; }

/* Bootstrap tables → DS look */
.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  --bs-table-border-color: var(--border);
  --bs-table-striped-bg: var(--bg-soft);
  --bs-table-hover-bg: var(--surface-2);
  color: var(--text) !important;
}
.table thead th { color: var(--text-muted) !important; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.table > :not(caption) > * > * { border-bottom-color: var(--border) !important; }

/* Bootstrap badges → DS tokens */
.badge.bg-secondary { background: var(--surface-3) !important; color: var(--text-muted) !important; }
.badge.bg-light     { background: var(--surface-2) !important; color: var(--text) !important; }

/* Bootstrap alerts → DS semantic colors */
.alert { border-radius: var(--r) !important; border-width: 1px !important; }
.alert-success { background: var(--success-soft) !important; border-color: var(--success) !important; color: var(--success) !important; }
.alert-danger  { background: var(--danger-soft)  !important; border-color: var(--danger)  !important; color: var(--danger)  !important; }
.alert-warning { background: var(--warning-soft) !important; border-color: var(--warning) !important; color: var(--warning) !important; }
.alert-info    { background: var(--info-soft)    !important; border-color: var(--info)    !important; color: var(--info)    !important; }

/* Modal → DS surface */
.modal-content {
  background: var(--surface) !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: var(--r-lg) !important;
  box-shadow: var(--shadow-lg) !important;
  color: var(--text) !important;
}
.modal-header { border-bottom-color: var(--border) !important; }
.modal-footer { border-top-color: var(--border) !important; }
.modal-backdrop { --bs-backdrop-bg: var(--scrim); }

/* ─── DASHBOARD HERO ─────────────────────────────────────────── */
.dash-hero-live {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; color: var(--success);
  text-transform: uppercase; letter-spacing: .08em;
  background: var(--success-soft); padding: 4px 10px;
  border-radius: var(--r-full);
}
.live-dot {
  width: 8px; height: 8px; background: var(--success);
  border-radius: 50%; animation: live-pulse 1.8s ease-in-out infinite;
}
@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 0 var(--success); opacity: 1; }
  50%       { box-shadow: 0 0 0 6px transparent; opacity: .6; }
}

/* Period switcher — always LTR regardless of page direction */
.period-pick {
  display: inline-flex; direction: ltr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 3px; gap: 2px;
  flex-shrink: 0;
}
.period-item {
  padding: 6px 14px; font-size: 13px; font-weight: 600;
  color: var(--text-muted); border-radius: var(--r-xs);
  cursor: pointer; transition: all var(--dur); white-space: nowrap;
  text-decoration: none; display: inline-block; user-select: none;
}
.period-item:hover { color: var(--text); background: var(--surface-2); }
.period-item.active { background: var(--primary); color: var(--primary-fg, #fff); }

/* Hero actions row — never wrap, keep inline */
.dash-hero-actions {
  display: flex; align-items: center; gap: var(--space-3);
  flex-wrap: nowrap; flex-shrink: 0;
}

/* ─── KPI CARD (reference design) ───────────────────────────── */
.kpi {
  direction: rtl; /* restore RTL for Arabic content */
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--space-5);
  position: relative; overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
  transition: transform var(--dur), box-shadow var(--dur);
  opacity: 0; transform: translateY(8px);
  animation: stagger-in .5s var(--ease-spring) forwards;
}
.kpi:nth-child(1) { animation-delay: 0ms; }
.kpi:nth-child(2) { animation-delay: 60ms; }
.kpi:nth-child(3) { animation-delay: 120ms; }
.kpi:nth-child(4) { animation-delay: 180ms; }
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::before {
  content: ''; position: absolute;
  inset-block-start: 0; inset-inline: 0; height: 3px;
  background: linear-gradient(to var(--ltr-end, right), var(--kpi-c, var(--primary)), transparent);
}
.kpi-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-block-end: var(--space-3);
}
.kpi-icon {
  width: 42px; height: 42px; border-radius: 12px;
  background: var(--kpi-soft, var(--primary-soft));
  color: var(--kpi-c, var(--primary));
  display: grid; place-items: center; font-size: 20px;
}
.kpi-trend {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; font-weight: 700; padding: 3px 8px;
  border-radius: var(--r-full);
}
.kpi-trend.up   { background: var(--success-soft); color: var(--success); }
.kpi-trend.down { background: var(--danger-soft);  color: var(--danger); }
.kpi-trend.neu  { background: var(--surface-2);    color: var(--text-muted); }
.kpi-num {
  font-size: 28px; font-weight: 800;
  letter-spacing: -0.025em; font-variant-numeric: tabular-nums;
  line-height: 1.1; margin-block-end: 4px;
}
.kpi-num .cur { font-size: .5em; color: var(--text-muted); font-weight: 700; margin-inline-end: 4px; }
.kpi-num .dec { color: var(--text-muted); font-size: .7em; font-weight: 700; }
.kpi-lbl { font-size: 13px; color: var(--text-muted); }
.kpi-spark { margin-block-start: var(--space-4); height: 36px; }
.kpi-spark svg { width: 100%; height: 100%; display: block; overflow: visible; }
/* Sparkline path/area */
.spark-line { fill: none; stroke: var(--kpi-c, var(--primary)); stroke-width: 2; }
.spark-area { fill: url(#sparkFill); opacity: .25; }

/* ─── ADMIN TOOLS GRID ───────────────────────────────────────── */
.admin-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}
.admin-section-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); overflow: hidden;
  opacity: 0; transform: translateY(8px);
  animation: stagger-in .5s var(--ease-spring) forwards;
  animation-delay: 300ms;
}
.admin-section-card .section-header {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-block-end: 1px solid var(--border);
}
.admin-section-card .section-icon {
  width: 44px; height: 44px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary);
  display: grid; place-items: center;
}
.admin-section-card .section-title { font-size: 15px; font-weight: 700; margin: 0; }
.admin-section-card .section-desc  { font-size: 12px; color: var(--text-muted); margin: 2px 0 0; }
.section-tools { padding: var(--space-2) 0; }
.tool-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3) var(--space-5); text-decoration: none;
  color: var(--text); transition: background var(--dur);
}
.tool-item:hover { background: var(--surface-2); color: var(--text); }
.tool-item .tool-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--bg-soft); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: 15px; flex-shrink: 0;
}
.tool-item .tool-title { font-size: 13px; font-weight: 600; }
.tool-item .tool-desc  { font-size: 11px; color: var(--text-muted); margin-block-start: 1px; }

/* ─── USER DASHBOARD ─────────────────────────────────────────── */
.dash-balance-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4); margin-block-end: var(--space-5);
}
.dash-balance-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--space-5);
  position: relative; overflow: hidden;
  transition: border-color var(--dur), transform var(--dur);
}
.dash-balance-card:hover { border-color: var(--primary); transform: translateY(-1px); }
.dash-balance-card::before {
  content: ''; position: absolute; inset-inline-start: 0; inset-block: 0;
  width: 3px; background: var(--primary); border-radius: 99px;
}
.dash-quick-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-3); margin-block-end: var(--space-5);
}
.dash-quick-item {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-2); padding: var(--space-4);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); text-decoration: none; color: var(--text);
  transition: border-color var(--dur), transform var(--dur), background var(--dur);
  text-align: center;
}
.dash-quick-item:hover {
  border-color: var(--primary); color: var(--primary);
  transform: translateY(-2px); background: var(--primary-soft);
}
.dash-quick-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--bg-soft); display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0;
  transition: background var(--dur);
}
.dash-quick-item:hover .dash-quick-icon { background: var(--primary-soft); }
.dash-quick-label { font-size: 12px; font-weight: 600; }

/* Recent activity list */
.dash-activity {
  display: flex; flex-direction: column; gap: 2px;
}
.dash-activity-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-3); border-radius: var(--r-sm);
  transition: background var(--dur);
}
.dash-activity-item:hover { background: var(--surface-2); }
.dash-activity-icon {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-size: 16px; flex-shrink: 0;
}
.dash-activity-icon.success { background: var(--success-soft); color: var(--success); }
.dash-activity-icon.danger  { background: var(--danger-soft);  color: var(--danger); }
.dash-activity-icon.info    { background: var(--info-soft);    color: var(--info); }
.dash-activity-icon.neutral { background: var(--surface-2);    color: var(--text-muted); }
.dash-activity-title { font-size: 13px; font-weight: 600; }
.dash-activity-sub   { font-size: 11px; color: var(--text-muted); margin-block-start: 1px; }
.dash-activity-amt   { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; margin-inline-start: auto; }
.dash-activity-amt.pos { color: var(--success); }
.dash-activity-amt.neg { color: var(--danger); }

/* ─── PAGE HEAD ─────────────────────────────────────────────── */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
  margin-block-end: var(--space-5);
}
.page-head h1 {
  font-size: clamp(20px, 3vw, 28px); font-weight: 800;
  letter-spacing: -0.025em; line-height: 1.15; margin: 0;
}
.page-head p { color: var(--text-muted); font-size: 14px; margin-block-start: 4px; margin: 0; }

/* ─── SETTINGS LAYOUT ────────────────────────────────────────── */
.settings-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-5);
  align-items: start;
}
.settings-aside {
  display: flex; flex-direction: column;
  gap: 2px; position: sticky;
  inset-block-start: 88px; height: fit-content;
}
.settings-aside-item {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--r-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; gap: var(--space-2);
  transition: all var(--dur); text-decoration: none;
}
.settings-aside-item:hover { background: var(--surface-2); color: var(--text); }
.settings-aside-item.active { background: var(--primary-soft); color: var(--primary); }

.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: var(--space-5);
  margin-block-end: var(--space-4);
}
.settings-section h3 { font-size: 17px; font-weight: 700; margin-block-end: 4px; }
.settings-sub { color: var(--text-muted); font-size: 13px; margin-block-end: var(--space-4); }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding-block: var(--space-3); border-block-start: 1px solid var(--border); gap: var(--space-4);
}
.settings-row:first-of-type { border-block-start: none; }
.settings-row-text { flex: 1; min-width: 0; }
.settings-row-title { font-weight: 600; font-size: 14px; }
.settings-row-desc { color: var(--text-muted); font-size: 12px; margin-block-start: 2px; }

/* DS Grid */
.ds-grid { display: grid; gap: var(--space-4); }
.ds-grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
@media (max-width: 720px) { .ds-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 1100px) {
  .settings-layout { grid-template-columns: 1fr; }
  .settings-aside { position: static; flex-direction: row; flex-wrap: wrap; }
}

/* ─── SCROLLBAR ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg-soft); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
