/* ============================================================
   Nebula HQ Admin Panel — v2 Design System
   ============================================================
   * Mobile-first responsive design (320px → 4K)
   * Glass morphism + subtle gradients
   * 8 accent color families for section variety
   * Modern layout using Grid + Flexbox
   * Touch-friendly (44px+ targets)
   * Deep space aesthetic
   ============================================================ */

/* ============================================================
   1. Design tokens — CSS variables
   ============================================================ */
:root {
  /* ---- Base surfaces (dark cosmic theme) ---- */
  --bg-0:            #05061a;              /* Deepest space */
  --bg-1:            #0a0b1e;              /* Main canvas */
  --bg-2:            #0d0f26;              /* Sidebar */
  --bg-3:            #12142e;              /* Cards */
  --bg-4:            #191c3a;              /* Elevated */

  /* ---- Text ---- */
  --text:            #f1f5f9;              /* Primary */
  --text-2:          #cbd5e1;              /* Body */
  --muted:           #64748b;              /* Muted */
  --muted-2:         #475569;              /* Subtle */

  /* ---- Lines ---- */
  --line:            rgba(124, 58, 237, 0.15);
  --line-strong:     rgba(124, 58, 237, 0.30);
  --line-subtle:     rgba(255, 255, 255, 0.06);

  /* ---- 8 Accent Families ---- */
  /* Purple — main brand, primary actions */
  --purple:          #a78bfa;
  --purple-2:        #7c3aed;
  --purple-3:        #6d28d9;
  --purple-tint:     rgba(124, 58, 237, 0.15);
  --purple-glow:     rgba(124, 58, 237, 0.35);

  /* Cyan — users, dashboards */
  --cyan:            #22d3ee;
  --cyan-2:          #06b6d4;
  --cyan-tint:       rgba(6, 182, 212, 0.15);
  --cyan-glow:       rgba(6, 182, 212, 0.35);

  /* Pink — transfers, wallet */
  --pink:            #f472b6;
  --pink-2:          #ec4899;
  --pink-tint:       rgba(236, 72, 153, 0.15);
  --pink-glow:       rgba(236, 72, 153, 0.35);

  /* Green — success, active */
  --green:           #4ade80;
  --green-2:         #22c55e;
  --green-tint:      rgba(34, 197, 94, 0.15);
  --green-glow:      rgba(34, 197, 94, 0.35);

  /* Amber — warnings, pending */
  --amber:           #fbbf24;
  --amber-2:         #f59e0b;
  --amber-tint:      rgba(245, 158, 11, 0.15);
  --amber-glow:      rgba(245, 158, 11, 0.35);

  /* Red — danger, errors */
  --red:             #f87171;
  --red-2:           #ef4444;
  --red-tint:        rgba(239, 68, 68, 0.15);
  --red-glow:        rgba(239, 68, 68, 0.35);

  /* Blue — info, subscriptions */
  --blue:            #60a5fa;
  --blue-2:          #3b82f6;
  --blue-tint:       rgba(59, 130, 246, 0.15);
  --blue-glow:       rgba(59, 130, 246, 0.35);

  /* Rose — referrals */
  --rose:            #fb7185;
  --rose-2:          #f43f5e;
  --rose-tint:       rgba(244, 63, 94, 0.15);
  --rose-glow:       rgba(244, 63, 94, 0.35);

  /* ---- Semantic aliases ---- */
  --accent:          var(--purple-2);
  --accent-glow:     var(--purple-glow);

  /* ---- Typography ---- */
  --font-sans:       'Vazirmatn', 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:       'JetBrains Mono', 'Fira Code', 'Menlo', monospace;

  /* ---- Spacing ---- */
  --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;

  /* ---- Radius ---- */
  --radius-sm:       6px;
  --radius:          10px;
  --radius-lg:       14px;
  --radius-xl:       20px;

  /* ---- Shadows ---- */
  --shadow-sm:       0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow:          0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg:       0 20px 60px rgba(0, 0, 0, 0.4);

  /* ---- Layout ---- */
  --sidebar-w:       260px;
  --header-h:        56px;
  --bottom-nav-h:    64px;

  /* ---- Motion ---- */
  --dur-fast:        150ms;
  --dur:             250ms;
  --dur-slow:        400ms;
  --ease:            cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:     cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   2. Reset & base
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-1);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(124, 58, 237, 0.08), transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(6, 182, 212, 0.05), transparent 50%),
    radial-gradient(ellipse at 40% 100%, rgba(236, 72, 153, 0.05), transparent 50%);
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Add subtle animated star field */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 20px 30px, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 40px 70px, rgba(255, 255, 255, 0.15), transparent),
    radial-gradient(1px 1px at 90px 40px, rgba(255, 255, 255, 0.2), transparent),
    radial-gradient(1px 1px at 130px 80px, rgba(255, 255, 255, 0.1), transparent),
    radial-gradient(1px 1px at 160px 30px, rgba(255, 255, 255, 0.15), transparent);
  background-size: 200px 100px;
  background-repeat: repeat;
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--purple);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--cyan); }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid var(--line);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  color: var(--purple);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--purple-3), var(--bg-3));
  border-radius: 5px;
  border: 2px solid var(--bg-1);
}
::-webkit-scrollbar-thumb:hover { background: var(--purple-2); }

/* ============================================================
   3. Layout — sidebar + main + bottom nav
   ============================================================ */

/* Sidebar (desktop) */
.sidebar {
  position: fixed;
  inset-inline-start: 0;
  top: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: linear-gradient(180deg, var(--bg-2) 0%, var(--bg-1) 100%);
  border-inline-end: 1px solid var(--line);
  padding: var(--space-5) var(--space-3);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  z-index: 100;
  transition: transform var(--dur) var(--ease);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 200px;
  background: radial-gradient(ellipse at top, var(--purple-glow), transparent 70%);
  opacity: 0.4;
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  position: relative;
  z-index: 1;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--purple-2), var(--cyan-2));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--purple-glow);
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.brand small {
  font-size: 11px;
  color: var(--muted);
  display: block;
  letter-spacing: 0.5px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: relative;
  z-index: 1;
}

.nav a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
  border-inline-start: 2px solid transparent;
  position: relative;
}

.nav a .ico {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
}

.nav a.active {
  background: linear-gradient(90deg, var(--purple-tint) 0%, transparent 100%);
  color: var(--purple);
  border-inline-start-color: var(--purple-2);
}

.nav-badge {
  margin-inline-start: auto;
  background: linear-gradient(135deg, var(--red-2), var(--pink-2));
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
  box-shadow: 0 0 8px var(--red-glow);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  position: relative;
  z-index: 1;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-3);
  font-size: 12px;
  color: var(--text-2);
}

.admin-user .ico { color: var(--cyan); }

.btn-logout {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--red);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  font-family: inherit;
}

.btn-logout:hover {
  background: var(--red-tint);
  border-color: var(--red);
  color: var(--red);
}

/* Language picker */
.lang-picker-top {
  margin: 0 var(--space-2);
  position: relative;
  z-index: 1;
}

.lang-picker-top summary {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-3);
  border-radius: var(--radius);
  background: var(--bg-3);
  border: 1px solid var(--line);
  cursor: pointer;
  list-style: none;
  transition: all var(--dur-fast) var(--ease);
}

.lang-picker-top summary::-webkit-details-marker { display: none; }
.lang-picker-top summary:hover { border-color: var(--purple-2); }

.lang-picker-top .lang-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
}

.lang-picker-top .lang-caret {
  color: var(--muted);
  transition: transform var(--dur-fast) var(--ease);
}

.lang-picker-top[open] .lang-caret { transform: rotate(180deg); }

.lang-menu {
  margin-top: var(--space-2);
  padding: var(--space-1);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.lang-opt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 8px var(--space-3);
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-sm);
  width: 100%;
  transition: all var(--dur-fast) var(--ease);
}

.lang-opt:hover { background: var(--purple-tint); color: var(--text); }
.lang-opt.current { color: var(--purple); }

/* Main content */
main {
  padding: var(--space-6);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

main.with-sidebar {
  margin-inline-start: var(--sidebar-w);
}

main.no-sidebar {
  margin: 0 auto;
  max-width: 500px;
  padding: var(--space-8) var(--space-4);
}

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  position: fixed;
  top: var(--space-3);
  inset-inline-start: var(--space-3);
  z-index: 200;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  transition: all var(--dur-fast) var(--ease);
}

.menu-toggle:hover {
  background: var(--purple-tint);
  border-color: var(--purple-2);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 99;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ============================================================
   4. Page header & layout helpers
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, var(--text) 0%, var(--purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.page-header .subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.page-header .subtitle a {
  color: var(--cyan);
}

/* ============================================================
   5. Cards
   ============================================================ */
.card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  position: relative;
  transition: border-color var(--dur-fast) var(--ease);
}

.card:hover {
  border-color: var(--line-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--line-subtle);
}

.card-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.2px;
}

/* ============================================================
   6. Stat cards (dashboard)
   ============================================================ */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.stat-card {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-start: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--purple-2), var(--cyan-2));
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
}

/* Rotate accent colors on stat cards for variety */
.stat-card:nth-child(4n+1)::before { background: linear-gradient(90deg, var(--purple-2), var(--pink-2)); }
.stat-card:nth-child(4n+2)::before { background: linear-gradient(90deg, var(--cyan-2), var(--blue-2)); }
.stat-card:nth-child(4n+3)::before { background: linear-gradient(90deg, var(--pink-2), var(--rose-2)); }
.stat-card:nth-child(4n+4)::before { background: linear-gradient(90deg, var(--green-2), var(--cyan-2)); }

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: var(--space-2);
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 500;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
  line-height: 1.1;
}

/* ============================================================
   7. Tables
   ============================================================ */
.table-wrap {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  overflow-x: auto;
  margin-bottom: var(--space-5);
  -webkit-overflow-scrolling: touch;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

table.data thead {
  background: var(--bg-4);
  border-bottom: 1px solid var(--line);
}

table.data th {
  text-align: start;
  padding: var(--space-3) var(--space-4);
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

table.data td {
  padding: var(--space-3) var(--space-4);
  font-size: 13px;
  color: var(--text-2);
  border-bottom: 1px solid var(--line-subtle);
  vertical-align: middle;
}

table.data tbody tr {
  transition: background var(--dur-fast) var(--ease);
}

table.data tbody tr:hover {
  background: rgba(124, 58, 237, 0.04);
}

table.data tbody tr:last-child td {
  border-bottom: none;
}

table.data td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Dual-date display */
.date-dual {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}
.date-shamsi {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.date-miladi {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.date-time {
  font-size: 11px;
  color: var(--cyan);
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ============================================================
   8. Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 10px var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  text-decoration: none;
  min-height: 40px;
  white-space: nowrap;
  line-height: 1;
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
  background: linear-gradient(135deg, var(--purple-2), var(--purple-3));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px var(--purple-glow);
}

.btn-primary:hover {
  box-shadow: 0 6px 20px var(--purple-glow);
  color: white;
}

.btn-ghost {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--bg-4);
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-danger {
  background: var(--red-tint);
  color: var(--red);
  border-color: var(--red-tint);
}

.btn-danger:hover {
  background: var(--red-2);
  color: white;
  box-shadow: 0 4px 12px var(--red-glow);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 11px;
  min-height: 32px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   9. Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-4);
  border: 1px solid var(--line);
  color: var(--text-2);
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.4;
}

.badge-active {
  background: var(--green-tint);
  border-color: transparent;
  color: var(--green);
}

.badge-banned {
  background: var(--red-tint);
  border-color: transparent;
  color: var(--red);
}

.badge-credit {
  background: var(--pink-tint);
  border-color: transparent;
  color: var(--pink);
}

.badge-debit {
  background: var(--amber-tint);
  border-color: transparent;
  color: var(--amber);
}

.badge-info {
  background: var(--blue-tint);
  border-color: transparent;
  color: var(--blue);
}

/* ============================================================
   10. Forms
   ============================================================ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: var(--space-2);
  letter-spacing: 0.2px;
}

.form-control,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="search"],
input[type="tel"],
textarea,
select {
  width: 100%;
  padding: 10px var(--space-3);
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: all var(--dur-fast) var(--ease);
  min-height: 40px;
}

.form-control:focus,
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--purple-2);
  background: var(--bg-3);
  box-shadow: 0 0 0 3px var(--purple-tint);
}

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.6;
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--purple-2);
  cursor: pointer;
}

input[type="file"] {
  padding: 8px;
  background: var(--bg-1);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--text);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}

input[type="file"]:hover {
  border-color: var(--purple-2);
  background: var(--purple-tint);
}

/* ============================================================
   11. Detail grid (key-value pairs)
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-3);
}

.detail-cell {
  background: var(--bg-1);
  border: 1px solid var(--line-subtle);
  border-radius: var(--radius);
  padding: var(--space-3);
}

.detail-cell .k {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  font-weight: 500;
}

.detail-cell .v {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* ============================================================
   12. Pagination
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
  flex-wrap: wrap;
}

.pagination a,
.pagination .current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 var(--space-3);
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--dur-fast) var(--ease);
}

.pagination a:hover {
  background: var(--purple-tint);
  border-color: var(--purple-2);
  color: var(--text);
}

.pagination .current {
  background: linear-gradient(135deg, var(--purple-2), var(--purple-3));
  border-color: transparent;
  color: white;
}

/* ============================================================
   13. Flash messages
   ============================================================ */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  margin-bottom: var(--space-4);
  font-size: 13px;
  animation: slideIn var(--dur) var(--ease);
  border: 1px solid;
}

@keyframes slideIn {
  from { transform: translateY(-10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.flash-success {
  background: var(--green-tint);
  border-color: var(--green);
  color: var(--green);
}

.flash-error,
.flash-danger {
  background: var(--red-tint);
  border-color: var(--red);
  color: var(--red);
}

.flash-warning {
  background: var(--amber-tint);
  border-color: var(--amber);
  color: var(--amber);
}

.flash button {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font-size: 16px;
  opacity: 0.7;
  padding: 4px;
  transition: opacity var(--dur-fast) var(--ease);
}

.flash button:hover { opacity: 1; }

/* ============================================================
   14. Chat / messenger UI (support chats)
   ============================================================ */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  min-height: 500px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.chat-header {
  padding: var(--space-3) var(--space-4);
  background: var(--bg-4);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background: linear-gradient(180deg, var(--bg-3) 0%, var(--bg-1) 100%);
  -webkit-overflow-scrolling: touch;
}

.chat-input-bar {
  padding: var(--space-3);
  background: var(--bg-4);
  border-top: 1px solid var(--line);
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

.chat-input-bar input,
.chat-input-bar textarea {
  flex: 1;
  min-height: 40px;
}

.msg {
  max-width: 75%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-body {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-time {
  font-size: 10px;
  color: var(--muted);
  padding: 0 var(--space-2);
}

.msg-user {
  align-self: flex-start;
}
.msg-user .msg-body {
  background: var(--bg-4);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) 4px;
}

.msg-admin {
  align-self: flex-end;
}
.msg-admin .msg-body {
  background: linear-gradient(135deg, var(--purple-2), var(--purple-3));
  color: white;
  border-radius: var(--radius-lg) var(--radius-lg) 4px var(--radius-lg);
  box-shadow: 0 2px 8px var(--purple-glow);
}
.msg-admin .msg-time {
  text-align: end;
}

/* ============================================================
   15. Login page (no-sidebar layout)
   ============================================================ */
.login-card {
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  margin-top: var(--space-10);
  box-shadow: var(--shadow-lg), 0 0 60px var(--purple-glow);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: -50%;
  inset-inline-start: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(ellipse at center, var(--purple-glow), transparent 60%);
  opacity: 0.3;
  pointer-events: none;
  animation: pulse 4s var(--ease) infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.1); opacity: 0.5; }
}

.login-card h1 {
  text-align: center;
  margin-bottom: var(--space-6);
  background: linear-gradient(135deg, var(--purple) 0%, var(--cyan) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  position: relative;
}

/* ============================================================
   16. Responsive breakpoints
   ============================================================ */

/* Tablet (max 1024px) */
@media (max-width: 1024px) {
  :root {
    --sidebar-w: 240px;
  }

  main {
    padding: var(--space-5);
  }

  .stat-value { font-size: 22px; }
  .page-header h1 { font-size: 20px; }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
  .menu-toggle {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    width: 280px;
  }

  [dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  main.with-sidebar {
    margin-inline-start: 0;
    padding: 72px var(--space-3) calc(var(--bottom-nav-h) + var(--space-4)) var(--space-3);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }

  .page-header h1 {
    font-size: 20px;
  }

  .card {
    padding: var(--space-4);
    border-radius: var(--radius);
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .stat-card {
    padding: var(--space-3);
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-label {
    font-size: 10px;
  }

  .table-wrap {
    border-radius: var(--radius);
  }

  table.data th,
  table.data td {
    padding: var(--space-2) var(--space-3);
    font-size: 12px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .btn {
    padding: 10px var(--space-3);
    font-size: 12px;
  }

  .btn-sm {
    padding: 6px 10px;
    font-size: 11px;
  }

  .chat-container {
    height: calc(100vh - 120px);
    border-radius: var(--radius);
  }

  .msg {
    max-width: 85%;
  }

  main.no-sidebar {
    padding: var(--space-5) var(--space-4);
  }

  .login-card {
    padding: var(--space-6);
    margin-top: var(--space-5);
  }
}

/* Small mobile (max 480px) */
@media (max-width: 480px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .page-header h1 {
    font-size: 18px;
  }

  .brand h1 { font-size: 14px; }

  main.with-sidebar {
    padding: 68px var(--space-2) calc(var(--bottom-nav-h) + var(--space-3)) var(--space-2);
  }
}

/* ============================================================
   17. Utilities
   ============================================================ */
.text-muted { color: var(--muted) !important; }
.text-purple { color: var(--purple) !important; }
.text-cyan { color: var(--cyan) !important; }
.text-pink { color: var(--pink) !important; }
.text-green { color: var(--green) !important; }
.text-amber { color: var(--amber) !important; }
.text-red { color: var(--red) !important; }

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* RTL/LTR aware */
[dir="rtl"] .nav a { text-align: right; }
[dir="ltr"] .nav a { text-align: left; }

/* Print */
@media print {
  .sidebar, .menu-toggle, .btn, .pagination { display: none !important; }
  main.with-sidebar { margin: 0; padding: 0; }
  body { background: white; color: black; }
}
