:root {
  --primary: #6366f1; /* Indigo-Modern */
  --primary-hover: #4f46e5;
  --secondary: #06b6d4; /* Cyan-Flash */
  --secondary-hover: #0891b2;
  --accent: #fb7185; /* Rose-Glow */
  --danger: #f43f5e;
  --warning: #f59e0b;
  --success: #10b981;

  --bg-dark: #020617; /* Deep Onyx */
  --bg-darker: #01040f;
  --text-light: #f8fafc;
  --text-muted: #94a3b8;
  --text-main: #f8fafc;

  --glass-bg: rgba(15, 23, 42, 0.7);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.82);
  --inner-glow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);

  --font-family: 'Cairo', sans-serif;
  --border-radius-lg: 24px;
  --border-radius-md: 12px;
  --transition-speed: 0.4s;
  --sidebar-width: 290px;

  /* Specific Components */
  --input-bg: rgba(0, 0, 0, 0.4);
  --table-hover: rgba(255, 255, 255, 0.03);
  --glow-color: rgba(99, 102, 241, 0.4);
}

[data-theme="light"] {
  --bg-dark: #f8fafc;
  --bg-darker: #f1f5f9;
  --text-light: #0f172a;
  --text-muted: #64748b;
  --text-main: #0f172a;

  --glass-bg: rgba(255, 255, 255, 0.75);
  --glass-border: rgba(0, 0, 0, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.08);

  --input-bg: #ffffff;
  --table-hover: rgba(0, 0, 0, 0.02);
}

/* ====== Global Animations ====== */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(99, 102, 241, 0); }
  100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0); }
}

@keyframes float-blob {
  0% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -50px) scale(1.1); }
  66% { transform: translate(-20px, 20px) scale(0.9); }
  100% { transform: translate(0, 0) scale(1); }
}

.animate-up {
  animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ====== Global Styles ====== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-darker);
  color: var(--text-light);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Animated background blobs */
body::before, body::after {
  content: '';
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  filter: blur(120px);
  z-index: -1;
  opacity: 0.15;
  pointer-events: none;
}

body::before {
  background: var(--primary);
  top: -10%;
  left: -10%;
  animation: float-blob 20s infinite alternate;
}

body::after {
  background: var(--secondary);
  bottom: -10%;
  right: -10%;
  animation: float-blob 25s infinite alternate-reverse;
}

/* ====== Utilities ====== */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow), var(--inner-glow);
  border-radius: var(--border-radius-lg);
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
}

.btn {
  font-family: var(--font-family);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0.8rem 1.8rem;
  border: 1px solid transparent;
  border-radius: var(--border-radius-md);
  cursor: pointer;
  transition: all var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  overflow: hidden;
  position: relative;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: white;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(99, 102, 241, 0.5);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--secondary), #0891b2);
  color: white;
  box-shadow: 0 4px 15px rgba(6, 182, 212, 0.2);
}

.btn-secondary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 25px rgba(6, 182, 212, 0.4);
  border-color: rgba(255, 255, 255, 0.2);
}

.form-group label {
  display: block;
  margin-bottom: 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.8rem 1.2rem;
  background-color: var(--input-bg);
  backdrop-filter: blur(5px);
  border: 1px solid var(--glass-border);
  border-radius: var(--border-radius-md);
  color: var(--text-light);
  font-family: var(--font-family);
  font-size: 1rem;
  transition: all var(--transition-speed);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  background-color: rgba(0, 0, 0, 0.6);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.error-message {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 1rem;
  min-height: 1.2rem;
}

/* ====== Auth Page (Login/Register) ====== */
.auth-body {
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle at top left, #0f172a, #01040f);
  position: relative;
  overflow: hidden;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 480px;
  padding: 3.5rem;
  margin: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6), var(--inner-glow);
}

.auth-header h1 {
  font-weight: 800;
  margin-bottom: 0.75rem;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-size: 2.2rem;
}

.auth-header p {
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-tabs {
  display: flex;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--glass-border);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: 1rem;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-speed);
}

.tab-btn:hover {
  color: var(--text-light);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-form {
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ====== Dashboard Layout ====== */
.dashboard-body {
  flex-direction: row;
  overflow: hidden;
  background: var(--bg-darker);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 20px;
  top: 20px;
  bottom: 20px;
  z-index: 1000;
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--glass-border);
  transition: transform var(--transition-speed) cubic-bezier(0.16, 1, 0.3, 1);
  transform: translateX(calc(100% + 40px));
}

@media (min-width: 992px) {
  .sidebar {
    transform: translateX(0);
  }
}

.sidebar-header {
  padding: 2rem 1.5rem;
  text-align: center;
  border-bottom: 1px solid var(--glass-border);
}

.sidebar-header h2 {
  color: white;
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sidebar-header h2 i {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-left: 0.5rem;
}

.user-info {
  padding: 1.25rem;
  margin: 0.5rem 1rem 1rem;
  background: rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius-md);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: white;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
  flex-shrink: 0;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.9rem;
  color: white;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-nav {
  padding: 0 0.75rem 1.5rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-group {
  margin-bottom: 0.25rem;
}

.nav-group-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  color: var(--text-light);
  cursor: pointer;
  border-radius: var(--border-radius-md);
  transition: all var(--transition-speed);
  border: 1px solid transparent;
  user-select: none;
}

.nav-group-header i:first-child {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.nav-group-header .toggle-icon {
  margin-right: auto;
  font-size: 0.8rem;
  transition: transform 0.3s ease;
  color: var(--text-muted);
}

.nav-group-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-group.expanded .nav-group-header {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.05);
}

.nav-group.expanded .toggle-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-right: 1.5rem; /* RTL Indent */
  opacity: 0;
}

.nav-group.expanded .nav-submenu {
  max-height: 500px;
  opacity: 1;
  padding-top: 0.25rem;
  padding-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1.25rem;
  color: var(--text-light);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--border-radius-md);
  transition: all var(--transition-speed);
  border: 1px solid transparent;
}

.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-muted);
  transition: all var(--transition-speed);
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
  transform: translateX(-5px);
}

.nav-submenu .nav-item {
  padding: 0.6rem 1.25rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), transparent);
  border-right: 4px solid var(--primary);
  color: white;
  text-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
}

.nav-item.active i {
  color: var(--primary);
  filter: drop-shadow(0 0 5px var(--primary));
}

/* Main Content */
.main-content {
  flex: 1;
  margin-right: 0; /* No margin on mobile */
  display: flex;
  flex-direction: column;
  height: 100vh;
  transition: margin-right var(--transition-speed) ease;
  width: 100%;
}

@media (min-width: 992px) {
  .main-content {
    margin-right: calc(var(--sidebar-width) + 40px);
  }
}

.topbar {
  display: flex;
  align-items: center;
  padding: 1.25rem 2.5rem;
  border-radius: 0;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(1, 4, 15, 0.4);
  backdrop-filter: blur(15px);
  z-index: 90;
}

.menu-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  color: var(--text-light);
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed);
  margin-left: 1.25rem;
}

.menu-btn:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.topbar-title h2 {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.content-wrapper {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  position: relative;
}

.content-section {
  display: none;
  animation: fadeIn 0.4s ease-out;
}

.content-section.active-section {
  display: block;
}

/* Dashboard Cards */
.dashboard-cards {
  display: grid;
  grid-template-columns: 1fr; /* 1 column on mobile */
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 576px) {
  .dashboard-cards {
    grid-template-columns: repeat(2, 1fr); /* 2 columns on small tablets */
  }
}

@media (min-width: 1200px) {
  .dashboard-cards {
    grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
  }
}

/* Report Hub Grid */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-top: 1.5rem;
}

.report-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    overflow: hidden;
}

.report-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary), var(--secondary));
    opacity: 0.7;
}

.report-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.report-card-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.report-card-header i {
    font-size: 1.5rem;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
}

.report-card-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
}

.report-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.report-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--border-radius-md);
    color: var(--text-light);
    text-decoration: none;
    font-size: 0.9rem;
    transition: 0.2s;
}

.report-link:hover {
    background: rgba(99, 102, 241, 0.1);
    color: white;
    padding-left: 1.25rem;
}

.report-link i {
    font-size: 0.8rem;
    opacity: 0.5;
}

/* Sidebar Sub-Groups */
.nav-subgroup {
    margin: 1rem 0 0.5rem;
    padding: 0 1.25rem;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-subgroup::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--glass-border);
    opacity: 0.5;
}

.nav-item.mini {
    padding: 0.6rem 1.25rem 0.6rem 2.5rem; /* Indented for nested report sections */
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0.9;
}

.nav-item.mini i {
    font-size: 0.9rem;
    opacity: 0.7;
}

.nav-item.mini:hover {
    padding-right: 1.5rem;
    opacity: 1;
}

    grid-template-columns: repeat(4, 1fr); /* 4 columns on desktop */
  }
}

/* ====== Stat Cards (Unified) ====== */
.stat-card {
  padding: 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.03);
  transition: transform var(--transition-speed);
}

.stat-card:hover {
  transform: translateY(-5px);
}

.stat-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  transition: all var(--transition-speed);
}

.stat-card:hover .stat-icon {
  background: var(--primary);
  color: white;
  transform: scale(1.1) rotate(5deg);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.stat-info h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ====== Welcome Banner ====== */
.welcome-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2.5rem;
  margin-bottom: 2.5rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(6, 182, 212, 0.05));
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
}

.welcome-banner::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 250px;
  height: 250px;
  background: var(--primary);
  filter: blur(100px);
  opacity: 0.2;
}

.welcome-text h2 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.welcome-text p {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 600;
}

.welcome-icon {
  font-size: 3.5rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 15px rgba(99, 102, 241, 0.4));
  animation: float-blob 6s ease-in-out infinite alternate;
}

/* ====== Grids & Layouts ====== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.filter-section {
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-group label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

/* ====== Dashboard Grid Layout ====== */
.dashboard-grid-2 {
  display: grid;
  grid-template-columns: 1fr; /* Stack on mobile */
  gap: 1.5rem;
  margin-bottom: 2rem;
}

@media (min-width: 992px) {
  .dashboard-grid-2 {
    grid-template-columns: 1.5fr 1fr; /* Side by side on desktop */
  }
}

/* ====== Chart Panel ====== */
.dashboard-chart-panel {
  padding: 1.5rem;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.panel-header h3 {
  color: var(--text-light);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-header h3 i {
  color: var(--primary);
}

.panel-badge {
  background: rgba(79, 70, 229, 0.15);
  color: var(--primary);
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.panel-link {
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: color 0.3s;
}

.panel-link:hover {
  color: var(--primary-hover);
}

.chart-container {
  width: 100%;
  min-height: 280px;
}

.chart-container canvas {
  width: 100%;
}

/* ====== Top Customers ====== */
.top-customers-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.top-customer-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 10px;
  transition: background 0.2s;
}

.top-customer-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.tc-rank {
  font-size: 1.2rem;
  min-width: 32px;
  text-align: center;
  font-weight: 800;
  color: var(--text-muted);
}

.tc-info {
  flex: 1;
  min-width: 0;
}

.tc-name {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tc-bar-container {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

/* ====== Tables & Lists ====== */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 0.5rem;
  margin-top: 1rem;
}

th {
  padding: 1.25rem 1rem;
  text-align: right;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--glass-border);
}

td {
  padding: 1.25rem 1rem;
  background: rgba(255, 255, 255, 0.02);
  transition: all 0.2s;
  color: var(--text-light);
  font-size: 0.95rem;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

td:first-child { border-radius: 0 12px 12px 0; }
td:last-child { border-radius: 12px 0 0 12px; }

/* Status Badges */
.status-badge {
  padding: 0.4rem 1rem;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-transform: uppercase;
}

.status-pending { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.2); }
.status-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.2); }
.status-danger { background: rgba(244, 63, 94, 0.15); color: #fb7185; border: 1px solid rgba(244, 63, 94, 0.2); }
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 1s ease;
}

.tc-amount {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--secondary);
  white-space: nowrap;
}

/* ====== Quick Actions ====== */
.quick-actions-panel {
  padding: 1.5rem;
}

.quick-actions-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2 columns on mobile */
  gap: 1rem;
}

@media (min-width: 576px) {
  .quick-actions-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 0.75rem;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text-light);
  text-decoration: none;
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.quick-action-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(79, 70, 229, 0.3);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.qa-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: white;
  transition: transform 0.3s ease;
}

.quick-action-btn:hover .qa-icon {
  transform: scale(1.1);
}

/* ====== Activity Feed ====== */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  transition: background 0.2s;
  border-right: 3px solid transparent;
}

.activity-item:hover {
  background: rgba(255, 255, 255, 0.03);
  border-right-color: var(--primary);
}

.activity-icon {
  width: 38px;
  min-width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.25rem;
}

.activity-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.activity-meta i {
  margin-left: 0.25rem;
}

.activity-amount {
  color: var(--secondary);
  font-weight: 600;
}

/* ====== Responsive Media Queries ====== */

/* Tablets and below (992px) */
@media (max-width: 992px) {
  .sidebar {
    width: 260px;
    --sidebar-width: 260px;
  }
  .main-content {
    margin-right: 260px;
  }
  .dashboard-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Small Tablets / Large Phones (768px) */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
    width: 280px;
    --sidebar-width: 0px;
  }
  
  .main-content {
    margin-right: 0;
  }
  
  .menu-btn {
    display: block;
  }
  
  .topbar {
    padding: 0.75rem 1rem;
  }
  
  .topbar-title h2 {
    font-size: 1.25rem;
  }
  
  .content-wrapper {
    padding: 1rem;
  }
  
  .dashboard-cards {
    grid-template-columns: 1fr;
  }
  
  .welcome-banner {
    flex-direction: column-reverse;
    text-align: center;
    gap: 1rem;
  }
  
  .welcome-icon {
    font-size: 2rem;
  }
  
  .auth-container {
    padding: 1.5rem;
  }

  /* Table Responsiveness */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: var(--border-radius-md);
  }
  
  table {
    min-width: 600px;
  }

  /* Quick Actions Grid */
  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Extra Small Phones (480px) */
@media (max-width: 480px) {
  .topbar-title h2 {
    font-size: 1.1rem;
  }
  
  .topbar-live-indicator {
    display: none;
  }
  
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }
  
  .stat-card {
    padding: 1rem;
    gap: 1rem;
  }
  
  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }
  
  .stat-value {
    font-size: 1.25rem;
  }
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10B981;
  animation: livePulse 1.5s ease-in-out infinite;
}

@keyframes livePulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
}

/* ====== Loading / Empty States ====== */
.loading-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  color: var(--text-muted);
  gap: 0.5rem;
}

.loading-placeholder i {
  font-size: 1.5rem;
}

.empty-state-small {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

/* ====== Table & Grid Utilities ====== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border-radius: var(--border-radius-md);
}

.table-responsive table {
  min-width: 600px;
  /* Force scroll on very small screens */
}

/* ====== Modal System (Premium Pop-ups) ====== */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  inset: 0;
  width: 100%;
  height: 100%;
  background: rgba(2, 6, 23, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  overflow-y: auto;
  padding: 1rem;
}

.modal-content {
  margin: 2rem auto;
  position: relative;
  width: 100%;
  max-width: 600px;
  animation: modalFadeIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transform-origin: center;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2,
.modal-header h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  margin: 0;
}

.close-modal {
  font-size: 1.75rem;
  font-weight: bold;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  transition: color 0.3s;
}

.close-modal:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--glass-border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Sidebar Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  z-index: 95;
  display: none;
  animation: fadeIn 0.3s ease-out;
}

.sidebar-overlay.show {
  display: block;
}

/* ====== Table Responsiveness ====== */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--primary) transparent;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--primary);
  border-radius: 3px;
}

.table-responsive table {
  min-width: 800px; /* Ensure tables don't squash too much */
}

/* ====== Responsive Media Queries ====== */

/* Large Tablets & Small Desktops */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 260px;
  }
}

/* Tablets (Portrait) */
@media (max-width: 991px) {
  .sidebar {
    transform: translateX(100%);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-content {
    margin-right: 0 !important;
  }

  #mobile-menu-btn {
    display: flex;
  }

  .topbar {
    padding: 1rem;
  }

  .content-wrapper {
    padding: 1rem;
  }
}

/* Mobile Devices */
@media (max-width: 767px) {
  .dashboard-cards {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .stat-card {
    padding: 1.25rem;
    flex-direction: column;
    text-align: center;
    gap: 0.75rem;
  }

  .stat-icon {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
  }

  .welcome-banner {
    flex-direction: column;
    text-align: center;
    gap: 1rem;
    padding: 1.5rem;
  }

  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .modal-content {
    width: 95% !important;
    margin: 10px auto;
    padding: 1.5rem 1rem;
  }

  .topbar-title h2 {
    font-size: 1.2rem;
  }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
  .quick-actions-grid {
    grid-template-columns: 1fr;
  }

  .auth-container {
    padding: 1.5rem;
    margin: 0.5rem;
  }

  .tab-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.9rem;
  }

  .stat-value {
    font-size: 1.25rem;
  }
}

/* ====== Print Styles ====== */
@media print {
  body {
    background: white;
    color: black;
  }

  .sidebar,
  .topbar,
  .tabs-nav,
  .btn,
  .menu-btn,
  .auth-tabs,
  .section-header {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
    padding: 0 !important;
  }

  .glass-panel {
    background: white !important;
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    color: black !important;
  }

  .modal-content,
  #customer-details-view {
    position: static !important;
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    height: auto !important;
    overflow: visible !important;
    transform: none !important;
  }

  table,
  th,
  td {
    border: 1px solid #ccc !important;
    color: black !important;
  }

  th {
    background-color: #f3f4f6 !important;
  }

  .print-only {
    display: block !important;
  }

  .no-print {
    display: none !important;
  }
}

/* ====== Notification System ====== */
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  border: 2px solid var(--bg-darker);
}

.notification-dropdown {
  position: absolute;
  top: 50px;
  left: 0;
  width: 320px;
  max-height: 480px;
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  animation: fadeIn 0.3s ease-out;
}

.notification-dropdown.active {
  display: flex;
}

.noti-header {
  padding: 1rem;
  font-weight: 700;
  border-bottom: 1px solid var(--glass-border);
  background: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

.noti-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
}

.noti-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: background 0.2s;
}

.noti-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.noti-item.unread {
  background: rgba(79, 70, 229, 0.05);
  border-right: 3px solid var(--primary);
}

.noti-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  display: block;
}

.noti-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: block;
  line-height: 1.4;
}

.noti-time {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  display: block;
}

/* ============================================================
   RBAC – Access Denied Modal
   ============================================================ */
#rbac-denied-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  transition: background 0.4s ease, backdrop-filter 0.4s ease;
}
#rbac-denied-overlay.show {
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
}

.rbac-modal {
  position: relative;
  width: 90%;
  max-width: 440px;
  background: linear-gradient(145deg, rgba(30, 30, 60, 0.95), rgba(15, 15, 35, 0.98));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 2.5rem 2rem 2rem;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 80px rgba(99, 102, 241, 0.08);
  transform: scale(0.8);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
}
#rbac-denied-overlay.show .rbac-modal {
  transform: scale(1);
  opacity: 1;
}

.rbac-modal-close {
  position: absolute;
  top: 14px;
  left: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.6);
  font-size: 1.4rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
}
.rbac-modal-close:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.rbac-modal-icon {
  width: 90px;
  height: 90px;
  margin: 0 auto 1.5rem;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05));
  border: 2px solid rgba(239, 68, 68, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: rbac-pulse 2s ease-in-out infinite;
}
.rbac-modal-icon i {
  font-size: 2.4rem;
  color: #ef4444;
}

@keyframes rbac-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.15); }
  50%      { transform: scale(1.06); box-shadow: 0 0 20px 6px rgba(239, 68, 68, 0.08); }
}

.rbac-modal-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.8rem;
}

.rbac-modal-message {
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.55);
  line-height: 1.7;
  margin-bottom: 2rem;
}

.rbac-modal-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.85rem 2.2rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  color: #fff;
  background: linear-gradient(135deg, var(--primary, #6366f1), #4f46e5);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.rbac-modal-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.35);
}
.rbac-modal-btn:active {
  transform: translateY(0);
}
