:root {
    --bg: #f8fafc;
    --panel: #ffffff;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #0284c7;
    --primary-600: #0369a1;
    --border: #e2e8f0;
    --danger: #ef4444;
    --sidebar-width: 300px;
    --header-height: 60px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg);
    /* Reverted to original var(--bg) */
    color: var(--text);
    /* Reverted to original var(--text) */
    margin: 0;
    line-height: 1.5;
    height: 100vh;
    /* Kept from original */
    display: flex;
    /* Kept from original */
    overflow: hidden;
    position: relative;
}

body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('img/watermark.png');
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    opacity: 0.1;
    /* High transparency */
    z-index: -1;
    pointer-events: none;
}

/* Sidebar Styles */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
    margin: 0;
}

.producer-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.municipality-group {
    margin-bottom: 16px;
}

.municipality-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-left: 8px;
}

.producer-item {
    padding: 10px 12px;
    margin-bottom: 4px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 15px;
}

.producer-item:hover {
    background: #f1f5f9;
}

.producer-item.active {
    background: var(--primary);
    color: white;
}

/* Main Content Styles */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    gap: 20px;
}

.time-periods {
    display: flex;
    gap: 12px;
    margin-bottom: 8px;
}

.period-btn {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}

.period-btn:hover {
    background: #f1f5f9;
    border-color: var(--primary);
}

.period-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Cards & Components */
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

h1 {
    margin: 0 0 16px;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: .3px;
}

/* Hidden inputs but kept in DOM for logic compatibility if needed, or we can use hidden utils */
.hidden-controls {
    display: none !important;
}

.map-wrap {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    height: calc(100vh - 100px);
}

#map {
    width: 100%;
    height: 100%;
}

.datatable-container {
    overflow-x: auto;
}

/* Table Styles Override for Light Theme */
table.dataTable tbody tr {
    background-color: transparent !important;
}

table.dataTable thead th {
    color: var(--text) !important;
}

.footer-note {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Legend */
details>summary {
    cursor: pointer;
    color: var(--primary);
}

details>ul {
    margin-bottom: 0;
}

/* Chart Styles */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.chart-header h3 {
    margin: 0;
    font-size: 18px;
}

.chart-controls {
    display: flex;
    gap: 8px;
}

.chart-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.chart-btn:hover {
    border-color: var(--primary);
    background: #f1f5f9;
}

.chart-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .main-content {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .chart-controls {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 4px;
    }
}

.hidden {
    display: none !important;
}