/* ==========================================================================
   FIXSTER SAAS ADMIN CONTROL CENTER
   Premium Modern Glassmorphism Dashboard (Desktop + Mobile Responsive)
   ========================================================================== */

:root {
  --ap-bg: #0b0c16;
  --ap-surface: #121324;
  --ap-surface-hover: #191b32;
  --ap-card-bg: rgba(22, 24, 44, 0.85);
  --ap-border: rgba(255, 255, 255, 0.08);
  --ap-border-active: rgba(139, 92, 246, 0.4);
  --ap-primary: #8b5cf6;
  --ap-primary-hover: #7c3aed;
  --ap-primary-glow: rgba(139, 92, 246, 0.25);
  --ap-text: #f8fafc;
  --ap-text-muted: #94a3b8;
  --ap-sidebar-w: 260px;
  --ap-sidebar-collapsed-w: 78px;
  --ap-topbar-h: 72px;
  --ap-radius-lg: 22px;
  --ap-radius-md: 14px;
  --ap-radius-sm: 10px;
  --ap-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  --ap-shadow-glow: 0 8px 24px rgba(139, 92, 246, 0.2);
  --ap-success: #10b981;
  --ap-warning: #f59e0b;
  --ap-danger: #ef4444;
  --ap-info: #0ea5e9;
}

body.light-theme {
  --ap-bg: #f8fafc;
  --ap-surface: #ffffff;
  --ap-surface-hover: #f1f5f9;
  --ap-card-bg: #ffffff;
  --ap-border: rgba(0, 0, 0, 0.08);
  --ap-border-active: rgba(139, 92, 246, 0.5);
  --ap-text: #0f172a;
  --ap-text-muted: #64748b;
  --ap-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Zero role mixing: when admin session is active, unmount consumer UI */
body.admin-session-active > *:not(#fixster-admin-root):not(#fixster-toast-container):not(script):not(style) {
  display: none !important;
}

body.admin-session-active {
  background: var(--ap-bg) !important;
  color: var(--ap-text) !important;
  overflow: hidden !important;
  height: 100vh !important;
}

#fixster-admin-root {
  display: none;
  width: 100vw;
  height: 100vh;
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: var(--ap-bg);
  color: var(--ap-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

body.admin-session-active #fixster-admin-root {
  display: flex !important;
}

/* ==========================================================================
   SIDEBAR (FIXED COLLAPSIBLE)
   ========================================================================== */

.ap-sidebar {
  width: var(--ap-sidebar-w);
  height: 100vh;
  background: var(--ap-surface);
  border-right: 1px solid var(--ap-border);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}

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

.ap-sidebar-header {
  height: var(--ap-topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--ap-border);
}

.ap-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.ap-brand-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.4);
  flex-shrink: 0;
}

.ap-brand-info {
  display: flex;
  flex-direction: column;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.ap-brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, #c084fc, #818cf8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.ap-brand-sub {
  font-size: 11px;
  color: var(--ap-text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ap-sidebar-toggle {
  background: none;
  border: none;
  color: var(--ap-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ap-sidebar-toggle:hover {
  background: var(--ap-surface-hover);
  color: var(--ap-text);
}

.ap-sidebar.is-collapsed .ap-brand-info {
  display: none;
}

/* Sidebar navigation menu */
.ap-sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ap-sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.ap-sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.ap-nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ap-text-muted);
  padding: 12px 14px 6px;
  white-space: nowrap;
}

.ap-sidebar.is-collapsed .ap-nav-section-title {
  display: none;
}

.ap-nav-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--ap-radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ap-text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  text-align: left;
  white-space: nowrap;
  width: 100%;
}

.ap-nav-btn:hover {
  background: var(--ap-surface-hover);
  color: var(--ap-text);
}

.ap-nav-btn.active {
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.18), rgba(99, 102, 241, 0.08));
  border-color: var(--ap-border-active);
  color: #fff;
  box-shadow: 0 4px 16px rgba(139, 92, 246, 0.15);
}

.ap-nav-btn.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 15%;
  bottom: 15%;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--ap-primary);
  box-shadow: 0 0 10px var(--ap-primary);
}

.ap-nav-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

/* Squircle color accents */
.ap-nav-icon.ic-dashboard { background: rgba(139, 92, 246, 0.15); color: #a855f7; }
.ap-nav-icon.ic-orders { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }
.ap-nav-icon.ic-masters { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.ap-nav-icon.ic-clients { background: rgba(244, 63, 94, 0.15); color: #f43f5e; }
.ap-nav-icon.ic-payments { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.ap-nav-icon.ic-subs { background: rgba(234, 179, 8, 0.15); color: #eab308; }
.ap-nav-icon.ic-reviews { background: rgba(168, 85, 247, 0.15); color: #c084fc; }
.ap-nav-icon.ic-complaints { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.ap-nav-icon.ic-notifs { background: rgba(99, 102, 241, 0.15); color: #818cf8; }
.ap-nav-icon.ic-top { background: rgba(234, 179, 8, 0.15); color: #facc15; }
.ap-nav-icon.ic-services { background: rgba(20, 184, 166, 0.15); color: #14b8a6; }
.ap-nav-icon.ic-ai { background: rgba(192, 132, 252, 0.15); color: #d8b4fe; }
.ap-nav-icon.ic-analytics { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.ap-nav-icon.ic-reports { background: rgba(147, 51, 234, 0.15); color: #a855f7; }
.ap-nav-icon.ic-logs { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }
.ap-nav-icon.ic-settings { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; }
.ap-nav-icon.ic-logout { background: rgba(239, 68, 68, 0.15); color: #f87171; }

.ap-nav-label {
  flex: 1;
}

.ap-sidebar.is-collapsed .ap-nav-label,
.ap-sidebar.is-collapsed .ap-nav-badge {
  display: none;
}

.ap-nav-badge {
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  background: var(--ap-primary);
  color: #fff;
}

.ap-sidebar-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--ap-border);
}

/* ==========================================================================
   MAIN CONTENT AREA
   ========================================================================== */

.ap-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--ap-bg);
}

.ap-topbar {
  height: var(--ap-topbar-h);
  background: var(--ap-surface);
  border-bottom: 1px solid var(--ap-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  z-index: 50;
}

.ap-topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
}

.ap-greeting {
  font-size: 16px;
  font-weight: 700;
  color: var(--ap-text);
  white-space: nowrap;
}

.ap-search-wrap {
  position: relative;
  max-width: 420px;
  width: 100%;
}

.ap-search-input {
  width: 100%;
  height: 40px;
  border-radius: var(--ap-radius-md);
  background: var(--ap-bg);
  border: 1px solid var(--ap-border);
  padding: 0 40px 0 38px;
  color: var(--ap-text);
  font-size: 13px;
  outline: none;
  transition: all 0.2s;
}

.ap-search-input:focus {
  border-color: var(--ap-primary);
  box-shadow: 0 0 0 3px var(--ap-primary-glow);
}

.ap-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ap-text-muted);
  font-size: 13px;
}

.ap-search-kbd {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  color: var(--ap-text-muted);
}

.ap-topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ap-live-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 30px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: var(--ap-success);
  font-size: 12px;
  font-weight: 700;
}

.ap-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ap-success);
  box-shadow: 0 0 8px var(--ap-success);
  animation: apPulse 2s infinite;
}

@keyframes apPulse {
  0% { transform: scale(0.9); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--ap-success); }
  100% { transform: scale(0.9); opacity: 0.8; }
}

.ap-clock {
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-text-muted);
  white-space: nowrap;
}

.ap-theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--ap-radius-sm);
  background: var(--ap-bg);
  border: 1px solid var(--ap-border);
  color: var(--ap-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}

.ap-theme-toggle:hover {
  border-color: var(--ap-primary);
}

.ap-admin-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  border-radius: var(--ap-radius-md);
  background: var(--ap-bg);
  border: 1px solid var(--ap-border);
}

.ap-avatar-box {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #a855f7, #6366f1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.ap-crown-badge {
  position: absolute;
  bottom: -3px;
  right: -3px;
  width: 16px;
  height: 16px;
  background: #f59e0b;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8px;
  color: #fff;
  border: 1.5px solid var(--ap-surface);
}

.ap-admin-meta {
  display: flex;
  flex-direction: column;
}

.ap-admin-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ap-text);
  line-height: 1.2;
}

.ap-admin-role {
  font-size: 11px;
  color: #a855f7;
  font-weight: 600;
}

/* ==========================================================================
   PAGE SECTIONS & WORKSPACE
   ========================================================================== */

.ap-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

.ap-section {
  display: none;
  animation: apFadeIn 0.25s ease forwards;
}

.ap-section.active {
  display: block;
}

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

.ap-section-header {
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.ap-section-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--ap-text);
  letter-spacing: -0.5px;
}

.ap-section-subtitle {
  font-size: 13px;
  color: var(--ap-text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   KPI CARDS GRID
   ========================================================================== */

.ap-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.ap-kpi-card {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  padding: 20px;
  box-shadow: var(--ap-shadow);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.ap-kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--ap-border-active);
  box-shadow: var(--ap-shadow-glow);
}

.ap-kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.ap-kpi-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--ap-text-muted);
}

.ap-kpi-icon {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.ap-kpi-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--ap-text);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  line-height: 1.15;
}

.ap-kpi-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ap-text-muted);
}

.ap-trend-up {
  color: var(--ap-success);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ==========================================================================
   CHARTS & OVERVIEW ROW
   ========================================================================== */

.ap-charts-row {
  display: grid;
  grid-template-columns: 2fr 1.2fr;
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 1024px) {
  .ap-charts-row {
    grid-template-columns: 1fr;
  }
}

.ap-chart-card {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  padding: 22px;
  box-shadow: var(--ap-shadow);
}

.ap-chart-card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ap-text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ==========================================================================
   TABLES & LISTS
   ========================================================================== */

.ap-table-card {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  box-shadow: var(--ap-shadow);
  overflow: hidden;
  margin-bottom: 24px;
}

.ap-table-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--ap-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.ap-table-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ap-select {
  height: 36px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  color: var(--ap-text);
  border-radius: var(--ap-radius-sm);
  padding: 0 12px;
  font-size: 13px;
  outline: none;
}

.ap-table-wrap {
  overflow-x: auto;
}

.ap-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

.ap-table th {
  padding: 14px 18px;
  color: var(--ap-text-muted);
  font-weight: 700;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--ap-border);
  background: rgba(255, 255, 255, 0.02);
  white-space: nowrap;
}

.ap-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--ap-border);
  color: var(--ap-text);
  vertical-align: middle;
  font-size: 14px;
  line-height: 1.45;
}

.ap-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.ap-pill {
  padding: 5px 12px;
  border-radius: 30px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.ap-pill-success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.ap-pill-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.ap-pill-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.ap-pill-info { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; }
.ap-pill-purple { background: rgba(168, 85, 247, 0.15); color: #c084fc; }

.ap-action-btn {
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  min-height: 34px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ap-btn-primary {
  background: var(--ap-primary);
  color: #fff;
}

.ap-btn-primary:hover {
  background: var(--ap-primary-hover);
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.3);
}

.ap-btn-secondary {
  background: var(--ap-surface);
  border-color: var(--ap-border);
  color: var(--ap-text);
}

.ap-btn-secondary:hover {
  background: var(--ap-surface-hover);
}

.ap-btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

.ap-btn-danger:hover {
  background: #ef4444;
  color: #fff;
}

/* ==========================================================================
   MODAL DIALOGS
   ========================================================================== */

.ap-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

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

.ap-modal {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border-active);
  border-radius: var(--ap-radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: var(--ap-shadow);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.ap-modal-overlay.active .ap-modal {
  transform: scale(1);
}

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

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

.ap-modal-body {
  padding: 22px;
  max-height: 75vh;
  overflow-y: auto;
}

.ap-modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--ap-border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ==========================================================================
   RESPONSIVE MOBILE CONTROLS (DRAWER & BOTTOM NAV)
   ========================================================================== */

.ap-mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--ap-surface);
  border-top: 1px solid var(--ap-border);
  z-index: 9999;
  justify-content: space-around;
  align-items: center;
  padding: 0 8px;
}

.ap-mobile-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--ap-text-muted);
  font-size: 11px;
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 10px;
}

.ap-mobile-nav-item.active {
  color: var(--ap-primary);
}

.ap-mobile-nav-item i {
  font-size: 18px;
}

@media (max-width: 768px) {
  .ap-sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    box-shadow: 0 0 40px rgba(0,0,0,0.6);
  }

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

  .ap-body {
    padding: 14px;
    padding-bottom: 80px;
  }

  .ap-mobile-bottom-nav {
    display: flex;
  }

  .ap-greeting {
    display: none;
  }

  .ap-search-wrap {
    max-width: 100%;
  }
}

/* ==========================================================================
   OFFLINE CACHE NOTICE BANNER
   ========================================================================== */
.ap-offline-banner {
  background: linear-gradient(90deg, rgba(245, 158, 11, 0.2), rgba(239, 68, 68, 0.15));
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fbbf24;
  padding: 10px 18px;
  border-radius: var(--ap-radius-md);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  animation: apFadeIn 0.3s ease;
}

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

/* ==========================================================================
   PLATFORM HEALTH MONITOR BAR
   ========================================================================== */
.ap-health-container {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  padding: 18px 22px;
  margin-bottom: 24px;
  backdrop-filter: blur(12px);
}

.ap-health-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.ap-health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.ap-health-chip {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: all 0.2s ease;
}

.ap-health-chip:hover {
  border-color: var(--ap-border-active);
  transform: translateY(-2px);
}

.ap-health-title {
  font-size: 11px;
  color: var(--ap-text-muted);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ap-health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.ap-health-dot.dot-online {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.ap-health-dot.dot-warn {
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.ap-health-dot.dot-down {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
}

.ap-health-latency {
  font-size: 13px;
  font-weight: 700;
  color: var(--ap-text);
  font-family: ui-monospace, monospace;
}

/* ==========================================================================
   ORDER FUNNEL COMPONENT
   ========================================================================== */
.ap-funnel-card {
  background: var(--ap-card-bg);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  padding: 22px;
  backdrop-filter: blur(12px);
}

.ap-funnel-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  overflow-x: auto;
  padding: 10px 0;
}

.ap-funnel-step {
  flex: 1;
  min-width: 140px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-md);
  padding: 14px 16px;
  text-align: center;
  position: relative;
}

.ap-funnel-step.step-highlight {
  border-color: var(--ap-primary);
  background: linear-gradient(180deg, rgba(139,92,246,0.12), rgba(99,102,241,0.04));
}

.ap-funnel-step-name {
  font-size: 12px;
  color: var(--ap-text-muted);
  font-weight: 600;
  margin-bottom: 6px;
}

.ap-funnel-step-num {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.ap-funnel-step-rate {
  font-size: 11px;
  color: var(--ap-primary);
  font-weight: 700;
  margin-top: 4px;
}

.ap-funnel-arrow {
  color: var(--ap-border-active);
  font-size: 16px;
  flex-shrink: 0;
}

/* ==========================================================================
   BUKHARA DISTRICTS HEATMAP
   ========================================================================== */
.ap-district-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ap-district-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ap-district-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 600;
}

.ap-district-bar-bg {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  overflow: hidden;
}

.ap-district-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #0ea5e9);
  border-radius: 6px;
  transition: width 0.5s ease;
}

/* ==========================================================================
   TOP MASTERS PODIUM
   ========================================================================== */
.ap-podium-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.ap-podium-card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
}

.ap-podium-card.podium-1 {
  border-color: rgba(234, 179, 8, 0.5);
  background: linear-gradient(180deg, rgba(234, 179, 8, 0.08), transparent);
}

.ap-podium-card.podium-2 {
  border-color: rgba(148, 163, 184, 0.4);
  background: linear-gradient(180deg, rgba(148, 163, 184, 0.08), transparent);
}

.ap-podium-card.podium-3 {
  border-color: rgba(217, 119, 6, 0.4);
  background: linear-gradient(180deg, rgba(217, 119, 6, 0.08), transparent);
}

.ap-podium-badge {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
}

.podium-1 .ap-podium-badge { background: #eab308; color: #000; box-shadow: 0 0 16px rgba(234, 179, 8, 0.4); }
.podium-2 .ap-podium-badge { background: #94a3b8; color: #000; box-shadow: 0 0 16px rgba(148, 163, 184, 0.3); }
.podium-3 .ap-podium-badge { background: #d97706; color: #fff; box-shadow: 0 0 16px rgba(217, 119, 6, 0.3); }

/* ==========================================================================
   SERVICES CARDS & TOGGLES
   ========================================================================== */
.ap-services-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}

.ap-service-card {
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  border-radius: var(--ap-radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: all 0.2s ease;
}

.ap-service-card:hover {
  border-color: var(--ap-border-active);
}

.ap-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.ap-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.ap-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.15);
  transition: .3s;
  border-radius: 24px;
}

.ap-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .ap-slider {
  background-color: var(--ap-primary);
}

input:checked + .ap-slider:before {
  transform: translateX(20px);
}

/* ==========================================================================
   COMMAND PALETTE (CTRL+K)
   ========================================================================== */
.ap-cmd-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  z-index: 100010;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

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

.ap-cmd-box {
  width: 100%;
  max-width: 580px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border-active);
  border-radius: var(--ap-radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(139, 92, 246, 0.25);
  overflow: hidden;
  transform: scale(0.96);
  transition: transform 0.2s;
}

.ap-cmd-overlay.active .ap-cmd-box {
  transform: scale(1);
}

.ap-cmd-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--ap-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ap-cmd-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--ap-text);
  font-size: 16px;
  font-weight: 500;
}

.ap-cmd-list {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px;
}

.ap-cmd-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--ap-radius-md);
  color: var(--ap-text);
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 13px;
  font-weight: 600;
}

.ap-cmd-item:hover, .ap-cmd-item.selected {
  background: var(--ap-surface-hover);
  color: #fff;
  border-left: 3px solid var(--ap-primary);
}

.ap-cmd-kbd {
  margin-left: auto;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  color: var(--ap-text-muted);
  font-family: monospace;
}

/* ==========================================================================
   PAGINATION CONTROLS
   ========================================================================== */
.ap-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-top: 1px solid var(--ap-border);
  font-size: 13px;
  color: var(--ap-text-muted);
  flex-wrap: wrap;
  gap: 10px;
}

.ap-pagination-info {
  font-size: 13px;
  font-weight: 500;
  color: var(--ap-text-muted);
}

.ap-pagination-pages {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ap-page-btn {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  background: var(--ap-surface);
  border: 1px solid var(--ap-border);
  color: var(--ap-text);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ap-page-btn:hover:not(:disabled) {
  background: var(--ap-surface-hover);
  border-color: var(--ap-primary);
  color: #fff;
}

.ap-page-btn.active {
  background: var(--ap-primary);
  border-color: var(--ap-primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--ap-primary-glow);
}

.ap-page-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ==========================================================================
   RECEIPT ZOOM LIGHTBOX
   ========================================================================== */
.ap-receipt-dialog {
  background: #0f101f;
  border: 1px solid var(--ap-border-active);
  border-radius: var(--ap-radius-lg);
  max-width: 800px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(139, 92, 246, 0.2);
}

.ap-receipt-viewport {
  width: 100%;
  max-height: 65vh;
  min-height: 320px;
  background: #05060c;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  position: relative;
  user-select: none;
}

.ap-receipt-viewport img {
  max-width: 100%;
  max-height: 60vh;
  object-contain: contain;
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: center center;
}

.ap-receipt-toolbar {
  padding: 12px 20px;
  background: var(--ap-surface);
  border-top: 1px solid var(--ap-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.ap-receipt-zoom-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================================================
   EMPTY STATES & SPINNERS
   ========================================================================== */
.ap-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
  text-align: center;
  color: var(--ap-text-muted);
}

.ap-empty-icon {
  font-size: 42px;
  color: rgba(255, 255, 255, 0.15);
  margin-bottom: 14px;
}

.ap-empty-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--ap-text);
  margin-bottom: 6px;
}

.ap-empty-desc {
  font-size: 13px;
  max-width: 360px;
  line-height: 1.5;
}

.ap-spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--ap-primary);
  border-radius: 50%;
  animation: apSpin 0.75s linear infinite;
  display: inline-block;
}

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

/* ==========================================================================
   ENHANCED KPI & BADGES
   ========================================================================== */
.ap-badge-gold {
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.2), rgba(245, 158, 11, 0.25));
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.ap-badge-silver {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.ap-badge-bronze {
  background: rgba(217, 119, 6, 0.2);
  color: #f97316;
  border: 1px solid rgba(217, 119, 6, 0.4);
}


