:root {
  --primary-bg: #070e1c; /* Deep Navy Blue Dark Mode */
  --panel-bg: rgba(7, 14, 28, 0.7);
  --glass-border: rgba(255, 255, 255, 0.1);
  --accent-blue: #1d4ed8; /* Royal Blue */
  --accent-orange: #d4af37; /* BPN Gold */
  
  /* Status Colors */
  --status-detecting: #94a3b8; /* White/Gray */
  --status-verifying: #eab308; /* Yellow */
  --status-mediating: #3b82f6; /* Blue */
  --status-resolved: #10b981;  /* BPN Green */

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --font-family: 'Inter', system-ui, sans-serif;
}

body.light-mode {
  --primary-bg: #f1f5f9; /* Bright UI */
  --panel-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(0, 0, 0, 0.1);
  --text-primary: #0f172a;
  --text-secondary: #475569;
}

body.light-mode .form-control {
  background: rgba(0,0,0,0.05);
  color: #0f172a;
  border-color: rgba(0,0,0,0.2);
}
body.light-mode .form-control:focus {
  background: #ffffff;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.2);
}
body.light-mode .navbar {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
body.light-mode .report-item {
  background: rgba(0,0,0,0.02);
}
body.light-mode .report-item:hover {
  background: rgba(0,0,0,0.06);
}
body.light-mode .map-overlay,
body.light-mode .login-card {
  background: rgba(255,255,255,0.9);
  color: #0f172a;
}
body.light-mode .map-overlay h3 {
  color: #0f172a;
}

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

body {
  font-family: var(--font-family);
  background: var(--primary-bg);
  background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.15), transparent 25%),
                    radial-gradient(circle at 85% 30%, rgba(249, 115, 22, 0.1), transparent 25%);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
}

.brand span {
  color: var(--accent-orange);
}

.brand-motto {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
  margin-left: 12px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-motto::before {
  content: "|";
  color: var(--glass-border);
  font-weight: 300;
  font-size: 1.2rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 6px;
}

.nav-links a:hover, .nav-links a.active {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.main-content {
  flex: 1;
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  height: calc(100vh - 70px); /* Fill remaining space */
}

/* Glassmorphism Panels */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Sidebar Styling */
.sidebar h2 {
  font-size: 1.25rem;
  margin-bottom: 1.5rem;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  padding: 1rem;
  border-radius: 12px;
  text-align: center;
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.06);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Map specific styling */
.map-container {
  padding: 0;
  position: relative;
}

#map {
  width: 100%;
  height: 100%;
  border-radius: 16px;
  background: #1e293b; /* Fallback */
  z-index: 1; /* Keep leaflet under navbar */
}

.map-overlay {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 400; /* Leaflet controls are ~1000 */
  background: rgba(11, 17, 32, 0.85);
  backdrop-filter: blur(8px);
  padding: 1rem;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  width: 250px;
}

.map-overlay h3 {
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

/* Status variants */
.c-detecting { background: var(--status-detecting); box-shadow: 0 0 10px var(--status-detecting); }
.c-verifying { background: var(--status-verifying); box-shadow: 0 0 10px var(--status-verifying); }
.c-mediating { background: var(--status-mediating); box-shadow: 0 0 10px var(--status-mediating); }
.c-resolved { background: var(--status-resolved); box-shadow: 0 0 10px var(--status-resolved); }

/* Forms & UI */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--glass-border);
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-blue);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  font-family: inherit;
  font-size: 1rem;
}

.btn-primary {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn-warning {
  background: var(--accent-orange);
  color: white;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.4);
}

.btn-warning:hover {
  background: #ea580c;
  transform: translateY(-2px);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.animated {
  animation: fadeIn 0.5s ease forwards;
}

/* List of active reports */
.report-list {
  margin-top: 1rem;
  overflow-y: auto;
  flex: 1;
  padding-right: 0.5rem;
}

.report-list::-webkit-scrollbar {
  width: 6px;
}
.report-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.2);
  border-radius: 10px;
}

.report-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--glass-border);
  padding: 1rem;
  border-radius: 8px;
  margin-bottom: 0.75rem;
  transition: background 0.2s;
  cursor: pointer;
}

.report-item:hover {
  background: rgba(255,255,255,0.08);
}

.report-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.report-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
}

/* Responsive */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr;
    grid-template-rows: auto 500px;
    height: auto;
  }
}

/* Login Page Specific */
.login-centered {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background-image: radial-gradient(circle at 15% 50%, rgba(59, 130, 246, 0.2), transparent 35%),
                    radial-gradient(circle at 85% 30%, rgba(249, 115, 22, 0.15), transparent 35%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(20px);
  padding: 2.5rem 2rem;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.login-card .brand {
  justify-content: center;
  margin-bottom: 2rem;
  font-size: 2rem;
}

.login-card .brand-motto {
  display: none;
}

/* ==========================================
   PREMIUM RESPONSIVE STYLING SUITE
   (Desktop, Tablet, & HP/Mobile Optimizations)
   ========================================== */

/* --- Tablet / Large Mobile (max-width: 1024px) --- */
@media (max-width: 1024px) {
  .main-content {
    width: 95% !important;
    margin: 0 auto !important;
    padding: 1rem !important;
  }
  
  .settings-container, 
  .admin-container {
    max-width: 95% !important;
    margin: 1.5rem auto !important;
  }
}

/* --- Medium Mobile / Tablet (max-width: 900px) --- */
@media (max-width: 900px) {
  .main-content {
    grid-template-columns: 1fr !important;
    grid-template-rows: auto !important;
    height: auto !important;
    min-height: calc(100vh - 120px) !important;
  }

  .report-grid {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  
  #mini-map {
    height: 350px !important;
  }
}

/* --- Mobile / HP Layouts (max-width: 768px) --- */
@media (max-width: 768px) {
  /* Dynamic Responsive Navbar */
  .navbar {
    flex-direction: column !important;
    align-items: stretch !important;
    padding: 0.75rem 1rem !important;
    gap: 0.75rem !important;
  }
  
  .brand {
    justify-content: space-between !important;
    font-size: 1.25rem !important;
    width: 100% !important;
  }
  
  .brand img {
    height: 32px !important;
  }
  
  .brand-motto {
    display: none !important; /* Banish long text on small screens */
  }
  
  .nav-links {
    display: flex !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding-bottom: 6px !important;
    gap: 0.5rem !important;
    align-items: center !important;
    -webkit-overflow-scrolling: touch !important;
    scrollbar-width: none !important; /* Firefox */
  }
  
  .nav-links::-webkit-scrollbar {
    display: none !important; /* Chrome, Safari, Opera */
  }
  
  .nav-links a {
    padding: 0.4rem 0.8rem !important;
    font-size: 0.85rem !important;
    border-radius: 20px !important;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid var(--glass-border) !important;
    flex-shrink: 0 !important;
  }
  
  /* User profile badge in scrollbar */
  .nav-links > div[style*="border-left"] {
    margin-left: 8px !important;
    padding-left: 8px !important;
    border-left: 1px solid var(--glass-border) !important;
    flex-shrink: 0 !important;
  }

  /* Map Panel Optimization */
  .map-container {
    display: flex !important;
    flex-direction: column !important;
    height: auto !important;
    padding: 0 !important;
  }
  
  #map {
    height: 380px !important;
    width: 100% !important;
    border-radius: 16px 16px 0 0 !important;
  }
  
  .map-overlay {
    position: relative !important;
    top: 0 !important;
    right: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 0 16px 16px !important;
    border-top: none !important;
    background: var(--panel-bg) !important;
    box-shadow: none !important;
  }

  /* List & Search Responsive stack */
  .search-container {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }
  
  .search-container h2 {
    font-size: 1.5rem !important;
  }
  
  .search-container > div[style*="display: flex"] {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
    gap: 0.75rem !important;
  }
  
  .search-container button.btn,
  .search-container input#tableSearch {
    width: 100% !important;
    margin: 0 !important;
  }

  /* Tracking Detail Grid Stack */
  #resultPanel > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 1.5rem !important;
  }
  
  #resultPanel {
    padding: 1.5rem !important;
  }
  
  #resultPanel div[style*="display: flex; justify-content: space-between; align-items: flex-start"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 1rem !important;
  }

  /* Admin Management Stack */
  .admin-tabs {
    overflow-x: auto !important;
    white-space: nowrap !important;
    -webkit-overflow-scrolling: touch !important;
    padding-bottom: 6px !important;
  }
  
  .tab-btn {
    padding: 8px 14px !important;
    font-size: 0.85rem !important;
  }
  
  #usersTab div[style*="display: grid"] {
    grid-template-columns: 1fr !important;
    gap: 0.75rem !important;
  }
  
  #usersTab button {
    width: 100% !important;
  }
}

/* --- Ultra Compact Mobile (max-width: 500px) --- */
@media (max-width: 500px) {
  .glass-panel {
    padding: 1rem !important;
    border-radius: 12px !important;
  }
  
  .stats-grid {
    gap: 0.75rem !important;
  }
  
  .stat-card {
    padding: 0.75rem 0.5rem !important;
  }
  
  .stat-value {
    font-size: 1.5rem !important;
  }

  /* Auto Stack cramped form rows */
  .form-row[style*="display: flex"],
  .form-row {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }

  /* Table design on small phones */
  th, td {
    padding: 0.75rem 0.5rem !important;
    font-size: 0.8rem !important;
  }
  
  /* Status Modal responsiveness */
  .modal > .glass-panel {
    width: 95% !important;
    padding: 1.25rem !important;
  }

  /* Progress circles on small screens */
  .tracking-timeline {
    padding: 0 !important;
    margin-bottom: 2rem !important;
  }
  
  .tracking-timeline .step {
    width: 60px !important;
  }
  
  .tracking-timeline .step > div[id*="dot"] {
    width: 28px !important;
    height: 28px !important;
    border-width: 2px !important;
  }
  
  .tracking-timeline .step > div:not([id*="dot"]) {
    font-size: 0.65rem !important;
  }

  /* Basemap files items styling */
  .file-item, .user-item {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem !important;
  }
  
  .file-item button, .user-item button {
    width: 100% !important;
  }
  
  .file-item input[style*="width: 140px"] {
    width: 100% !important;
  }
  
  .file-item select {
    width: 100% !important;
  }
  
  .file-item div[style*="display:flex"] {
    width: 100% !important;
    justify-content: space-between !important;
  }

  /* Summary banner & Analytics grids stacking on mobile */
  .summary-banner {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .analytics-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .form-actions {
    grid-column: span 1 !important;
  }
}

/* Form Actions Layout spanning across 2 columns on desktop */
.form-actions {
  grid-column: span 2;
  width: 100%;
  margin-top: 1rem;
}

/* Premium Map Disclaimer Styling */
.map-disclaimer {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 500;
  background: rgba(15, 23, 42, 0.85); /* Restored original semi-transparent background */
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--glass-border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.7rem;
  line-height: 1.3;
  color: var(--text-secondary); /* Restored original text color */
  max-width: 450px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  pointer-events: none;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.map-disclaimer strong {
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .map-disclaimer {
    position: relative !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    max-width: 100% !important;
    margin: 8px 0 !important;
    border-radius: 8px !important;
    background: rgba(0, 0, 0, 0.2) !important; /* Restored original mobile background */
    padding: 6px 10px !important;
    font-size: 0.65rem !important;
    line-height: 1.2 !important;
    gap: 6px !important;
  }
}
