/* ===== RESET & BASE ===== */
*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; overflow:hidden; font-family:'Inter',system-ui,sans-serif; background:#f0f2f5; color:#1e293b; font-size:13px; }

/* ===== LAYOUT ===== */
body { display:flex; }

/* ===== SIDEBAR ===== */
.sidebar {
    width:230px; min-width:230px; height:100vh;
    background:linear-gradient(180deg,#0f2b4c 0%,#163a64 100%);
    display:flex; flex-direction:column;
    transition:width .25s ease, min-width .25s ease;
    z-index:100; position:relative;
}
.sidebar.collapsed { width:62px; min-width:62px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .sidebar-footer .nav-label { display:none; }
.sidebar.collapsed .sidebar-header { justify-content:center; }

.sidebar-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:16px 14px; border-bottom:1px solid rgba(255,255,255,.08);
}
.sidebar-logo { display:flex; align-items:center; gap:10px; color:#fff; }
.sidebar-logo .material-icons-round { font-size:28px; color:#60a5fa; }
.sidebar-title { font-weight:700; font-size:16px; letter-spacing:.5px; }
.btn-toggle-sidebar {
    background:none; border:none; color:rgba(255,255,255,.6);
    cursor:pointer; font-size:20px; display:flex;
}
.btn-toggle-sidebar:hover { color:#fff; }

.sidebar-nav { list-style:none; flex:1; padding:12px 8px; overflow-y:auto; }
.nav-item {
    display:flex; align-items:center; gap:12px;
    padding:10px 12px; border-radius:8px; cursor:pointer;
    color:rgba(255,255,255,.65); transition:all .15s ease; margin-bottom:2px;
    white-space:nowrap;
}
.nav-item:hover { background:rgba(255,255,255,.07); color:#fff; }
.nav-item.active { background:rgba(96,165,250,.18); color:#60a5fa; font-weight:600; }
.nav-item .material-icons-round { font-size:20px; }
.nav-label { font-size:13px; }

.sidebar-footer {
    padding:14px; border-top:1px solid rgba(255,255,255,.08);
    display:flex; align-items:center; gap:10px;
    color:rgba(255,255,255,.45); font-size:11px;
}
.sidebar-footer .material-icons-round { font-size:16px; }

/* ===== MAIN CONTENT ===== */
.main-content {
    flex:1; height:100vh; display:flex; flex-direction:column;
    overflow:hidden;
}

/* ===== TOP HEADER ===== */
.top-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 24px; background:#fff;
    border-bottom:1px solid #e2e8f0; min-height:62px; flex-shrink:0;
}
.header-title { font-size:15px; font-weight:700; color:#0f2b4c; }
.header-subtitle { font-size:11px; color:#64748b; margin-top:2px; }
.header-filters { display:flex; gap:12px; align-items:flex-end; }
.filter-group { display:flex; flex-direction:column; gap:2px; }
.filter-group label { font-size:10px; font-weight:600; color:#94a3b8; text-transform:uppercase; letter-spacing:.5px; }
.filter-group select {
    padding:5px 10px; border:1px solid #cbd5e1; border-radius:6px;
    font-size:12px; font-family:inherit; background:#fff; color:#1e293b;
    cursor:pointer; min-width:130px; outline:none;
}
.filter-group select:focus { border-color:#3b82f6; box-shadow:0 0 0 2px rgba(59,130,246,.15); }

/* ===== PAGES ===== */
.page { display:none; flex:1; overflow-y:auto; padding:16px 24px 24px; }
.page.active { display:block; }

.section-header { margin-bottom:14px; }
.section-header h2 { font-size:16px; font-weight:700; color:#0f2b4c; }
.section-header p { font-size:12px; color:#64748b; margin-top:2px; }

/* ===== KPI STRIP ===== */
.kpi-strip {
    display:grid;
    grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));
    gap:12px; margin-bottom:16px;
}
.kpi-card {
    background:#fff; border-radius:10px; padding:14px 16px;
    box-shadow:0 1px 3px rgba(0,0,0,.06);
    border-left:4px solid #3b82f6;
    display:flex; flex-direction:column; gap:4px;
}
.kpi-card.green { border-left-color:#22c55e; }
.kpi-card.red { border-left-color:#ef4444; }
.kpi-card.amber { border-left-color:#f59e0b; }
.kpi-card.purple { border-left-color:#8b5cf6; }
.kpi-label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:#94a3b8; }
.kpi-value { font-size:22px; font-weight:800; color:#0f2b4c; }
.kpi-sub { font-size:10px; color:#64748b; }

/* ===== CARDS & CHARTS ===== */
.card { background:#fff; border-radius:10px; padding:16px; box-shadow:0 1px 3px rgba(0,0,0,.06); }
.card-title { font-size:13px; font-weight:700; color:#0f2b4c; margin-bottom:10px; }
.chart-wrapper { position:relative; height:220px; }
.chart-wrapper-lg { position:relative; height:380px; }
.grid-2col { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.full-chart { width:100%; }

/* ===== HABILIDADES GRID ===== */
.hab-legenda {
    display:flex; flex-wrap:wrap; gap:12px 20px; margin-top:12px;
    padding:10px 14px; background:#fff; border-radius:8px; box-shadow:0 1px 3px rgba(0,0,0,.06);
}
.hab-legenda-item { display:flex; align-items:center; gap:6px; font-size:12px; color:#475569; font-weight:500; }
.hab-legenda-cor { width:14px; height:14px; border-radius:4px; flex-shrink:0; }
.hab-grid {
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(120px, 1fr));
    gap:8px;
}
.hab-card {
    border-radius:10px; padding:12px 10px; cursor:pointer;
    transition:transform .15s, box-shadow .15s;
    display:flex; flex-direction:column; align-items:center; justify-content:center; gap:4px;
    border:none;
}
.hab-card:hover { transform:translateY(-3px); box-shadow:0 8px 24px rgba(0,0,0,.18); }
.hab-card .hab-code { font-size:12px; font-weight:700; text-align:center; }
.hab-card .hab-pct { font-size:22px; font-weight:800; text-shadow:0 1px 2px rgba(255,255,255,.5); }
.hab-card .hab-faixa { font-size:10px; font-weight:700; text-transform:uppercase; letter-spacing:.5px; opacity:.85; }

/* Faixas de cor */
.faixa-critico   { background:linear-gradient(135deg,#fca5a5,#f87171); color:#1e293b; }
.faixa-atencao   { background:linear-gradient(135deg,#fdba74,#fb923c); color:#1e293b; }
.faixa-intermediario { background:linear-gradient(135deg,#fde68a,#fcd34d); color:#1e293b; }
.faixa-adequado  { background:linear-gradient(135deg,#86efac,#4ade80); color:#1e293b; }

/* ===== MODAL ===== */
.modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,.45);
    display:flex; align-items:center; justify-content:center; z-index:500;
}
.modal-overlay.hidden { display:none; }
.modal-box {
    background:#fff; border-radius:14px; padding:28px 32px;
    max-width:520px; width:90%; position:relative;
    box-shadow:0 20px 60px rgba(0,0,0,.2);
}
.modal-close {
    position:absolute; top:12px; right:16px;
    background:none; border:none; font-size:24px; cursor:pointer;
    color:#94a3b8;
}
.modal-close:hover { color:#1e293b; }
#modal-title { font-size:16px; font-weight:700; color:#0f2b4c; margin-bottom:8px; }
#modal-desc { font-size:13px; color:#475569; line-height:1.5; margin-bottom:14px; }
#modal-details { font-size:12px; color:#64748b; line-height:1.6; }
#modal-details .detail-row { display:flex; justify-content:space-between; padding:4px 0; border-bottom:1px solid #f1f5f9; }
#modal-details .detail-label { font-weight:600; color:#334155; }

/* ===== INSIGHTS ===== */
.insights-list { display:flex; flex-direction:column; gap:10px; }
.insight-card {
    background:#fff; border-radius:10px; padding:16px 20px;
    box-shadow:0 1px 3px rgba(0,0,0,.06);
    display:flex; align-items:flex-start; gap:14px;
    border-left:4px solid #3b82f6;
}
.insight-card .insight-icon { font-size:22px; color:#3b82f6; flex-shrink:0; margin-top:1px; }
.insight-card .insight-text { font-size:13px; color:#334155; line-height:1.55; }

/* ===== TABLE ===== */
.table-wrapper { overflow:auto; max-height:calc(100vh - 180px); border-radius:10px; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.06); }
#tabela-detalhe { width:100%; border-collapse:collapse; font-size:12px; }
#tabela-detalhe thead { position:sticky; top:0; z-index:2; }
#tabela-detalhe th {
    background:#0f2b4c; color:#fff; font-weight:600; text-align:left;
    padding:10px 12px; white-space:nowrap;
}
#tabela-detalhe td { padding:8px 12px; border-bottom:1px solid #f1f5f9; }
#tabela-detalhe tbody tr:hover { background:#f8fafc; }
.badge {
    display:inline-block; padding:2px 8px; border-radius:10px;
    font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.3px;
}
.badge-critico { background:#fee2e2; color:#991b1b; }
.badge-atencao { background:#fef3c7; color:#92400e; }
.badge-intermediario { background:#fef9c3; color:#854d0e; }
.badge-adequado { background:#dcfce7; color:#166534; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:#cbd5e1; border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:#94a3b8; }

/* ===== RESPONSIVE ===== */
@media (max-width:1200px) {
    .grid-2col { grid-template-columns:1fr; }
    .header-filters { flex-wrap:wrap; }
}
@media (max-width:900px) {
    .sidebar { width:62px; min-width:62px; }
    .sidebar .nav-label, .sidebar .sidebar-title, .sidebar .sidebar-footer .nav-label { display:none; }
    .top-header { flex-direction:column; align-items:flex-start; gap:8px; }
}

/* ===== LOADING ===== */
.loading-spinner {
    display:flex; align-items:center; justify-content:center;
    padding:40px; color:#94a3b8; font-size:13px; gap:8px;
}
.loading-spinner::before {
    content:''; width:18px; height:18px; border:2px solid #e2e8f0;
    border-top-color:#3b82f6; border-radius:50%;
    animation:spin .6s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }
