:root {
  /* Primitive Color Tokens */
  --color-white: rgba(255, 255, 255, 1);
  --color-black: rgba(0, 0, 0, 1);
  --color-cream-50: rgba(252, 252, 249, 1);
  --color-cream-100: rgba(255, 255, 253, 1);
  --color-gray-200: rgba(245, 245, 245, 1);
  --color-gray-300: rgba(167, 169, 169, 1);
  --color-gray-400: rgba(119, 124, 124, 1);
  --color-slate-500: rgba(98, 108, 113, 1);
  --color-brown-600: rgba(94, 82, 64, 1);
  --color-charcoal-700: rgba(31, 33, 33, 1);
  --color-charcoal-800: rgba(38, 40, 40, 1);
  --color-slate-900: rgba(19, 52, 59, 1);
  --color-teal-300: rgba(50, 184, 198, 1);
  --color-teal-400: rgba(45, 166, 178, 1);
  --color-teal-500: rgba(33, 128, 141, 1);
  --color-teal-600: rgba(29, 116, 128, 1);
  --color-teal-700: rgba(26, 104, 115, 1);
  --color-teal-800: rgba(41, 150, 161, 1);
  --color-red-400: rgba(255, 84, 89, 1);
  --color-red-500: rgba(192, 21, 47, 1);
  --color-orange-400: rgba(230, 129, 97, 1);
  --color-orange-500: rgba(168, 75, 47, 1);

  /* RGB versions for opacity control */
  --color-brown-600-rgb: 94, 82, 64;
  --color-teal-500-rgb: 33, 128, 141;
  --color-slate-900-rgb: 19, 52, 59;
  --color-slate-500-rgb: 98, 108, 113;
  --color-red-500-rgb: 192, 21, 47;
  --color-red-400-rgb: 255, 84, 89;
  --color-orange-500-rgb: 168, 75, 47;
  --color-orange-400-rgb: 230, 129, 97;

  /* Background color tokens (Light Mode) */
  --color-bg-1: rgba(59, 130, 246, 0.08);
  --color-bg-2: rgba(245, 158, 11, 0.08);
  --color-bg-3: rgba(34, 197, 94, 0.08);
  --color-bg-4: rgba(239, 68, 68, 0.08);
  --color-bg-5: rgba(147, 51, 234, 0.08);
  --color-bg-6: rgba(249, 115, 22, 0.08);
  --color-bg-7: rgba(236, 72, 153, 0.08);
  --color-bg-8: rgba(6, 182, 212, 0.08);

  /* Semantic Color Tokens (Light Mode) */
  --color-background: var(--color-cream-50);
  --color-surface: var(--color-cream-100);
  --color-text: var(--color-slate-900);
  --color-text-secondary: var(--color-slate-500);
  --color-primary: var(--color-teal-500);
  --color-primary-hover: var(--color-teal-600);
  --color-primary-active: var(--color-teal-700);
  --color-secondary: rgba(var(--color-brown-600-rgb), 0.12);
  --color-secondary-hover: rgba(var(--color-brown-600-rgb), 0.2);
  --color-secondary-active: rgba(var(--color-brown-600-rgb), 0.25);
  --color-border: rgba(var(--color-brown-600-rgb), 0.2);
  --color-btn-primary-text: var(--color-cream-50);
  --color-card-border: rgba(var(--color-brown-600-rgb), 0.12);
  --color-card-border-inner: rgba(var(--color-brown-600-rgb), 0.12);
  --color-error: var(--color-red-500);
  --color-success: var(--color-teal-500);
  --color-warning: var(--color-orange-500);
  --color-info: var(--color-slate-500);
  --color-focus-ring: rgba(var(--color-teal-500-rgb), 0.4);
  --color-select-caret: rgba(var(--color-slate-900-rgb), 0.8);

  /* Common style patterns */
  --focus-ring: 0 0 0 3px var(--color-focus-ring);
  --focus-outline: 2px solid var(--color-primary);
  --status-bg-opacity: 0.15;
  --status-border-opacity: 0.25;
  --select-caret-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23134252' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  --select-caret-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23f5f5f5' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");

  /* RGB versions for opacity control */
  --color-success-rgb: 33, 128, 141;
  --color-error-rgb: 192, 21, 47;
  --color-warning-rgb: 168, 75, 47;
  --color-info-rgb: 98, 108, 113;

  /* Typography */
  --font-family-base: "FKGroteskNeue", "Geist", "Inter", -apple-system,
    BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-family-mono: "Berkeley Mono", ui-monospace, SFMono-Regular, Menlo,
    Monaco, Consolas, monospace;
  --font-size-xs: 11px;
  --font-size-sm: 12px;
  --font-size-base: 14px;
  --font-size-md: 14px;
  --font-size-lg: 16px;
  --font-size-xl: 18px;
  --font-size-2xl: 20px;
  --font-size-3xl: 24px;
  --font-size-4xl: 30px;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 550;
  --font-weight-bold: 600;
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --letter-spacing-tight: -0.01em;

  /* Spacing */
  --space-0: 0;
  --space-1: 1px;
  --space-2: 2px;
  --space-4: 4px;
  --space-6: 6px;
  --space-8: 8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;

  /* Border Radius */
  --radius-sm: 6px;
  --radius-base: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.04),
    0 2px 4px -1px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.04),
    0 4px 6px -2px rgba(0, 0, 0, 0.02);
  --shadow-inset-sm: inset 0 1px 0 rgba(255, 255, 255, 0.15),
    inset 0 -1px 0 rgba(0, 0, 0, 0.03);

  /* Animation */
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --ease-standard: cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --container-sm: 640px;
  --container-md: 768px;
  --container-lg: 1024px;
  --container-xl: 1280px;
}

/* Dark mode colors */
@media (prefers-color-scheme: dark) {
  :root {
    --color-gray-400-rgb: 119, 124, 124;
    --color-teal-300-rgb: 50, 184, 198;
    --color-gray-300-rgb: 167, 169, 169;
    --color-gray-200-rgb: 245, 245, 245;

    --color-bg-1: rgba(29, 78, 216, 0.15);
    --color-bg-2: rgba(180, 83, 9, 0.15);
    --color-bg-3: rgba(21, 128, 61, 0.15);
    --color-bg-4: rgba(185, 28, 28, 0.15);
    --color-bg-5: rgba(107, 33, 168, 0.15);
    --color-bg-6: rgba(194, 65, 12, 0.15);
    --color-bg-7: rgba(190, 24, 93, 0.15);
    --color-bg-8: rgba(8, 145, 178, 0.15);
    
    --color-background: var(--color-charcoal-700);
    --color-surface: var(--color-charcoal-800);
    --color-text: var(--color-gray-200);
    --color-text-secondary: rgba(var(--color-gray-300-rgb), 0.7);
    --color-primary: var(--color-teal-300);
    --color-primary-hover: var(--color-teal-400);
    --color-primary-active: var(--color-teal-800);
    --color-secondary: rgba(var(--color-gray-400-rgb), 0.15);
    --color-secondary-hover: rgba(var(--color-gray-400-rgb), 0.25);
    --color-secondary-active: rgba(var(--color-gray-400-rgb), 0.3);
    --color-border: rgba(var(--color-gray-400-rgb), 0.3);
    --color-error: var(--color-red-400);
    --color-success: var(--color-teal-300);
    --color-warning: var(--color-orange-400);
    --color-info: var(--color-gray-300);
    --color-focus-ring: rgba(var(--color-teal-300-rgb), 0.4);
    --color-btn-primary-text: var(--color-slate-900);
    --color-card-border: rgba(var(--color-gray-400-rgb), 0.2);
    --color-card-border-inner: rgba(var(--color-gray-400-rgb), 0.15);
    --shadow-inset-sm: inset 0 1px 0 rgba(255, 255, 255, 0.1),
      inset 0 -1px 0 rgba(0, 0, 0, 0.15);
    --color-border-secondary: rgba(var(--color-gray-400-rgb), 0.2);
    --color-select-caret: rgba(var(--color-gray-200-rgb), 0.8);

    --color-success-rgb: var(--color-teal-300-rgb);
    --color-error-rgb: var(--color-red-400-rgb);
    --color-warning-rgb: var(--color-orange-400-rgb);
    --color-info-rgb: var(--color-gray-300-rgb);
  }
}

[data-color-scheme="dark"] {
  --color-gray-400-rgb: 119, 124, 124;
  --color-teal-300-rgb: 50, 184, 198;
  --color-gray-300-rgb: 167, 169, 169;
  --color-gray-200-rgb: 245, 245, 245;

  --color-bg-1: rgba(29, 78, 216, 0.15);
  --color-bg-2: rgba(180, 83, 9, 0.15);
  --color-bg-3: rgba(21, 128, 61, 0.15);
  --color-bg-4: rgba(185, 28, 28, 0.15);
  --color-bg-5: rgba(107, 33, 168, 0.15);
  --color-bg-6: rgba(194, 65, 12, 0.15);
  --color-bg-7: rgba(190, 24, 93, 0.15);
  --color-bg-8: rgba(8, 145, 178, 0.15);
  
  --color-background: var(--color-charcoal-700);
  --color-surface: var(--color-charcoal-800);
  --color-text: var(--color-gray-200);
  --color-text-secondary: rgba(var(--color-gray-300-rgb), 0.7);
  --color-primary: var(--color-teal-300);
  --color-primary-hover: var(--color-teal-400);
  --color-primary-active: var(--color-teal-800);
  --color-secondary: rgba(var(--color-gray-400-rgb), 0.15);
  --color-secondary-hover: rgba(var(--color-gray-400-rgb), 0.25);
  --color-secondary-active: rgba(var(--color-gray-400-rgb), 0.3);
  --color-border: rgba(var(--color-gray-400-rgb), 0.3);
  --color-error: var(--color-red-400);
  --color-success: var(--color-teal-300);
  --color-warning: var(--color-orange-400);
  --color-info: var(--color-gray-300);
  --color-focus-ring: rgba(var(--color-teal-300-rgb), 0.4);
  --color-btn-primary-text: var(--color-slate-900);
  --color-card-border: rgba(var(--color-gray-400-rgb), 0.15);
  --color-card-border-inner: rgba(var(--color-gray-400-rgb), 0.15);
  --shadow-inset-sm: inset 0 1px 0 rgba(255, 255, 255, 0.1),
    inset 0 -1px 0 rgba(0, 0, 0, 0.15);
  --color-border-secondary: rgba(var(--color-gray-400-rgb), 0.2);
  --color-select-caret: rgba(var(--color-gray-200-rgb), 0.8);

  --color-success-rgb: var(--color-teal-300-rgb);
  --color-error-rgb: var(--color-red-400-rgb);
  --color-warning-rgb: var(--color-orange-400-rgb);
  --color-info-rgb: var(--color-gray-300-rgb);
}

[data-color-scheme="light"] {
  --color-brown-600-rgb: 94, 82, 64;
  --color-teal-500-rgb: 33, 128, 141;
  --color-slate-900-rgb: 19, 52, 59;
  
  --color-background: var(--color-cream-50);
  --color-surface: var(--color-cream-100);
  --color-text: var(--color-slate-900);
  --color-text-secondary: var(--color-slate-500);
  --color-primary: var(--color-teal-500);
  --color-primary-hover: var(--color-teal-600);
  --color-primary-active: var(--color-teal-700);
  --color-secondary: rgba(var(--color-brown-600-rgb), 0.12);
  --color-secondary-hover: rgba(var(--color-brown-600-rgb), 0.2);
  --color-secondary-active: rgba(var(--color-brown-600-rgb), 0.25);
  --color-border: rgba(var(--color-brown-600-rgb), 0.2);
  --color-btn-primary-text: var(--color-cream-50);
  --color-card-border: rgba(var(--color-brown-600-rgb), 0.12);
  --color-card-border-inner: rgba(var(--color-brown-600-rgb), 0.12);
  --color-error: var(--color-red-500);
  --color-success: var(--color-teal-500);
  --color-warning: var(--color-orange-500);
  --color-info: var(--color-slate-500);
  --color-focus-ring: rgba(var(--color-teal-500-rgb), 0.4);

  --color-success-rgb: var(--color-teal-500-rgb);
  --color-error-rgb: var(--color-red-500-rgb);
  --color-warning-rgb: var(--color-orange-500-rgb);
  --color-info-rgb: var(--color-slate-500-rgb);
}

@font-face {
  font-family: 'FKGroteskNeue';
  src: url('https://r2cdn.perplexity.ai/fonts/FKGroteskNeue.woff2')
    format('woff2');
}

/* ===== RESET & BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: inherit;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  font-family: var(--font-family-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-background);
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background: var(--color-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  height: 100vh;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

/* ===== HEADER REDESIGN ===== */
.app-header {
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-12) var(--space-24);
  position: relative;
  z-index: 100;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--container-xl);
  margin: 0 auto;
}

.header-content h1 {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin: 0;
}

.version-badge {
  background: var(--color-secondary);
  color: var(--color-text-secondary);
  padding: var(--space-4) var(--space-12);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  border: 1px solid var(--color-border);
}

/* ===== MAIN LAYOUT (70/30 SPLIT) ===== */
.app-container {
    display: flex;
    height: calc(100vh - 64px);
    background: var(--color-background);
}

.map-section {
    flex: 7;  /* 70% for map */
    position: relative;
    background: var(--color-background);
    border-right: 1px solid var(--color-border);
    z-index: 1;
}

.agents-section {
    flex: 3;  /* 30% for agents */
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    min-width: 300px;
    max-width: 400px;
}

/* ===== MAP CONTAINER ===== */
.map-container {
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
}

/* ===== ADDITIONAL STYLES TO REPLACE INLINE STYLES ===== */

/* Loading indicator styles */
.loading-indicator {
    text-align: center;
    padding: var(--space-20);
    color: var(--color-text-secondary);
}

.loading-indicator .spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-secondary);
    border-top: 4px solid var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
    margin: 0 auto var(--space-12);
}

#loading {
    text-align: center;
    padding: var(--space-20);
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-base);
    margin-top: var(--space-16);
}

/* Treatment card specific styles */
.treatment-card h5 {
    color: var(--color-primary);
    margin-bottom: var(--space-6);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
}

/* Chip color variants */
.chip.success { 
    background-color: rgba(var(--color-success-rgb), 0.15);
    color: var(--color-success);
    border: 1px solid rgba(var(--color-success-rgb), 0.25);
}

.chip.warning { 
    background-color: rgba(var(--color-warning-rgb), 0.15);
    color: var(--color-warning);
    border: 1px solid rgba(var(--color-warning-rgb), 0.25);
}

.chip.error { 
    background-color: rgba(var(--color-error-rgb), 0.15);
    color: var(--color-error);
    border: 1px solid rgba(var(--color-error-rgb), 0.25);
}

/* ===== PROTECTION & SECURITY ===== */

.protected-content {
    transition: filter 0.3s ease;
}

.protected-content.blurred {
    filter: blur(10px) !important;
    user-select: none !important;
    pointer-events: none !important;
}

/* Security UI Components */
.security-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--accent-primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    text-align: center;
    font-size: 0.9rem;
}

.security-indicator {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.security-indicator.secure {
    background: var(--success);
    color: white;
}

.security-indicator.insecure {
    background: var(--error);
    color: white;
}

.security-badge {
    display: inline-block;
    padding: 4px 8px;
    background: var(--success);
    color: white;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-left: 8px;
}

.security-badge.mini {
    padding: 2px 6px;
    font-size: 0.6rem;
    margin-left: 4px;
}

.security-badge.secure {
    background: var(--success);
}

.session-badge {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 8px;
    font-size: 0.6rem;
    margin-top: 4px;
}

.security-error {
    padding: 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    text-align: center;
    color: var(--error);
}

.results-container.secure {
}

.loading-indicator.secure {
}

.chip.secure {
    background: var(--success);
    color: white;
}

.treatment-card.secure {
}

.security-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    margin: 8px 0;
}

.security-footer, .analysis-footer {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-primary);
    color: var(--text-secondary);
    text-align: center;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.agent-security-status {
    display: flex;
    align-items: center;
}

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

/* Typing animation for chat */
.typing-animation {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
}

.typing-animation span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* ===== DESKTOP POPUP DESIGN (OPTIMIZED SIZE) ===== */
/* ===== POPUP WITH RIGHT-SIDE POSITIONING & CENTERED ARROW ===== */
.ol-popup {
  position: absolute;
  background: var(--color-surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--color-card-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-lg);
  padding: var(--space-32) var(--space-10) var(--space-12) var(--space-10);
  
  min-width: 280px !important;
  max-width: 340px !important;
  max-height: 550px !important;
  
  font-family: var(--font-family-base);
  color: var(--color-text);
  overflow: visible !important;
  box-sizing: border-box;
  transition: min-width 0.4s ease, max-width 0.4s ease, max-height 0.4s ease !important;
}

.ol-popup-content-wrapper {
    max-height: 430px !important;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
    padding-right: 4px;
    
    /* ✅ ACTUAL BOTTOM PADDING - NOT SCROLL-PADDING */
    padding-bottom: 80px !important;  /* Creates real space at bottom */
}

.ol-popup-content-wrapper::-webkit-scrollbar {
  width: 4px;
}

.ol-popup-content-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.ol-popup-content-wrapper::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--space-2);
}

/* Fix close button z-index and visibility */
.ol-popup-closer {
    position: absolute !important;
    top: 12px !important;
    right: 12px !important;
    width: 24px !important;
    height: 24px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: var(--color-secondary) !important;
    border-radius: var(--radius-full) !important;
    text-decoration: none !important;
    color: var(--color-text-secondary) !important;
    font-size: var(--font-size-base) !important;
    transition: all var(--duration-fast) var(--ease-standard) !important;
    
    /* ✅ KEY FIXES FOR VISIBILITY */
    z-index: 10000 !important;  /* Very high z-index */
    border: 1px solid var(--color-border) !important;
    box-shadow: var(--shadow-sm) !important;
}

.ol-popup-closer:hover {
    background: var(--color-secondary-hover) !important;
    color: var(--color-text) !important;
    transform: scale(1.1) !important;
}

.ol-popup-closer:after {
  content: "✕";
}

.ol-popup h4 {
  color: var(--color-text);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin: 0 0 var(--space-8) 0;
}

/* Ensure explanation section doesn't overlap buttons */
.explanation-section {
    background: linear-gradient(135deg, var(--color-secondary), var(--color-surface));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-16);
    margin-bottom: var(--space-16);
    position: relative;
    overflow: hidden;
    
    /* ✅ ENSURE IT DOESN'T COVER BUTTONS */
    margin-top: var(--space-24); /* Add space for buttons */
    z-index: 1 !important; /* Lower than buttons */
}

.explanation-section h4 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 1em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}


/* Ensure explanation content starts collapsed */
.explanation-content {
    max-height: 120px !important;
    overflow: hidden !important;
    transition: max-height 0.3s ease !important;
}

.explanation-content.expanded {
    max-height: none !important;
}

.explanation-content p {
    margin-bottom: var(--space-8);
    text-align: left;
}

.explanation-content p:last-child {
    margin-bottom: 0;
}

.explanation-text {
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  color: var(--color-text-secondary);
}

/* If your dots are in a specific container, center them */
.loading-spinner,
.explanation-loading .dots,
.ai-analysis-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    text-align: center;
}

/* Analysis and Recommendations Sections */
.analysis-section {
    border: none !important;
    padding: 16px !important;
    background: transparent !important;
    border-radius: var(--radius-base);
    margin-bottom: var(--space-12);
}

/* Better paragraph spacing in AI analysis */
.analysis-section p {
    margin-bottom: 1em;
    line-height: 1.7;
}

.analysis-section p:last-child {
    margin-bottom: 0;
}

.recommendations-section {
    background: rgba(var(--color-success-rgb), 0.05);
    border-radius: var(--radius-base);
    padding: var(--space-12);
}

.recommendations-content {
    /* Use gap instead of margins for cleaner spacing */
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

.recommendation-item {
    background: var(--color-surface);
    border-radius: var(--radius-base);
    padding: var(--space-8);
    margin: var(--space-8) 0;
    border: 1px solid var(--color-border);
    display: flex;
    align-items: flex-start;
    gap: var(--space-8);
}

.rec-number {
    background: var(--color-primary);
    color: var(--color-btn-primary-text);
    border-radius: var(--radius-full);
    width: 20px;
    height: 20px;
    display: none !important;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-bold);
    flex-shrink: 0;
}

.rec-title {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--color-text);
}

/* Recommendation Cards Styling */
.recommendation-card {
    background: var(--color-surface) !important;
    border: 1px solid rgba(167, 169, 169, 0.15) !important;
    border-radius: var(--radius-lg) !important;
    padding: 16px !important;
    margin-bottom: 12px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
    transition: all var(--duration-fast) var(--ease-standard);
    border-left: none !important;
}

.recommendation-card:last-child {
    margin-bottom: 0 !important;
}

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

.rec-header {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    margin-bottom: var(--space-8);
}

.rec-icon {
    background: var(--color-success);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.rec-title {
    color: var(--color-text) !important;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    flex: 1;
}

.rec-description {
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
    line-height: 1.5;
    padding-left: var(--space-32); /* Indent to align with title */
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .recommendation-card {
        padding: var(--space-8);
        margin-bottom: var(--space-8);
    }
    
    .rec-description {
        padding-left: var(--space-24);
        font-size: var(--font-size-xs);
    }
}


/* Index badges */
.index-badge {
    background: var(--color-primary);
    color: var(--color-btn-primary-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: var(--font-size-xs);
    font-family: var(--font-family-mono);
}

.index-badge:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

/* Simple solid green badge style (old style) */
.index-highlight {
    background-color: #22c55e !important; /* Solid emerald green */
    color: white !important;
    padding: 2px 8px !important;
    border-radius: 9999px !important; /* Full pill shape */
    font-size: 0.75rem !important;
    font-weight: 600 !important;
    font-family: var(--font-family-base) !important;
    letter-spacing: 0.05em !important;
    text-transform: uppercase !important;
    display: inline-block !important;
    margin: 0 2px !important;
    cursor: help !important;
    white-space: nowrap !important;
    transition: all 0.2s ease !important;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.4) !important;
}

.index-highlight:hover {
    background-color: #16a34a !important; /* Slightly darker green on hover */
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.6) !important;
    transform: translateY(-1px) !important;
}

/* Alternative: More subtle green styling */
.index-highlight-subtle {
    background: rgba(16, 185, 129, 0.15) !important;
    color: #059669 !important;
    border: 1px solid rgba(16, 185, 129, 0.3) !important;
    padding: 2px 6px !important;
    border-radius: 6px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
}


/* Metric values */
.metric-value {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    white-space: nowrap;
}

/* Center the existing dots in AI Analysis section */
.explanation-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-20);
    text-align: center;
}

.spinner-dots {
    display: flex;
    gap: 4px;
}

.spinner-dots div {
    width: 8px;
    height: 8px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: dotPulse 1.4s ease-in-out infinite both;
}

.dot1 { animation-delay: -0.32s; }
.dot2 { animation-delay: -0.16s; }
.dot3 { animation-delay: 0s; }

@keyframes dotPulse {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .explanation-content {
        max-height: 100px;
        font-size: var(--font-size-xs);
    }
    
    .recommendation-item {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .rec-number {
        width: 18px;
        height: 18px;
        font-size: 10px;
    }
    
    .index-badge {
        font-size: 10px;
        padding: 1px 3px;
    }
}

/* ===== CARBON CREDITS ===== */
.carbon-quick-actions {
    margin: var(--space-16) 0;
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.quick-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-12) var(--space-16);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-background);
}

.quick-actions-header h4 {
    margin: 0;
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: var(--space-8);
}

.toggle-quick-actions {
    cursor: pointer;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-lg);
    color: var(--color-text-secondary);
    background: none;
    border: none;
    padding: var(--space-4);
    border-radius: var(--radius-base);
    transition: all var(--duration-fast) var(--ease-standard);
}

.toggle-quick-actions:hover {
    color: var(--color-text);
    background: var(--color-secondary);
}

/* ✅ UPDATED: Flex wrap layout for small badges */
.quick-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    padding: var(--space-16);
}

/* ✅ UPDATED: Exact same style as index badges */
.carbon-quick-btn {
    background: var(--color-primary);
    color: var(--color-btn-primary-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: var(--font-size-xs);
    font-family: var(--font-family-mono);
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.carbon-quick-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

/* Remove icon styling since badges don't need it */
.carbon-quick-btn::before {
    display: none;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .quick-actions-grid {
        gap: var(--space-2);
        padding: var(--space-12);
    }
    
    .carbon-quick-btn {
        font-size: var(--font-size-xs);
        padding: 2px 4px;
    }
    
    .quick-actions-header {
        padding: var(--space-8) var(--space-12);
    }
}

/* ===== DESKTOP CHART CONTAINERS (FULL FILL OPTIMIZATION) ===== */
/* ===== TIGHTER CHART CONTAINERS ===== */
.chart-container {
    position: relative;
    width: 95% !important;        /* ✅ ALMOST FULL WIDTH OF POPUP */
    height: 180px !important;     /* ✅ SLIGHTLY SMALLER HEIGHT */
    margin: 5px auto !important;  /* ✅ MINIMAL MARGINS */
    padding: 4px !important;      /* ✅ VERY TIGHT PADDING */
    border: 1px solid var(--color-border);
    border-radius: var(--radius-base);
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    overflow: visible !important;
    box-sizing: border-box;
    z-index: 1;
}

.chart-container canvas {
    max-height: 170px !important; /* ✅ FILL CONTAINER BETTER */
    max-width: 100% !important;
    display: block !important;
    width: 100% !important;
    height: 170px !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ===== DESKTOP DETAILS/SUMMARY STYLING ===== */
.ol-popup details {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-base);
    margin: 15px 0;
    padding: 0;
    overflow: visible;  /* ✅ ALLOW CHARTS TO RENDER */
}

.ol-popup summary {
    color: var(--color-text);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    background: var(--color-secondary);
    border-radius: var(--radius-base);
    transition: all 0.2s ease;
}

.ol-popup summary:hover {
    background: var(--color-secondary-hover);
    color: var(--color-text);
}

.ol-popup details[open] summary {
    border-bottom: 1px solid var(--color-border);
    background: var(--color-secondary-hover);
    border-radius: var(--radius-base) var(--radius-base) 0 0;
}

.ol-popup details[open] {
    padding-bottom: 15px;
}

/* Force chart visibility on desktop */
.ol-popup details[open] .chart-container canvas {
    display: block !important;
    width: 100% !important;
    height: 320px !important;     /* ✅ MATCH INCREASED HEIGHT */
    visibility: visible !important;
    opacity: 1 !important;
}

/* ===== FIX POPUP POSITIONING & CLIPPING ===== */
.ol-popup {
  min-width: 280px !important;
  max-width: 340px !important;
  max-height: 550px !important;
  padding: var(--space-16) !important; /* Add top padding */
  margin-top: 0px !important;         /* Add space above popup */
  transition: min-width 0.4s ease, max-width 0.4s ease, max-height 0.4s ease !important;
  overflow: visible !important;
  /* Prevent clipping */
  box-sizing: border-box;
}

/* ✅ EXPANDED STATE */
.ol-popup.expanded {
  min-width: 500px !important;
  max-width: 600px !important;
  max-height: 550px !important;
}

.ol-popup.expanded .ol-popup-content-wrapper {
  max-height: 480px !important;
}

/* ===== MOBILE CHART MODAL SYSTEM ===== */
.chart-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.chart-modal-overlay.active {
    display: flex;
}

.chart-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    max-width: 90vw;
    max-height: 80vh;
    width: 100%;
    position: relative;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.chart-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
}

.chart-modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    margin: 0;
}

.chart-modal-close {
    background: var(--color-secondary);
    border: none;
    border-radius: var(--radius-full);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all var(--duration-fast) var(--ease-standard);
}

.chart-modal-close:hover {
    background: var(--color-secondary-hover);
    color: var(--color-text);
}

.chart-modal-content {
    height: 300px;
    position: relative;
}

.chart-modal-content canvas {
    width: 100% !important;
    height: 100% !important;
    max-height: 300px !important;
}

/* ===== MOBILE CHART TRIGGER BUTTONS ===== */
.mobile-chart-trigger {
    display: block !important;
    width: 100%;
    max-width: 100%;
    background: var(--color-primary);
    color: var(--color-btn-primary-text);
    border: none;
    border-radius: var(--radius-base);
    padding: 12px 16px;
    margin: 10px 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-standard);
    
    /* ✅ PREVENT TEXT CUTOFF */
    box-sizing: border-box;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    
    /* ✅ CENTER CONTENT */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.mobile-chart-trigger:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
}

.mobile-chart-trigger:active {
    background: var(--color-primary-active);
    transform: translateY(0);
}

/* ===== TAB SYSTEM REDESIGN ===== */
.tab-headers {
  display: flex;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 var(--space-4);
  gap: var(--space-2);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  padding: var(--space-16);
  cursor: pointer;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  font-family: var(--font-family-base);
  color: var(--color-text-secondary);
  border-radius: var(--radius-base) var(--radius-base) 0 0;
  transition: all var(--duration-fast) var(--ease-standard);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
}

.tab-btn:hover {
  background: var(--color-secondary);
  color: var(--color-text);
}

.tab-btn.active {
  background: var(--color-background);
  color: var(--color-text);
  border-bottom: 2px solid var(--color-primary);
}

.tab-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ===== TAB CONTENT ===== */
.tab-content-container {
  flex: 1;
  overflow: hidden;
  background: var(--color-background);
}

.tab-content {
  height: 100%;
  padding: var(--space-24);
  display: none;
  flex-direction: column;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.tab-content::-webkit-scrollbar {
  width: 6px;
}

.tab-content::-webkit-scrollbar-track {
  background: var(--color-background);
}

.tab-content::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

.tab-content.active {
  display: flex;
}

.agent-header h3 {
  color: var(--color-text);
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-20);
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

/* ===== CHAT REDESIGN ===== */
.chat-messages {
  flex: 1;
  background: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-20);
  margin-bottom: var(--space-20);
  overflow-y: auto;
  max-height: 450px;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.chat-messages::-webkit-scrollbar {
  width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--space-2);
}

.message {
  margin-bottom: var(--space-16);
  display: flex;
  animation: messageSlide 0.3s ease-out;
}

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

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.message-content {
  max-width: 85%;
  padding: var(--space-12) var(--space-16);
  border-radius: var(--radius-lg);
  font-size: var(--font-size-sm);
  line-height: var(--line-height-normal);
  word-wrap: break-word;
}

.message.user .message-content {
  background: var(--color-primary);
  color: var(--color-btn-primary-text);
  border-bottom-right-radius: var(--space-4);
}

.message.assistant .message-content {
  background: var(--color-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-card-border);
  border-bottom-left-radius: var(--space-4);
}

.chat-input-container {
  display: flex;
  gap: var(--space-12);
  align-items: flex-end;
}

/* ===== FORM ELEMENTS REDESIGN ===== */
.form-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-20);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-8);
  margin-bottom: var(--space-16);
}

.form-group label {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  display: block;
  margin-bottom: var(--space-8);
}

input, textarea, select {
  display: block;
  width: 100%;
  padding: var(--space-8) var(--space-12);
  font-size: var(--font-size-md);
  line-height: var(--line-height-normal);
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-base);
  transition: border-color var(--duration-fast) var(--ease-standard),
    box-shadow var(--duration-fast) var(--ease-standard);
  font-family: var(--font-family-base);
  resize: vertical;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--color-primary);
  outline: var(--focus-outline);
  background-color: var(--color-surface);
}

input::placeholder, textarea::placeholder {
  color: var(--color-text-secondary);
}

select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: var(--select-caret-light);
  background-repeat: no-repeat;
  background-position: right var(--space-12) center;
  background-size: 16px;
  padding-right: var(--space-32);
}

@media (prefers-color-scheme: dark) {
  select {
    background-image: var(--select-caret-dark);
  }
}

[data-color-scheme="dark"] select {
  background-image: var(--select-caret-dark);
}

[data-color-scheme="light"] select {
  background-image: var(--select-caret-light);
}

/* ===== BUTTONS REDESIGN ===== */
.btn-primary, .btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-16);
  border-radius: var(--radius-base);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-normal);
  cursor: pointer;
  transition: all var(--duration-normal) var(--ease-standard);
  border: none;
  text-decoration: none;
  position: relative;
  gap: var(--space-8);
}

.btn-primary:focus-visible, .btn-outline:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn-primary {
  background: var(--color-primary);
  color: var(--color-btn-primary-text);
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-primary:active {
  background: var(--color-primary-active);
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn-primary:disabled {
  background: var(--color-text-secondary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.5;
}

.btn-outline {
  background: var(--color-secondary);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-outline:hover {
  background: var(--color-secondary-hover);
  border-color: var(--color-border);
  transform: translateY(-1px);
}

.btn-outline:active {
  background: var(--color-secondary-active);
}

/* ===== LOADING STATES ===== */
.loading-indicator {
  text-align: center;
  padding: var(--space-24);
  color: var(--color-text-secondary);
}

.spinner {
  width: var(--space-32);
  height: var(--space-32);
  border: 3px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius-full);
  animation: spin 1s linear infinite;
  margin: 0 auto var(--space-12);
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== RESULTS CONTAINERS ===== */
.results-container {
  background: var(--color-surface);
  border: 1px solid var(--color-card-border);
  border-radius: var(--radius-lg);
  padding: var(--space-20);
  margin-top: var(--space-20);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-standard);
}

.results-container:hover {
  box-shadow: var(--shadow-md);
}

.results-container h4 {
  color: var(--color-text);
  margin-bottom: var(--space-12);
  font-weight: var(--font-weight-semibold);
  margin: 0;
  font-size: var(--font-size-base);
  line-height: var(--line-height-tight);
}

/* ===== UPLOAD COMPONENTS ===== */
.upload-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-16);
}

.image-preview {
  text-align: center;
  margin: var(--space-16) 0;
}

.image-preview img {
  max-width: 100%;
  max-height: 280px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-card-border);
}

/* ===== STATUS & INDICATORS ===== */
.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-6) var(--space-12);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  margin-right: var(--space-8);
  margin-bottom: var(--space-6);
  transition: all var(--duration-fast) var(--ease-standard);
  background: var(--color-secondary);
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.chip.success { 
  background-color: rgba(var(--color-success-rgb), var(--status-bg-opacity));
  color: var(--color-success);
  border: 1px solid rgba(var(--color-success-rgb), var(--status-border-opacity));
}

.chip.warning { 
  background-color: rgba(var(--color-warning-rgb), var(--status-bg-opacity));
  color: var(--color-warning);
  border: 1px solid rgba(var(--color-warning-rgb), var(--status-border-opacity));
}

.chip.error { 
  background-color: rgba(var(--color-error-rgb), var(--status-bg-opacity));
  color: var(--color-error);
  border: 1px solid rgba(var(--color-error-rgb), var(--status-border-opacity));
}

/* ===== HEALTH SCORING ===== */
.health-score {
  font-size: calc(var(--font-size-4xl) * 1.25);
  font-weight: var(--font-weight-bold);
  text-align: center;
  margin: var(--space-20) 0;
  font-family: var(--font-family-base);
}

.health-score.excellent { color: var(--color-success); }
.health-score.good { color: var(--color-warning); }
.health-score.poor { color: var(--color-error); }

/* ===== TREATMENT CARDS ===== */
.treatment-card {
  background-color: var(--color-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-card-border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--duration-normal) var(--ease-standard);
  padding: var(--space-16);
  margin-bottom: var(--space-12);
}

.treatment-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--color-card-border);
}

.treatment-card h5 {
  color: var(--color-text);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-8);
  margin: 0;
  font-size: var(--font-size-base);
  line-height: var(--line-height-tight);
}

/* ✅ CENTERED LEFT-POINTING ARROW */
.ol-popup::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 50% !important;                    /* ✅ CENTER VERTICALLY */
    left: -10px !important;                 /* ✅ POSITION ON LEFT EDGE */
    transform: translateY(-50%) !important;  /* precise centering */
    margin-top: 0 !important;                /* stop half‑pixel rounding */
    will-change: transform;                   /* smoother repaint on expand */
    width: 0 !important;
    height: 0 !important;
    border-style: solid !important;
    border-width: 10px 10px 10px 0 !important;  /* ✅ TRIANGLE POINTING LEFT */
    border-color: transparent var(--color-surface) transparent transparent !important;
    z-index: 1001 !important;
    pointer-events: none !important;
}

/* ✅ CENTERED LEFT-POINTING ARROW BORDER */
.ol-popup::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 50% !important;                    /* ✅ CENTER VERTICALLY */
    left: -11px !important;                 /* ✅ BORDER SHADOW */
    transform: translateY(-50%) !important;  /* precise centering */
    margin-top: 0 !important;                /* stop half‑pixel rounding */
    will-change: transform;                   /* smoother repaint on expand */
    width: 0 !important;
    height: 0 !important;
    border-style: solid !important;
    border-width: 11px 11px 11px 0 !important;  /* ✅ BORDER TRIANGLE POINTING LEFT */
    border-color: transparent var(--color-card-border) transparent transparent !important;
    z-index: 1000 !important;
    pointer-events: none !important;
}

/* ===== DYNAMIC POPUP EXPANSION ===== */
.ol-popup {
  /* Keep your existing narrow styles */
  min-width: 280px !important;
  max-width: 340px !important;
  max-height: 550px !important;
  
  /* ✅ ADD SMOOTH TRANSITIONS */
  transition: min-width 0.4s ease, max-width 0.4s ease, max-height 0.4s ease !important;
}

/* ✅ EXPANDED STATE FOR CHARTS */
.ol-popup.expanded {
  min-width: 650px !important;  /* Wide enough for full charts */
  max-width: 750px !important;
  max-height: 700px !important;
}

.ol-popup.expanded .ol-popup-content-wrapper {
  max-height: 620px !important;
}

/* Fix toggle button visibility and positioning */
.popup-collapse-btn {
    position: absolute !important;
    top: 12px !important;
    right: 44px !important;  /* Left of close button */
    width: 24px !important;
    height: 24px !important;
    background: var(--color-primary) !important;
    color: var(--color-btn-primary-text) !important;
    border: none !important;
    border-radius: var(--radius-full) !important;
    font-size: 14px !important;
    font-weight: bold !important;
    cursor: pointer !important;
    transition: all var(--duration-fast) var(--ease-standard) !important;
    
    /* ✅ KEY FIXES FOR VISIBILITY */
    z-index: 10000 !important;  /* Same high z-index as close button */
    box-shadow: var(--shadow-sm) !important;
    border: 1px solid rgba(255,255,255,0.2) !important;
}

.popup-collapse-btn:hover {
    background: var(--color-primary-hover) !important;
    transform: scale(1.1) !important;
    box-shadow: var(--shadow-md) !important;
}

/* ===== AI EXPLANATION TOGGLE BUTTON (FIXED VERSION) ===== */
.explanation-toggle-btn {
    /* Position */
    position: relative !important;
    margin-left: auto !important;
    
    /* Size - make it prominent */
    width: auto !important;
    height: 28px !important;
    padding: 6px 12px !important;
    
    /* Styling - single label with icon */
    background: var(--color-primary) !important;
    color: var(--color-btn-primary-text) !important;
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius-base) !important;
    
    /* Typography */
    font-size: 9px !important;
    font-weight: 600 !important;
    font-family: var(--font-family-base) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    
    /* Layout */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    cursor: pointer !important;
    
    /* Effects */
    box-shadow: var(--shadow-sm) !important;
    transition: all 0.2s ease !important;
    z-index: 10001 !important;
    user-select: none !important;
}

.explanation-toggle-btn:hover {
    background: var(--color-primary-hover) !important;
    transform: translateY(-1px) !important;
    box-shadow: var(--shadow-md) !important;
}

.explanation-toggle-btn:active {
    transform: translateY(0) !important;
}

/* Icon rotation for expanded state */
.explanation-toggle-btn .toggle-icon {
    transition: transform 0.3s ease;
    font-size: 12px;
}

.explanation-toggle-btn.expanded .toggle-icon {
    transform: rotate(180deg);
}


/* ===== TIGHTER DETAILS SECTIONS ===== */
.ol-popup details {
    margin: 8px 0 !important;      /* ✅ REDUCED FROM 15px */
    padding: 0 !important;
}

.ol-popup summary {
    padding: 8px 12px !important;  /* ✅ REDUCED FROM 12px 16px */
    margin-bottom: 5px !important; /* ✅ LESS SPACE BELOW SUMMARY */
}

.ol-popup details[open] {
    padding-bottom: 8px !important; /* ✅ REDUCED FROM 15px */
}

/* ===== COMPACT ELEMENT SPACING ===== */
.ol-popup h4 {
  margin: 0 0 var(--space-4) 0 !important; /* ✅ REDUCED MARGINS */
}

.ol-popup p {
  margin: var(--space-4) 0 !important; /* ✅ TIGHTER PARAGRAPH SPACING */
}

.ol-popup hr {
  margin: var(--space-6) 0 !important; /* ✅ LESS SPACE AROUND DIVIDERS */
}

.ol-popup details {
    margin: 4px 0 !important;      /* ✅ VERY TIGHT DETAILS SPACING */
    padding: 0 !important;
}

.ol-popup summary {
    padding: 6px 8px !important;   /* ✅ COMPACT SUMMARY PADDING */
    margin-bottom: 2px !important; /* ✅ MINIMAL SPACE BELOW */
    font-size: var(--font-size-xs) !important; /* ✅ SMALLER FONT */
}

.ol-popup details[open] {
    padding-bottom: 4px !important; /* ✅ MINIMAL BOTTOM PADDING */
}

/* ✅ TIGHTER STATISTICS GRID */
.ol-popup div[style*="display: grid"] {
    gap: 2px !important; /* ✅ LESS GAP BETWEEN STATS */
    font-size: 0.8em !important; /* ✅ SMALLER TEXT */
    margin: var(--space-4) 0 !important; /* ✅ LESS MARGIN */
}

/* ✅ EXPANDED STATE FOR WIDER CHARTS */
.ol-popup.expanded {
  min-width: 500px !important;  /* ✅ COMPACT BUT WIDE ENOUGH FOR CHARTS */
  max-width: 600px !important;
  max-height: 550px !important;
  left: 0px;                  /* ✅ BETTER CENTERING */
  margin-top: px !important;
}

.ol-popup.expanded .ol-popup-content-wrapper {
  max-height: 480px !important;
}

/* ✅ EXPANDED CHARTS FILL MORE SPACE */
.ol-popup.expanded .chart-container {
  width: 98% !important;        /* ✅ NEARLY FULL WIDTH WHEN EXPANDED */
  height: 200px !important;     /* ✅ TALLER WHEN EXPANDED */
}

.ol-popup.expanded .chart-container canvas {
  height: 190px !important;     /* ✅ MATCH CONTAINER HEIGHT */
  max-height: 190px !important;
}

/* ===== RESPONSIVE DESIGN (OPTIMIZED) ===== */

/* Large Desktop */
@media (min-width: 1200px) {
    .chart-container {
        height: 240px !important;     /* ✅ PROPORTIONALLY LARGER ON BIG SCREENS */
        padding: 10px !important;
        width: 65% !important;         /* ✅ SLIGHTLY WIDER ON LARGE SCREENS */
    }
    
    .chart-container canvas {
        max-height: 220px !important; /* ✅ MATCH CONTAINER ADJUSTMENT */
        height: 220px !important;
    }
    
    .ol-popup {
        min-width: 280px !important;  /* Keep narrow popup */
        max-width: 340px !important;
    }
    
    .map-section {
        flex: 7;
    }
    
    .agents-section {
        flex: 3;
    }
}



/* Standard Desktop */
@media (max-width: 1199px) and (min-width: 769px) {
    .map-section {
        flex: 6.5;
    }
    
    .agents-section {
        flex: 3.5;
    }
}

/* Mobile and Tablet */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: 100vh;
    }
    
    .map-section {
        flex: none;
        height: 60vh;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }
    
    .agents-section {
        flex: none;
        height: 40vh;
        border-left: none;
        min-width: unset;
        max-width: unset;
        overflow-y: auto;
    }
    
    /* ✅ MOBILE POPUP ADJUSTMENTS */
    .ol-popup {
        min-width: 200px !important;  /* ✅ EVEN SMALLER ON MOBILE */
        max-width: calc(100vw - 15px) !important;
        max-height: 70vh !important;
        padding: 8px;
        left: -10px;
    }
    
    .ol-popup-content-wrapper {
        max-height: calc(60vh - 120px) !important;  /* Smaller max-height on mobile */
        padding-bottom: 100px !important;           /* More padding on mobile */
    }
    
    /* ✅ HIDE DESKTOP CHARTS ON MOBILE */
    .chart-container {
        display: none !important;
    }
    
    /* ✅ SHOW MOBILE BUTTONS */
    .mobile-chart-trigger {
        display: flex !important;
        font-size: var(--font-size-sm);
        padding: 10px 12px;
        margin: 8px 0;
    }
    
    /* ✅ MOBILE TAB ADJUSTMENTS */
    .tab-content {
        padding: 16px;
        height: calc(40vh - 60px);
    }
    
    .agent-header h3 {
        font-size: 1rem;
        margin-bottom: 12px;
    }
    
    .chat-messages {
        max-height: calc(40vh - 160px);
        padding: 12px;
    }
    
    .message-content {
        max-width: 95%;
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .btn-primary, .btn-outline {
        padding: 8px 12px;
        font-size: 0.8rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .app-header {
        padding: 8px 16px;
    }
    
    .header-content h1 {
        font-size: var(--font-size-md);
    }
    
    .version-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .ol-popup {
        min-width: 280px !important;
        max-width: calc(100vw - 20px) !important;
        max-height: 70vh !important;
        padding: 12px;
        left: -15px;
    }
    
    .ol-popup-content-wrapper {
        max-height: calc(70vh - 60px) !important;
    }

    .mobile-chart-trigger {
        font-size: 0.75rem;
        padding: 8px 10px;
        margin: 6px 0;
    }
    
    .ol-popup h4 {
        font-size: 0.9rem;
    }
    
    .ol-popup p {
        font-size: 0.8rem;
    }
    
    .tab-btn {
        font-size: 0.7rem;
        padding: 8px 4px;
    }
    
    .chart-modal {
        padding: 16px;
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .chart-modal-content {
        height: 250px;
    }
}

/* ===== DESKTOP/MOBILE VISIBILITY CONTROLS ===== */
@media (min-width: 769px) {
    .mobile-chart-trigger {
        display: none !important;  /* ✅ HIDE MOBILE BUTTONS ON DESKTOP */
    }
    
    .chart-container {
        display: block !important;  /* ✅ SHOW DESKTOP CHARTS */
    }
    
    .chart-modal-overlay {
        display: none !important;  /* ✅ NO MODALS ON DESKTOP */
    }
}

/* ===== SCROLL BAR STYLING ===== */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

*::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 3px;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-secondary);
}

/* ===== ANIMATIONS & MICRO-INTERACTIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.fade-in {
  animation: fadeIn var(--duration-normal) ease-out;
}

.slide-up {
  animation: slideUp 0.4s ease-out;
}

.pulse {
  animation: pulse 2s infinite;
}

/* Focus visible for accessibility */
*:focus-visible {
  outline: var(--focus-outline);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --color-border: var(--color-text-secondary);
    --color-text-secondary: var(--color-text);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== UTILITY CLASSES ===== */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mb-sm { margin-bottom: var(--space-8); }
.mb-md { margin-bottom: var(--space-16); }
.mb-lg { margin-bottom: var(--space-24); }

.p-sm { padding: var(--space-8); }
.p-md { padding: var(--space-16); }
.p-lg { padding: var(--space-24); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: var(--space-4); }
.gap-8 { gap: var(--space-8); }
.gap-16 { gap: var(--space-16); }

.block { display: block; }
.hidden { display: none; }

/* ✅ FIXED: Arrow now points to clicked coordinate, not popup center */
.ol-popup::after {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 180px !important;                  /* ✅ FIXED POSITION - matches offset */
    left: -10px !important;
    transform: none !important;              /* ✅ Remove transform */
    margin-top: 0 !important;
    width: 0 !important;
    height: 0 !important;
    border-style: solid !important;
    border-width: 10px 10px 10px 0 !important;
    border-color: transparent var(--color-surface) transparent transparent !important;
    z-index: 1001 !important;
    pointer-events: none !important;
}

/* ✅ FIXED: Border arrow at same position */
.ol-popup::before {
    content: "" !important;
    display: block !important;
    position: absolute !important;
    top: 180px !important;                  /* ✅ FIXED POSITION - matches offset */
    left: -11px !important;
    transform: none !important;              /* ✅ Remove transform */
    margin-top: 0 !important;
    width: 0 !important;
    height: 0 !important;
    border-style: solid !important;
    border-width: 11px 11px 11px 0 !important;
    border-color: transparent var(--color-card-border) transparent transparent !important;
    z-index: 1000 !important;
    pointer-events: none !important;
}

/* ✅ Arrow stays at same position even when popup expands */
.ol-popup.expanded::after {
    top: 180px !important;  /* ✅ Same fixed position */
}

.ol-popup.expanded::before {
    top: 180px !important;  /* ✅ Same fixed position */
}

/* ========================================
   CARBON CREDIT QUICK ACTIONS - FIXED COLLAPSE
   ======================================== */

.carbon-quick-actions {
    margin: var(--space-12) 0;
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.quick-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-10) var(--space-16);
    border-bottom: 1px solid var(--color-border);
    background: var(--color-background);
}

.quick-actions-header h4 {
    margin: 0;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: var(--space-6);
}

.toggle-quick-actions {
    cursor: pointer;
    font-weight: var(--font-weight-bold);
    font-size: var(--font-size-xl);
    color: var(--color-text-secondary);
    background: none;
    border: none;
    padding: var(--space-4);
    border-radius: var(--radius-base);
    transition: all var(--duration-fast) var(--ease-standard);
    line-height: 1;
    min-width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-quick-actions:hover {
    color: var(--color-text);
    background: var(--color-secondary);
}

/* Collapsible grid - FIXED */
.quick-actions-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-6);
    padding: var(--space-12);
    max-height: 200px;
    opacity: 1;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
}

.quick-actions-grid.collapsed {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0;
}

/* Match your existing index-badge style exactly */
.carbon-quick-btn {
    background: var(--color-primary);
    color: var(--color-btn-primary-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: var(--font-size-xs);
    font-family: var(--font-family-mono);
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: var(--space-4);
    transition: all 0.2s ease;
    text-decoration: none;
    white-space: nowrap;
}

.carbon-quick-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
    background: var(--color-primary-hover);
}

/* ========================================
   LARGER CHAT MESSAGES AREA
   ======================================== */

.chat-messages {
    flex: 1;
    background: var(--color-surface);
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-lg);
    padding: var(--space-20);
    margin-bottom: var(--space-16);
    overflow-y: auto;
    max-height: 500px;
    min-height: 400px;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

/* ========================================
   MOBILE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .quick-actions-grid {
        gap: var(--space-4);
        padding: var(--space-10);
        max-height: 150px;
    }
    
    .carbon-quick-btn {
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .quick-actions-header {
        padding: var(--space-8) var(--space-12);
    }
    
    .quick-actions-header h4 {
        font-size: var(--font-size-xs);
    }
    
    .chat-messages {
        max-height: 350px;
        min-height: 250px;
        padding: var(--space-12);
    }
}

/* ========================================
   PRESCRIPTION STATUS CONTAINER (UNIFIED)
   ======================================== */

.prescription-status-container {
    background: var(--color-surface);
    border: 1px solid var(--color-card-border);
    border-radius: var(--radius-lg);
    padding: var(--space-20);
    margin-top: var(--space-20);
    box-shadow: var(--shadow-sm);
    transition: all var(--duration-normal) var(--ease-standard);
}

.prescription-status-container.processing {
    background: rgba(var(--color-warning-rgb), 0.05);
}

.prescription-status-container.success {
    background: rgba(var(--color-success-rgb), 0.05);
}

.prescription-status-container.error {
    background: rgba(var(--color-error-rgb), 0.05);
}

.status-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-12);
    text-align: center;
}

.status-message {
    color: var(--color-text);
    font-size: var(--font-size-base);
    line-height: var(--line-height-normal);
    margin: 0;
    animation: fadeIn 0.3s ease-in;
}

.status-message strong {
    color: var(--color-primary);
    font-weight: var(--font-weight-semibold);
}

/* Spinner for processing state */
#prescription-spinner {
    width: var(--space-32);
    height: var(--space-32);
    border: 3px solid var(--color-border);
    border-top: 3px solid var(--color-primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Mobile adjustments */
@media (max-width: 768px) {
    .prescription-status-container {
        padding: var(--space-16);
        margin-top: var(--space-16);
    }
    
    .status-message {
        font-size: var(--font-size-sm);
    }
    
    #prescription-spinner {
        width: var(--space-24);
        height: var(--space-24);
    }
}

/* Add this to your styles.css if not already present */
@keyframes loadingBar {
    0% { transform: translateX(-100%); }
    50% { transform: translateX(0); }
    100% { transform: translateX(100%); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Chat message formatting - VERIFY THESE EXIST */
.message-content ul.chat-list {
    list-style: none;
    padding-left: 0;
    margin: var(--space-12) 0;
}

.message-content ul.chat-list li {
    padding: var(--space-8) 0 var(--space-8) var(--space-20);
    margin: var(--space-6) 0;
    position: relative;
    line-height: var(--line-height-normal);
}

.message-content ul.chat-list li::before {
    content: "•";
    color: var(--color-primary);
    font-weight: bold;
    position: absolute;
    left: var(--space-6);
}

/* Index badges in chat */
.message-content .index-badge {
    background: var(--color-primary);
    color: var(--color-btn-primary-text);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
    font-size: var(--font-size-xs);
    font-family: var(--font-family-mono);
    display: inline-block;
    margin: 0 2px;
    cursor: help;
    transition: all 0.2s ease;
}

.message-content .index-badge:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-sm);
}

/* Metric values in chat */
.message-content .metric-value {
    font-family: var(--font-family-mono);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary);
}

/* Improved chat message paragraph spacing */
.message-content p {
    margin: 0 0 1em 0 !important;  /* ✅ Add space after paragraphs */
    line-height: 1.6;
}

.message-content p:last-child {
    margin-bottom: 0 !important;
}

/* Better spacing for sections with headers */
.message-content strong {
    display: inline-block;
    margin-top: 0.5em;
}

/* List spacing */
.message-content ul.chat-list {
    margin: 1em 0 !important;  /* ✅ Space around lists */
}

.message-content ul.chat-list li {
    margin: 0.5em 0;  /* ✅ Space between list items */
}

/* Badge spacing */
.message-content .index-badge {
    margin: 0 3px;  /* ✅ Space around badges */
}

/* Polygon Selector Styles */
.polygon-selector-panel {
    position: absolute;
    top: 70px;
    left: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 280px;
    max-width: 320px;
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.selector-header h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.btn-icon:hover {
    background: rgba(0, 0, 0, 0.05);
}

.polygon-dropdown {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.2s;
}

.polygon-dropdown:hover {
    border-color: #4299e1;
}

.polygon-dropdown:focus {
    outline: none;
    border-color: #3182ce;
    box-shadow: 0 0 0 3px rgba(66, 153, 225, 0.1);
}

.polygon-info {
    margin-top: 12px;
    padding: 12px;
    background: #f7fafc;
    border-radius: 6px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 13px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    color: #718096;
    font-weight: 500;
}

.info-value {
    color: #2d3748;
    font-weight: 600;
}

.polygon-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f7fafc;
    border-radius: 6px;
    margin-top: 10px;
}

.polygon-loading .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #4299e1;
}

.polygon-loading span {
    font-size: 13px;
    color: #718096;
}

/* Map Controls - Bottom Left Position */
.map-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 250px;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#polygon-select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#polygon-select:hover {
    border-color: var(--color-primary);
}

#polygon-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.polygon-info {
    font-size: 12px;
    color: var(--color-text-secondary);
    padding: 4px 0;
}

.polygon-info.has-selection {
    color: var(--color-success);
    font-weight: 500;
}

/* Map Controls */
.map-controls {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 280px;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 2px;
}

#polygon-select {
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    background: white;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

#polygon-select:hover {
    border-color: var(--color-primary);
}

#polygon-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Show green only when field is selected */
#polygon-select.has-selection {
    border-color: var(--color-success);
    border-width: 2px;
}

.polygon-info {
    font-size: 12px;
    color: var(--color-success);
    font-weight: 500;
    padding: 6px 8px;
    background: rgba(34, 197, 94, 0.1);
    border-radius: 4px;
}
