/**
 * ============================================================================
 * Enterprise ERP Design System - Core Theme
 * Modern, High-Contrast, Professional SaaS UI
 * Strictly adheres to project standards:
 * - NO purple gradients
 * - Modest button/card radii (4px-8px for buttons, 10px-14px for cards)
 * - NO pill buttons
 * - High readability, accessible contrast, smooth micro-interactions
 * ============================================================================
 */

:root {
  /* Primary Brand: Refined Executive Blue */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-light: #eff6ff;
  --primary-subtle: #dbeafe;
  --primary-border: #bfdbfe;
  --primary-glow: rgba(37, 99, 235, 0.15);

  /* Status Colors */
  --success: #059669;
  --success-hover: #047857;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;
  --success-text: #065f46;

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;
  --danger-text: #991b1b;

  --warning: #d97706;
  --warning-hover: #b45309;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;

  --info: #0284c7;
  --info-hover: #0369a1;
  --info-light: #f0f9ff;
  --info-border: #bae6fd;
  --info-text: #075985;

  /* Neutral Slate Scale */
  --g50: #f8fafc;
  --g100: #f1f5f9;
  --g200: #e2e8f0;
  --g300: #cbd5e1;
  --g400: #94a3b8;
  --g500: #64748b;
  --g600: #475569;
  --g700: #334155;
  --g800: #1e293b;
  --g900: #0f172a;

  /* Surfaces & Borders */
  --surface-card: #ffffff;
  --surface-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #2563eb;

  /* Radii - Clean architectural radius (no pill shapes) */
  --r-xs: 4px;
  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Layout */
  --sb: 230px;
  --header-height: 60px;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
  --shadow-md: 0 2px 6px -1px rgba(15, 23, 42, 0.06), 0 1px 3px -1px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 8px 20px -3px rgba(15, 23, 42, 0.07), 0 4px 6px -2px rgba(15, 23, 42, 0.03);
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.04), 0 4px 14px -2px rgba(15, 23, 42, 0.03);
}

/* Base Reset & Typography */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0f172a;
  min-height: 100vh;
  color: var(--g800);
  line-height: 1.5;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--g300);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--g400);
}

.page {
  display: none;
}

/* ============================================================================
   ADMIN DASHBOARD LAYOUT & SIDEBAR
   ============================================================================ */
.admin-layout {
  display: flex;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--g50) 0%, #f1f5f9 100%);
}

.sidebar {
  width: var(--sb);
  background: linear-gradient(180deg, #090d16 0%, #0c121f 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  padding: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 40;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
}

/* Responsive Sidebar */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }

  .sidebar .sb-brand-text span {
    font-size: 0.85rem;
  }

  .sidebar .nav-text {
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -100%;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .sidebar.mobile-open {
    left: 0;
  }

  .sidebar .sb-close {
    display: flex;
  }

  .admin-main {
    padding: 16px;
    padding-top: 80px;
  }

  .asec {
    padding: 20px 16px;
  }
}

/* Mobile Sidebar Close Button */
.sb-close {
  display: none;
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sb-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sb-close svg {
  width: 18px;
  height: 18px;
}

/* Mobile Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 39;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 768px) {
  .sidebar-overlay {
    display: block;
  }
}

.sidebar .sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.08) 0%, transparent 100%);
}

.sidebar .sb-logo {
  width: 40px;
  height: 40px;
  border-radius: var(--r);
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.sidebar .sb-logo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.sidebar .sb-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.sidebar .sb-brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.sidebar .sb-brand-text span {
  font-weight: 700;
  font-size: 0.95rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.sidebar .sb-brand-text small {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--g400);
  margin-top: 2px;
}

.sidebar .sb-nav {
  flex: 1;
  padding: 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar .sb-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 12px 10px 4px;
  margin-top: 4px;
}

.sidebar .nav-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--r);
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 2px;
}

.sidebar .nav-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar .nav-btn.active {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.18) 0%, rgba(37, 99, 235, 0.12) 100%);
  color: #ffffff;
  font-weight: 600;
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.15);
}

.sidebar .nav-btn.active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, var(--primary) 0%, #60a5fa 100%);
  box-shadow: 0 0 8px rgba(37, 99, 235, 0.5);
}

.sidebar .nav-btn.active .nav-icon {
  color: #60a5fa;
  filter: drop-shadow(0 0 4px rgba(96, 165, 250, 0.4));
}

.sidebar .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: inherit;
}

.sidebar .nav-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav-btn.danger {
  color: #f87171;
}

.sidebar .nav-btn.danger:hover {
  background: rgba(220, 38, 38, 0.12);
  color: #ef4444;
}

.sidebar .sb-bottom {
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sidebar .sb-user {
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar .sb-uav {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
}

.sidebar .sb-uinfo {
  min-width: 0;
}

.sidebar .sb-uname {
  font-size: 0.82rem;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .sb-urole {
  font-size: 0.7rem;
  color: #64748b;
}

/* ============================================================================
   ADMIN MAIN CONTENT & SECTIONS
   ============================================================================ */
.admin-main {
  flex: 1;
  background: var(--g50);
  min-height: 100vh;
  overflow-y: auto;
  position: relative;
}

/* Mobile Menu Toggle */
.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1000;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--primary);
  color: #ffffff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.mobile-menu-toggle svg {
  width: 24px;
  height: 24px;
}

.mobile-menu-toggle:hover {
  background: var(--primary-hover);
  transform: scale(1.05);
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: flex;
  }
}

.asec {
  display: none;
  padding: 28px 32px;
  max-width: 1440px;
  margin: 0 auto;
}

.asec.active {
  display: block;
}

.sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--g200);
}

.sec-title h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--g900);
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sec-title p {
  color: var(--g500);
  font-size: 0.86rem;
  margin-top: 3px;
}

/* Grid System */
.grid2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.grid3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

@media (max-width: 1100px) {
  .grid2 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   CARDS & CONTAINERS
   ============================================================================ */
.card {
  background: var(--surface-card);
  border-radius: var(--r-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

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

.card:hover::before {
  opacity: 1;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--g100);
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--g900);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}

.card-ico {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--primary-light);
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
  border: 1px solid var(--primary-border);
}

/* Overview KPI Cards */
.ov-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

  .asec {
    padding: 24px 20px;
  }
}

@media (max-width: 768px) {
  .sec-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .sec-title h1 {
    font-size: 1.25rem;
  }

  .ov-card {
    padding: 16px;
  }

  .ov-val {
    font-size: 1.45rem;
  }
}

@media (max-width: 640px) {
  .ov-grid {
    grid-template-columns: 1fr;
  }
}

.ov-card {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
  border-radius: var(--r-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.ov-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.ov-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--g300);
}

.ov-card:hover::before {
  opacity: 1;
}

.ov-ico {
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  background: var(--g100);
  border: 1px solid var(--g200);
}

.ov-val {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--g900);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.ov-lbl {
  font-size: 0.78rem;
  color: var(--g500);
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ============================================================================
   BUTTONS (MODEST RADIUS, HIGH CONTRAST, NO PILL BUTTONS)
   ============================================================================ */
.btn {
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.84rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  line-height: 1.4;
  box-shadow: var(--shadow-sm);
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  border-color: var(--primary-dark);
  position: relative;
  overflow: hidden;
}
.btn-primary::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.3s ease;
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-dark) 100%);
  box-shadow: var(--shadow-md);
}
.btn-primary:hover:not(:disabled)::before {
  left: 100%;
}

.btn-secondary {
  background: #ffffff;
  color: var(--g700);
  border-color: var(--g300);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--g50);
  color: var(--g900);
  border-color: var(--g400);
}

.btn-success {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success-hover);
}
.btn-success:hover:not(:disabled) {
  background: var(--success-hover);
  box-shadow: var(--shadow-md);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
  border-color: var(--danger-hover);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  box-shadow: var(--shadow-md);
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
  border-color: var(--warning-hover);
}
.btn-warning:hover:not(:disabled) {
  background: var(--warning-hover);
  box-shadow: var(--shadow-md);
}

.btn-info {
  background: var(--info);
  color: #ffffff;
  border-color: var(--info-hover);
}
.btn-info:hover:not(:disabled) {
  background: var(--info-hover);
  box-shadow: var(--shadow-md);
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}

/* ============================================================================
   FORM CONTROLS & INPUTS
   ============================================================================ */
.ig {
  margin-bottom: 14px;
}

.ig label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  color: var(--g700);
  font-size: 0.82rem;
}

.ig input,
.ig select,
.ig textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="url"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--g300);
  border-radius: var(--r);
  font-size: 0.88rem;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: #ffffff;
  color: var(--g900);
  outline: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.ig input:focus,
.ig select:focus,
.ig textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="url"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow), 0 4px 12px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.ig input::placeholder,
textarea::placeholder {
  color: var(--g400);
}

/* Range Slider */
.thresh {
  background: var(--g50);
  border: 1px solid var(--g200);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.thresh label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--g700);
  font-size: 0.84rem;
}

.thresh input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--g200);
  outline: none;
  -webkit-appearance: none;
  cursor: pointer;
  accent-color: var(--primary);
}

.thresh-val {
  background: var(--primary);
  color: #ffffff;
  padding: 2px 8px;
  border-radius: var(--r-xs);
  font-weight: 700;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  margin-left: 8px;
  vertical-align: middle;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tslider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--g300);
  transition: 0.2s ease;
  border-radius: 11px;
}

.tslider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: #ffffff;
  transition: 0.2s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

input:checked + .tslider {
  background: var(--success);
}

input:checked + .tslider:before {
  transform: translateX(18px);
}

/* ============================================================================
   TABLES & DATA GRIDS
   ============================================================================ */
.utab,
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.utab th,
table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--g500);
  background: var(--g50);
  border-bottom: 1px solid var(--g200);
  white-space: nowrap;
}

.utab td,
table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--g100);
  color: var(--g800);
  vertical-align: middle;
}

.utab tr:last-child td {
  border-bottom: none;
}

.utab tr:hover td {
  background: var(--g50);
}

/* Filter Bar */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: #ffffff;
  border-radius: var(--r-sm);
  border: 1px solid var(--g200);
  box-shadow: var(--shadow-sm);
}

.filter-bar label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--g700);
}

/* ============================================================================
   TABS & SEGMENTED CONTROLS
   ============================================================================ */
.tabs {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 18px;
  background: var(--g100);
  padding: 3px;
  border-radius: var(--r-sm);
  border: 1px solid var(--g200);
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  padding: 7px 14px;
  background: transparent;
  border: none;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--g500);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.tab:hover:not(.active) {
  color: var(--g800);
}

.tab.active {
  background: #ffffff;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.tab-c {
  display: none;
}

.tab-c.active {
  display: block;
}

/* ============================================================================
   ALERTS, BADGES & STATUS INDICATORS
   ============================================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  font-size: 0.84rem;
  font-weight: 500;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert-s {
  background: var(--success-light);
  color: var(--success-text);
  border-color: var(--success-border);
}

.alert-d {
  background: var(--danger-light);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.alert-w {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

.alert-i {
  background: var(--info-light);
  color: var(--info-text);
  border-color: var(--info-border);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: var(--r-xs);
  font-size: 0.74rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-s {
  background: var(--success-light);
  color: var(--success-text);
  border-color: var(--success-border);
}

.badge-i {
  background: var(--info-light);
  color: var(--info-text);
  border-color: var(--info-border);
}

.badge-w {
  background: var(--warning-light);
  color: var(--warning-text);
  border-color: var(--warning-border);
}

/* Status Indicator Dot */
.status-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.s-item {
  display: flex;
  align-items: center;
  gap: 7px;
  background: #ffffff;
  border: 1px solid var(--g200);
  padding: 6px 12px;
  border-radius: var(--r-sm);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--g700);
}

.s-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

.s-dot.off {
  background: var(--danger);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

/* ============================================================================
   VIDEO VIEWPORTS & CAMERA CONTAINERS
   ============================================================================ */
.vid-admin {
  position: relative;
  width: 100%;
  background: #090d16;
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 14px;
  border: 2px solid var(--g200);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vid-admin.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}

#video,
#liveVideo {
  width: 100%;
  display: block;
}

#overlay,
#liveOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ============================================================================
   STUDENT ROSTER & ATTENDANCE LOG LISTS
   ============================================================================ */
.slist,
.alog {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--g200);
  border-radius: var(--r-sm);
  padding: 8px;
  background: var(--g50);
}

.si {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  background: #ffffff;
  margin-bottom: 6px;
  border-radius: var(--r-xs);
  border: 1px solid var(--g200);
  transition: all 0.15s ease;
  gap: 10px;
}

.si:last-child {
  margin-bottom: 0;
}

.si:hover {
  border-color: var(--primary-border);
  box-shadow: var(--shadow-sm);
}

.si-av {
  width: 32px;
  height: 32px;
  border-radius: var(--r-xs);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.si-info {
  flex: 1;
  min-width: 0;
}

.si-name {
  font-weight: 600;
  color: var(--g900);
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.si-time {
  font-size: 0.74rem;
  color: var(--g500);
}

.le {
  padding: 10px 12px;
  background: #ffffff;
  margin-bottom: 6px;
  border-radius: var(--r-xs);
  border: 1px solid var(--g200);
  border-left: 3px solid var(--success);
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: box-shadow 0.15s;
}

.le:last-child {
  margin-bottom: 0;
}

.le.synced {
  border-left-color: var(--info);
}

.le strong {
  font-size: 0.86rem;
  color: var(--g900);
}

.le small {
  color: var(--g500);
  font-size: 0.74rem;
}

/* ============================================================================
   PROGRESS BARS
   ============================================================================ */
.pbar,
.progress-bar {
  height: 8px;
  background: var(--g200);
  border-radius: 4px;
  overflow: hidden;
  margin: 10px 0;
}

.pfill,
.progress-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.3s ease;
  border-radius: 4px;
}

/* File Upload Dropzone */
.fi-wrap {
  position: relative;
  display: inline-block;
  width: 100%;
  margin-bottom: 12px;
}

.fi-wrap input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.fi-label {
  display: block;
  padding: 18px 16px;
  background: var(--primary-light);
  border: 2px dashed var(--primary-border);
  border-radius: var(--r-sm);
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 0.86rem;
}

.fi-label:hover {
  background: #e0e7ff;
  border-color: var(--primary);
}

/* Loading Overlay */
.loading-ov {
  position: fixed;
  inset: 0;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
}

.loading-ov.hidden {
  display: none;
}

.spinner {
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  width: 44px;
  height: 44px;
  animation: spin 0.7s linear infinite;
}

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

.loading-ov p {
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: 500;
}

/* Informational Banners */
.dinfo {
  background: var(--info-light);
  border: 1px solid var(--info-border);
  border-left: 3px solid var(--info);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  margin: 12px 0;
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--info-text);
}

.sbanner {
  background: var(--warning-light);
  border: 1px solid var(--warning-border);
  border-left: 3px solid var(--warning);
  padding: 12px 14px;
  border-radius: var(--r-sm);
  margin-bottom: 14px;
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--warning-text);
}

hr.div {
  border: none;
  border-top: 1px solid var(--g200);
  margin: 18px 0;
}

.sec-label {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--g800);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Folder & Upload Previews */
.fpreview {
  background: var(--g50);
  border: 1px solid var(--g200);
  border-radius: var(--r-sm);
  padding: 8px;
  max-height: 180px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.fitem {
  padding: 8px 12px;
  background: #ffffff;
  margin-bottom: 6px;
  border-radius: var(--r-xs);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--g200);
  font-size: 0.84rem;
}

/* Capture preview */
.caprev {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.caprev img {
  width: 100%;
  height: 65px;
  object-fit: cover;
  border-radius: var(--r-xs);
  border: 2px solid var(--success);
}

/* Empty states */
.empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--g500);
  font-size: 0.86rem;
}

/* ============================================================================
   MOBILE & TABLET RESPONSIVE REFINEMENTS
   ============================================================================ */
@media (max-width: 768px) {
  :root {
    --sb: 0px;
  }

  .admin-layout {
    flex-direction: column;
  }

  .asec {
    padding: 18px 14px;
  }

  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    width: 100%;
    flex-direction: row;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid #1e293b;
    border-right: none;
    background: #090d16;
    z-index: 1000;
  }

  .sidebar .sb-brand,
  .sidebar .sb-label,
  .sidebar .sb-user {
    display: none !important;
  }

  .sidebar .sb-bottom {
    display: flex;
    flex-direction: row;
    border-top: none;
    padding: 0;
    margin: 0;
  }

  .sidebar .sb-nav {
    flex-direction: row;
    padding: 0;
    gap: 2px;
    width: 100%;
    justify-content: space-around;
  }

  .sidebar .nav-btn {
    flex-direction: column;
    padding: 6px 4px;
    font-size: 0.68rem;
    text-align: center;
    gap: 4px;
    min-width: 50px;
    border-radius: var(--r-xs);
  }

  .sidebar .nav-btn.active::before {
    left: 20%;
    right: 20%;
    top: -6px;
    bottom: auto;
    width: auto;
    height: 3px;
    border-radius: 0 0 3px 3px;
  }

  .admin-main {
    padding-bottom: 74px; /* Ensure space above mobile bottom bar */
  }
}
