:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-sec: #6c757d;
    --primary: #4361ee;
    --primary-light: #eef0ff;
    --border: #dee2e6;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    padding: 20px;
}

/* Login */
#login-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}
.login-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
    text-align: center;
    max-width: 380px;
    width: 90%;
}
.login-box h1 {
    font-size: 1.3rem;
    color: var(--primary);
    margin-bottom: 8px;
}
.login-box p {
    font-size: 0.9rem;
    color: var(--text-sec);
    margin-bottom: 20px;
}
.login-box input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 16px;
    outline: none;
    transition: border .15s;
}
.login-box input:focus {
    border-color: var(--primary);
}
.login-box button {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
}
.login-box button:hover {
    opacity: 0.9;
}
#login-erro {
    color: var(--danger);
    font-size: 0.85rem;
    margin-bottom: 12px;
    min-height: 1.2em;
}

#dashboard-content {
    display: block;
}

header {
    text-align: center;
    margin-bottom: 24px;
}
header h1 { font-size: 1.8rem; color: var(--primary); }
header p { color: var(--text-sec); font-size: 0.95rem; }

main { max-width: 1200px; margin: 0 auto; }

/* Cards */
#cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    text-align: center;
}
.card-valor {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}
.card-rotulo {
    display: block;
    font-size: 0.85rem;
    color: var(--text-sec);
    margin-top: 4px;
}

/* Filters */
#filtros {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    background: var(--surface);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.filtro-grupo {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    flex: 1;
}
.filtro-grupo label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sec);
    margin-bottom: 4px;
}
.filtro-grupo select,
.filtro-grupo input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--surface);
    cursor: pointer;
}
.filtro-grupo input {
    cursor: text;
}
.filtro-grupo input::placeholder {
    color: var(--text-sec);
    font-size: 0.85rem;
}

.filtro-grupo.filtro-limpar {
    flex: 0 0 auto;
    min-width: auto;
    justify-content: flex-end;
}
#btn-limpar-filtros {
    padding: 8px 16px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--text-sec);
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
#btn-limpar-filtros:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

/* Charts */
#graficos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.grafico-container {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.grafico-container h2 {
    font-size: 1rem;
    margin-bottom: 12px;
    color: var(--text);
}
.grafico-container canvas {
    max-height: 300px;
}

/* Table */
#tabela-section {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
#tabela-section h2 {
    font-size: 1rem;
    margin-bottom: 12px;
}
#tabela-wrapper {
    overflow-x: auto;
    max-width: 100%;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-weight: 600;
    color: var(--text-sec);
    cursor: pointer;
    user-select: none;
}
th:hover { color: var(--primary); }
th .seta { font-size: 0.75rem; margin-left: 4px; }
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}
tr:hover { background: var(--primary-light); }

.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
}
.status-verde { background: var(--success); }
.status-amarelo { background: var(--warning); }
.status-vermelho { background: var(--danger); }

.btn-expandir {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-sec);
}
.btn-expandir:hover { background: var(--primary-light); color: var(--primary); }

.detalhe-row {
    display: none;
}
.detalhe-row.visivel {
    display: table-row;
}
.detalhe-cell {
    padding: 12px 20px;
    background: var(--bg);
}
.detalhe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.detalhe-mes h4 {
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 6px;
}
.detalhe-mes ul {
    list-style: none;
    font-size: 0.82rem;
}
.detalhe-mes li {
    padding: 2px 0;
    color: var(--text-sec);
}

/* Alunos */
.alunos-section {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 12px;
}
.btn-alunos {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 10px;
}
.btn-alunos:hover {
    background: var(--primary-light);
}
.btn-alunos-arrow {
    font-size: 0.75rem;
}
.alunos-content {
    display: none;
}
.alunos-content.alunos-visivel {
    display: block;
}
.tabela-alunos {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
.tabela-alunos th {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-sec);
    text-align: left;
    font-size: 0.78rem;
}
.tabela-alunos th.th-periodo {
    text-align: center;
    width: 60px;
}
.tabela-alunos td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}
.tabela-alunos .num-cell {
    text-align: center;
}
.tabela-alunos .ra-cell {
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--text-sec);
}
.tabela-alunos .def-cell {
    font-size: 0.78rem;
    color: var(--text-sec);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.aluno-row {
    cursor: pointer;
}
.aluno-row:hover {
    background: var(--primary-light);
}
.aluno-docs {
    display: none;
}
.aluno-docs.aluno-docs-visivel {
    display: table-row;
}
.aluno-docs td {
    overflow-x: auto;
    max-width: 0;
}
.aluno-docs-content {
    padding: 8px 12px;
    background: #f0f2f5;
    border-radius: 6px;
    margin: 2px 0;
    overflow-x: auto;
    max-width: 100%;
}
.aluno-docs-content ul {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.aluno-docs-content li {
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 0.8rem;
    overflow-wrap: break-word;
    word-break: break-word;
}
.aluno-docs-content .doc-data {
    color: var(--text-sec);
    font-size: 0.75rem;
}
.aluno-docs-content .sem-docs {
    color: var(--text-sec);
    font-style: italic;
    font-size: 0.8rem;
}

/* Anos */
.anos-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}
.ano-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text);
    transition: all .15s;
}
.ano-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}
.ano-btn.ano-ativo {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.ano-docs {
    display: none;
}
.ano-docs.ano-docs-visivel {
    display: block;
}

/* Footer */
footer {
    text-align: center;
    color: var(--text-sec);
    font-size: 0.8rem;
    padding: 20px 0;
}

/* Responsive */
@media (max-width: 768px) {
    #graficos { grid-template-columns: 1fr; }
    #filtros { flex-direction: column; }
    .filtro-grupo { min-width: auto; }
}
