:root {
    /* Brand Color Scheme */
    --color-white: #FFFFFF;
    --color-grey: #242424;
    --color-blue: #5C7C89;
    --color-teal: #1F4959;
    --color-navy: #011425;
    /* Semantic Colors */
    --color-primary: #1F4959;
    --color-secondary: #5C7C89;
    --color-dark: #242424;
    --color-background: #f5f7fa;
}

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

body {
    font-family: 'Amazon Ember', 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    background: var(--color-background);
    min-height: 100vh;
}

/* Header - Clean Professional */
.dashboard-header {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    padding: 16px 24px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid #e2e8f0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1920px;
    margin: 0 auto;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.header-content h1 {
    color: #232f3e;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin: 0;
}

.header-info {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: #666;
}

#countdown {
    font-weight: bold;
    color: #ff9900;
}

/* Main Container */
.main-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    max-width: 1920px;
    margin: 0 auto;
    height: calc(100vh - 80px);
}

/* Map Section (Left) */
.map-section {
    flex: 1;
    background: #FAFBFC;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    border: 1px solid #e2e8f0;
}

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

.map-header h2 {
    font-size: 18px;
    color: #232f3e;
    font-weight: 600;
}

.map-legend {
    display: flex;
    gap: 16px;
    font-size: 13px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dot.green { background: #38a169; }
.dot.orange { background: #ff9900; }
.dot.red { background: #e53e3e; }

.map-container {
    flex: 1;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
}

/* Sidebar (Right) */
.sidebar {
    width: 450px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.mini-card {
    background: #FAFBFC;
    border-radius: 10px;
    padding: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #e2e8f0;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mini-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.mini-card.risk {
    border-left: 4px solid #e53e3e;
}

.mini-card-icon { font-size: 32px; }
.mini-card-value { font-size: 28px; font-weight: bold; color: #232f3e; }
.mini-card-label { font-size: 12px; color: #666; text-transform: uppercase; }

/* Sidebar Tabs */
.sidebar-tabs {
    display: flex;
    gap: 8px;
}

.sidebar-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: #FAFBFC;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.sidebar-tab:hover {
    color: #667eea;
    border-color: #667eea;
}

.sidebar-tab.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* Sidebar Content */
.sidebar-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    background: #FAFBFC;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
}

.sidebar-content.active {
    display: block;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section h3 {
    font-size: 16px;
    color: #232f3e;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}

/* Risk Summary Cards */
.risk-summary-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.risk-mini-card {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    border-left: 4px solid #3498db;
}

.risk-mini-card.da-risk { border-left-color: #e74c3c; }
.risk-mini-card.dat-risk { border-left-color: #f39c12; }
.risk-mini-card.picker-risk { border-left-color: #9b59b6; }
.risk-mini-card.multiple-risk { border-left-color: #e67e22; }

.risk-mini-label { font-size: 11px; color: #666; margin-bottom: 5px; }
.risk-mini-value { font-size: 24px; font-weight: bold; color: #2c3e50; }

.risks-table-container { max-height: 400px; overflow-y: auto; }

.daily-risks-container {
    max-height: 300px;
    overflow-y: auto;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 10px;
}

.daily-risk-item {
    background: #FAFBFC;
    border-left: 4px solid #e74c3c;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 4px;
    font-size: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.daily-risk-item.severity-high { border-left-color: #e74c3c; }
.daily-risk-item.severity-medium { border-left-color: #f39c12; }
.daily-risk-item.severity-low { border-left-color: #3498db; }

.daily-risk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.daily-risk-site { font-weight: bold; font-size: 14px; }
.daily-risk-time { color: #666; font-size: 11px; }

.daily-risk-badges { display: flex; gap: 5px; margin-bottom: 8px; }

.daily-risk-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: bold;
    color: white;
}

.daily-risk-badge.da { background: #e74c3c; }
.daily-risk-badge.dat { background: #f39c12; }
.daily-risk-badge.picker { background: #9b59b6; }

.daily-risk-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    font-size: 11px;
    color: #666;
}

/* Risks List */
.risks-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.risk-item {
    background: #fff5f5;
    border-left: 4px solid #e53e3e;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.risk-item:hover {
    background: #fed7d7;
    transform: translateX(4px);
}

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

.risk-header strong { font-size: 16px; color: #232f3e; }

.risk-badge {
    font-size: 11px;
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 4px;
    color: #666;
}

.risk-details { display: flex; gap: 6px; margin-bottom: 8px; }

.risk-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: uppercase;
}

.risk-tag.da { background: #fed7d7; color: #742a2a; }
.risk-tag.dat { background: #feebc8; color: #7c2d12; }

.risk-metrics {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #666;
}

/* Recommendations List */
.recommendations-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recommendation-item {
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    padding: 12px;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.rec-route { font-weight: 600; color: #232f3e; font-size: 14px; }

.rec-drivers {
    background: #667eea;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.rec-reason {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
    margin-bottom: 8px;
}

.rec-footer {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 11px;
}

.rec-type {
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

.rec-type.current { background: #fed7d7; color: #742a2a; }
.rec-type.future { background: #bee3f8; color: #2c5282; }
.rec-confidence { color: #666; }

/* Analysis Tab */
.analysis-filters {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filter-select {
    flex: 1;
    min-width: 100px;
    padding: 8px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    font-size: 13px;
    background: #FAFBFC;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
}

.export-btn {
    padding: 8px 16px;
    background: #38a169;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.export-btn:hover { background: #2f855a; }

.analysis-table-wrapper {
    overflow-x: auto;
    max-height: calc(100vh - 400px);
    background: #FAFBFC;
    border-radius: 8px;
}

#analysis-table,
#risk-events-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

#analysis-table thead,
#risk-events-table thead {
    position: sticky;
    top: 0;
    background: #f7fafc;
    z-index: 10;
}

#analysis-table th,
#risk-events-table th {
    padding: 12px 8px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    color: #232f3e;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
    text-transform: uppercase;
}

#analysis-table td,
#risk-events-table td {
    padding: 10px 8px;
    font-size: 12px;
    border-bottom: 1px solid #e2e8f0;
}

#analysis-table tbody tr:hover,
#risk-events-table tbody tr:hover {
    background: #f7fafc;
    cursor: pointer;
}

#analysis-table tbody tr.at-risk { background: #fff5f5; }

.status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.normal { background: #c6f6d5; color: #22543d; }
.status-badge.warning { background: #feebc8; color: #7c2d12; }
.status-badge.danger { background: #fed7d7; color: #742a2a; }

.metric-value { font-weight: 500; }
.metric-value.good { color: #38a169; }
.metric-value.warning { color: #ff9900; }
.metric-value.bad { color: #e53e3e; }

/* Loading Text */
.loading-text {
    text-align: center;
    color: #666;
    padding: 20px;
    font-size: 14px;
}

/* Custom Bubble Markers */
.custom-bubble-marker {
    background: transparent !important;
    border: none !important;
}

.bubble-marker {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.bubble-marker:hover {
    transform: scale(1.05) translateY(-2px);
}

/* Custom Leaflet Popup */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    min-width: 250px;
}

.map-popup { padding: 16px; }

.map-popup h3 {
    margin: 0 0 4px 0;
    color: #232f3e;
    font-size: 18px;
}

.map-popup-cluster {
    font-size: 12px;
    color: #666;
    margin-bottom: 12px;
}

.map-popup-metrics {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.map-popup-metric { display: flex; flex-direction: column; }

.map-popup-metric strong {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    margin-bottom: 2px;
}

.map-popup-metric span {
    font-size: 16px;
    font-weight: bold;
    color: #232f3e;
}

.map-popup-btn {
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.map-popup-btn:hover { background: #5568d3; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover { color: #000; }

#site-chart {
    margin: 20px 0;
    max-height: 400px;
}

.site-metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.metric-item {
    background: #f7fafc;
    padding: 12px;
    border-radius: 6px;
}

.metric-item-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
}

.metric-item-value {
    font-size: 20px;
    font-weight: bold;
    color: #232f3e;
}

/* Legend Box */
.legend-box {
    background: #f7fafc;
    border-radius: 8px;
    padding: 12px;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 13px;
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
}

.legend-dot.dark-green { background: #22543d; }
.legend-dot.green { background: #38a169; }
.legend-dot.yellow { background: #ecc94b; }
.legend-dot.orange { background: #ff9900; }
.legend-dot.red { background: #e53e3e; }

.legend-text { color: #4a5568; font-weight: 500; }

/* Scrollbar Styling */
.sidebar-content::-webkit-scrollbar,
.analysis-table-wrapper::-webkit-scrollbar,
#mon-table-container::-webkit-scrollbar,
#mon-reasons-list::-webkit-scrollbar {
    width: 8px;
}

.sidebar-content::-webkit-scrollbar-track,
.analysis-table-wrapper::-webkit-scrollbar-track,
#mon-table-container::-webkit-scrollbar-track,
#mon-reasons-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.sidebar-content::-webkit-scrollbar-thumb,
.analysis-table-wrapper::-webkit-scrollbar-thumb,
#mon-table-container::-webkit-scrollbar-thumb,
#mon-reasons-list::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover,
.analysis-table-wrapper::-webkit-scrollbar-thumb:hover,
#mon-table-container::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Responsive */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }
    .map-section { height: 500px; }
    .sidebar { width: 100%; }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
    }
    .summary-cards { grid-template-columns: 1fr; }
    .sidebar-tabs { flex-direction: column; }
}

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

.risk-item, .recommendation-item {
    animation: fadeIn 0.3s ease-in;
}