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

:root {
  --bg: #F8FAFC;
  --bg-soft: #ECFDF5;
  --card: #FFFFFF;
  --card-hover: #F8FAFC;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #F6931E;
  --primary: #04884F;
  --primary-glow: rgba(4, 136, 79, 0.25);
  --border: rgba(4, 136, 79, 0.15);
  --success: #04884F;
  --danger: #ef4444;
  --bg-dark: #0f172a;
  --shadow: 0 10px 20px -5px rgba(4, 136, 79, 0.12), 0 4px 6px -2px rgba(4, 136, 79, 0.05);
  --font-main: 'Poppins', 'Open Sans', -apple-system, sans-serif;
}

body {
  font-family: var(--font-main);
  background: var(--bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(4, 136, 79, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(246, 147, 30, 0.08) 0px, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

header {
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 10px rgba(15, 140, 80, 0.05);
}

header h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
}

.logout {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.logout:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: var(--danger);
}

.wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-soft);
  border-radius: 12px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(15, 140, 80, 0.05);
}

.tab-btn.active {
  background: var(--card);
  color: var(--primary);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--border);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, background 0.2s;
}

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

.card strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 4px;
  letter-spacing: -0.025em;
}

.muted {
  color: var(--text-muted);
  font-size: 13px;
}

.flex {
  display: flex;
  gap: 12px;
  align-items: center;
}

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

/* Stat Cards */
.stat-card {
  padding: 24px;
  background: linear-gradient(145deg, var(--bg-soft), var(--card));
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}

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

.stat-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.05em;
}

.stat-trend {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Form elements */
input,
select,
textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  width: 100%;
  transition: all 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

button.primary {
  background: var(--primary);
  background: linear-gradient(135deg, var(--primary) 0%, #16a34a 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

button.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -4px var(--primary-glow);
}

button.ghost {
  background: rgba(15, 140, 80, 0.03);
  border: 1px solid var(--border);
  color: var(--primary);
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

button.ghost:hover {
  background: rgba(15, 140, 80, 0.08);
  border-color: var(--primary);
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  background: rgba(15, 140, 80, 0.03);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

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

tr:hover td {
  background: rgba(15, 140, 80, 0.02);
}

/* Badges */
.badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge.success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge.danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Custom Chart Style */
.analytics-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  height: 100%;
}

.analytics-bar {
  width: 100%;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(to top, var(--primary), var(--accent));
  min-height: 4px;
  transition: height 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  cursor: pointer;
}

.analytics-bar:hover {
  filter: brightness(1.2);
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Router Status Dots */
.router-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.router-status-dot.online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: pulse-green 2s infinite;
}
.router-status-dot.offline {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}
@keyframes pulse-green {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* Floating Mobile PWA Banner */
.mobile-pwa-banner {
  position: fixed;
  bottom: 74px;
  left: 16px;
  right: 16px;
  max-width: 440px;
  margin: 0 auto;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid #6366f1;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Fixed Mobile Bottom Navigation */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  z-index: 1000;
  padding: 4px 8px;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
}

.mob-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  flex: 1;
  max-width: 72px;
  transition: all 0.15s ease;
}

.mob-nav-btn.active {
  color: var(--primary);
}

.mob-nav-btn .mob-icon {
  font-size: 18px;
  line-height: 1;
  margin-bottom: 2px;
}

.mob-nav-btn .mob-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

@media (max-width: 768px) {
  body {
    padding-bottom: 75px;
  }

  .wrap {
    padding: 12px 14px;
  }

  .desktop-only-table {
    display: none !important;
  }

  .mobile-router-cards {
    display: flex !important;
  }

  .mobile-bottom-nav {
    display: flex !important;
  }

  .header-install-text {
    display: none;
  }

  .tabs {
    display: none;
  }
}

@media (min-width: 769px) {
  .mobile-router-cards {
    display: none !important;
  }
  #mobileVendorList {
    display: none !important;
  }
  .desktop-only-table {
    display: block !important;
  }
}

/* Toggle Switch Bar Component */
.toggle-switch-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .25s ease;
  border-radius: 22px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

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

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

.badge-plan {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-plan.starter {
  background: rgba(14, 165, 233, 0.12);
  color: #0284c7;
}

.badge-plan.business {
  background: rgba(99, 102, 241, 0.15);
  color: #6366f1;
}

.badge-plan.enterprise {
  background: rgba(246, 147, 30, 0.15);
  color: var(--accent);
}

.badge-plan.trial {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-muted);
}

/* ==========================================================================
   NORECH ADMIN PORTAL UPGRADE — COPILOT, HEALTH, MATRIX & VOUCHERS
   ========================================================================== */

/* 1. Floating AI Copilot FAB & Drawer */
.copilot-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: linear-gradient(135deg, #04884F 0%, #F6931E 100%);
  color: #ffffff;
  border: none;
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 25px -5px rgba(4, 136, 79, 0.4), 0 8px 10px -6px rgba(246, 147, 30, 0.3);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.copilot-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 30px -6px rgba(4, 136, 79, 0.5);
}
.copilot-fab .kbd-shortcut {
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: monospace;
  margin-left: 4px;
}

.copilot-drawer {
  position: fixed;
  top: 0;
  right: -480px;
  width: 460px;
  max-width: 95vw;
  height: 100vh;
  background: #ffffff;
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border-left: 1px solid var(--border);
}
.copilot-drawer.open {
  right: 0;
}
.copilot-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 9998;
  display: none;
}
.copilot-backdrop.open {
  display: block;
}

.copilot-header {
  padding: 16px 20px;
  background: linear-gradient(135deg, #04884F 0%, #03683c 100%);
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.copilot-header h3 {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}
.copilot-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.15);
  padding: 3px 8px;
  border-radius: 999px;
}

.copilot-mode-tabs {
  display: flex;
  background: #f1f5f9;
  border-bottom: 1px solid #e2e8f0;
}
.copilot-mode-tab {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.copilot-mode-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: #ffffff;
}

.copilot-chips {
  padding: 10px 16px;
  background: #f8fafc;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid #e2e8f0;
}
.copilot-chip {
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s ease;
}
.copilot-chip:hover {
  background: var(--bg-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #fafafa;
}

.copilot-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
}
.copilot-msg.user {
  align-self: flex-end;
  background: var(--primary);
  color: #ffffff;
  border-bottom-right-radius: 2px;
}
.copilot-msg.assistant {
  align-self: flex-start;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
  border-bottom-left-radius: 2px;
}

.copilot-staged-box {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px;
  margin-top: 8px;
}
.copilot-staged-box .title {
  font-weight: 700;
  color: #b45309;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.copilot-staged-box .actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.copilot-input-area {
  padding: 12px 16px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
}
.copilot-input-area input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 13px;
  outline: none;
}
.copilot-input-area input:focus {
  border-color: var(--primary);
}

/* 2. Device Health Badges & AI Diagnostics Modal */
.health-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}
.health-badge-pill.healthy {
  background: rgba(4, 136, 79, 0.12);
  color: #04884F;
  border: 1px solid rgba(4, 136, 79, 0.3);
}
.health-badge-pill.warning {
  background: rgba(246, 147, 30, 0.12);
  color: #d97706;
  border: 1px solid rgba(246, 147, 30, 0.35);
}
.health-badge-pill.offline {
  background: rgba(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.diagnostics-anomaly-card {
  background: #f8fafc;
  border-left: 4px solid var(--accent);
  padding: 10px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 8px;
}

.diagnostics-prescription {
  display: flex;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(4, 136, 79, 0.05);
  border: 1px solid rgba(4, 136, 79, 0.15);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12px;
}

/* 3. Capability Matrix Table & QoS Previewer */
.matrix-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
}
.matrix-table th {
  background: #f1f5f9;
  padding: 10px 12px;
  text-align: center;
  border-bottom: 2px solid #cbd5e1;
  font-weight: 700;
}
.matrix-table th:first-child {
  text-align: left;
}
.matrix-table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  text-align: center;
}
.matrix-table td:first-child {
  text-align: left;
  font-weight: 600;
}
.matrix-cell-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
}
.matrix-cell-badge.supported {
  background: #dcfce7;
  color: #15803d;
}
.matrix-cell-badge.fallback {
  background: #fef3c7;
  color: #b45309;
}
.matrix-cell-badge.unsupported {
  background: #fee2e2;
  color: #b91c1c;
}

.vsa-preview-box {
  background: #0f172a;
  color: #38bdf8;
  font-family: monospace;
  font-size: 12px;
  padding: 12px 16px;
  border-radius: 8px;
  overflow-x: auto;
  line-height: 1.6;
}

/* 4. Voucher Cuttable Toolbar & Batch Filter */
.voucher-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: var(--bg-soft);
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
}