:root {
  --bg: #0a0e16;
  --bg-secondary: #0f1420;
  --surface: #131a26;
  --surface-hover: #1a2230;
  --border: #232c3d;

  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #556378;

  --primary: #22c3ee;
  --primary-hover: #1aa8cf;
  --primary-light: #7fe3fa;
  --primary-subtle: rgba(34, 195, 238, 0.12);
  --primary-text: #04141c;

  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --success: #22c55e;
  --success-subtle: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  --info: #3b82f6;
  --info-subtle: rgba(59, 130, 246, 0.12);

  --sidebar-bg: #0c1119;
  --sidebar-border: #182030;
  --sidebar-text: #71809b;
  --sidebar-text-hover: #cbd5e1;
  --sidebar-active-bg: rgba(34, 195, 238, 0.14);
  --sidebar-active-text: #7fe3fa;
  --sidebar-active-border: #22c3ee;

  --card-bg: #131a26;
  --card-border: #232c3d;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.02);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);

  --topbar-bg: #0f1420;
  --topbar-border: #202838;

  --input-bg: #0f1420;
  --input-border: #2a3548;

  --modal-bg: #131a26;
  --modal-overlay: rgba(0, 0, 0, 0.75);

  --table-head-bg: #171f2c;
  --table-row-hover: rgba(34, 195, 238, 0.05);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sidebar-w: 236px;
  --sidebar-w-collapsed: 68px;
  --topbar-h: 60px;
}

:root[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-secondary: #eaf0f7;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #dde4ed;

  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --primary: #0891b2;
  --primary-hover: #0e7490;
  --primary-light: #06b6d4;
  --primary-subtle: rgba(8, 145, 178, 0.10);
  --primary-text: #ffffff;

  --danger: #dc2626;
  --danger-subtle: rgba(220, 38, 38, 0.08);
  --success: #16a34a;
  --success-subtle: rgba(22, 163, 74, 0.08);
  --warning: #d97706;
  --warning-subtle: rgba(217, 119, 6, 0.08);
  --info: #2563eb;
  --info-subtle: rgba(37, 99, 235, 0.08);

  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-text: #64748b;
  --sidebar-text-hover: #1e293b;
  --sidebar-active-bg: rgba(8, 145, 178, 0.08);
  --sidebar-active-text: #0891b2;
  --sidebar-active-border: #0891b2;

  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 0 0 1px rgba(15, 23, 42, 0.03);
  --shadow-lg: 0 8px 32px rgba(15, 23, 42, 0.12);

  --topbar-bg: #ffffff;
  --topbar-border: #e2e8f0;

  --input-bg: #ffffff;
  --input-border: #cbd5e1;

  --modal-bg: #ffffff;
  --modal-overlay: rgba(15, 23, 42, 0.45);

  --table-head-bg: #f1f5f9;
  --table-row-hover: rgba(8, 145, 178, 0.04);
}

/* Logo Kronos Fit: uma versao pra cada tema (a arte ja vem pronta do design, so trocamos qual arquivo aparece). */
.brand-logo-light { display: none; }
:root[data-theme="light"] .brand-logo-dark { display: none; }
:root[data-theme="light"] .brand-logo-light { display: block; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }
.aluno-nome-link { font-weight: 600; color: var(--text); }
.aluno-nome-link:hover { color: var(--primary); text-decoration: underline; }

.hidden { display: none !important; }

/* ===== AUTH (login/registro) ===== */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 0%, var(--bg-secondary) 0%, var(--bg) 55%);
}
.auth-card {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 42px 36px 34px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 0 0 1px var(--primary-subtle), var(--shadow-lg);
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #0b6b86);
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}
.auth-brand .brand-logo { width: 100%; max-width: 280px; height: auto; }
.auth-card h1 { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; text-align: center; }
.auth-card .sub { color: var(--text-secondary); font-size: 0.85rem; margin: 0 0 30px; text-align: center; line-height: 1.55; }
.auth-switch { margin-top: 20px; font-size: 0.85rem; color: var(--text-secondary); text-align: center; }

.auth-card .form-group { margin-bottom: 16px; }
.auth-card .form-control { padding: 11px 14px; border-radius: 10px; }

.auth-check { display: flex; align-items: center; gap: 8px; margin: 4px 0 22px; }
.auth-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex: none; }
.auth-check label { font-size: 0.82rem; color: var(--text-secondary); cursor: pointer; user-select: none; }

.auth-card .btn-primary {
  padding: 13px 16px;
  border-radius: 11px;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  box-shadow: 0 10px 24px var(--primary-subtle);
}
.auth-card .btn-primary:hover { filter: brightness(1.06); }

/* ===== FORM ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 0.8rem; font-weight: 600; color: var(--text-secondary); }
.form-control {
  padding: 10px 13px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 9px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-subtle); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 9px;
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, filter .15s, border-color .15s;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-success { background: var(--success); color: #ffffff; }
.btn-danger { background: var(--danger); color: #ffffff; }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary-light); }
.btn-link { background: none; border: none; color: var(--primary); font-weight: 600; padding: 0; cursor: pointer; font-size: inherit; font-family: var(--font); }
.btn-sm { padding: 6px 11px; font-size: 0.78rem; }
.btn-block { width: 100%; }

.error-text { color: var(--danger); font-size: 0.82rem; min-height: 1.1em; margin: 4px 0 0; }

/* ===== APP SHELL (sidebar + topbar) ===== */
.app-shell { display: none; min-height: 100vh; }
.app-shell.active { display: flex; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; justify-content: center; padding: 14px 10px 26px; }
.sidebar-brand .brand-logo { height: auto; width: 100%; max-width: 190px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--sidebar-text);
  font-size: 0.85rem;
  font-weight: 500;
  border-left: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none; border-right: none; border-bottom: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}
.nav-item svg { width: 17px; height: 17px; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--sidebar-text-hover); }
.nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); border-left-color: var(--sidebar-active-border); }
.sidebar-footer { border-top: 1px solid var(--sidebar-border); padding-top: 12px; margin-top: 8px; font-size: 0.72rem; color: var(--text-muted); padding-left: 12px; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 60px 0 22px; /* padding-right reserva espaco pro botao fixo de tema */
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 1.02rem; font-weight: 700; margin: 0; }
.topbar .page-sub { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-chip {
  display: flex; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-secondary);
  background: none; border: none; padding: 4px 6px; border-radius: 20px; cursor: pointer; font-family: var(--font);
}
.user-chip:hover { background: var(--surface-hover); color: var(--text); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-subtle); color: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.78rem;
  background-size: cover; background-position: center; flex: none;
}
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; }

.page-content { padding: 24px 28px; flex: 1; }
.page-title-row { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 20px; }
.page-title-row h2 { font-size: 1.15rem; margin: 0 0 2px; }
.page-title-row p { margin: 0; color: var(--text-muted); font-size: 0.82rem; }

/* ===== KPI / STAT CARDS ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; margin-bottom: 22px; }
.kpi-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-card .kpi-label { font-size: 0.72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; }
.kpi-card .kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.kpi-icon.blue { background: var(--primary-subtle); color: var(--primary-light); }
.kpi-icon.green { background: var(--success-subtle); color: var(--success); }
.kpi-icon.red { background: var(--danger-subtle); color: var(--danger); }
.kpi-icon.amber { background: var(--warning-subtle); color: var(--warning); }

/* ===== CARD ===== */
.card { background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 14px; padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.card-title { font-size: 0.92rem; font-weight: 700; }
.fin-chart-hint { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

/* ===== Graficos do Dashboard financeiro (Chart.js, vendorizado localmente em js/vendor/) ===== */
.fin-charts-grid { display: grid; grid-template-columns: 1fr; gap: 4px; }
.fin-charts-grid .card { margin-bottom: 14px; }
.fin-donuts-row { display: flex; gap: 18px; flex-wrap: wrap; }
.fin-chart-canvas-wrap { position: relative; height: 240px; width: 100%; }
.fin-chart-canvas-wrap-donut { height: 220px; }
.fin-chart-canvas-wrap-tall { height: 340px; }
.fin-chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 160px; color: var(--text-muted); font-size: 0.84rem; text-align: center; padding: 20px; }
@media (max-width: 640px) {
  .fin-chart-canvas-wrap { height: 200px; }
  .fin-chart-canvas-wrap-donut { height: 260px; }
  .fin-chart-canvas-wrap-tall { height: 260px; }
}

/* ===== Dashboard (Visao geral) ===== */
/* Financeiro vira o card "hero": sozinho, ocupando a largura toda, grafico mais alto - e o card com
   mais informacao/peso visual do Dashboard, entao ganha destaque em vez de dividir 50/50 com outro
   card menor do lado. */
.dash-hero { margin-bottom: 18px; }
/* Frequencia/Agenda/Experimentais/Evolucao/Atencao: cards de tamanho bem variado (lista curta,
   mini-stats, grafico), entao usa flexbox com wrap em vez de colunas fixas - em telas largas isso
   preenche a largura toda com varios cards por linha ao inves de deixar colunas largas com espaco
   vazio dentro dos cards menores. Flexbox (nao CSS grid) e proposital aqui: com grid "auto-fit",
   quando o numero de cards nao divide exato pelas colunas, o ultimo card sozinho na linha de baixo
   fica preso numa coluna estreita com celulas vazias do lado. Com flex-wrap, o card orfao da ultima
   linha estica sozinho (flex-grow) e preenche a linha toda. min-height evita que os cards de
   conteudo curto (ex: Atencao com so 1-2 linhas) fiquem parecendo uma caixa solta/incompleta ao
   lado de cards mais altos (ex: Agenda de hoje, com varios horarios listados). */
.dash-flow-grid { display: flex; flex-wrap: wrap; gap: 18px; align-items: stretch; margin-bottom: 18px; }
.dash-flow-grid > .card { flex: 1 1 320px; min-width: 0; min-height: 210px; margin-bottom: 0; display: flex; flex-direction: column; }
/* align-items:stretch faz os cards da mesma linha ficarem com a mesma altura (a do mais alto do
   grupo); esses tres seletores fazem o CONTEUDO abaixo do card-header crescer e se centralizar
   nesse espaco extra, em vez de ficar grudado no topo com uma sobra vazia embaixo - e o que faz um
   card curto (ex: Atencao com 1 linha) parecer completo ao lado de um card alto (ex: Agenda de hoje). */
.dash-flow-grid > .card > .dash-list { flex: 1; justify-content: center; }
.dash-flow-grid > .card > .dash-mini-stats { flex: 1; align-content: center; margin-bottom: 0; }
.dash-flow-grid > .card > .fin-chart-canvas-wrap { flex: 1; height: auto; min-height: 180px; }
.dash-card-link { background: none; border: none; padding: 0; font-family: var(--font); font-size: 0.76rem; font-weight: 700; color: var(--primary-light); cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.dash-card-link:hover { text-decoration: underline; }
.dash-mini-stats { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }
.dash-mini-stat-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; margin-bottom: 4px; }
.dash-mini-stat-value { font-size: 1.3rem; font-weight: 700; }
.dash-progress-track { height: 8px; border-radius: 999px; background: var(--bg-secondary); overflow: hidden; }
.dash-progress-fill { height: 100%; border-radius: 999px; background: var(--success); transition: width .3s ease; }
.dash-list { display: flex; flex-direction: column; gap: 8px; }
.dash-list-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; background: var(--bg-secondary); border-radius: 10px; font-size: 0.84rem; }
.dash-list-item.clickable { cursor: pointer; transition: background .15s; }
.dash-list-item.clickable:hover { background: var(--surface-hover, var(--border)); }
.dash-list-item-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dash-list-item-title { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-list-item-sub { font-size: 0.74rem; color: var(--text-muted); }
.dash-list-item-side { flex: none; text-align: right; font-size: 0.78rem; color: var(--text-secondary); }
.dash-empty-msg { color: var(--text-muted); font-size: 0.84rem; text-align: center; padding: 18px 10px; }
.dash-attention-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 10px; font-size: 0.85rem; font-weight: 600; border-left: 3px solid var(--danger); background: var(--danger-subtle); color: var(--text); }
.dash-attention-item.warn { border-left-color: var(--warning); background: var(--warning-subtle); }
.dash-attention-item.ok { border-left-color: var(--success); background: var(--success-subtle); }
.dash-attention-count { margin-left: auto; font-weight: 700; }
.dash-kpi-sub { font-size: 0.68rem; color: var(--text-muted); font-weight: 500; margin-top: 4px; }

/* Secao dentro de um card (ex: Endereco / Contato de emergencia dentro do card "Dados do aluno" na ficha) -
   separador sutil em vez de virar outro card pequeno, pra nao fragmentar a tela em blocos vazios. */
.cadastro-subsection { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); }
.cadastro-subsection-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; margin-bottom: 14px; }

/* Pares label/valor - usado em varios lugares (Visao geral, Cadastro, Financeiro da ficha). overflow-wrap evita que
   textos longos e sem espaco (e-mail, etc.) estourem a coluna e "sobreponham" a celula vizinha. */
.info-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px 20px; font-size: 0.88rem; }
.info-grid-4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.info-pair { min-width: 0; }
.info-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; margin-bottom: 5px; }
.info-value { display: block; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; word-break: break-word; }
.value-ok { color: var(--success); }
.value-warn { color: var(--danger); }
.info-value.disponivel { color: var(--success); }
.info-value.poucas-vagas { color: var(--warning); }
.info-value.lotado { color: var(--danger); }

/* ===== Modal de detalhe da turma (Agenda) ===== */
.turma-stats-row { display: flex; gap: 10px; margin-top: 14px; }
.turma-stat { flex: 1; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 10px 8px; text-align: center; }
.turma-stat-label { display: block; font-size: 0.64rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.turma-stat-value { font-size: 1rem; font-weight: 700; }
.turma-stat-value.disponivel { color: var(--success); }
.turma-stat-value.poucas-vagas { color: var(--warning); }
.turma-stat-value.lotado { color: var(--danger); }

.td-aluno-row { display: flex; flex-direction: column; gap: 8px; padding: 9px 11px; background: var(--bg-secondary); border-radius: 9px; margin-bottom: 6px; }
.td-aluno-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.td-aluno-main { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.td-aluno-nome {
  background: none; border: none; padding: 0; color: var(--primary); font-weight: 600; font-size: 0.86rem;
  cursor: pointer; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font);
}
.td-aluno-nome:hover { text-decoration: underline; color: var(--primary-light); }
.td-info-btn {
  width: 17px; height: 17px; border-radius: 50%; border: 1px solid var(--border); background: transparent;
  color: var(--text-muted); font-size: 0.62rem; font-weight: 700; font-style: italic; cursor: pointer; flex: none;
  display: flex; align-items: center; justify-content: center; font-family: Georgia, serif; line-height: 1;
}
.td-info-btn:hover { border-color: var(--primary); color: var(--primary-light); }
.td-aluno-badges { display: flex; gap: 4px; flex: none; flex-wrap: wrap; justify-content: flex-end; }

/* Linha de acoes abaixo dos badges - tres botoes de icone lado a lado, mesmo tamanho da lixeira. */
.td-aluno-actions { display: flex; align-items: center; gap: 6px; }
.td-checkin-btn.presente { border-color: var(--success); color: var(--success); }
.td-checkin-btn.presente:hover, .td-checkin-btn.presente.active { background: var(--success-subtle); }
.td-checkin-btn.falta { border-color: var(--danger); color: var(--danger); }
.td-checkin-btn.falta:hover, .td-checkin-btn.falta.active { background: var(--danger-subtle); }

.td-add-panel { margin-top: 12px; padding: 14px; background: var(--bg-secondary); border-radius: 10px; border: 1px solid var(--border); }
.td-busca-resultados { max-height: 180px; overflow-y: auto; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.td-busca-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--card-bg); border-radius: 8px; cursor: pointer; font-size: 0.84rem; }
.td-busca-item:hover { border-color: var(--primary); background: var(--surface-hover); }
.td-busca-vazio { font-size: 0.8rem; color: var(--text-muted); font-style: italic; padding: 8px 2px; }

#td-info-popover {
  position: fixed;
  z-index: 1200;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 0 0 1px var(--primary-subtle), var(--shadow-lg);
  padding: 14px 16px;
  width: 250px;
  font-size: 0.8rem;
}
#td-info-popover .info-grid { grid-template-columns: 1fr; gap: 9px; font-size: 0.78rem; }
#td-info-popover .info-value { font-size: 0.82rem; }
#td-info-popover a.info-value { color: var(--primary); text-decoration: none; }
#td-info-popover a.info-value:hover { text-decoration: underline; }

.observacoes-texto { font-size: 0.88rem; line-height: 1.65; color: var(--text); white-space: pre-wrap; margin: 0; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
thead th { text-align: left; padding: 10px 12px; background: var(--table-head-bg); color: var(--text-muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
thead th:first-child { border-radius: 8px 0 0 8px; }
thead th:last-child { border-radius: 0 8px 8px 0; }
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: var(--table-row-hover); }

/* ===== BADGE ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-neutral { background: rgba(148, 163, 184, 0.14); color: var(--text-secondary); }
.badge-primary { background: var(--primary-subtle); color: var(--primary-light); }

/* ===== FORM GRID / TOGGLE ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group.full { grid-column: 1 / -1; }
.toggle-label { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; font-size: 0.85rem; color: var(--text); }
.toggle-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: .2s; }
.toggle-slider:before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(18px); }

/* ===== FILTROS / BUSCA ===== */
.filters-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.search-input { flex: 1; min-width: 220px; }
.days-chip { font-size: 0.78rem; font-weight: 600; }
.days-chip.ok { color: var(--success); }
.days-chip.warn { color: var(--warning); }
.days-chip.bad { color: var(--danger); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); font-size: 0.85rem; }

/* ===== AGENDA ===== */
.agenda-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.agenda-date-nav { display: flex; align-items: center; gap: 8px; }
.agenda-date-label { font-size: 0.95rem; font-weight: 700; min-width: 190px; text-align: center; text-transform: capitalize; }
/* ---- Dia: resumo do dia + linhas de horario (Manha/Tarde/Noite), mesma logica visual da Semana ---- */
.day-summary-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.day-summary-stat { flex: 1 1 120px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; padding: 10px 12px; text-align: center; }
.day-summary-label { display: block; font-size: 0.62rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 700; margin-bottom: 4px; }
.day-summary-value { font-size: 1.15rem; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.day-summary-value.success { color: var(--success); }
.day-summary-value.warning { color: var(--warning); }
.day-summary-value.danger { color: var(--danger); }

.day-periodo-label { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 18px 0 8px; }
.day-periodo-label:first-of-type { margin-top: 0; }

.day-hora-row { display: flex; align-items: stretch; gap: 12px; border-radius: 10px; padding: 8px 10px; margin-bottom: 4px; }
.day-hora-row.row-even { background: var(--bg-secondary); }
.day-hora-row.row-odd { background: var(--card-bg); }
.day-hora-label { flex: none; width: 52px; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; font-weight: 700; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.day-hora-turmas { flex: 1; display: flex; flex-wrap: wrap; gap: 8px; }
.day-hora-turmas .week-turma-card { flex: 1 1 170px; max-width: 230px; }
.day-hora-empty { font-size: 0.76rem; color: var(--text-muted); font-style: italic; display: flex; align-items: center; }

.chk-btn { width: 26px; height: 26px; border-radius: 6px; border: 1px solid var(--border); background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--text-muted); }
.chk-btn.yes.active { background: var(--success-subtle); border-color: var(--success); color: var(--success); }
.chk-btn.no.active { background: var(--danger-subtle); border-color: var(--danger); color: var(--danger); }

/* Reaproveitadas pela lista de turnos de trabalho do professor (cadastro de professor). */
.slot-aluno-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 7px 10px; background: var(--bg-secondary); border-radius: 8px; font-size: 0.82rem; }
.slot-aluno-nome { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-empty-msg { font-size: 0.78rem; color: var(--text-muted); font-style: italic; padding: 6px 0; }

.agenda-view-switch { display: flex; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.av-btn { background: none; border: none; color: var(--text-secondary); font-family: var(--font); font-size: 0.82rem; font-weight: 600; padding: 6px 14px; border-radius: 7px; cursor: pointer; }
.av-btn.active { background: var(--primary); color: var(--primary-text); }

/* Abas soltas/independentes (visualmente separadas, cada uma com seu proprio contorno) - diferente
   do .agenda-view-switch (barra continua). Usado onde o pedido e "botoes separados", nao uma pilula unica. */
.tab-switch-detached { display: flex; gap: 10px; flex-wrap: wrap; }
.tab-btn { background: var(--surface); border: 1px solid var(--border); color: var(--text-secondary); font-family: var(--font); font-size: 0.85rem; font-weight: 600; padding: 9px 18px; border-radius: 9px; cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* Cards de horario disponivel (wizard "Nova Aula Experimental") - grid que colapsa pra 1-2 colunas
   sozinho em telas pequenas, pensado pra selecao por toque (sem tabela estourando no celular). */
.ne-horarios-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 14px; }
.ne-horario-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px 10px; cursor: pointer; background: var(--surface); text-align: center; transition: border-color .15s, background .15s, color .15s; }
.ne-horario-card:hover { border-color: var(--primary); }
.ne-horario-card.selected { border-color: var(--primary); background: var(--primary); color: var(--primary-text); }
.ne-horario-card .ne-hora { font-size: 1.05rem; font-weight: 700; }
.ne-horario-card .ne-prof { font-size: 0.78rem; margin-top: 3px; }
.ne-horario-card .ne-vagas { font-size: 0.7rem; margin-top: 5px; opacity: 0.85; }
.ne-resumo { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 0.85rem; }
.ne-resumo div { display: flex; justify-content: space-between; padding: 4px 0; }
.ne-resumo span:first-child { color: var(--text-secondary); }
.ne-resumo strong { font-weight: 600; }
.agenda-filter-select { max-width: 220px; margin-left: auto; }

.agenda-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 18px; padding: 12px 16px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 12px; }
.agenda-stat { display: flex; align-items: baseline; gap: 6px; font-size: 0.82rem; color: var(--text-secondary); }
.agenda-stat strong { font-size: 1.05rem; color: var(--text); }
.agenda-stat.vagas strong { color: var(--success); }
.agenda-stat.ocupadas strong { color: var(--primary-light); }

/* ---- Semana: grade unica estilo planilha (linhas = horario, colunas = dom..sab) ---- */
/* Um so CSS grid pras 14 linhas x 8 colunas (rotulo + 7 dias) - a altura de cada linha se
   ajusta sozinha pela celula mais alta daquele horario (comportamento nativo do CSS Grid),
   sem o efeito "escada" que a versao antiga (7 colunas independentes) tinha. */
.agenda-week-grid {
  display: grid;
  gap: 1px;
  background: var(--card-border);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  /* Em telas estreitas as 7 colunas nao cabem lado a lado sem espremer o texto do cabecalho ate
     sobrepor (ex: "DOMINGO"/"SEGUNDA" virando uma mancha ilegivel) - com minmax(86px, 1fr) nas
     colunas (ver app.js) a grade so encolhe ate esse minimo e o excedente rola horizontalmente,
     em vez de forcar o conteudo pra um espaco menor do que ele cabe. */
  overflow-x: auto;
}

.week-grid-header-cell {
  background: var(--card-bg);
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.week-grid-header-cell.today { background: var(--primary-subtle); }
.week-grid-corner { background: var(--card-bg); }
.week-grid-day-nome { font-size: 0.85rem; font-weight: 800; letter-spacing: .01em; text-transform: uppercase; color: var(--text); }
.week-grid-header-cell.today .week-grid-day-nome { color: var(--primary-light); }
.week-grid-day-num { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; }

.week-grid-time-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 8px 4px;
  font-variant-numeric: tabular-nums;
}

.week-grid-day-cell {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 34px;
}

/* Zebra sutil entre horarios, pra facilitar a leitura horizontal (tipo planilha). */
.week-grid-time-cell.row-even, .week-grid-day-cell.row-even { background: var(--bg-secondary); }
.week-grid-time-cell.row-odd, .week-grid-day-cell.row-odd { background: var(--card-bg); }

/* Card de turma (um professor, dentro de uma celula dia x horario) - verde/amarelo/vermelho conforme vagas. */
.week-turma-card {
  background: var(--surface);
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--text-muted);
  border-radius: 8px;
  padding: 7px 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 5px;
  transition: border-color .15s, background .15s;
}
.week-turma-card:hover { border-color: var(--primary); background: var(--surface-hover); }
.week-turma-card.disponivel { border-left-color: var(--success); }
.week-turma-card.poucas-vagas { border-left-color: var(--warning); }
.week-turma-card.lotado { border-left-color: var(--danger); }

.week-turma-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.week-turma-prof { font-size: 0.74rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.week-turma-occ { font-size: 0.65rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; background: var(--surface-hover); color: var(--text-secondary); white-space: nowrap; flex: none; }
.week-turma-occ.disponivel { background: var(--success-subtle); color: var(--success); }
.week-turma-occ.poucas-vagas { background: var(--warning-subtle); color: var(--warning); }
.week-turma-occ.lotado { background: var(--danger-subtle); color: var(--danger); }

.week-turma-vagas { font-size: 0.68rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-turma-vagas.disponivel { color: var(--success); }
.week-turma-vagas.poucas-vagas { color: var(--warning); }
.week-turma-vagas.lotado { color: var(--danger); }

/* ---- Mes ---- */
.agenda-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.month-day-head { text-align: center; font-size: 0.7rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; padding-bottom: 6px; }
.month-day-cell { min-height: 78px; background: var(--card-bg); border: 1px solid var(--card-border); border-radius: 10px; padding: 8px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; }
.month-day-cell:hover { border-color: var(--primary); }
.month-day-cell.outside { opacity: 0.35; }
.month-day-cell.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.month-day-num { font-size: 0.82rem; font-weight: 700; }
.month-day-summary { font-size: 0.68rem; color: var(--text-muted); line-height: 1.4; }
.month-day-summary .vagas-livres { color: var(--success); font-weight: 600; }

/* ===== TOAST (mensagem de confirmacao) ===== */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  border-radius: 12px;
  background: var(--card-bg);
  border: 1px solid var(--success);
  box-shadow: 0 0 0 1px var(--success-subtle), var(--shadow-lg);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  pointer-events: auto;
  animation: toast-in .25s ease-out;
  max-width: 340px;
}
.toast.hide { animation: toast-out .2s ease-in forwards; }
.toast-icon {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--success-subtle); color: var(--success);
  display: flex; align-items: center; justify-content: center;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(24px); } }
@media (prefers-reduced-motion: reduce) {
  .toast, .toast.hide { animation: none; }
}

/* ===== MODAL ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: var(--modal-overlay); z-index: 1000; align-items: center; justify-content: center; padding: 20px; }
.modal-overlay.show { display: flex; }
.modal {
  position: relative;
  overflow: hidden;
  background: var(--modal-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 28px;
  width: 100%;
  max-width: 460px;
  box-shadow: 0 0 0 1px var(--primary-subtle), var(--shadow-lg);
}
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #0b6b86);
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.01em; margin: 0; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.3rem; cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { color: var(--danger); background: var(--danger-subtle); }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }

.modal .form-control { padding: 11px 14px; border-radius: 10px; }
.modal .btn-primary {
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  box-shadow: 0 8px 20px var(--primary-subtle);
}
.modal .btn-primary:hover { filter: brightness(1.06); }
.modal .btn-danger {
  border-radius: 10px;
  background: linear-gradient(135deg, var(--danger), #b91c1c);
  box-shadow: 0 8px 20px var(--danger-subtle);
}
.modal .btn-danger:hover { filter: brightness(1.06); }

.confirm-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--danger-subtle);
  color: var(--danger);
  border: 1px solid var(--danger-subtle);
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.btn-icon:hover { border-color: var(--primary); color: var(--primary-light); }
.btn-icon.btn-icon-danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-subtle); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Botao de abrir o menu e fundo escurecido do drawer mobile - escondidos por padrao (so aparecem
   dentro do media query abaixo, quando a sidebar fixa vira um menu gaveta). */
.sidebar-toggle { display: none; background: none; border: none; color: var(--text); padding: 6px; margin-right: 8px; cursor: pointer; flex: none; align-items: center; justify-content: center; }
.sidebar-toggle svg { width: 22px; height: 22px; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 199; }
.sidebar-backdrop.show { display: block; }

@media (max-width: 860px) {
  .sidebar-toggle { display: flex; }
  /* Sem menu lateral visivel e sem esse botao, a recepcao ficava presa na primeira tela no celular -
     agora a sidebar vira uma gaveta (fora do fluxo, sobrepondo o conteudo). Fica display:none ate abrir
     (mesmo padrao ja usado pelos modais - .modal-overlay tambem so ganha display quando .show e
     adicionada), em vez de ficar sempre presente e so deslizar via left/transform. */
  .sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 200;
    box-shadow: var(--shadow);
  }
  .sidebar.open { display: flex; }
  .page-content { padding: 18px; }
  /* Nome completo do usuario (ex: "Renato Professor") nao cabe ao lado do titulo da pagina + botao
     Sair numa tela de celular - sem isso o texto quebra em varias linhas e estoura a altura fixa da
     topbar, sobrepondo o titulo. O avatar com as iniciais ja identifica o usuario e abre "Meu perfil"
     com o nome completo, entao some so o nome, mantendo o botao clicavel. */
  .user-chip span { display: none; }
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 1100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: border-color .15s, color .15s;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary-light); }
.theme-toggle svg { width: 18px; height: 18px; }
