/* ============================================================
   SayaRadius ISP Management System - Global Stylesheet
   Design: Dark Industrial / Network Operations Center Aesthetic
   ============================================================ */

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

/* ─── CSS Variables / Design Tokens ─── */
:root {
  /* Brand Colors */
  --primary: #00d4aa;
  --primary-dim: #00a882;
  --primary-glow: rgba(0, 212, 170, 0.15);
  --primary-glow-strong: rgba(0, 212, 170, 0.3);
  --accent: #ff6b35;
  --accent-dim: #cc5429;
  --accent-glow: rgba(255, 107, 53, 0.15);
  --warning: #ffd60a;
  --warning-dim: #cc9c00;
  --danger: #ff3b5c;
  --danger-dim: #cc2f49;
  --info: #4facfe;
  --success: #00d4aa;

  /* Background System */
  --bg-base: #050b12;
  --bg-surface: #0a1520;
  --bg-elevated: #0f1e2e;
  --bg-card: #0d1926;
  --bg-card-hover: #122130;
  --bg-input: #091319;
  --bg-modal: #0c1823;

  /* Border System */
  --border: rgba(0, 212, 170, 0.12);
  --border-strong: rgba(0, 212, 170, 0.25);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-focus: rgba(0, 212, 170, 0.5);

  /* Text System */
  --text-primary: #e8f4f1;
  --text-secondary: #7da8c0;
  --text-muted: #4a7a92;
  --text-accent: #00d4aa;
  --text-inverse: #050b12;

  /* Sidebar */
  --sidebar-width: 260px;
  --sidebar-collapsed: 72px;
  --sidebar-bg: #060e17;
  --sidebar-border: rgba(0, 212, 170, 0.1);

  /* Topbar */
  --topbar-height: 64px;
  --topbar-bg: rgba(5, 11, 18, 0.95);

  /* Typography */
  --font-display: 'Sora', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-primary: 0 0 20px rgba(0, 212, 170, 0.2);
  --shadow-elevated: 0 8px 40px rgba(0, 0, 0, 0.6);

  /* Transitions */
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}


/* ─── Default to light mode ─── */
/* JS overrides this based on localStorage — default is light */
body {
  --bg-base: #f0f4f8;
  --bg-surface: #e8eef4;
  --bg-elevated: #dde6ef;
  --bg-card: #ffffff;
  --bg-card-hover: #f5f8fb;
  --bg-input: #eaf0f6;
  --bg-modal: #ffffff;
  --topbar-bg: rgba(240,244,248,0.96);
  --border: rgba(0,180,140,0.18);
  --border-strong: rgba(0,180,140,0.32);
  --border-subtle: rgba(0,0,0,0.08);
  --text-primary: #0d2233;
  --text-secondary: #2a5068;
  --text-muted: #6b96ae;
  --shadow-card: 0 2px 16px rgba(0,0,0,0.08);
  color-scheme: light;
}
/* Dark mode only when .dark-mode class is explicitly applied */
body.dark-mode {
  --bg-base: #050b12;
  --bg-surface: #0a1520;
  --bg-elevated: #0f1e2e;
  --bg-card: #0d1926;
  --bg-card-hover: #122130;
  --bg-input: #091319;
  --bg-modal: #0c1823;
  --topbar-bg: rgba(5,11,18,0.95);
  --border: rgba(0,212,170,0.12);
  --border-strong: rgba(0,212,170,0.25);
  --border-subtle: rgba(255,255,255,0.05);
  --text-primary: #e8f4f1;
  --text-secondary: #7da8c0;
  --text-muted: #4a7a92;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4);
  color-scheme: dark;
}

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

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

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

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: rgba(0, 212, 170, 0.25); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ─── Layout ─── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  min-width: 0;
  width: calc(100vw - var(--sidebar-width));
  max-width: calc(100vw - var(--sidebar-width));
  overflow-x: hidden;
  transition: margin-left var(--transition-slow), width var(--transition-slow);
  background:
    radial-gradient(ellipse 60% 40% at 20% 0%, rgba(0, 212, 170, 0.04) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 80% 80%, rgba(79, 172, 254, 0.03) 0%, transparent 50%),
    var(--bg-base);
}

.main-content.sidebar-collapsed { margin-left: var(--sidebar-collapsed); width: calc(100vw - var(--sidebar-collapsed)); max-width: calc(100vw - var(--sidebar-collapsed)); }

.page-container {
  padding: var(--space-xl);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  padding: 20px var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
  flex-shrink: 0;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), #0099cc);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-primary);
}

.logo-icon svg { width: 20px; height: 20px; color: var(--bg-base); }

.logo-text {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition), width var(--transition);
}

.logo-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.logo-sub {
  font-size: 10px;
  color: var(--primary);
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-top: 2px;
}

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

/* Nav */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-md) 0;
}

.nav-section { margin-bottom: var(--space-md); }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 0 var(--space-lg);
  margin-bottom: var(--space-xs);
  white-space: nowrap;
  transition: opacity var(--transition);
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(0, 212, 170, 0.06);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-glow);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  transition: transform var(--transition);
}

.nav-item:hover svg { transform: translateX(2px); }

.nav-item-label {
  transition: opacity var(--transition);
  flex: 1;
}

.sidebar.collapsed .nav-item-label { opacity: 0; pointer-events: none; }

.nav-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-badge { opacity: 0; }

/* Sidebar Footer */
.sidebar-footer {
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  cursor: pointer;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--primary), #0099cc);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--bg-base);
  flex-shrink: 0;
  border: 2px solid var(--border-strong);
}

.user-info { overflow: hidden; transition: opacity var(--transition); }
.sidebar.collapsed .user-info { opacity: 0; width: 0; }

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

.user-role {
  font-size: 11px;
  color: var(--primary);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* ─── Topbar ─── */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-xl);
  gap: var(--space-md);
  z-index: 90;
  backdrop-filter: blur(12px);
  transition: left var(--transition-slow);
}

.topbar.sidebar-collapsed { left: var(--sidebar-collapsed); }

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex: 1;
}

.btn-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-glow);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: 13px;
}

.breadcrumb-item { color: var(--text-muted); }
.breadcrumb-sep { color: var(--text-muted); opacity: 0.4; }
.breadcrumb-current { color: var(--text-primary); font-weight: 500; }

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

/* Search */
.topbar-search {
  position: relative;
}

.topbar-search input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 36px 8px var(--space-md);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-display);
  width: 240px;
  transition: all var(--transition);
  outline: none;
}

.topbar-search input:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
  width: 300px;
}

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

.topbar-search-icon {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

/* Icon Buttons */
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

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

.icon-btn svg { width: 18px; height: 18px; }

.icon-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  border-radius: var(--radius-full);
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  border: 2px solid var(--bg-base);
}

/* Status dot */
.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-indicator.online { background: var(--primary); box-shadow: 0 0 6px var(--primary); }
.status-indicator.offline { background: var(--danger); }
.status-indicator.warning { background: var(--warning); }

/* ─── Page Header ─── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-xl);
  gap: var(--space-md);
}

.page-title { font-size: 26px; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-family: var(--font-mono); }

.page-actions { display: flex; gap: var(--space-sm); align-items: center; flex-shrink: 0; }

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--primary);
  color: var(--bg-base);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dim);
  box-shadow: 0 4px 16px rgba(0, 212, 170, 0.3);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-glow);
}

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

.btn-danger:hover { background: rgba(255, 59, 92, 0.1); }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition);
}

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

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

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.card-title svg { width: 16px; height: 16px; color: var(--primary); }

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

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 60px;
  height: 60px;
  background: radial-gradient(circle, var(--card-accent, var(--primary-glow)) 0%, transparent 70%);
  pointer-events: none;
}

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

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-bottom: var(--space-sm);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: var(--space-xs);
  font-family: var(--font-mono);
}

.stat-change {
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
}

.stat-change.up { color: var(--primary); }
.stat-change.down { color: var(--danger); }
.stat-change svg { width: 12px; height: 12px; }

.stat-icon {
  position: absolute;
  top: var(--space-lg);
  right: var(--space-lg);
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg { width: 22px; height: 22px; }

/* ─── Tables ─── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}

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

thead tr {
  border-bottom: 1px solid var(--border-strong);
}

thead th {
  padding: 12px var(--space-md);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-family: var(--font-mono);
  white-space: nowrap;
}

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

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(0, 212, 170, 0.03); }

tbody td {
  padding: 12px var(--space-md);
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody td.text-primary { color: var(--text-primary); font-weight: 500; }

/* ─── Badges / Status ─── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-mono);
  white-space: nowrap;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.badge-success { background: rgba(0, 212, 170, 0.12); color: var(--primary); }
.badge-success .badge-dot { background: var(--primary); }
.badge-danger { background: rgba(255, 59, 92, 0.12); color: var(--danger); }
.badge-danger .badge-dot { background: var(--danger); }
.badge-warning { background: rgba(255, 214, 10, 0.12); color: var(--warning); }
.badge-warning .badge-dot { background: var(--warning); }
.badge-info { background: rgba(79, 172, 254, 0.12); color: var(--info); }
.badge-info .badge-dot { background: var(--info); }
.badge-neutral { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
.badge-neutral .badge-dot { background: var(--text-muted); }

/* ─── Forms / Inputs ─── */
.form-group { margin-bottom: var(--space-md); }

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
}

input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px var(--space-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-display);
  outline: none;
  transition: all var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%234a7a92' stroke-width='2'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

select option { background: var(--bg-elevated); color: var(--text-primary); }

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

/* ─── Modal ─── */
/* modal-overlay — see MODAL FIX section below */

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

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

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex;
  align-items: center;
}

.modal-close:hover { color: var(--danger); background: rgba(255,59,92,0.1); }
.modal-close svg { width: 20px; height: 20px; }

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

.modal-footer {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
  padding: var(--space-md) var(--space-xl);
  border-top: 1px solid var(--border);
}

/* ─── Grid Utilities ─── */
.grid { display: grid; gap: var(--space-lg); width: 100%; min-width: 0; }
.grid > * { min-width: 0; overflow: hidden; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* ─── Alerts ─── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-md);
  font-size: 13px;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: rgba(0, 212, 170, 0.08); border: 1px solid rgba(0,212,170,0.2); color: var(--primary); }
.alert-danger { background: rgba(255, 59, 92, 0.08); border: 1px solid rgba(255,59,92,0.2); color: var(--danger); }
.alert-warning { background: rgba(255, 214, 10, 0.08); border: 1px solid rgba(255,214,10,0.2); color: var(--warning); }
.alert-info { background: rgba(79, 172, 254, 0.08); border: 1px solid rgba(79,172,254,0.2); color: var(--info); }

/* ─── Loading ─── */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Loading skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--bg-elevated) 25%, rgba(255,255,255,0.03) 50%, var(--bg-elevated) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Tooltip ─── */
[data-tooltip] { position: relative; }

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
  font-family: var(--font-mono);
}

[data-tooltip]:hover::after { opacity: 1; }

/* ─── Tabs ─── */
.tabs { display: flex; gap: 2px; padding: 4px; background: var(--bg-input); border-radius: var(--radius-md); }

.tab-btn {
  flex: 1;
  padding: 8px var(--space-md);
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--bg-elevated);
  color: var(--primary);
  box-shadow: var(--shadow-card);
}

/* ─── Progress Bar ─── */
.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #0099cc);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Toast Notifications ─── */
#toast-container {
  position: fixed;
  bottom: var(--space-xl);
  right: var(--space-xl);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  animation: toastIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-elevated);
}

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

.toast.out { animation: toastOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(20px); }
}

.toast-success { border-left: 3px solid var(--primary); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-warning { border-left: 3px solid var(--warning); }
.toast-info { border-left: 3px solid var(--info); }

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast-success svg { color: var(--primary); }
.toast-error svg { color: var(--danger); }
.toast-warning svg { color: var(--warning); }
.toast-info svg { color: var(--info); }

/* ─── Misc Utilities ─── */
.text-primary-color { color: var(--primary) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-mono { font-family: var(--font-mono) !important; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-medium { font-weight: 500; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

/* ─── Divider ─── */
.divider { height: 1px; background: var(--border-subtle); margin: var(--space-md) 0; }

/* ─── Empty State ─── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl);
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-md);
}

.empty-state svg { width: 48px; height: 48px; opacity: 0.3; }
.empty-state-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-state-desc { font-size: 13px; }

/* ─── Page Transitions ─── */
.page-enter {
  animation: pageEnter 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes pageEnter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Responsive ─── */
@media (max-width: 1200px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .page-container { padding: var(--space-lg); }
}



/* Chart Fix */
.card canvas { width: 100% !important; display: block; }
#revenueChart { max-height: 220px; }
#clientChart  { max-height: 220px; }

/* Theme Toggle */
.theme-toggle { width:38px; height:38px; border-radius:var(--radius-sm); border:1px solid var(--border); background:var(--bg-input); color:var(--text-secondary); display:flex; align-items:center; justify-content:center; cursor:pointer; transition:all var(--transition); }
.theme-toggle:hover { border-color:var(--primary); color:var(--primary); background:var(--primary-glow); }
.theme-toggle svg { width:18px; height:18px; }
.theme-toggle .icon-moon { display:block; }
.theme-toggle .icon-sun  { display:none; }
body.light-mode .theme-toggle .icon-moon { display:none; }
body.light-mode .theme-toggle .icon-sun  { display:block; }

/* Light Mode */
body.light-mode { --bg-base:#f0f4f8; --bg-surface:#e8eef4; --bg-elevated:#dde6ef; --bg-card:#ffffff; --bg-card-hover:#f5f8fb; --bg-input:#eaf0f6; --bg-modal:#ffffff; --sidebar-bg:#060e17; --topbar-bg:rgba(240,244,248,0.96); --border:rgba(0,180,140,0.18); --border-strong:rgba(0,180,140,0.32); --border-subtle:rgba(0,0,0,0.08); --text-primary:#0d2233; --text-secondary:#2a5068; --text-muted:#6b96ae; --shadow-card:0 2px 16px rgba(0,0,0,0.08); }
body.light-mode .main-content { background: radial-gradient(ellipse 60% 40% at 20% 0%, rgba(0,212,170,0.06) 0%, transparent 60%), var(--bg-base); }
body.light-mode .topbar { border-bottom:1px solid rgba(0,180,140,0.15); box-shadow:0 1px 8px rgba(0,0,0,0.06); }
body.light-mode .card, body.light-mode .stat-card { box-shadow:0 2px 12px rgba(0,0,0,0.06); }
body.light-mode tbody tr:hover { background:rgba(0,212,170,0.04); }
body.light-mode input, body.light-mode select, body.light-mode textarea { color:var(--text-primary); }


/* Light mode sidebar */
body.light-mode .sidebar { background:#e8eef4; border-right:1px solid rgba(0,180,140,0.2); }
body.light-mode .nav-section-label { color:#6b96ae; }
body.light-mode .nav-item { color:#2a5068; }
body.light-mode .nav-item:hover { background:rgba(0,180,140,0.08); color:#0d2233; }
body.light-mode .nav-item.active { background:rgba(0,212,170,0.12); color:#009977; }
body.light-mode .nav-item.active::before { background:#00c49a; }
body.light-mode .logo-name { color:#0d2233; }
body.light-mode .logo-sub { color:#00a882; }
body.light-mode .sidebar-footer { border-top:1px solid rgba(0,180,140,0.15); }
body.light-mode .user-name { color:#0d2233; }
body.light-mode .user-role { color:#009977; }
body.light-mode .logo-icon { background:rgba(0,180,140,0.15); border:1px solid rgba(0,180,140,0.3); }
body.light-mode .sidebar-logo { border-bottom:1px solid rgba(0,180,140,0.15); }

/* MODAL FIX - Pattern A: .modal-overlay wrapper */
.modal-overlay { position:fixed; inset:0; background:rgba(5,11,18,0.85); backdrop-filter:blur(8px); z-index:1000; display:none; align-items:center; justify-content:center; padding:var(--space-lg); }
.modal-overlay.open { display:flex; }
.modal-overlay .modal { background:var(--bg-modal); border:1px solid var(--border-strong); border-radius:var(--radius-xl); width:100%; max-width:560px; max-height:85vh; overflow-y:auto; box-shadow:var(--shadow-elevated); position:relative; transform:none; }

/* MODAL FIX - Pattern B: .modal is the wrapper */
.modal { display:none; position:fixed; inset:0; z-index:1000; align-items:center; justify-content:center; }
.modal.open { display:flex; }
.modal-backdrop { position:absolute; inset:0; background:rgba(5,11,18,0.85); backdrop-filter:blur(8px); cursor:pointer; }
.modal-box { position:relative; z-index:1; background:var(--bg-modal); border:1px solid var(--border-strong); border-radius:var(--radius-xl); width:100%; max-width:560px; max-height:85vh; overflow-y:auto; box-shadow:var(--shadow-elevated); padding:var(--space-xl); margin:var(--space-lg); }
.modal-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:var(--space-lg); padding-bottom:var(--space-md); border-bottom:1px solid var(--border); }
.modal-title { font-size:18px; font-weight:700; color:var(--text-primary); }
.modal-close { background:none; border:none; color:var(--text-muted); cursor:pointer; padding:4px; border-radius:var(--radius-sm); transition:all var(--transition); display:flex; align-items:center; }
.modal-close:hover { color:var(--danger); background:rgba(255,59,92,0.1); }
.modal-close svg { width:20px; height:20px; }
.modal-footer { display:flex; gap:var(--space-sm); justify-content:flex-end; padding-top:var(--space-md); margin-top:var(--space-lg); border-top:1px solid var(--border); }

/* MOBILE SIDEBAR */
#sidebar-overlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.75); z-index:200; cursor:pointer; }
#sidebar-overlay.active { display:block; }

@media (max-width: 768px) {
  .sidebar { position:fixed !important; top:0 !important; left:0 !important; height:100vh !important; width:270px !important; transform:translateX(-100%) !important; transition:transform 0.3s ease !important; z-index:300 !important; overflow-y:auto !important; overflow-x:hidden !important; }
  .sidebar.mobile-open { transform:translateX(0) !important; box-shadow:8px 0 48px rgba(0,0,0,0.85) !important; }
  .main-content, .main-content.collapsed, .main-content.sidebar-collapsed { margin-left:0 !important; width:100vw !important; max-width:100vw !important; }
  .topbar, .topbar.collapsed, .topbar.sidebar-collapsed { left:0 !important; right:0 !important; z-index:100 !important; padding:0 12px !important; }
  .btn-toggle { position:relative !important; z-index:101 !important; flex-shrink:0 !important; }
  .topbar-search { display:none !important; }
  .page-container { padding:12px !important; }
  .page-header { flex-direction:row !important; align-items:flex-start !important; justify-content:space-between !important; flex-wrap:nowrap !important; gap:8px !important; margin-bottom:16px !important; }
  .page-title { font-size:20px !important; }
  .page-actions { flex-shrink:0 !important; width:auto !important; }
  .grid-2,.grid-3,.grid-4,.grid-5 { grid-template-columns:repeat(2,1fr) !important; gap:10px !important; }
  .stat-card { padding:12px 40px 12px 12px !important; }
  .stat-label { font-size:9px !important; white-space:normal !important; line-height:1.3 !important; }
  .stat-value { font-size:20px !important; }
  .stat-icon { width:28px !important; height:28px !important; top:10px !important; right:8px !important; }
  .stat-icon svg { width:14px !important; height:14px !important; }
  .card { padding:14px !important; }
  .modal-box { margin:12px !important; max-width:calc(100vw - 24px) !important; }
  #toast-container { bottom:12px !important; right:12px !important; left:12px !important; }
  .toast { min-width:unset !important; width:100% !important; }
}

/* Hamburger always visible above sidebar overlay */
@media (max-width: 768px) {
  .btn-toggle {
    z-index: 400 !important;
    position: relative !important;
  }
  .topbar {
    z-index: 399 !important;
  }
}


/* ─── Collapsible Nav Groups ─── */
.nav-group { margin-bottom: 2px; }

.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 10px var(--space-lg);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font-display);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  position: relative;
  transition: all var(--transition);
}

.nav-group-toggle:hover {
  color: var(--text-primary);
  background: rgba(0, 212, 170, 0.06);
}

.nav-group-toggle svg:first-child {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-group-chevron {
  width: 14px !important;
  height: 14px !important;
  margin-left: auto;
  transition: transform var(--transition);
  flex-shrink: 0;
  color: var(--text-muted);
}

.nav-group.open .nav-group-chevron {
  transform: rotate(180deg);
}

.nav-group.open .nav-group-toggle {
  color: var(--primary);
}

.nav-group-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-group.open .nav-group-items {
  max-height: 300px;
}

.nav-item.nav-sub {
  padding-left: calc(var(--space-lg) + 26px);
  font-size: 13px;
  gap: var(--space-sm);
}

.nav-sub-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
  transition: background var(--transition);
}

.nav-item.nav-sub:hover .nav-sub-dot,
.nav-item.nav-sub.active .nav-sub-dot {
  background: var(--primary);
}

.nav-item.nav-sub.active {
  color: var(--primary);
  background: var(--primary-glow);
}

.nav-item.nav-sub.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
}

/* Active section label highlight */
.nav-section.section-active .nav-section-label {
  color: var(--primary);
}

/* Collapsed sidebar — hide group chevron text */
.sidebar.collapsed .nav-group-chevron { display: none; }
.sidebar.collapsed .nav-group-toggle { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-group-toggle svg:first-child { margin: 0; }
.sidebar.collapsed .nav-group-items { display: none; }

/* Light mode overrides for nav-group */
body.light-mode .nav-group-toggle { color: #2a5068; }
body.light-mode .nav-group-toggle:hover { background: rgba(0,180,140,0.08); color: #0d2233; }
body.light-mode .nav-group.open .nav-group-toggle { color: #009977; }

/* ── Dashboard mobile overrides ── */
@media(max-width:600px) {
  .split-card-header { flex-wrap:wrap; gap:8px; padding:12px 14px 10px; }
  .split-card-body { padding:12px 14px !important; }
  .split-card-title { font-size:12px; }
  .nh-section-label { font-size:9px; }
  .days-chip { font-size:9px; padding:2px 5px; }
  .badge { font-size:10px; padding:2px 7px; }
  .btn-sm { padding:4px 8px; font-size:11px; }
}
