/* K53 Platform - Premium Design System */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
  /* Core Colors (HSL for better control) */
  --primary-h: 221;
  --primary-s: 83%;
  --primary-l: 53%;
  --primary: hsl(var(--primary-h), var(--primary-s), var(--primary-l));
  --primary-dark: hsl(var(--primary-h), var(--primary-s), 40%);
  --primary-light: hsl(var(--primary-h), var(--primary-s), 90%);

  --secondary-h: 160;
  --secondary-s: 84%;
  --secondary-l: 39%;
  --secondary: hsl(var(--secondary-h), var(--secondary-s), var(--secondary-l));

  --accent: #f59e0b;
  --danger: #ef4444;
  --success: #10b981;

  /* Neutral Palette */
  --white: #ffffff;
  --bg-main: #f8fafc;
  --bg-card: rgba(255, 255, 255, 0.8);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;

  /* Shadows & Glassmorphism */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --glass-bg: rgba(255, 255, 255, 0.7);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: blur(12px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  padding: 0;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  background-image:
    radial-gradient(at 0% 0%, hsla(221, 83%, 93%, 1) 0, transparent 50%),
    radial-gradient(at 100% 100%, hsla(160, 84%, 93%, 1) 0, transparent 50%);
  min-height: 100vh;
}

/* Layout Utilities */
.container {
  width: 100%;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
  margin-left: auto;
  margin-right: auto;
  max-width: 1200px;
}

/* Glass Components */
.glass-card {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
}

/* Typography */
h1,
h2,
h3,
h4 {
  font-weight: 700;
  color: #0f172a;
  margin-top: 0;
  letter-spacing: -0.025em;
}

p {
  color: var(--text-muted);
}

/* Interactive Elements */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  font-weight: 600;
  border-radius: 12px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  font-size: 0.95rem;
  gap: 0.5rem;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 14px 0 rgba(var(--primary-h), var(--primary-s), var(--primary-l), 0.39);
}

.btn-primary:active {
  transform: scale(0.96);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

/* Bottom Nav - Mobile Application Feel */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  padding: 0.75rem 0.5rem;
  z-index: 1000;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 500;
}

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

.nav-icon {
  width: 24px;
  height: 24px;
  margin-bottom: 2px;
}

/* Animation Utilities */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fadeInUp 0.5s ease-out forwards;
}

/* Responsive Grid Adjustments */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

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

  .bottom-nav {
    display: none;
    /* Hide bottom nav on desktop, use header instead */
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Dashboard Finance Grid */
.finance-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}

@media (min-width: 768px) {
  .finance-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.revenue-card {
  background: white;
  /* Fallback */
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.revenue-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.revenue-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
  display: block;
}

.revenue-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
  margin-bottom: 0.5rem;
}

.revenue-trend {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

.trend-up {
  color: var(--success);
}

.trend-down {
  color: var(--danger);
}

/* Market Insight Panel */
.market-insight-panel {
  background: white;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-top: 2rem;
  box-shadow: var(--shadow-sm);
  display: none;
  /* Hidden by default until populated */
}

.insight-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.municipality-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  /* max-height: 400px; removed to allow full expansion */
  /* overflow-y: auto; removed */
  padding-right: 0.5rem;
}

@media (min-width: 640px) {
  .municipality-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .municipality-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.mun-card {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.mun-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.opportunity-badge {
  font-size: 0.7rem;
  font-weight: 700;
  background: #dbeafe;
  color: #1e40af;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  border: 1px solid #bfdbfe;
}

.mun-bar-container {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  margin-top: 0.75rem;
  overflow: hidden;
}

.mun-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.5s ease-out;
}

/* Analytics Section */
.analytics-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 2rem;
}

@media (min-width: 1024px) {
  .analytics-section {
    grid-template-columns: 1fr;
  }
}

.opportunity-tag {
  background: var(--accent);
  color: white;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-weight: 700;
}

/* Admin Table Styling */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th {
  text-align: left;
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}

.admin-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

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