/* Paleta, tipografia e componentes portados do protótipo validado
   (financeiro-escola.html) — manter em sincronia se a paleta mudar lá. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Sora:wght@500;600;700;800&family=Poppins:wght@500;600;700&display=swap');

:root {
  --magenta: #C41E68;
  --saida-cor: #C41E68;
  --rosa: #D9709E;
  --pessego: #F6C6A0;
  --laranja: #F5A94E;
  --verde-agua: #4EC5A4;
  --teal: #1F9C8C;
  --azul-marinho: #254B77;
  --azul-marinho-escuro: #1B3A5C;
  --azul-claro: #8FB4D9;
  --amarelo: #F2C230;
  --amarelo-texto: #A67C00;

  --bg: #F7F5F1;
  --card-bg: #FFFFFF;
  --border: #E7E2DC;
  --text: #26232B;
  --text-muted: #7A7570;

  --sidebar-w: 236px;

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'Poppins', sans-serif;

  --radius: 14px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  display: flex;
}

a, button { font-family: inherit; }

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--azul-marinho-escuro);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  color: white;
  overflow-y: auto;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 18px; margin-bottom: 8px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--magenta), var(--teal));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 16px; color: white;
  flex-shrink: 0;
}
.brand-text h1 { font-family: var(--font-display); font-size: 15.5px; font-weight: 600; letter-spacing: -0.01em; }
.brand-text p { font-size: 10.5px; color: rgba(255,255,255,0.5); margin-top: 1px; }

.nav-scroll { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 10px; flex: 1; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 9px;
  color: rgba(255,255,255,0.72);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; margin-bottom: 2px;
  border: none; background: none; width: 100%; text-align: left;
  text-decoration: none;
  transition: background .12s, color .12s;
  position: relative;
}
.nav-item .ic { width: 18px; height: 18px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.nav-item .ic svg { width: 17px; height: 17px; stroke: currentColor; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: white; }
.nav-item.ativo { background: rgba(255,255,255,0.1); color: white; }
.nav-item.ativo::before {
  content: ''; position: absolute; left: -16px; top: 8px; bottom: 8px; width: 3px;
  background: var(--teal); border-radius: 0 3px 3px 0;
}

.sidebar-footer { margin-top: 10px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--rosa); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; color: white; flex-shrink: 0;
}
.user-info p:first-child { font-size: 12.5px; font-weight: 600; }
.user-info p:last-child { font-size: 10.5px; color: rgba(255,255,255,0.5); margin-top: 1px; }
.user-info a { color: rgba(255,255,255,0.55); font-size: 10.5px; text-decoration: none; }
.user-info a:hover { color: white; }

/* ============ MAIN AREA ============ */
.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; height: 100vh; }

.topbar {
  height: 64px; min-height: 64px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
}
.topbar-title h2 { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--azul-marinho); }
.topbar-title p { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.conteudo { flex: 1; overflow-y: auto; padding: 28px; }

/* ============ CARDS ============ */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 22px; position: relative; overflow: hidden; }
.card::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--azul-claro); }
.card.entrada::before { background: var(--teal); }
.card.saida::before { background: var(--saida-cor); }
.card.saldo::before { background: var(--amarelo); }
.card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.card .valor { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 600; color: var(--text); }
.card.entrada .valor { color: var(--teal); }
.card.saida .valor { color: var(--saida-cor); }
.card.saldo .valor { color: var(--amarelo-texto); }
.card .sub { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }

/* ============ PANEL ============ */
.panel { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 18px; }
.panel h3 { font-family: var(--font-display); font-size: 16px; font-weight: 600; color: var(--azul-marinho); margin-bottom: 4px; }

/* ============ FORM ============ */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; align-items: start; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-3 { grid-column: span 3; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2, .form-grid .span-3 { grid-column: span 1; } }

label {
  display: block; font-size: 11px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em;
}
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="month"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font-body); font-size: 13.5px; color: var(--text); background: #FCFBFA;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--teal); background: white; }
.checkbox-row { display: flex; align-items: center; gap: 8px; padding-top: 9px; }
.checkbox-row input { width: auto; margin: 0; }

/* ============ BOTÕES ============ */
button, .btn {
  display: inline-block;
  padding: 11px 22px; border: none; border-radius: 8px; background: var(--magenta); color: white;
  font-weight: 600; font-size: 13.5px; cursor: pointer; transition: opacity .15s;
  text-decoration: none;
}
button:hover, .btn:hover { opacity: 0.9; }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { background: var(--bg); opacity: 1; }
.btn-danger { background: none; border: 1px solid rgba(196,30,104,0.3); color: var(--magenta); }
.btn-danger:hover { background: rgba(196,30,104,0.06); opacity: 1; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.acoes-cel { display: flex; gap: 6px; white-space: nowrap; }
.form-inline { display: inline; }

/* ============ TABELA ============ */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 12.5px; }
thead th { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: 20px; }
.tag.ativo, .tag.pago { background: rgba(31,156,140,0.12); color: var(--teal); }
.tag.inativo, .tag.atrasado { background: rgba(196,30,104,0.1); color: var(--saida-cor); }
.tag.trancado, .tag.pendente { background: rgba(245,169,78,0.18); color: #9C6A0A; }

.valor-cell { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; }
.valor-cell.entrada { color: var(--teal); }
.valor-cell.saida { color: var(--saida-cor); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 13px; }
.empty-state .icon { font-size: 28px; margin-bottom: 10px; }

.erro {
  background: rgba(245,169,78,0.18); color: #9C6A0A;
  border-radius: 8px; padding: 10px 14px; font-size: 0.85rem; margin-bottom: 16px;
}
.sucesso { background: rgba(31,156,140,0.12); color: #0F6B5C; }

.subnav { display: flex; gap: 6px; margin-bottom: 14px; }
.subnav a { padding: 6px 14px; border-radius: 999px; font-size: 0.82rem; font-weight: 600; text-decoration: none; color: var(--text-muted); border: 1px solid var(--border); }
.subnav a.ativo { background: var(--magenta); color: #fff; border-color: var(--magenta); }

.search-form { display: flex; gap: 8px; }
.search-form input { margin-bottom: 0; min-width: 220px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-header h2 { font-family: var(--font-display); color: var(--azul-marinho); font-size: 1.2rem; }

/* ============ FILTRO DE PERÍODO (topbar) ============ */
.pill-select {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 9px;
  padding: 7px 12px;
}
.pill-select label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; margin: 0; }
.pill-select input { border: none; background: transparent; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px; color: var(--azul-marinho); width: auto; padding: 0; }
.pill-select input:focus { outline: none; }

/* ============ SUBABAS ============ */
.subtabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.subtab {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--card-bg); color: var(--text-muted);
  font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer;
}
.subtab.ativo { background: var(--magenta); border-color: var(--magenta); color: white; }
.subtab.desativado { opacity: 0.45; cursor: not-allowed; }

/* ============ GRID DE PAINÉIS (Visão geral) ============ */
.dashboard-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
@media (max-width: 900px) { .dashboard-grid { grid-template-columns: 1fr; } }

.panel-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 20px; }

.donut-linha { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; padding-top: 6px; }
.donut { width: 120px; height: 120px; border-radius: 50%; flex-shrink: 0; position: relative; }
.donut-centro {
  position: absolute; inset: 16px; border-radius: 50%; background: var(--card-bg);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 12.5px; color: var(--text); text-align: center; padding: 4px;
}
.donut-legenda { display: flex; flex-direction: column; gap: 7px; max-width: 220px; }
.legenda-item { display: flex; align-items: center; gap: 7px; font-size: 11.5px; }
.legenda-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.legenda-item .nome { color: var(--text); font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legenda-item .pct { color: var(--text-muted); }

.top-categorias { display: flex; flex-direction: column; gap: 12px; }
.cat-row { display: flex; align-items: center; gap: 12px; }
.cat-row .cat-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.cat-row .cat-name { font-size: 12.5px; width: 90px; flex-shrink: 0; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cat-bar-track { flex: 0 1 45%; height: 8px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 6px; }
.cat-row .cat-val { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 11.5px; font-weight: 600; flex: 1; min-width: 78px; text-align: right; color: var(--text-muted); }

.btn-chip {
  display: inline-block; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg);
  font-size: 12.5px; font-weight: 600; cursor: pointer; color: var(--text);
}
.btn-chip:hover { border-color: var(--teal); color: var(--teal); }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }

/* ============ TABELA COM BUSCA/FILTROS (cabeçalho de painel) ============ */
.table-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters select, .filters input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 12.5px; background: #FCFBFA; }
th.th-sort { cursor: pointer; user-select: none; }
th.th-sort:hover { color: var(--text); }
.muted-small { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.header-hint { font-size: 11.5px; color: var(--text-muted); background: var(--bg); padding: 10px 12px; border-radius: 8px; margin-top: 10px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ============ PAINEL DE FORMULÁRIO (campos soltos, não em <form-grid> padrão) ============ */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font-body); font-size: 13.5px; color: var(--text); background: #FCFBFA;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--teal); background: white; }
.span-full { grid-column: 1 / -1; }
.radio-group { display: flex; gap: 16px; align-items: center; padding: 9px 2px; flex-wrap: wrap; }
.radio-group label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text); font-weight: 500; text-transform: none; cursor: pointer; }
.radio-group input[type="checkbox"], .radio-group input[type="radio"] { width: auto; accent-color: var(--teal); }

.btn-primary { padding: 11px 22px; border: none; border-radius: 8px; background: var(--magenta); color: white; font-weight: 600; font-size: 13.5px; cursor: pointer; margin-top: 6px; transition: opacity .15s; }
.btn-primary:hover { opacity: 0.9; }
.btn-secondary { padding: 10px 18px; border: 1px solid var(--border); border-radius: 8px; background: white; color: var(--text-muted); font-weight: 600; font-size: 13px; cursor: pointer; margin-top: 6px; margin-left: 8px; }
.btn-secondary:hover { background: var(--bg); }

/* botão redondo "novo X", usado nas subabas Entradas/Saídas ao lado da busca */
.btn-fab { position: relative; width: 36px; height: 36px; border-radius: 9px; border: none; background: var(--magenta); color: white; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; transition: opacity .15s; }
.btn-fab:hover { opacity: .88; }
.btn-fab svg { width: 17px; height: 17px; }

/* ============ PAINEL DE FORMULÁRIO EXPANSÍVEL (Lançamentos) ============ */
.form-panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.form-panel-head h3 { margin-bottom: 0; }
.form-panel-close { width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--border); background: white; color: var(--text-muted); font-size: 15px; line-height: 1; cursor: pointer; flex-shrink: 0; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; padding: 0; }
.form-panel-close:hover { background: var(--bg); color: var(--text); }

/* ============ GRÁFICO DE BARRAS (Entradas × Saídas) ============ */
.chart { display: flex; align-items: flex-end; gap: 18px; height: 190px; padding-top: 10px; min-width: min-content; }
.chart-col { flex: 0 0 auto; min-width: 66px; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart-bars { display: flex; gap: 6px; align-items: flex-end; height: 150px; width: 100%; justify-content: center; }
.bar-wrap { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-val { font-size: 9px; font-weight: 700; color: var(--text-muted); margin-bottom: 3px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar { width: 22px; border-radius: 4px 4px 0 0; }
.bar.entrada { background: var(--teal); }
.bar.saida { background: var(--saida-cor); }
.chart-label { font-size: 10.5px; color: var(--text-muted); font-weight: 600; }
.legend { display: flex; gap: 16px; margin-top: 14px; font-size: 11.5px; color: var(--text-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; }
.legend .dot.entrada { background: var(--teal); }
.legend .dot.saida { background: var(--saida-cor); }

/* ============ SEÇÃO RECOLHÍVEL (comparativo mês a mês) ============ */
.sec { border: 1px solid var(--border); border-radius: 11px; overflow: hidden; }
.sec-head { display: flex; align-items: center; gap: 11px; padding: 13px 15px; cursor: pointer; user-select: none; background: #FCFBF9; }
.sec-badge { width: 26px; height: 26px; border-radius: 7px; flex-shrink: 0; color: white; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; }
.sec-head .txt { flex: 1; min-width: 0; }
.sec-head .txt h4 { font-size: 13.5px; font-weight: 600; margin: 0; color: var(--text); }
.sec-head .txt span { font-size: 11.5px; color: var(--text-muted); }
.sec-head .chev { font-size: 11px; color: var(--text-muted); transition: transform .15s; flex-shrink: 0; }
.sec.collapsed .sec-head .chev { transform: rotate(-90deg); }
.sec-body { padding: 16px 15px 18px; border-top: 1px solid var(--border); }
.sec.collapsed .sec-body { display: none; }
.badge-1 { background: var(--magenta); }
.badge-2 { background: var(--rosa); }
.badge-3 { background: var(--azul-marinho); }
.badge-4 { background: var(--teal); }

/* ============ TELA DE LOGIN/INSTALAÇÃO (sem sidebar) ============ */
.tela-login { min-height: 100vh; width: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card-login { width: 100%; max-width: 360px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px 28px; box-shadow: 0 8px 24px rgba(37,75,119,0.08); }
.card-login h1 { font-family: var(--font-display); font-size: 1.3rem; color: var(--azul-marinho); margin: 0 0 6px; }
.card-login p.sub { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 22px; }
