:root {
    /* --- Palette --- */
    /* Deep Blue / Slate Theme */
    --primary: #0f172a;
    --primary-light: #1e293b;
    --secondary: #64748b;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --surface: #ffffff;

    /* --- Shadows (Premium Depth) --- */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* --- Transitions --- */
    --transition-base: all 0.2s ease-in-out;
}

body {
    background-color: var(--bg);
    font-family: 'Inter', sans-serif;
    color: var(--primary);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.025em; /* Tighter headings for modern look */
}

/* --- Unified Header Section --- */
.analytics-header {
    background: rgba(255, 255, 255, 0.85); /* Semi-transparent */
    backdrop-filter: blur(12px); /* Glassmorphism */
    -webkit-backdrop-filter: blur(12px);
    padding: 20px 0;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    margin-bottom: 30px;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: var(--transition-base);
}

.header-title {
    color: var(--primary);
    font-weight: 800;
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-link {
    color: var(--secondary);
    font-weight: 500;
    text-decoration: none;
    margin-right: 24px;
    font-size: 0.95rem;
    transition: var(--transition-base);
    position: relative;
}

.nav-link:hover {
    color: var(--accent);
}

.nav-link.active {
    color: var(--accent);
    font-weight: 700;
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent);
    border-radius: 2px;
}

/* --- Cards --- */
.card, .chart-card, .kpi-card {
    background: var(--surface);
    border: 1px solid rgba(226, 232, 240, 0.6);
    border-radius: 16px; /* Softer corners */
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition-base);
}

.card:hover, .chart-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px); /* Subtle lift */
    border-color: rgba(59, 130, 246, 0.2);
}

.card-header-custom {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface);
}

.card-title-text, .chart-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

/* --- KPI Cards (Analytics) --- */
.kpi-card {
    padding: 24px;
    height: 100%;
    border-left: 4px solid var(--accent);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.kpi-label {
    font-size: 0.8rem;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 2.25rem;
    font-weight: 800;
    color: var(--primary);
    line-height: 1.1;
}

/* --- Chart Containers --- */
.chart-card {
    padding: 28px;
    position: relative;
}

.click-hint {
    position: absolute;
    top: 28px;
    right: 28px;
    font-size: 0.7rem;
    color: var(--secondary);
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 20px;
    pointer-events: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- Map Styling --- */
#map {
    height: 600px; /* Slightly taller */
    width: 100%;
    z-index: 1;
}

/* --- Table Styling --- */
.table-container {
    padding: 0;
}

table.dataTable {
    margin-top: 0 !important;
    border-collapse: separate;
    border-spacing: 0;
    width: 100% !important;
}

table.dataTable thead th {
    background-color: #f8fafc;
    color: var(--secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 16px 16px;
    border-bottom: 1px solid #e2e8f0;
}

table.dataTable tbody td {
    padding: 16px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.9rem;
    color: #334155;
    white-space: nowrap;
}

table.dataTable tbody tr:hover {
    background-color: #f8fafc;
}

/* Table Filter Footers */
table.dataTable tfoot th {
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
}

tfoot select {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.85rem;
    background-color: #fff;
    color: #475569;
    transition: var(--transition-base);
}

tfoot select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* --- Map Filter Toggle --- */
.map-filter-wrapper {
    background-color: #f1f5f9;
    padding: 8px 16px;
    border-radius: 50px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    transition: var(--transition-base);
}

.map-filter-wrapper:hover {
    border-color: #cbd5e1;
}

.form-check-input:checked {
    background-color: var(--accent);
    border-color: var(--accent);
}

.toggle-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #475569;
    margin-left: 10px;
    cursor: pointer;
}

/* --- Popup Styling --- */
.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: var(--shadow-xl);
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.05);
}

.leaflet-popup-content {
    margin: 0;
    width: 280px !important;
}

.popup-header {
    background: #f8fafc;
    padding: 16px;
    border-bottom: 1px solid #e2e8f0;
}

.popup-header h6 {
    margin: 0;
    color: var(--primary);
    font-weight: 700;
    font-size: 1rem;
}

.popup-body {
    padding: 16px;
    font-size: 0.9rem;
    color: #475569;
}

.popup-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.popup-label {
    color: #94a3b8;
    font-weight: 500;
    margin-right: 12px;
}

.popup-val {
    text-align: right;
    font-weight: 600;
    color: var(--primary);
}

.contact-box {
    background: #eff6ff;
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    font-size: 0.85rem;
    border: 1px solid #dbeafe;
}

/* --- Modals --- */
.modal-content {
    border: none;
    border-radius: 20px;
    box-shadow: var(--shadow-2xl);
}

.modal-header {
    border-bottom: 1px solid #f1f5f9;
    padding: 24px 32px;
    background: #fff;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.modal-body {
    padding: 32px;
    background-color: #fff;
}

.modal-footer {
    border-top: 1px solid #f1f5f9;
    padding: 20px 32px;
    background-color: #f8fafc;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
}

/* --- Footer --- */
.app-footer {
    margin-top: auto;
    padding: 60px 0 30px 0;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    font-weight: 400;
}

/* Contact Popover Trigger */
.contact-trigger {
    cursor: pointer;
    color: var(--accent);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 4px;
    transition: color 0.2s ease;
}

.contact-trigger:hover {
    color: var(--accent-hover);
}
