/* ===== 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:#F3F6FB; color:#17324D; font-size:13px; }

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

/* ===== SIDEBAR ===== */
.sidebar {
    width:230px; min-width:230px; height:100vh;
    background:linear-gradient(180deg,#173A5E 0%,#24507A 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:#7DD3FC; }
.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(59,130,246,.34); color:#FFFFFF; font-weight:600; box-shadow:inset 0 0 0 1px rgba(125,211,252,.28); }
.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;
}
.data-status { padding:8px 24px; background:#EEF4FF; color:#34506B; font-size:11px; line-height:1.5; flex-shrink:0; }
.data-status.error { background:#FEE2E2; color:#B91C1C; }
.comparison-note { color:#667A90; font-size:11px; margin:0 0 12px; line-height:1.5; }

/* ===== TOP HEADER ===== */
.top-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:12px 24px; background:#fff;
    border-bottom:1px solid #D6E0EE; min-height:62px; flex-shrink:0;
}
.header-title { font-size:15px; font-weight:700; color:#17324D; }
.header-subtitle { font-size:11px; color:#667A90; 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:#667A90; text-transform:uppercase; letter-spacing:.5px; }
.filter-group select {
    padding:5px 10px; border:1px solid #D6E0EE; border-radius:6px;
    font-size:12px; font-family:inherit; background:#fff; color:#17324D;
    cursor:pointer; min-width:130px; outline:none;
}
.filter-group select:focus { border-color:#3B82F6; box-shadow:0 0 0 2px rgba(59,130,246,.18); }

/* ===== 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:#17324D; }
.section-header p { font-size:12px; color:#667A90; 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:#6366F1; }
.kpi-label { font-size:10px; font-weight:600; text-transform:uppercase; letter-spacing:.5px; color:#667A90; }
.kpi-value { font-size:22px; font-weight:800; color:#17324D; }
.kpi-sub { font-size:10px; color:#667A90; }

/* ===== 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:#17324D; margin-bottom:10px; }
.chart-wrapper { position:relative; height:220px; }
.chart-card { min-width:0; overflow-x:auto; }
.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:#667A90; font-weight:500; }
.hab-legenda-cor { width:14px; height:14px; border-radius:4px; flex-shrink:0; }
.hab-layout {
    display:grid;
    grid-template-columns:minmax(0, 1fr) 390px;
    gap:16px;
    align-items:start;
}
.hab-grid-wrap { min-width: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.active { outline:3px solid rgba(59,130,246,.24); box-shadow:0 10px 24px rgba(59,130,246,.22); transform:translateY(-2px); }
.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; }
.hab-detail-panel {
    background:#fff;
    border-radius:10px;
    padding:18px 20px 18px;
    box-shadow:0 1px 3px rgba(0,0,0,.06);
    position:sticky;
    top:16px;
    max-height:calc(100vh - 120px);
    overflow:auto;
}
.hab-detail-empty {
    color:#667A90;
    font-size:13px;
    line-height:1.6;
}
.hab-detail-content.hidden { display:none; }
.hab-detail-top {
    display:grid;
    grid-template-columns:minmax(0, 1fr) 120px;
    gap:14px;
    align-items:start;
    margin-bottom:14px;
}
.hab-detail-mini { min-width:0; }
.hab-detail-meta-grid {
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px 16px;
}
.hab-detail-section { margin-bottom:0; min-width:0; }
.hab-detail-section-desc {
    margin-bottom:14px;
    padding:12px 14px;
    background:#EEF4FF;
    border-radius:8px;
}
.hab-detail-section-span { grid-column:1 / -1; }
.hab-detail-label {
    font-size:10px;
    font-weight:800;
    color:#17324D;
    text-transform:none;
    margin-bottom:3px;
}
.hab-detail-value {
    font-size:13px;
    color:#34506B;
    line-height:1.4;
}
.hab-detail-highlight {
    font-size:19px;
    font-weight:800;
    color:#17324D;
    letter-spacing:.5px;
}
.hab-detail-text {
    font-size:13px;
    color:#34506B;
    line-height:1.45;
}

/* Faixas de cor */
.faixa-critico   { background:linear-gradient(135deg,#FCA5A5,#EF4444); color:#17324D; }
.faixa-atencao   { background:linear-gradient(135deg,#FCD34D,#F59E0B); color:#17324D; }
.faixa-adequado  { background:linear-gradient(135deg,#86EFAC,#22C55E); color:#17324D; }

/* ===== 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:#667A90;
}
.modal-close:hover { color:#17324D; }
#modal-title { font-size:16px; font-weight:700; color:#17324D; margin-bottom:8px; }
#modal-desc { font-size:13px; color:#667A90; line-height:1.5; margin-bottom:14px; }
#modal-details { font-size:12px; color:#667A90; 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 #6366F1;
}
.insight-card .insight-icon { font-size:22px; color:#3B82F6; flex-shrink:0; margin-top:1px; }
.insight-card .insight-text { font-size:13px; color:#4E647B; 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:#17324D; 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:#EEF4FF; }
.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:#B91C1C; }
.badge-atencao { background:#FEF3C7; color:#B45309; }
.badge-adequado { background:#DCFCE7; color:#15803D; }

/* ===== RELATÓRIOS ===== */
.report-toolbar {
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    gap:16px;
    margin-bottom:14px;
}
.report-toolbar-main {
    display:flex;
    flex-direction:column;
    gap:12px;
    min-width:0;
    flex:1;
}
.report-summary {
    font-size:13px;
    color:#34506B;
    line-height:1.45;
}
.report-subfilters {
    display:flex;
    gap:12px;
    flex-wrap:wrap;
}
.report-filter-group {
    min-width:210px;
}
.report-filter-group select {
    width:100%;
    background:#F8FBFF;
    border-color:#D6E0EE;
}
.report-actions {
    display:flex;
    justify-content:flex-end;
    align-items:center;
    gap:10px;
    flex-shrink:0;
}
.btn-primary {
    display:inline-flex;
    align-items:center;
    gap:8px;
    border:none;
    border-radius:8px;
    padding:10px 14px;
    background:#173A5E;
    color:#fff;
    font:inherit;
    font-size:12px;
    font-weight:700;
    cursor:pointer;
    box-shadow:0 4px 14px rgba(23,58,94,.16);
    transition:transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}
.btn-primary:hover:not(:disabled) {
    transform:translateY(-1px);
    box-shadow:0 8px 18px rgba(23,58,94,.2);
}
.btn-primary:disabled {
    opacity:.45;
    cursor:not-allowed;
    box-shadow:none;
}
.report-empty {
    border:1px dashed #CBD5E1;
    border-radius:10px;
    padding:18px 20px;
    color:#667A90;
    background:#F8FBFF;
    font-size:13px;
    line-height:1.5;
}
.hidden { display:none !important; }
#tabela-relatorio { width:100%; border-collapse:collapse; font-size:12px; }
#tabela-relatorio thead { position:sticky; top:0; z-index:2; }
#tabela-relatorio th {
    background:#17324D; color:#fff; font-weight:600; text-align:left;
    padding:10px 12px; white-space:nowrap;
}
#tabela-relatorio td { padding:8px 12px; border-bottom:1px solid #f1f5f9; vertical-align:top; }
#tabela-relatorio tbody tr:hover { background:#EEF4FF; }
.report-cell-pct {
    font-size:14px;
    font-weight:800;
    color:#17324D;
}
.report-cell-code {
    font-weight:700;
    color:#17324D;
}
.report-cell-desc {
    color:#34506B;
    line-height:1.45;
}

/* ===== SCROLLBAR ===== */
.student-charts { margin-bottom:16px; }
.student-summary { color:#34506B; line-height:1.7; }
.student-summary p + p { margin-top:10px; }
.student-toolbar { display:flex; flex-wrap:wrap; gap:12px; margin:16px 0; align-items:flex-end; }
.student-search { flex:1; min-width:180px; }
.student-search input { border:1px solid #D6E0EE; border-radius:6px; padding:7px 10px; font:inherit; min-width:0; }
.student-table { width:100%; border-collapse:collapse; font-size:12px; }
.student-table thead { position:sticky; top:0; z-index:2; }
.student-table th { background:#17324D; color:white; padding:10px 12px; text-align:left; white-space:nowrap; }
.student-table td { padding:10px 12px; border-bottom:1px solid #e8eef5; vertical-align:top; }
.student-table tbody tr:hover { background:#EEF4FF; }
.student-table-wrap { max-height:560px; }
.student-button { border:1px solid #D6E0EE; border-radius:6px; background:#fff; color:#173A5E; padding:6px 10px; font:inherit; cursor:pointer; white-space:nowrap; }
.student-button:hover:not(:disabled) { background:#EEF4FF; }
.student-button:disabled { opacity:.4; cursor:default; }
.student-pagination { display:flex; align-items:center; justify-content:flex-end; gap:12px; margin-top:12px; font-size:12px; }
.student-detail { margin-top:16px; scroll-margin-top:16px; }
.student-detail-top { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.student-detail-meta { color:#34506B; line-height:1.7; margin-bottom:14px; }
.student-answer-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(105px,1fr)); gap:8px; margin:12px 0 18px; }
.student-answer { border:1px solid #86EFAC; border-radius:8px; padding:10px; background:#DCFCE7; color:#166534; }
.student-answer.wrong { border-color:#FCA5A5; background:#FEE2E2; color:#991B1B; }
.student-answer small { display:block; margin-top:4px; }
.student-review { color:#92400E; background:#FEF3C7; border-radius:6px; padding:8px 10px; margin:10px 0; line-height:1.6; }

::-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; }
    .hab-layout { grid-template-columns:1fr; }
    .hab-detail-panel { position:static; min-height:auto; }
    .hab-detail-meta-grid { grid-template-columns:1fr; }
    .hab-detail-top { grid-template-columns:1fr; }
}
@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; }
    .report-toolbar { flex-direction:column; align-items:flex-start; }
    .report-toolbar-main { width:100%; }
    .report-subfilters { width:100%; }
    .report-filter-group { min-width:min(100%, 220px); flex:1; }
    .report-actions { width:100%; justify-content:flex-start; }
}

/* ===== LOADING ===== */
.loading-spinner {
    display:flex; align-items:center; justify-content:center;
    padding:40px; color:#667A90; 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); } }
