/* ==========================================================================
   Refinamento visual Radar Previdenciário — 2026-04
   Camada reversível: preserva markup multi-page, alinha paleta TCM.
   Transforma .nav horizontal em sidebar vertical (azul-petróleo claro).
   Identidade: cor sidebar distinta de radar-saude (branca) e emenda-pix (cinza-azul).
   ========================================================================== */

:root {
    /* Paleta sóbria TCM (compartilhada com radar-saude e emenda-pix) */
    --primary: #1f3f73;
    --primary-dark: #14243d;
    --primary-light: #2f5f9f;
    --accent: #2f8a68;
    --accent-light: #49a983;
    --danger: #8f2f2b;
    --danger-light: #b9433b;
    --warning: #b87520;
    --warning-light: #d59a3a;
    --info: #2b7199;

    --text-dark: #1f2530;
    --text-secondary: #596273;
    --text-muted: #7a8494;
    --text-tertiary: #a8afbb;

    --bg-light: #f4f6f8;
    --bg-subtle: #fafbfc;
    --bg-card: #ffffff;
    --bg-hover: #f0f3f6;
    --bg-sidebar: #bfd0dc;           /* Identidade única: azul-petróleo saturado */
    --bg-sidebar-hover: #a8bfcd;

    --border: #e1e6ee;
    --border-strong: #cbd3df;
    --border-sidebar: #a3b8c6;

    --radius-sm: 5px;
    --radius-md: 7px;
    --radius-lg: 9px;
    --radius-xl: 11px;
    --radius-full: 9999px;

    --shadow-xs: 0 1px 2px rgba(20, 28, 42, 0.04);
    --shadow-sm: 0 1px 2px rgba(20, 28, 42, 0.05);
    --shadow: 0 1px 3px rgba(20, 28, 42, 0.05), 0 1px 2px rgba(20, 28, 42, 0.04);
    --shadow-md: 0 4px 8px -2px rgba(20, 28, 42, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(20, 28, 42, 0.08);

    --sidebar-width: 220px;
    --header-height: 68px;
    --transition: 0.15s ease;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    letter-spacing: 0;
    line-height: 1.55;
}

/* ============== HEADER TOP (sólido institucional) ============== */
.header {
    background: #152033 !important;
    color: #fff;
    padding: 0 !important;
    box-shadow: 0 1px 0 rgba(255,255,255,0.04), 0 12px 30px rgba(20,28,42,0.12);
    position: relative;
    height: var(--header-height);
    z-index: 1001;
}
.header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2f8a68 0%, #2f5f9f 54%, #b87520 100%);
    z-index: 2;
}
.header-content {
    max-width: none !important;
    padding: 0 1.25rem !important;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}
.header-logo img {
    background: rgba(255,255,255,0.96);
    border-radius: 7px;
    padding: 4px 9px;
    height: 40px !important;
    width: auto;
}
.header h1 {
    color: #fff !important;
    font-size: 1rem !important;
    font-weight: 600 !important;
    letter-spacing: 0 !important;
    line-height: 1.15;
    margin: 0;
}
.header-subtitle {
    color: rgba(255,255,255,0.72) !important;
    font-size: 0.72rem !important;
    font-weight: 400;
    margin-top: 0.05rem;
}
.header-sync-info {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.9);
    border-radius: 8px;
    padding: 0.35rem 0.75rem;
    font-size: 0.72rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.header-sync-info.stale {
    background: rgba(184, 117, 32, 0.2);
    border-color: rgba(213, 154, 58, 0.55);
    color: #ffe1a3;
}

.coverage-note {
    margin-bottom: 1.25rem;
    padding: 0.8rem 1rem;
    border: 1px solid #cbd8e5;
    border-left: 4px solid var(--info);
    border-radius: var(--radius-md);
    background: #f7fafc;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.coverage-note strong { color: var(--text-dark); }

/* ============== SIDEBAR (de .nav horizontal → vertical fixa) ============== */
.nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--header-height));
    background: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-sidebar);
    border-bottom: none !important;
    box-shadow: none !important;
    padding: 1rem 0.5rem;
    overflow-y: auto;
    z-index: 1000;
}
.nav ul {
    display: flex !important;
    flex-direction: column;
    padding: 0 !important;
    margin: 0;
    list-style: none;
    gap: 0.15rem;
    max-width: none;
}
.nav li {
    list-style: none;
    width: 100%;
}
.nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    padding: 0.65rem 0.9rem !important;
    border-bottom: none !important;
    border-left: 3px solid transparent;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 500 !important;
    color: var(--text-secondary) !important;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.nav a svg {
    width: 17px;
    height: 17px;
    opacity: 0.75;
    flex-shrink: 0;
}
.nav a:hover {
    background: var(--bg-sidebar-hover);
    color: var(--primary) !important;
    transform: none;
}
.nav a:hover svg { opacity: 1; }
.nav a.active {
    background: #fff;
    color: var(--primary) !important;
    font-weight: 600 !important;
    border-bottom: none !important;
    border-left-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.nav a.active svg { opacity: 1; color: var(--primary); }

/* ============== MAIN CONTENT (deslocado para a direita) ============== */
main,
.container,
.page-content,
body > section,
body > div.container {
    margin-left: var(--sidebar-width);
    max-width: none !important;
}

/* Se o conteúdo estiver direto sob .header/nav (sem wrapper), aplicar também via seletor genérico */
body > *:not(.header):not(.nav):not(script):not(style):not(footer) {
    margin-left: var(--sidebar-width);
}

/* ============== CARDS / SECTIONS ============== */
.card,
.stat-card,
.kpi-card,
.chart-container,
.section-panel,
.card-section,
.summary-card,
.metric-card,
.data-card {
    background: var(--bg-card) !important;
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
    padding: 1rem 1.15rem !important;
    transition: box-shadow var(--transition) !important;
}
.card:hover,
.stat-card:hover,
.kpi-card:hover,
.chart-container:hover,
.section-panel:hover,
.card-section:hover,
.summary-card:hover,
.metric-card:hover,
.data-card:hover {
    box-shadow: var(--shadow-md) !important;
    transform: none !important;
}

.card-title,
.chart-title,
.stat-label,
.kpi-label,
.section-panel-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.4px;
    text-transform: uppercase;
}
.stat-value,
.kpi-value,
.metric-value {
    color: var(--text-dark);
    letter-spacing: -0.02em;
    font-weight: 700;
}

/* ============== FORMULÁRIOS ============== */
input, select, textarea {
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-strong) !important;
    padding: 0.55rem 0.8rem !important;
    font-size: 0.88rem !important;
    background: #fff !important;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: inherit;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 3px rgba(47, 138, 104, 0.14) !important;
    outline: none !important;
}

/* ============== BOTÕES ============== */
.btn {
    border-radius: var(--radius-md) !important;
    font-weight: 500 !important;
    padding: 0.55rem 1rem !important;
    font-size: 0.88rem !important;
    transition: background var(--transition), box-shadow var(--transition) !important;
    box-shadow: none !important;
}
.btn-primary {
    background: var(--primary) !important;
    color: #fff !important;
    border: 1px solid var(--primary) !important;
}
.btn-primary:hover:not(:disabled) {
    background: var(--primary-light) !important;
    transform: none !important;
    box-shadow: var(--shadow-md) !important;
}
.btn-secondary {
    background: var(--bg-light);
    color: var(--text-secondary);
    border: 1px solid var(--border-strong);
}
.btn-secondary:hover {
    background: var(--bg-sidebar-hover);
    transform: none !important;
}

/* ============== TABELAS ============== */
table {
    border-radius: var(--radius-lg);
    overflow: hidden;
    border-collapse: collapse;
    width: 100%;
}
table thead th {
    background: var(--bg-sidebar) !important;
    color: var(--text-dark) !important;
    font-weight: 600 !important;
    font-size: 0.78rem !important;
    letter-spacing: 0.3px !important;
    text-transform: uppercase !important;
    border-bottom: 1px solid var(--border-strong);
    padding: 0.65rem 0.85rem;
    text-align: left;
}
table tbody td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
}
table tbody tr:hover {
    background: var(--bg-sidebar-hover);
}

/* ============== FOOTER ============== */
footer {
    margin-left: var(--sidebar-width);
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.78rem;
}

/* ============== RESPONSIVO ============== */
@media (max-width: 900px) {
    :root { --sidebar-width: 190px; }
}
@media (max-width: 768px) {
    .nav {
        position: static;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-sidebar);
        padding: 0.5rem;
    }
    .nav ul {
        flex-direction: row !important;
        overflow-x: auto;
        gap: 0.25rem;
        flex-wrap: nowrap;
    }
    .nav a {
        flex-shrink: 0;
        border-left: none !important;
        border-bottom: 3px solid transparent !important;
        border-radius: 7px 7px 0 0;
        padding: 0.55rem 0.75rem !important;
    }
    .nav a.active {
        border-left: none !important;
        border-bottom-color: var(--primary) !important;
    }
    main,
    .container,
    footer,
    body > *:not(.header):not(.nav):not(script):not(style) {
        margin-left: 0;
    }
    .header h1 { font-size: 0.9rem !important; }
    .header-subtitle { display: none !important; }
}

@media (max-width: 768px) {
    html,
    body {
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    .header {
        height: auto;
        min-height: var(--header-height);
    }

    .header-content {
        min-width: 0;
        padding: 0.7rem 1rem !important;
        flex-wrap: wrap;
        gap: 0.6rem;
    }

    .header-brand { min-width: 0; }
    .header-logo img { max-width: 45vw; }
    .header-actions { width: 100%; justify-content: flex-start; }

    .nav {
        position: static;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
    }

    .nav ul { justify-content: flex-start !important; }

    main,
    .container,
    .page-content,
    footer,
    body > section,
    body > div.container,
    body > *:not(.header):not(.nav):not(script):not(style) {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: 0 !important;
    }

    .container,
    .page-content { padding: 1rem !important; }

    .data-info {
        align-items: flex-start;
        flex-direction: column;
    }

    .data-info > span { margin-left: 0 !important; }
    .stats-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .charts-row { grid-template-columns: minmax(0, 1fr) !important; }
    .chart-container,
    .stat-card,
    .table-container { min-width: 0; max-width: 100%; }

    .table-container {
        overflow-x: auto !important;
        overflow-y: hidden !important;
    }

    .table-container table { min-width: 720px; }
    .footer-content { padding: 1rem; }
}

/* ============== TOOLTIPS / BADGES (se existirem) ============== */
.badge,
.chip,
.tag {
    border-radius: var(--radius-full);
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 600;
}
