/* ==========================================================================
   TWIN FARMS - BANANA SPECTRAL ANALYSIS SYSTEM
   Sleek, Premium, Responsive Styling (Vanilla CSS)
   ========================================================================== */

/* DESIGN TOKENS & SYSTEM VARIABLES */
:root {
    /* Fonts */
    --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, sans-serif;

    /* Theme Colors (Default: Light Mode) */
    --bg-app: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

    /* Brand Accent Colors */
    --brand-primary: #15803d; /* Vibrant Green */
    --brand-dark: #166534;    /* Deep Forest Green */
    --brand-light: #dcfce7;   /* Light Mint Green */
    --brand-accent: #10b981;  /* Emerald Active */

    /* Index Spectrum Colors (Matches screenshots) */
    --color-precision: #1d4ed8;
    --color-optimal: #0ea5e9;
    --color-excellent: #06b6d4;
    --color-very-good: #10b981;
    --color-good: #84cc16;
    --color-fair: #eab308;
    --color-low: #f97316;
    --color-poor: #ea580c;
    --color-very-poor: #ef4444;
    --color-critical: #7f1d1d;
    --color-nodata: #94a3b8;
}

/* DARK MODE OVERRIDES */
.dark-mode {
    --bg-app: #0f172a;
    --bg-sidebar: #1e293b;
    --bg-card: #1e293b;
    --border-color: #334155;
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
    
    --brand-primary: #16a34a;
    --brand-dark: #14532d;
    --brand-light: #14532d;
}

/* RESET & BASE */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-app);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* APP LAYOUT STRUCTURE */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR STYLING */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    flex-shrink: 0;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    margin-bottom: 2rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    color: var(--brand-primary);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    line-height: 1;
    color: var(--brand-primary);
    letter-spacing: -0.5px;
}

.brand-text .sub-brand {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    flex-grow: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item:hover {
    background-color: var(--bg-app);
    color: var(--brand-primary);
}

.nav-item.active {
    background-color: var(--brand-primary);
    color: #ffffff;
    box-shadow: 0 4px 6px -1px rgba(21, 128, 61, 0.2);
}

.nav-icon {
    width: 20px;
    height: 20px;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.65rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background-color: var(--bg-app);
}

.theme-toggle svg {
    width: 16px;
    height: 16px;
}

.theme-toggle .moon-icon {
    display: none;
}

.dark-mode .theme-toggle .sun-icon {
    display: none;
}

.dark-mode .theme-toggle .moon-icon {
    display: inline-block;
}

.version-info {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* MAIN CONTENT AREA */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 1.5rem 2rem;
    overflow-y: auto;
}

/* APP HEADER STYLING */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.selector-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.selector-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '▼';
    font-size: 8px;
    color: var(--text-muted);
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
}

select {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    appearance: none;
    outline: none;
    transition: all 0.2s;
}

select:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 2px var(--brand-light);
}

.link-fincas {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: underline;
    text-underline-offset: 4px;
    transition: color 0.2s;
}

.link-fincas:hover {
    color: var(--brand-dark);
}

/* Sync status indicators */
.sync-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-app);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.online {
    background-color: var(--brand-accent);
    box-shadow: 0 0 6px var(--brand-accent);
}

/* Local Python API status badges */
.api-status {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background-color: var(--bg-app);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.api-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.api-status.connected {
    color: var(--brand-accent);
    border-color: rgba(16, 185, 129, 0.2);
}

.api-status.connected .api-status-dot {
    background-color: var(--brand-accent);
    box-shadow: 0 0 6px var(--brand-accent);
}

.api-status.disconnected {
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

.api-status.disconnected .api-status-dot {
    background-color: #ef4444;
    box-shadow: 0 0 6px #ef4444;
}

.info-icon {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-color: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-icon:hover {
    background-color: var(--border-color);
    color: var(--text-primary);
}

/* Download Button */
.btn-download {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: var(--bg-app);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 0.55rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-download:hover {
    background-color: var(--border-color);
}

.download-icon {
    width: 15px;
    height: 15px;
}

/* User Badge */
.user-badge {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.user-badge:hover {
    background-color: var(--bg-app);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid var(--brand-primary);
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-email {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* DASHBOARD GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 1.5rem;
    flex-grow: 1;
}

/* CARD COMMON STYLING */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* MAP CARD SPECIFICS */
.map-card {
    position: relative;
    padding: 0; /* Full cover for the map */
    min-height: 550px;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

.map-controls {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 999; /* Must overlay Leaflet controls */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 0.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.dark-mode .map-controls {
    background-color: rgba(30, 41, 59, 0.9);
}

.map-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: transparent;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    transition: background-color 0.2s;
    text-align: left;
}

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

.dark-mode .map-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.check-box {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    border: 1px solid var(--text-muted);
    border-radius: 3px;
    font-size: 8px;
    color: transparent;
    transition: all 0.2s;
}

.map-btn.active .check-box {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: white;
}

/* Legend Overlay */
.map-legend-overlay {
    position: absolute;
    bottom: 20px;
    left: 20px;
    z-index: 999;
    background-color: rgba(255, 255, 255, 0.9);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
    backdrop-filter: blur(4px);
    width: calc(100% - 40px);
    max-width: 350px;
}

.dark-mode .map-legend-overlay {
    background-color: rgba(30, 41, 59, 0.9);
}

.legend-header {
    font-size: 0.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.legend-gradient {
    height: 10px;
    border-radius: 3px;
    background: linear-gradient(to right, 
        var(--color-critical) 0%, 
        var(--color-very-poor) 10%, 
        var(--color-poor) 20%, 
        var(--color-low) 30%, 
        var(--color-fair) 45%, 
        var(--color-good) 60%, 
        var(--color-very-good) 75%, 
        var(--color-excellent) 85%, 
        var(--color-optimal) 95%, 
        var(--color-precision) 100%
    );
    margin-bottom: 0.25rem;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* RIGHT TABS PANEL */
.right-tabs-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tabs-header {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tab-btn {
    background-color: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 0.75rem 1rem;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

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

.tab-btn.active {
    color: var(--brand-primary);
    border-bottom-color: var(--brand-primary);
}

.tab-btn.highlight {
    color: var(--brand-accent);
}

.tab-btn.highlight.active {
    border-bottom-color: var(--brand-accent);
}

/* Pulse dot on health tab */
.pulse-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #ef4444;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.tab-content-container {
    flex-grow: 1;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    min-height: 480px;
    overflow-y: auto;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease;
}

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

/* INDEX METRIC TABLE STYLING */
.table-container {
    overflow-x: auto;
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.metrics-table th {
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border-color);
    padding: 0.5rem 0.75rem;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
}

.metrics-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

.metrics-table tbody tr:hover {
    background-color: var(--bg-app);
}

.num-col {
    text-align: right;
}

/* Legend Bullet */
.legend-bullet {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
}

/* HISTORICAL CHART & GENERAL CHART SECTION */
.chart-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-top: 1px solid var(--border-color);
    padding-top: 1.25rem;
}

.chart-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chart-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.select-wrapper.mini select {
    padding: 0.25rem 1.5rem 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.select-wrapper.mini::after {
    right: 8px;
}

.button-group.mini {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.button-group.mini button {
    border: none;
    background-color: var(--bg-app);
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
    font-family: var(--font-body);
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
}

.button-group.mini button.active {
    background-color: var(--brand-primary);
    color: white;
}

.chart-container {
    height: 220px;
    position: relative;
    width: 100%;
}

.chart-container-doughnut {
    height: 250px;
    position: relative;
    width: 100%;
    display: flex;
    justify-content: center;
}

.chart-footer-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* DEFORESTATION VIEW */
.deforestacion-info {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.alert-box {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
}

.alert-box.success {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.dark-mode .alert-box.success {
    background-color: rgba(22, 101, 52, 0.2);
    border-color: rgba(22, 101, 52, 0.4);
    color: #86efac;
}

.alert-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.alert-box h4 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.metric-cards-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.m-card {
    background-color: var(--bg-app);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.m-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.m-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.m-change {
    font-size: 0.7rem;
    font-weight: 500;
}

.m-change.positive { color: var(--brand-accent); }
.m-change.neutral { color: var(--text-muted); }

/* FOLIAR DISEASE & IA SCANNER */
.disease-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.disease-info-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.disease-info-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.disease-scanner-box {
    background-color: var(--bg-app);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    min-height: 380px;
    position: relative;
    overflow: hidden;
}

.upload-zone {
    width: 100%;
    height: 100%;
    min-height: 380px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--brand-primary);
    background-color: rgba(21, 128, 61, 0.02);
}

.file-input-hidden {
    display: none;
}

.upload-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0.75rem;
}

.upload-icon-huge {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
}

.primary-prompt {
    font-weight: 600;
    font-size: 0.95rem;
}

.secondary-prompt {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.samples-wrapper {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.samples-wrapper span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
}

.sample-chips {
    display: flex;
    gap: 0.5rem;
}

.chip {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

/* SCANNING ANIMATION STATE */
.scanning-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.85);
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

.scanner-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(to bottom, rgba(16, 185, 129, 0), rgba(16, 185, 129, 1));
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.8);
    animation: scan 2s linear infinite;
}

@keyframes scan {
    0% { top: 0%; }
    50% { top: 100%; }
    100% { top: 0%; }
}

.scanner-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--brand-accent);
    animation: spin 1s ease-in-out infinite;
}

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

/* SCANNER RESULT DASHBOARD */
.analysis-results-wrapper {
    display: flex;
    gap: 1.5rem;
    width: 100%;
    animation: fadeIn 0.4s ease;
}

.visualizer-container {
    width: 40%;
    background-color: #000;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.scanned-image {
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: contain;
}

.spots-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Warning hotspots */
.warning-spot {
    position: absolute;
    width: 24px;
    height: 24px;
    background-color: rgba(239, 68, 68, 0.4);
    border: 2px solid #ef4444;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulseSpot 1.5s infinite;
}

@keyframes pulseSpot {
    0% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(0.9); opacity: 0.5; }
}

.diagnosis-panel {
    width: 60%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    text-align: left;
}

.diagnosis-header {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.badge {
    align-self: flex-start;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.critical { background-color: #fee2e2; color: #991b1b; }
.badge.warning { background-color: #fef9c3; color: #854d0e; }
.badge.success { background-color: #dcfce7; color: #166534; }

.dark-mode .badge.critical { background-color: rgba(153, 27, 27, 0.2); color: #fca5a5; }
.dark-mode .badge.warning { background-color: rgba(133, 77, 14, 0.2); color: #fde047; }
.dark-mode .badge.success { background-color: rgba(22, 101, 52, 0.2); color: #86efac; }

.diagnosis-header h4 {
    font-size: 1.15rem;
    font-weight: 700;
}

.diagnosis-stats {
    display: flex;
    gap: 1rem;
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 0;
}

.diag-stat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.diag-stat .label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
}

.diag-stat .value {
    font-size: 0.95rem;
    font-weight: 700;
}

.diag-stat .value.accent {
    color: #ef4444;
}

.recommendations {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.recommendations h5 {
    font-size: 0.8rem;
    font-weight: 700;
}

.recommendations ul {
    list-style-type: none;
    padding-left: 0;
}

.recommendations li {
    font-size: 0.78rem;
    position: relative;
    padding-left: 1rem;
    margin-bottom: 0.35rem;
    color: var(--text-primary);
}

.recommendations li::before {
    content: "•";
    color: var(--brand-primary);
    font-weight: bold;
    font-size: 1.1rem;
    position: absolute;
    left: 0;
    top: -2px;
}

.panel-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: auto;
}

.btn-primary {
    background-color: var(--brand-primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

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

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background-color: var(--bg-app);
}

/* UTILITY CLASSES */
.hidden {
    display: none !important;
}

/* INTERACTIVE POPUPS FOR LEAFLET MAP */
.custom-leaflet-popup {
    font-family: var(--font-body);
}

.custom-leaflet-popup h4 {
    margin-bottom: 0.25rem;
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--brand-primary);
}

.custom-leaflet-popup p {
    font-size: 0.78rem;
    margin-bottom: 0.15rem;
    color: #334155;
}

.custom-leaflet-popup strong {
    font-weight: 600;
}

/* SYSTEM DETAILS MODAL STYLING */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

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

.modal-header h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--brand-primary);
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-muted);
    cursor: pointer;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-body {
    font-size: 0.85rem;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.modal-body ul {
    padding-left: 1.25rem;
}

.modal-body li {
    margin-bottom: 0.35rem;
}

/* RESPONSIVE LAYOUT BREAKPOINTS */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    .map-card {
        min-height: 450px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
    }
    .main-content {
        padding: 1rem;
    }
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .header-right {
        width: 100%;
        justify-content: space-between;
    }
    .analysis-results-wrapper {
        flex-direction: column;
    }
    .visualizer-container {
        width: 100%;
    }
    .diagnosis-panel {
        width: 100%;
    }
}
