/* MARISA ONE — Design System */
/* Global Intelligent Operations Platform */

/* ═══════════════════════════════════════════════════════════════
   DESIGN TOKENS
═══════════════════════════════════════════════════════════════ */

/* ══════════════════════════════════════════════════════════════
   MARISA ONE — Multi-Theme Color System
   Themes: dark (default) | ocean | sunset | emerald | light
   ══════════════════════════════════════════════════════════════ */

/* ── Shared tokens (all themes) ─────────────────────────────── */
:root {
  --brand-danger:     #FF3A3A;
  --brand-warning:    #FFB800;
  --brand-success:    #00D97E;

  --font-display:     'Inter', 'Segoe UI', sans-serif;
  --font-arabic:      'Tajawal', 'Cairo', sans-serif;
  --font-mono:        'JetBrains Mono', 'Fira Code', monospace;

  --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-sm: 6px; --radius-md: 10px; --radius-lg: 16px;
  --radius-xl: 24px; --radius-full: 9999px;

  --transition-fast:   150ms cubic-bezier(0.4,0,0.2,1);
  --transition-normal: 250ms cubic-bezier(0.4,0,0.2,1);
  --transition-slow:   400ms cubic-bezier(0.4,0,0.2,1);

  --sidebar-width:     260px;
  --sidebar-collapsed: 64px;
  --topbar-height:     64px;
  --z-sidebar:         200;
  --z-modal:           500;
  --z-toast:           900;
}

/* ── 🌑 DARK THEME (default — deep ocean) ─────────────────── */
[data-theme="dark"] {
  --brand-primary:    #0B4FD6;
  --brand-secondary:  #00C5FF;
  --brand-accent:     #00FFB2;

  --bg-base:          #060D1A;
  --bg-surface:       #0D1B2E;
  --bg-raised:        #112238;
  --bg-overlay:       #162D47;
  --bg-hover:         #1A3555;

  --border-subtle:    rgba(0,197,255,.08);
  --border-default:   rgba(0,197,255,.15);
  --border-strong:    rgba(0,197,255,.3);

  --text-primary:     #EDF2FF;
  --text-secondary:   #8BA3C0;
  --text-muted:       #4A6580;
  --text-inverse:     #060D1A;

  --glow-primary:     0 0 20px rgba(11,79,214,.4);
  --glow-secondary:   0 0 20px rgba(0,197,255,.3);
  --glow-accent:      0 0 20px rgba(0,255,178,.3);
  --glow-danger:      0 0 20px rgba(255,58,58,.4);

  --theme-name: "dark";
}

/* ── 🌊 OCEAN THEME (bright cyan — هادئ ومريح) ──────────────── */
[data-theme="ocean"] {
  --brand-primary:    #0077B6;
  --brand-secondary:  #00B4D8;
  --brand-accent:     #90E0EF;

  --bg-base:          #03045E;
  --bg-surface:       #023E8A;
  --bg-raised:        #0077B6;
  --bg-overlay:       #0096C7;
  --bg-hover:         #00B4D8;

  --border-subtle:    rgba(0,180,216,.15);
  --border-default:   rgba(0,180,216,.3);
  --border-strong:    rgba(144,224,239,.5);

  --text-primary:     #CAF0F8;
  --text-secondary:   #90E0EF;
  --text-muted:       #48CAE4;
  --text-inverse:     #03045E;

  --glow-primary:     0 0 24px rgba(0,119,182,.5);
  --glow-secondary:   0 0 20px rgba(0,180,216,.4);
  --glow-accent:      0 0 20px rgba(144,224,239,.4);
  --glow-danger:      0 0 20px rgba(255,58,58,.4);
}

/* ── 🌅 SUNSET THEME (برتقالي دافئ — حيوي ومشرق) ─────────── */
[data-theme="sunset"] {
  --brand-primary:    #E63946;
  --brand-secondary:  #FF6B35;
  --brand-accent:     #FFD166;

  --bg-base:          #1A0A00;
  --bg-surface:       #2D1300;
  --bg-raised:        #3D1F00;
  --bg-overlay:       #4D2B00;
  --bg-hover:         #5C3500;

  --border-subtle:    rgba(255,107,53,.12);
  --border-default:   rgba(255,107,53,.25);
  --border-strong:    rgba(255,209,102,.4);

  --text-primary:     #FFF3E0;
  --text-secondary:   #FFCC80;
  --text-muted:       #FF9800;
  --text-inverse:     #1A0A00;

  --glow-primary:     0 0 24px rgba(230,57,70,.5);
  --glow-secondary:   0 0 20px rgba(255,107,53,.4);
  --glow-accent:      0 0 20px rgba(255,209,102,.4);
  --glow-danger:      0 0 20px rgba(255,58,58,.4);
}

/* ── 🌿 EMERALD THEME (أخضر زمردي — طبيعي وراقي) ─────────── */
[data-theme="emerald"] {
  --brand-primary:    #1B4332;
  --brand-secondary:  #40916C;
  --brand-accent:     #95D5B2;

  --bg-base:          #081C15;
  --bg-surface:       #1B4332;
  --bg-raised:        #2D6A4F;
  --bg-overlay:       #40916C;
  --bg-hover:         #52B788;

  --border-subtle:    rgba(64,145,108,.15);
  --border-default:   rgba(64,145,108,.3);
  --border-strong:    rgba(149,213,178,.5);

  --text-primary:     #D8F3DC;
  --text-secondary:   #95D5B2;
  --text-muted:       #52B788;
  --text-inverse:     #081C15;

  --glow-primary:     0 0 24px rgba(27,67,50,.6);
  --glow-secondary:   0 0 20px rgba(64,145,108,.4);
  --glow-accent:      0 0 20px rgba(149,213,178,.4);
  --glow-danger:      0 0 20px rgba(255,58,58,.4);
}

/* ── ☀️ LIGHT THEME (فاتح — نظيف وهادئ) ─────────────────── */
[data-theme="light"] {
  --brand-primary:    #0B4FD6;
  --brand-secondary:  #0077B6;
  --brand-accent:     #00B4D8;

  --bg-base:          #F0F4F8;
  --bg-surface:       #FFFFFF;
  --bg-raised:        #E8F0FE;
  --bg-overlay:       #D0E4FF;
  --bg-hover:         #C5D9F7;

  --border-subtle:    rgba(11,79,214,.08);
  --border-default:   rgba(11,79,214,.18);
  --border-strong:    rgba(11,79,214,.35);

  --text-primary:     #0D1B2E;
  --text-secondary:   #2D4A6B;
  --text-muted:       #5A7A9A;
  --text-inverse:     #FFFFFF;

  --glow-primary:     0 0 16px rgba(11,79,214,.2);
  --glow-secondary:   0 0 12px rgba(0,119,182,.2);
  --glow-accent:      0 0 12px rgba(0,180,216,.2);
  --glow-danger:      0 0 12px rgba(255,58,58,.25);
}

/* ── 🌙 MIDNIGHT THEME (بنفسجي عميق — غامض وأنيق) ─────────── */
[data-theme="midnight"] {
  --brand-primary:    #7C3AED;
  --brand-secondary:  #A855F7;
  --brand-accent:     #E879F9;

  --bg-base:          #0C0118;
  --bg-surface:       #160527;
  --bg-raised:        #1E0B35;
  --bg-overlay:       #2A1045;
  --bg-hover:         #361558;

  --border-subtle:    rgba(168,85,247,.1);
  --border-default:   rgba(168,85,247,.22);
  --border-strong:    rgba(232,121,249,.45);

  --text-primary:     #F3E8FF;
  --text-secondary:   #D8B4FE;
  --text-muted:       #A855F7;
  --text-inverse:     #0C0118;

  --glow-primary:     0 0 24px rgba(124,58,237,.5);
  --glow-secondary:   0 0 20px rgba(168,85,247,.4);
  --glow-accent:      0 0 20px rgba(232,121,249,.4);
  --glow-danger:      0 0 20px rgba(255,58,58,.4);
}

/* ── Backwards compatibility — :root inherits dark by default ─ */
:root {
  --brand-primary:    #0B4FD6;
  --brand-secondary:  #00C5FF;
  --brand-accent:     #00FFB2;
  --bg-base:          #060D1A;
  --bg-surface:       #0D1B2E;
  --bg-raised:        #112238;
  --bg-overlay:       #162D47;
  --bg-hover:         #1A3555;
  --border-subtle:    rgba(0,197,255,.08);
  --border-default:   rgba(0,197,255,.15);
  --border-strong:    rgba(0,197,255,.3);
  --text-primary:     #EDF2FF;
  --text-secondary:   #8BA3C0;
  --text-muted:       #4A6580;
  --text-inverse:     #060D1A;
  --glow-primary:     0 0 20px rgba(11,79,214,.4);
  --glow-secondary:   0 0 20px rgba(0,197,255,.3);
  --glow-accent:      0 0 20px rgba(0,255,178,.3);
  --glow-danger:      0 0 20px rgba(255,58,58,.4);
}

/* Transitions */
  --transition-fast:   150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:   400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Layout */
  --sidebar-width:     260px;
  --sidebar-collapsed: 68px;
  --topbar-height:     64px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.3);
  --shadow-md:   0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.5);
  --shadow-xl:   0 16px 64px rgba(0,0,0,0.6);
}

/* Light Theme */
[data-theme="light"] {
  --bg-base:        #F0F4FA;
  --bg-surface:     #FFFFFF;
  --bg-raised:      #F8FAFD;
  --bg-overlay:     #EBF1F9;
  --bg-hover:       #E3EAF5;

  --border-subtle:  rgba(11, 79, 214, 0.07);
  --border-default: rgba(11, 79, 214, 0.15);
  --border-strong:  rgba(11, 79, 214, 0.3);

  --text-primary:   #0D1B2E;
  --text-secondary: #445E7B;
  --text-muted:     #8BA3C0;
  --text-inverse:   #FFFFFF;

  --glow-primary:   0 0 20px rgba(11, 79, 214, 0.15);
  --glow-secondary: 0 0 20px rgba(0, 197, 255, 0.12);
}

/* ═══════════════════════════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════════════════════════ */

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

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

[lang="ar"] body,
[data-lang="ar"] body {
  font-family: var(--font-arabic);
}

[lang="en"] body,
[data-lang="en"] body {
  font-family: var(--font-display);
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-display);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ═══════════════════════════════════════════════════════════════
   SCROLLBAR
═══════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--brand-secondary); }

/* ═══════════════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════════════ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR
═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR — Collapsible with toggle button
═══════════════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-inline-end: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  z-index: var(--z-sidebar);
  transition: width 0.28s cubic-bezier(.4,0,.2,1);
  overflow: visible;  /* allow toggle button to show outside */
  box-shadow: 4px 0 32px rgba(0,0,0,.25);
}

.sidebar.collapsed { width: 64px; }

/* ── Logo area ─────────────────────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: var(--topbar-height);
  border-bottom: 1px solid var(--border-subtle);
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, rgba(11,79,214,.08), rgba(0,197,255,.04));
}

.sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 0 16px rgba(0,197,255,.3);
  letter-spacing: -1px;
  overflow: hidden;
}

.sidebar-logo-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.sidebar-logo-text {
  overflow: hidden;
  white-space: nowrap;
  transition: opacity .22s, width .22s;
  flex: 1;
}

.sidebar.collapsed .sidebar-logo-text { opacity: 0; width: 0; pointer-events: none; }

.brand-name {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-primary);
  letter-spacing: .5px;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-sub {
  font-size: 9px;
  color: var(--brand-secondary);
  letter-spacing: .04em;
  white-space: nowrap;
}

/* ── Toggle button ─────────────────────────────────────────── */
/* Toggle button — attached to topbar, always visible */
.sidebar-toggle-btn {
  display: none; /* handled via topbar-toggle instead */
}


/* ── Nav ───────────────────────────────────────────────────── */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-subtle) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }

.nav-section-label {
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 18px 18px 6px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s, height .2s, padding .2s;
  height: auto;
}

.sidebar.collapsed .nav-section-label {
  opacity: 0;
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 14px;
  margin: 2px 8px;
  border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
  position: relative;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  letter-spacing: .01em;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: linear-gradient(135deg,rgba(11,79,214,.22),rgba(0,197,255,.1));
  color: var(--brand-secondary);
  border: 1px solid rgba(0,197,255,.18);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--brand-secondary);
  border-radius: 99px;
}

/* Tooltip on collapsed sidebar */
.sidebar.collapsed .nav-item {
  padding: 10px;
  justify-content: center;
  margin: 2px 8px;
}

.sidebar.collapsed .nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  inset-inline-start: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s;
  box-shadow: 0 4px 20px rgba(0,0,0,.3);
  z-index: 200;
}

.sidebar.collapsed .nav-item:hover::after { opacity: 1; }

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}

.nav-label {
  flex: 1;
  overflow: hidden;
  transition: opacity .18s, width .18s;
  white-space: nowrap;
}

.sidebar.collapsed .nav-label { opacity: 0; width: 0; }

.nav-badge {
  padding: 2px 6px;
  border-radius: 99px;
  font-size: 9px;
  font-weight: 800;
  background: var(--brand-danger);
  color: #fff;
  flex-shrink: 0;
  transition: opacity .18s;
}

.sidebar.collapsed .nav-badge { opacity: 0; width: 0; padding: 0; overflow: hidden; }

/* ── Sidebar footer ────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 12px;
  flex-shrink: 0;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  overflow: hidden;
}

.user-card:hover { background: var(--bg-hover); }

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg,var(--brand-primary),var(--brand-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
}

.user-info { overflow: hidden; transition: opacity .18s, width .18s; }
.sidebar.collapsed .user-info { opacity: 0; width: 0; }

.user-name {
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  color: var(--text-primary);
}

.user-role {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN AREA
═══════════════════════════════════════════════════════════════ */

.main-area {
  flex: 1;
  margin-inline-start: var(--sidebar-width);
  transition: margin .28s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-inline-start var(--transition-normal);
}

/* When sidebar is collapsed, push main-area in */
.sidebar.collapsed ~ .main-area,
.sidebar.collapsed + * .main-area,
.sidebar.collapsed + .main-area {
  margin-inline-start: var(--sidebar-collapsed);
}


.sidebar.collapsed ~ .main-area {
  margin-inline-start: var(--sidebar-collapsed);
}

/* ═══════════════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════════════ */

.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 var(--space-6);
  gap: var(--space-4);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
}

.topbar-toggle {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 2px solid var(--border-strong);
  background: var(--bg-raised);
  color: var(--brand-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all .2s;
  flex-shrink: 0;
  font-weight: 900;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.topbar-toggle:hover {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: #fff;
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--glow-secondary);
}




.topbar-breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
  margin-inline-start: var(--space-2);
}

.topbar-spacer { flex: 1; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  width: 220px;
  transition: all var(--transition-fast);
}

.topbar-search:focus-within {
  border-color: var(--brand-secondary);
  box-shadow: var(--glow-secondary);
  width: 280px;
}

.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  color: var(--text-primary);
  font-size: 13px;
  width: 100%;
  font-family: inherit;
}

.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all var(--transition-fast);
  position: relative;
}

.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--border-strong); }

.icon-btn .badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--brand-danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow-danger);
}

.lang-toggle {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: all var(--transition-fast);
  font-family: inherit;
}

.lang-toggle:hover {
  background: var(--bg-hover);
  color: var(--brand-secondary);
  border-color: var(--brand-secondary);
}

/* ═══════════════════════════════════════════════════════════════
   PAGE CONTENT
═══════════════════════════════════════════════════════════════ */

.page-content {
  flex: 1;
  padding: var(--space-6);
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
}

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

/* ═══════════════════════════════════════════════════════════════
   CARDS
═══════════════════════════════════════════════════════════════ */

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

/* Stat Cards */
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
  transition: all var(--transition-normal);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-default);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  inset-inline-end: 0;
  width: 3px;
  height: 100%;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.stat-card.primary::after { background: var(--brand-primary); }
.stat-card.secondary::after { background: var(--brand-secondary); }
.stat-card.success::after { background: var(--brand-success); }
.stat-card.warning::after { background: var(--brand-warning); }
.stat-card.danger::after { background: var(--brand-danger); }
.stat-card.accent::after { background: var(--brand-accent); }

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-bottom: var(--space-4);
}

.stat-icon.primary { background: rgba(11,79,214,0.15); }
.stat-icon.secondary { background: rgba(0,197,255,0.12); }
.stat-icon.success { background: rgba(0,217,126,0.12); }
.stat-icon.warning { background: rgba(255,184,0,0.12); }
.stat-icon.danger { background: rgba(255,58,58,0.12); }
.stat-icon.accent { background: rgba(0,255,178,0.1); }

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-1);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-trend {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 11px;
  font-weight: 600;
  margin-top: var(--space-2);
}

.stat-trend.up { color: var(--brand-success); }
.stat-trend.down { color: var(--brand-danger); }

/* ═══════════════════════════════════════════════════════════════
   GRID
═══════════════════════════════════════════════════════════════ */

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

/* ═══════════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════════ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), #0066FF);
  color: white;
  border-color: var(--brand-primary);
  box-shadow: 0 2px 8px rgba(11,79,214,0.3);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(11,79,214,0.5);
}

.btn-secondary {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-danger {
  background: rgba(255,58,58,0.1);
  color: var(--brand-danger);
  border-color: rgba(255,58,58,0.3);
}

.btn-danger:hover { background: var(--brand-danger); color: white; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: var(--space-1) var(--space-3); font-size: 12px; }
.btn-lg { padding: var(--space-3) var(--space-6); font-size: 14px; }

/* ═══════════════════════════════════════════════════════════════
   TABLES
═══════════════════════════════════════════════════════════════ */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--bg-raised);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: var(--space-3) var(--space-4);
  text-align: start;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

tbody td {
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════════
   STATUS BADGES
═══════════════════════════════════════════════════════════════ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-active { background: rgba(0,217,126,0.12); color: var(--brand-success); }
.badge-active::before { background: var(--brand-success); animation: pulse 2s infinite; }
.badge-idle { background: rgba(255,184,0,0.12); color: var(--brand-warning); }
.badge-idle::before { background: var(--brand-warning); }
.badge-offline { background: rgba(74,101,128,0.2); color: var(--text-muted); }
.badge-offline::before { background: var(--text-muted); }
.badge-alert { background: rgba(255,58,58,0.12); color: var(--brand-danger); }
.badge-alert::before { background: var(--brand-danger); animation: pulse 1s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ═══════════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════════ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

.form-control {
  background: var(--bg-raised);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
  width: 100%;
}

.form-control:focus {
  border-color: var(--brand-secondary);
  box-shadow: 0 0 0 3px rgba(0,197,255,0.1);
}

.form-control::placeholder { color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════════
   LIVE INDICATOR
═══════════════════════════════════════════════════════════════ */

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,217,126,0.1);
  border: 1px solid rgba(0,217,126,0.3);
  border-radius: var(--radius-full);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--brand-success);
  letter-spacing: 0.5px;
}

.live-dot {
  width: 7px;
  height: 7px;
  background: var(--brand-success);
  border-radius: 50%;
  animation: livePulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 6px var(--brand-success);
}

@keyframes livePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════════
   VEHICLE CARDS (Tracking)
═══════════════════════════════════════════════════════════════ */

.vehicle-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.vehicle-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.vehicle-card:hover {
  border-color: var(--border-default);
  background: var(--bg-overlay);
}

.vehicle-card.selected {
  border-color: var(--brand-secondary);
  background: rgba(0,197,255,0.06);
  box-shadow: var(--glow-secondary);
}

.vehicle-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.vehicle-info { flex: 1; overflow: hidden; }

.vehicle-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vehicle-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.vehicle-speed {
  font-size: 12px;
  font-weight: 700;
  color: var(--brand-secondary);
  text-align: end;
  white-space: nowrap;
}

/* ═══════════════════════════════════════════════════════════════
   MAP CONTAINER
═══════════════════════════════════════════════════════════════ */

.map-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #0A1628;
}

.map-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.map-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.map-controls {
  position: absolute;
  top: var(--space-3);
  inset-inline-end: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: all;
}

.map-info-panel {
  position: absolute;
  bottom: var(--space-4);
  inset-inline-start: var(--space-4);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  min-width: 240px;
  box-shadow: var(--shadow-xl);
  pointer-events: all;
  backdrop-filter: blur(12px);
}

/* ═══════════════════════════════════════════════════════════════
   DETAIL PANEL
═══════════════════════════════════════════════════════════════ */

.detail-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.detail-panel-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-raised);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.detail-section {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.detail-section:last-child { border-bottom: none; }

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.detail-item {}
.detail-item-label { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.detail-item-value { font-size: 13px; font-weight: 600; color: var(--text-primary); }

/* Live Data */
.live-data-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-3);
}

.live-data-item {
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  text-align: center;
}

.live-data-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--brand-secondary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.live-data-unit {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.live-data-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ═══════════════════════════════════════════════════════════════
   MODAL
═══════════════════════════════════════════════════════════════ */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6,13,26,0.85);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.modal-backdrop.open { display: flex; }

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-lg { max-width: 720px; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 800; color: var(--text-primary); }

.modal-body { padding: var(--space-6); }

.modal-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ═══════════════════════════════════════════════════════════════
   NOTIFICATIONS PANEL
═══════════════════════════════════════════════════════════════ */

.notifications-panel {
  position: absolute;
  top: calc(var(--topbar-height) - 4px);
  inset-inline-end: var(--space-4);
  width: 340px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  z-index: 150;
  display: none;
  overflow: hidden;
}

.notifications-panel.open { display: block; }

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

.notif-item {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
  cursor: pointer;
}

.notif-item:hover { background: var(--bg-hover); }
.notif-item.unread { background: rgba(0,197,255,0.04); }

.notif-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.notif-content { flex: 1; }
.notif-title { font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════
   TOAST
═══════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: var(--space-6);
  inset-inline-end: var(--space-6);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toastIn 300ms cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 280px;
}

.toast.success { border-color: rgba(0,217,126,0.4); }
.toast.error   { border-color: rgba(255,58,58,0.4); }
.toast.warning { border-color: rgba(255,184,0,0.4); }

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

/* ═══════════════════════════════════════════════════════════════
   LOADING
═══════════════════════════════════════════════════════════════ */

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-default);
  border-top-color: var(--brand-secondary);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  position: fixed;
  inset: 0;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 999;
  gap: var(--space-4);
}

.page-loader-logo {
  font-size: 32px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-secondary), var(--brand-accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════════ */

@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform var(--transition-normal), width var(--transition-normal); }
  [dir="rtl"] .sidebar { transform: translateX(100%); }
  .sidebar.mobile-open { transform: translateX(0) !important; width: var(--sidebar-width) !important; }
  .main-area { margin-inline-start: 0 !important; }
  .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .topbar-search { display: none; }
}

@media (max-width: 600px) {
  .page-content { padding: var(--space-4); }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
}

/* ── Floating sidebar collapse tab ─────────────────────────────
   Always visible tab on the right edge of the sidebar          */
.sidebar-collapse-tab {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  inset-inline-start: calc(var(--sidebar-width) - 1px);
  width: 18px;
  height: 56px;
  background: var(--brand-primary);
  border-radius: 0 8px 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: calc(var(--z-sidebar) + 1);
  transition: inset-inline-start .28s cubic-bezier(.4,0,.2,1), background .2s;
  box-shadow: 4px 0 16px rgba(0,0,0,.3);
}

.sidebar-collapse-tab:hover {
  background: var(--brand-secondary);
  width: 22px;
}

.sidebar-collapse-tab::after {
  content: '‹';
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
}

.sidebar.collapsed ~ .sidebar-collapse-tab,
body.sidebar-collapsed .sidebar-collapse-tab {
  inset-inline-start: calc(64px - 1px);
}

.sidebar.collapsed ~ .sidebar-collapse-tab::after,
body.sidebar-collapsed .sidebar-collapse-tab::after {
  content: '›';
}
