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

:root {
    --primary: #1e3a5f;
    --primary-dark: #0d2137;
    --primary-light: #2c5282;
    --accent: #38a169;
    --accent-light: #48bb78;
    --danger: #c53030;
    --danger-light: #fc8181;
    --warning: #d69e2e;
    --text-dark: #1a202c;
    --text-muted: #718096;
    --bg-light: #f7fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    font-size: 14px;
}

/* Header Institucional */
.header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    color: white;
    padding: 0;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent) 0%, var(--warning) 50%, var(--danger) 100%);
}

.header-content {
    max-width: 100%;
    margin: 0 auto;
    padding: 1.25rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo img {
    height: 64px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.header-subtitle {
    opacity: 0.85;
    font-size: 0.85rem;
    font-weight: 400;
    margin-top: 0.15rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.header-actions select {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    cursor: pointer;
    font-size: 0.875rem;
    min-width: 140px;
}

.header-actions select option {
    background: var(--primary-dark);
    color: white;
}

.btn-sync {
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-sync:hover {
    background: var(--accent-light);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(56, 161, 105, 0.4);
}

.header-sync-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.9);
}

.header-sync-info svg {
    opacity: 0.7;
}

.header-nav {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-nav a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.header-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.header-nav a.active {
    background: rgba(255,255,255,0.15);
    color: white;
    border-bottom-color: var(--accent);
}

/* Navigation */
.nav {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.nav ul {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    list-style: none;
    padding: 0 3rem;
}

.nav a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
}

.nav a:hover {
    color: var(--primary);
    background: var(--bg-light);
}

.nav a.active {
    color: var(--primary);
    border-bottom-color: var(--accent);
    background: linear-gradient(180deg, transparent 0%, rgba(56, 161, 105, 0.05) 100%);
}

/* Container */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 1.5rem 3rem;
}

/* Alertas Banner */
.alertas-banner {
    background: linear-gradient(135deg, #fffaf0 0%, #fef3c7 100%);
    border: 1px solid var(--warning);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
}

.alerta-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alertas-banner span {
    font-size: 0.9rem;
    color: #744210;
}

.alerta-link {
    margin-left: auto;
    color: #975a16;
    font-weight: 600;
    text-decoration: none;
    font-size: 0.875rem;
    white-space: nowrap;
}

.alerta-link:hover {
    text-decoration: underline;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-card.highlight {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
    border: none;
}

.stat-card.highlight::before {
    background: var(--accent);
}

.stat-card.danger {
    border-color: var(--danger-light);
}

.stat-card.danger::before {
    background: var(--danger);
}

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.stat-icon {
    font-size: 1.5rem;
    opacity: 0.9;
}

.stat-trend {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    background: rgba(56, 161, 105, 0.1);
    color: var(--accent);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 500;
}

/* Charts */
.charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

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

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
}

.chart-actions {
    display: flex;
    gap: 0.5rem;
}

.chart-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--bg-light);
    border-radius: 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
}

.chart-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chart-wrapper {
    height: 280px;
    position: relative;
}

/* Table */
.table-container {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
}

.table-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.table-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
}

.table-actions {
    display: flex;
    gap: 0.5rem;
}

.table-search {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
    width: 200px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 0.875rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--bg-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

.loading {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem;
    font-size: 0.9rem;
}

.valor {
    font-weight: 600;
    color: var(--text-dark);
    font-family: 'Consolas', 'Monaco', monospace;
}

.valor.risco {
    color: var(--danger);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge.risco {
    background: #fff5f5;
    color: var(--danger);
    border: 1px solid #fed7d7;
}

.badge.ok {
    background: #f0fff4;
    color: var(--accent);
    border: 1px solid #c6f6d5;
}

/* Municipio Column */
.municipio-col {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.municipio-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.8rem;
}

.municipio-name {
    font-weight: 600;
    color: var(--text-dark);
}

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

/* Footer */
.footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.7);
    padding: 1.5rem 3rem;
    margin-top: 2rem;
}

.footer-content {
    max-width: 100%;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-logo {
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer p {
    font-size: 0.8rem;
    margin: 0;
}

.footer-links {
    display: flex;
    gap: 1.5rem;
}

.footer-links a {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.8rem;
}

.footer-links a:hover {
    color: white;
}

/* Data Info */
.data-info {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.data-info strong {
    color: var(--text-dark);
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .nav ul {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav a {
        padding: 0.75rem 1rem;
    }

    .footer-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    th, td {
        padding: 0.75rem 1rem;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}
