:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar: #0f172a;
  --sidebar-2: #1e293b;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 12px 34px rgba(15, 23, 42, .07);
  --radius: 18px;
}

.dark {
  color-scheme: dark;
  --bg: #020617;
  --surface: #0f172a;
  --surface-2: #111c30;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --line: #263449;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --sidebar: #020617;
  --sidebar-2: #0f172a;
  --shadow: 0 18px 40px rgba(0, 0, 0, .22);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font: 14px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.35rem, 2.5vw, 1.85rem); line-height: 1.15; }
h2 { font-size: 1.05rem; line-height: 1.3; }
.muted, small { color: var(--muted); }
.block { display: block; margin-top: 3px; }
.grow { flex: 1; }
.span-2 { grid-column: span 2; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.button {
  display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 11px; padding: 9px 14px; cursor: pointer;
  font-weight: 750; transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--primary); }
.button-primary:hover { background: var(--primary-dark); }
.button-secondary { color: var(--text); background: var(--surface); border-color: var(--line); }
.button-success { color: #fff; background: var(--success); }
.button-warning { color: #fff; background: var(--warning); }
.button-danger { color: #fff; background: var(--danger); }
.button-wide { width: 100%; }
.button-small { min-height: 32px; padding: 6px 10px; font-size: .78rem; }
.icon-button {
  display: inline-grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; color: var(--text); background: var(--surface);
  cursor: pointer; font-weight: 800;
}
.icon-button:hover { border-color: var(--primary); color: var(--primary); }
.icon-button.danger { color: var(--danger); }
.icon-button.success { color: var(--success); }
.link-button { border: 0; color: var(--primary); background: transparent; cursor: pointer; font-weight: 700; }

input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px;
  color: var(--text); outline: 0; background: var(--surface);
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
textarea { resize: vertical; }
label { display: grid; align-content: start; gap: 6px; color: var(--text); font-size: .82rem; font-weight: 700; }
label.check { display: flex; align-items: center; }
label.check input { width: auto; }
fieldset { min-width: 0; border: 1px solid var(--line); border-radius: 12px; }
legend { color: var(--muted); font-size: .78rem; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr)) auto; align-items: end; gap: 12px; }
.form-actions { display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 10px; margin-top: 5px; }
.stack { display: grid; gap: 16px; }
.password-field { display: flex; gap: 7px; }
.password-field input { flex: 1; }
.checkbox-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; padding: 12px; }
.checkbox-grid label { display: flex; align-items: start; font-weight: 550; }
.checkbox-grid input { width: auto; margin-top: 3px; }
.checkbox-grid.tall { max-height: 300px; overflow: auto; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed; z-index: 50; inset: 0 auto 0 0; display: flex; width: 288px; flex-direction: column;
  padding: 18px; color: #e2e8f0; background: linear-gradient(165deg, var(--sidebar), var(--sidebar-2));
  box-shadow: 12px 0 40px rgba(2, 6, 23, .15);
}
.sidebar-brand { display: flex; min-height: 58px; align-items: center; gap: 11px; margin-bottom: 22px; }
.sidebar-brand > div:nth-child(2) { min-width: 0; display: grid; }
.sidebar-brand strong { font-size: 1.15rem; letter-spacing: .05em; }
.sidebar-brand small { overflow: hidden; color: #94a3b8; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-close { display: none; margin-left: auto; color: #fff; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }
.sidebar-nav { display: grid; flex: 1; align-content: start; gap: 4px; overflow: auto; }
.sidebar-nav a, .sidebar-footer a {
  display: flex; min-height: 44px; align-items: center; gap: 11px; border-radius: 11px;
  padding: 9px 11px; color: #cbd5e1; font-weight: 650; transition: .18s ease;
}
.sidebar-nav a:hover, .sidebar-nav a.active { color: #fff; background: var(--primary); transform: translateX(2px); }
.sidebar-footer { display: grid; gap: 7px; border-top: 1px solid rgba(148,163,184,.15); padding-top: 12px; }
.sidebar-footer small { padding: 0 11px; color: #64748b; }
.sidebar-install { border: 1px solid rgba(255,255,255,.16); border-radius: 10px; padding: 9px; color: #fff; background: rgba(255,255,255,.06); cursor: pointer; text-align: left; }
.workspace { display: flex; min-height: 100vh; margin-left: 288px; flex-direction: column; }
.topbar {
  position: sticky; z-index: 30; top: 0; display: flex; min-height: 78px; align-items: center; gap: 14px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  padding: 12px clamp(18px, 3vw, 34px); background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(18px);
}
.page-heading { flex: 1; }
.page-heading h1 { margin: 0; }
.page-heading p { margin: 4px 0 0; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 9px; border-left: 1px solid var(--line); padding-left: 13px; }
.user-chip > span { display: grid; width: 38px; height: 38px; place-items: center; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--primary), var(--purple)); font-weight: 800; }
.user-chip div { display: grid; }
.user-chip small { font-size: .72rem; }
.menu-button { display: none; }
.content { width: 100%; max-width: 1700px; flex: 1; margin: 0 auto; padding: clamp(18px, 3vw, 32px); }
.app-footer { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 18px 32px; color: var(--muted); font-size: .76rem; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; background: var(--surface); box-shadow: var(--shadow); }
.card-header, .section-heading, .detail-actions, .toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.card-header h2, .section-heading h2 { margin: 0; }
.section-heading { margin: 22px 0 14px; }
.toolbar { margin-bottom: 18px; }
.search-form { display: flex; align-items: center; gap: 8px; }
.search-form > input:not([type="hidden"]) { min-width: 220px; }
.search-form > span { margin-right: -34px; z-index: 1; color: var(--muted); }
.search-form > span + input { padding-left: 32px; }
.inline-filters, .row-actions, .card-actions, .detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.inline-filters input { width: 90px; }
.inline-filters select { width: 70px; }
.detail-actions { justify-content: flex-start; margin-bottom: 18px; }
.detail-actions form, .row-actions form, .card-actions form { display: inline-flex; margin: 0; }
.filter-card { margin-bottom: 18px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; margin-bottom: 20px; }
.stats-grid.compact { margin-bottom: 18px; }
.stat-card {
  position: relative; min-height: 128px; overflow: hidden; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; color: #fff; box-shadow: var(--shadow);
}
.stat-card p { margin: 0 0 9px; color: rgba(255,255,255,.82); font-weight: 650; }
.stat-card strong { display: block; font-size: clamp(1.35rem, 2.5vw, 1.8rem); line-height: 1.05; }
.stat-card small { display: block; margin-top: 8px; color: rgba(255,255,255,.72); }
.tone-blue { background: linear-gradient(145deg, #2563eb, #1d4ed8); }
.tone-purple { background: linear-gradient(145deg, #8b5cf6, #6d28d9); }
.tone-green { background: linear-gradient(145deg, #10b981, #047857); }
.tone-orange { background: linear-gradient(145deg, #f59e0b, #c2410c); }
.tone-red { background: linear-gradient(145deg, #ef4444, #b91c1c); }
.stat-spark { position: absolute; right: -18px; bottom: -32px; width: 110px; height: 110px; border: 18px solid rgba(255,255,255,.12); border-radius: 50%; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; margin-bottom: 20px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin: 18px 0; }
.mini-stat { border: 1px solid var(--line); border-radius: 13px; padding: 13px; background: var(--surface-2); }
.mini-stat span, .mini-stat strong { display: block; }
.mini-stat span { color: var(--muted); font-size: .76rem; }
.mini-stat strong { margin-top: 4px; font-size: 1.02rem; }
.mini-stat.green { border-color: color-mix(in srgb, var(--success) 30%, var(--line)); }
.mini-stat.amber { border-color: color-mix(in srgb, var(--warning) 30%, var(--line)); }
.mini-stat.red { border-color: color-mix(in srgb, var(--danger) 30%, var(--line)); }
.list { display: grid; }
.list-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 11px; border-top: 1px solid var(--line); padding: 11px 0; color: var(--text); }
.list-row small { display: block; }
.list-value { display: grid; justify-items: end; gap: 4px; font-weight: 750; }
.avatar { display: inline-grid; width: 36px; height: 36px; flex: 0 0 36px; place-items: center; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--primary), var(--purple)); font-weight: 800; }
.notice-list, .notice-grid { display: grid; gap: 12px; }
.notice { border-left: 3px solid var(--primary); padding: 10px 0 10px 12px; }
.notice > div { display: flex; align-items: center; justify-content: space-between; }
.notice strong { display: block; margin: 7px 0 3px; }
.notice p { margin: 0; color: var(--muted); font-size: .85rem; }
.notice-urgente { border-color: var(--danger) !important; }
.quick-actions { display: flex; align-items: center; justify-content: space-between; gap: 20px; background: linear-gradient(130deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface)); }
.quick-grid { display: grid; grid-template-columns: repeat(4, minmax(105px,1fr)); gap: 9px; }
.quick-grid a { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; color: var(--text); background: var(--surface); font-weight: 750; }
.quick-grid a:first-letter { color: var(--primary); }

.table-card { padding: 0; overflow: hidden; }
.table-card > .card-header { padding: 20px 20px 0; }
.table-wrap { width: 100%; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th { padding: 12px 14px; color: var(--muted); background: var(--surface-2); font-size: .72rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { border-top: 1px solid var(--line); padding: 12px 14px; vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 3%, transparent); }
.person-cell { display: flex; min-width: 220px; align-items: center; gap: 10px; }
.person-cell > span:last-child { display: grid; }
.actions-col { width: 150px; }
.grade-table input { min-width: 96px; }
.sticky-form-actions { position: sticky; z-index: 5; bottom: 0; display: flex; align-items: center; justify-content: space-between; gap: 14px; border-top: 1px solid var(--line); padding: 14px 18px; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px); }
.pagination { display: flex; justify-content: center; gap: 6px; border-top: 1px solid var(--line); padding: 14px; }
.pagination a, .pagination span { display: grid; min-width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--surface); }
.pagination a.active { border-color: var(--primary); color: #fff; background: var(--primary); }
.empty-state { display: grid; min-height: 170px; place-items: center; align-content: center; padding: 24px; color: var(--muted); text-align: center; }
.empty-state > span { display: grid; width: 58px; height: 58px; place-items: center; border-radius: 50%; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, transparent); font-size: 1.5rem; font-weight: 800; }
.empty-state p { margin: 10px 0 0; }

.badge { display: inline-flex; width: max-content; align-items: center; border-radius: 999px; padding: 4px 8px; color: var(--muted); background: var(--surface-2); font-size: .68rem; font-weight: 850; white-space: nowrap; }
.badge-ativo, .badge-pago, .badge-aprovado, .badge-geral { color: #047857; background: #d1fae5; }
.badge-pendente, .badge-recuperacao, .badge-evento { color: #a16207; background: #fef3c7; }
.badge-atrasado, .badge-reprovado, .badge-urgente, .badge-inativo { color: #b91c1c; background: #fee2e2; }
.badge-concluido, .badge-formado, .badge-turma { color: #1d4ed8; background: #dbeafe; }
.badge-cursando { color: #6d28d9; background: #ede9fe; }
.dark .badge-ativo, .dark .badge-pago, .dark .badge-aprovado, .dark .badge-geral { color: #6ee7b7; background: #064e3b; }
.dark .badge-pendente, .dark .badge-recuperacao, .dark .badge-evento { color: #fcd34d; background: #78350f; }
.dark .badge-atrasado, .dark .badge-reprovado, .dark .badge-urgente, .dark .badge-inativo { color: #fca5a5; background: #7f1d1d; }
.dark .badge-concluido, .dark .badge-formado, .dark .badge-turma { color: #93c5fd; background: #1e3a8a; }
.dark .badge-cursando { color: #c4b5fd; background: #4c1d95; }

.alert { position: relative; margin: 0 0 16px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 42px 12px 14px; background: var(--surface); }
.alert button { position: absolute; top: 7px; right: 8px; border: 0; color: inherit; background: transparent; cursor: pointer; font-size: 1.2rem; }
.alert-success { border-color: color-mix(in srgb, var(--success) 35%, var(--line)); color: var(--success); }
.alert-error { border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); color: var(--danger); }
.alert-warning { border-color: color-mix(in srgb, var(--warning) 35%, var(--line)); color: var(--warning); }
.alert-info { border-color: color-mix(in srgb, var(--primary) 35%, var(--line)); color: var(--primary); }

.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.entity-card { display: grid; gap: 11px; }
.entity-card h2, .entity-card p { margin: 0; }
.entity-card p { min-height: 42px; color: var(--muted); }
.entity-card-head { display: flex; align-items: center; justify-content: space-between; }
.entity-icon { display: grid; width: 46px; height: 46px; place-items: center; border-radius: 14px; color: #fff; background: linear-gradient(145deg, var(--primary), var(--purple)); font-size: 1.25rem; }
.entity-meta { display: grid; grid-template-columns: repeat(3,1fr); gap: 7px; }
.entity-meta span { display: grid; border-radius: 10px; padding: 8px; color: var(--muted); background: var(--surface-2); font-size: .7rem; text-align: center; }
.entity-meta strong { color: var(--text); font-size: .9rem; }
.money-row { display: flex; justify-content: space-between; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; font-size: .72rem; }
.money-row span, .money-row strong { display: block; }
.card-actions { border-top: 1px solid var(--line); padding-top: 11px; }
.teacher-card { display: flex; gap: 14px; }
.profile-avatar { display: grid; width: 88px; height: 88px; flex: 0 0 88px; place-items: center; overflow: hidden; border-radius: 24px; color: #fff; background: linear-gradient(145deg, var(--primary), var(--purple)); font-size: 2rem; font-weight: 850; }
.profile-avatar.small { width: 54px; height: 54px; flex-basis: 54px; border-radius: 16px; font-size: 1.2rem; }
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.teacher-main { display: grid; flex: 1; gap: 10px; }
.teacher-main h2 { margin: 5px 0 3px; }
.teacher-main p { margin: 0; color: var(--muted); }
.teacher-main dl { display: grid; gap: 7px; margin: 0; }
.teacher-main dt { color: var(--muted); font-size: .7rem; }
.teacher-main dd { margin: 0; }
.notice-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
.notice-card { display: grid; align-content: start; gap: 9px; border-top: 3px solid var(--primary); }
.notice-card h2, .notice-card p { margin: 0; }
.notice-card p { color: var(--muted); }

.modal {
  width: min(540px, calc(100vw - 28px)); max-height: calc(100vh - 28px); margin: auto;
  border: 1px solid var(--line); border-radius: 20px; padding: 0; color: var(--text);
  background: var(--surface); box-shadow: 0 30px 80px rgba(2,6,23,.35);
}
.modal::backdrop { background: rgba(2,6,23,.65); backdrop-filter: blur(4px); }
.modal.modal-lg { width: min(780px, calc(100vw - 28px)); }
.modal-header { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 17px 20px; background: var(--surface); }
.modal-header h2 { margin: 0; }
.modal-body { padding: 20px; }

.profile-grid { display: grid; grid-template-columns: minmax(260px,1fr) minmax(0,2fr); gap: 18px; }
.profile-card { display: grid; justify-items: center; align-content: start; text-align: center; }
.profile-card h2 { margin: 14px 0 3px; }
.profile-card > p { color: var(--muted); }
.profile-card dl { display: grid; width: 100%; gap: 10px; margin: 20px 0 0; text-align: left; }
.profile-card dl div, .detail-list div { border-top: 1px solid var(--line); padding-top: 9px; }
dt { color: var(--muted); font-size: .72rem; font-weight: 700; }
dd { margin: 3px 0 0; font-weight: 650; }
.tabs { display: flex; gap: 6px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; border-radius: 10px; padding: 9px 12px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 750; white-space: nowrap; }
.tabs button.active { color: #fff; background: var(--primary); }
.detail-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; margin: 0; }
.progress { height: 8px; overflow: hidden; border-radius: 999px; background: var(--line); }
.progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--primary),#60a5fa); }
.progress.large { height: 12px; }

.attendance-list { display: grid; gap: 9px; margin: 16px 0; }
.attendance-row { display: grid; grid-template-columns: auto minmax(180px,1fr) auto minmax(180px,.8fr); align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 15px; padding: 11px; background: var(--surface); transition: .18s ease; }
.attendance-row.is-present { border-left: 4px solid var(--success); }
.attendance-row.is-absent { border-left: 4px solid var(--danger); }
.attendance-person { display: grid; }
.presence-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.presence-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.presence-toggle span { position: relative; width: 43px; height: 24px; border-radius: 99px; background: var(--danger); transition: .2s; }
.presence-toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.presence-toggle input:checked + span { background: var(--success); }
.presence-toggle input:checked + span::after { transform: translateX(19px); }
.is-present .justification { opacity: .45; }

.settings-tabs { margin-bottom: 16px; }
.narrow-card { max-width: 560px; }
.system-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin: 18px 0; }
.system-grid div { display: grid; border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--surface-2); }
.system-grid span { color: var(--muted); font-size: .72rem; }
.system-grid strong { margin-top: 4px; }
.manual-hero { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; background: linear-gradient(130deg,color-mix(in srgb,var(--primary) 10%,var(--surface)),var(--surface)); }
.manual-hero p { margin-bottom: 0; color: var(--muted); }
.accordion { display: grid; gap: 10px; }
.accordion details { padding: 0; }
.accordion summary { display: flex; align-items: center; justify-content: space-between; padding: 17px 19px; cursor: pointer; list-style: none; font-weight: 800; }
.accordion summary::-webkit-details-marker { display: none; }
.accordion details > p { border-top: 1px solid var(--line); margin: 0; padding: 17px 19px; color: var(--muted); }
.accordion details[open] summary b { transform: rotate(45deg); }
.support-card { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-top: 18px; }

.login-body { min-height: 100vh; background: #08111f; }
.login-shell { display: grid; min-height: 100vh; grid-template-columns: minmax(0,1.2fr) minmax(420px,.8fr); }
.login-brand { display: grid; align-content: center; padding: clamp(32px,8vw,110px); color: #fff; background: radial-gradient(circle at 18% 15%,rgba(59,130,246,.36),transparent 35%),linear-gradient(145deg,#020617,#172554); }
.login-brand h1 { max-width: 730px; margin: 18px 0; font-size: clamp(2.2rem,5vw,4.4rem); letter-spacing: -.04em; }
.login-brand > p:not(.eyebrow) { max-width: 620px; color: #cbd5e1; font-size: 1.05rem; }
.brand-mark { display: grid; width: 70px; height: 70px; place-items: center; border: 1px solid rgba(255,255,255,.24); border-radius: 21px; background: rgba(255,255,255,.08); font-size: 1.35rem; font-weight: 900; letter-spacing: .08em; }
.login-features { display: flex; flex-wrap: wrap; gap: 17px; margin-top: 23px; color: #bfdbfe; font-weight: 650; }
.login-card { display: grid; width: min(100%,520px); align-content: center; justify-self: center; padding: clamp(28px,6vw,70px); color: var(--text); background: var(--surface); }
.login-card h2 { margin: 4px 0; font-size: 1.45rem; }
.login-card .muted { margin-bottom: 24px; }
.login-card .theme-toggle { margin-top: 18px; justify-self: center; }
.school-logo { display: grid; width: 68px; height: 68px; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; color: #fff; background: linear-gradient(145deg,var(--primary),var(--purple)); font-size: 1.2rem; font-weight: 900; }
.school-logo img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.school-logo-small { width: 44px; height: 44px; flex: 0 0 44px; border-radius: 13px; }

.portal-body { min-height: 100vh; padding-bottom: 78px; background: radial-gradient(circle at 50% -10%,color-mix(in srgb,var(--primary) 16%,transparent),transparent 35%),var(--bg); }
.portal-header { position: sticky; z-index: 20; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); padding: 12px max(16px,calc((100vw - 1180px)/2)); background: color-mix(in srgb,var(--surface) 90%,transparent); backdrop-filter: blur(18px); }
.portal-brand { display: flex; align-items: center; gap: 10px; }
.portal-brand img, .portal-brand > span { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 11px; object-fit: contain; background: #fff; color: var(--primary); font-weight: 900; }
.portal-brand div { display: grid; }
.portal-brand small { font-size: .72rem; }
.portal-container { width: min(1180px,calc(100% - 28px)); margin: 24px auto; }
.portal-student-card { display: flex; align-items: center; gap: 18px; border: 1px solid color-mix(in srgb,var(--primary) 24%,var(--line)); border-radius: 24px; padding: clamp(20px,4vw,34px); color: #fff; background: linear-gradient(135deg,#1d4ed8,#312e81); box-shadow: 0 25px 60px rgba(37,99,235,.18); }
.portal-student-card h1 { margin: 5px 0; }
.portal-student-card p { margin-bottom: 8px; color: #dbeafe; }
.portal-student-card .eyebrow { color: #bfdbfe; }
.portal-avatar { width: 96px; height: 96px; flex-basis: 96px; border: 4px solid rgba(255,255,255,.3); }
.portal-tabs { margin: 18px 0; border: 1px solid var(--line); border-radius: 15px; padding: 6px; background: var(--surface); box-shadow: var(--shadow); }
.tab-count { display: inline-grid; min-width: 19px; height: 19px; place-items: center; border-radius: 99px; color: var(--primary); background: #fff; font-size: .66rem; }
.portal-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; }
.subject-progress, .history-list { display: grid; max-height: 430px; gap: 13px; overflow: auto; }
.subject-progress > div { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.subject-progress span { display: grid; }
.subject-progress .progress { grid-column: 1/-1; }
.history-list > div { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; border-bottom: 1px solid var(--line); padding-bottom: 10px; }
.history-list span:nth-child(2) { display: grid; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; }
.status-dot.green { background: var(--success); }.status-dot.red { background: var(--danger); }
.portal-contact { position: fixed; z-index: 25; right: 16px; bottom: 16px; border-radius: 999px; padding: 13px 19px; color: #fff; background: #16a34a; box-shadow: 0 12px 30px rgba(22,163,74,.35); font-weight: 800; }
.not-found { display: grid; justify-items: center; }

.diagnostic-body { min-height: 100vh; background: linear-gradient(145deg,var(--bg),color-mix(in srgb,var(--primary) 10%,var(--bg))); }
.diagnostic-shell { width: min(720px,calc(100% - 28px)); margin: 7vh auto; }
.check-list { display: grid; gap: 8px; margin: 22px 0; }
.check-list > div { display: flex; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 12px; padding: 11px; }
.check-list > div > span { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: #fff; font-weight: 900; }
.check-list .ok > span { background: var(--success); }.check-list .fail > span { background: var(--danger); }
.check-list div div { display: grid; }

.finance-command-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  margin-bottom: 14px; padding: 17px 19px;
  background: linear-gradient(120deg, color-mix(in srgb, var(--primary) 8%, var(--surface)), var(--surface));
}
.finance-command-bar h2, .finance-command-bar p { margin-bottom: 0; }
.finance-command-bar > div:first-child > p:last-child { margin-top: 4px; color: var(--muted); font-size: .8rem; }
.finance-command-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.finance-kpis { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 11px; margin-bottom: 14px; }
.finance-kpi {
  position: relative; display: grid; min-height: 102px; align-content: center; overflow: hidden;
  border: 1px solid var(--line); border-radius: 15px; padding: 15px 16px 15px 19px;
  background: var(--surface); box-shadow: var(--shadow);
}
.finance-kpi::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--primary); }
.finance-kpi > span { color: var(--muted); font-size: .75rem; font-weight: 750; }
.finance-kpi > strong { margin: 3px 0; font-size: clamp(1.15rem,2vw,1.45rem); line-height: 1.15; }
.finance-kpi > small { font-size: .7rem; }
.finance-kpi.kpi-green::before { background: var(--success); }
.finance-kpi.kpi-blue::before { background: var(--primary); }
.finance-kpi.kpi-red::before { background: var(--danger); }
.finance-kpi.kpi-amber::before { background: var(--warning); }
.finance-overview-grid { display: grid; grid-template-columns: minmax(0,2fr) minmax(250px,.8fr); gap: 14px; margin-bottom: 14px; }
.finance-trend, .finance-status-card { min-height: 265px; }
.finance-legend { display: flex; flex-wrap: wrap; gap: 12px; color: var(--muted); font-size: .7rem; font-weight: 700; }
.finance-legend span::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; }
.legend-paid::before { background: var(--success); }.legend-open::before { background: var(--warning); }
.finance-bars { display: flex; height: 175px; align-items: end; justify-content: space-around; gap: 12px; margin-top: 12px; }
.finance-bar-column { display: grid; height: 100%; flex: 1; grid-template-rows: 1fr auto; gap: 7px; justify-items: center; }
.finance-bar-stack { display: flex; width: min(56px,100%); height: 100%; align-items: end; justify-content: center; gap: 4px; border-bottom: 1px solid var(--line); }
.finance-bar-stack span { width: min(18px,42%); min-height: 2px; border-radius: 5px 5px 2px 2px; transition: height .2s ease; }
.bar-paid { background: linear-gradient(#34d399,var(--success)); }.bar-open { background: linear-gradient(#fbbf24,var(--warning)); }
.finance-status-card { display: grid; align-content: start; gap: 17px; }
.finance-status-card h2 { margin-bottom: 0; }
.finance-status-list { display: grid; gap: 7px; }
.finance-status-list a { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 11px; padding: 9px 10px; color: var(--text); background: var(--surface-2); }
.finance-status-list a:hover { border-color: var(--primary); }
.status-dot.status-pago { background: var(--success); }.status-dot.status-pendente { background: var(--warning); }.status-dot.status-atrasado { background: var(--danger); }.status-dot.status-cancelado { background: var(--muted); }
.finance-controls { position: sticky; z-index: 12; top: 88px; margin-bottom: 14px; padding: 16px 18px; box-shadow: 0 12px 32px rgba(15,23,42,.11); }
.finance-controls-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 13px; }
.finance-controls-head h2 { margin-bottom: 0; }
.filter-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.filter-chips span { border: 1px solid color-mix(in srgb,var(--primary) 20%,var(--line)); border-radius: 999px; padding: 4px 8px; color: var(--primary); background: color-mix(in srgb,var(--primary) 7%,var(--surface)); font-size: .66rem; font-weight: 750; }
.finance-filter-grid { display: grid; grid-template-columns: minmax(220px,1.8fr) repeat(4,minmax(112px,1fr)); gap: 9px; align-items: end; }
.finance-filter-grid label { font-size: .72rem; }
.finance-filter-grid input, .finance-filter-grid select { min-height: 39px; padding: 8px 9px; }
.finance-filter-grid .button { min-height: 38px; }
.finance-status-tabs { display: flex; gap: 6px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.finance-status-tabs a { display: inline-flex; min-height: 34px; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; color: var(--muted); background: var(--surface-2); font-size: .73rem; font-weight: 750; white-space: nowrap; }
.finance-status-tabs a b { display: grid; min-width: 19px; height: 19px; place-items: center; border-radius: 99px; color: var(--text); background: var(--surface); font-size: .65rem; }
.finance-status-tabs a.active { border-color: var(--primary); color: #fff; background: var(--primary); }
.finance-status-tabs a.active b { color: var(--primary); background: #fff; }
.finance-view-switch { display: flex; width: fit-content; gap: 5px; margin-top: 10px; border: 1px solid var(--line); border-radius: 11px; padding: 4px; background: var(--surface-2); }
.finance-view-switch a { display: inline-flex; min-height: 32px; align-items: center; gap: 7px; border-radius: 8px; padding: 6px 11px; color: var(--muted); font-size: .73rem; font-weight: 800; }
.finance-view-switch a b { display: grid; min-width: 19px; height: 19px; place-items: center; border-radius: 99px; background: var(--surface); font-size: .65rem; }
.finance-view-switch a.active { color: #fff; background: var(--primary); box-shadow: 0 5px 14px color-mix(in srgb,var(--primary) 25%,transparent); }
.finance-view-switch a.active b { color: var(--primary); }
.finance-table-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; }
.finance-table-heading h2, .finance-table-heading p { margin-bottom: 0; }
.finance-table-heading > span { color: var(--muted); font-size: .76rem; }
.finance-table-heading > span strong { color: var(--text); }
.finance-table .person-cell { min-width: 190px; }
.finance-table td { padding-top: 10px; padding-bottom: 10px; }
.finance-table td > small { font-size: .68rem; }
.text-danger { color: var(--danger); }
.form-section { margin: 0; padding: 14px; background: color-mix(in srgb,var(--surface-2) 75%,var(--surface)); }
.form-section legend { padding: 0 6px; color: var(--primary); letter-spacing: .04em; text-transform: uppercase; }
.batch-filter-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; margin-bottom: 10px; }
.batch-selection-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--surface); }
.batch-selection-tools > span { color: var(--muted); font-size: .72rem; font-weight: 700; }
.batch-selection-tools > div { display: flex; gap: 8px; }
.batch-students { margin-top: 10px; padding: 8px; background: var(--surface); }
.batch-students label { border-radius: 8px; padding: 6px; }
.batch-students label:hover { background: var(--surface-2); }
.batch-students label span { display: grid; }
.batch-students label small { font-size: .66rem; }
.student-finance-list { display: grid; gap: 10px; }
.student-finance-list-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; padding: 3px 3px 6px; }
.student-finance-list-heading h2 { margin-bottom: 0; font-size: 1.08rem; }
.student-finance-list-heading > p { max-width: 440px; margin: 0; color: var(--muted); font-size: .76rem; text-align: right; }
.student-finance-card { overflow: clip; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
.student-finance-card[open] { border-color: color-mix(in srgb,var(--primary) 32%,var(--line)); }
.student-finance-card > summary { display: grid; grid-template-columns: minmax(230px,1.65fr) repeat(3,minmax(120px,.75fr)) auto; align-items: center; gap: 14px; min-height: 78px; padding: 12px 15px; cursor: pointer; list-style: none; }
.student-finance-card > summary::-webkit-details-marker { display: none; }
.student-finance-card > summary:hover { background: color-mix(in srgb,var(--primary) 4%,var(--surface)); }
.student-finance-card > summary > span:not(.person-cell) { display: grid; }
.student-finance-card > summary small { color: var(--muted); font-size: .66rem; }
.student-finance-card > summary strong { margin-top: 2px; font-size: .83rem; }
.student-finance-open { border-radius: 9px; padding: 7px 9px; color: var(--primary); background: color-mix(in srgb,var(--primary) 9%,var(--surface)); font-size: .7rem; font-weight: 800; white-space: nowrap; }
.student-finance-card[open] .student-finance-open { color: var(--muted); background: var(--surface-2); }
.student-finance-card[open] .student-finance-open::before { content: "Fechar"; font-size: .7rem; }
.student-finance-card[open] .student-finance-open { font-size: 0; }
.student-finance-card-body { border-top: 1px solid var(--line); padding: 15px; background: color-mix(in srgb,var(--surface-2) 52%,var(--surface)); }
.student-finance-actions { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.student-finance-actions h3 { margin: 2px 0 0; font-size: .96rem; }
.student-finance-actions > div:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.button-disabled { cursor: not-allowed; opacity: .55; color: var(--muted); background: var(--surface-2); }
.student-finance-totals { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.student-finance-totals > div { display: grid; border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; background: var(--surface); }
.student-finance-totals span { color: var(--muted); font-size: .65rem; }
.student-finance-totals strong { margin-top: 2px; font-size: .88rem; }
.student-history-table { background: var(--surface); }
.student-history-table td { padding-top: 8px; padding-bottom: 8px; }

.sidebar-overlay { display: none; }
[hidden] { display: none !important; }

@media (max-width: 1180px) {
  .cards-grid, .notice-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .quick-actions { align-items: stretch; flex-direction: column; }
  .finance-filter-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .finance-search { grid-column: span 2; }
}

@media (max-width: 980px) {
  .sidebar { transform: translateX(-105%); transition: transform .22s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close, .menu-button { display: inline-grid; }
  .sidebar-overlay { position: fixed; z-index: 45; inset: 0; background: rgba(2,6,23,.62); }
  .sidebar-overlay.show { display: block; }
  .workspace { margin-left: 0; }
  .stats-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .filter-grid .button { grid-column: 1/-1; }
  .profile-grid { grid-template-columns: 1fr; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-card { min-height: 100vh; }
  .finance-kpis { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .finance-overview-grid { grid-template-columns: 1fr; }
  .finance-controls { top: 78px; }
}

@media (max-width: 720px) {
  .content { padding: 14px; }
  .topbar { min-height: 68px; padding: 10px 14px; }
  .page-heading p, .user-chip div { display: none; }
  .user-chip { border-left: 0; padding-left: 0; }
  .app-footer { padding: 16px; }
  .app-footer span:last-child { display: none; }
  .toolbar, .card-header, .section-heading, .manual-hero, .support-card { align-items: stretch; flex-direction: column; }
  .search-form { width: 100%; flex-wrap: wrap; }
  .search-form > input:not([type="hidden"]) { min-width: 0; flex: 1 1 190px; }
  .search-form select { flex: 1 1 135px; }
  .search-form .button { flex: 1; }
  .form-grid, .detail-list, .portal-grid { grid-template-columns: 1fr; }
  .form-grid > .span-2, .detail-list > .span-2 { grid-column: auto; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .cards-grid, .notice-grid { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .attendance-row { grid-template-columns: auto 1fr auto; }
  .attendance-row .justification { grid-column: 2/-1; }
  .system-grid { grid-template-columns: repeat(2,1fr); }
  .portal-header { padding: 10px 14px; }
  .portal-header .button { font-size: 0; }
  .portal-header .button::after { content: "Contato"; font-size: .8rem; }
  .portal-student-card { align-items: flex-start; }
  .portal-avatar { width: 64px; height: 64px; flex-basis: 64px; border-radius: 18px; font-size: 1.35rem; }
  .portal-student-card h1 { font-size: 1.25rem; }
  .portal-contact { right: 10px; bottom: 10px; left: 10px; text-align: center; }
  .sticky-form-actions { align-items: stretch; flex-direction: column; }
  .finance-command-bar, .finance-controls-head, .finance-table-heading, .student-finance-list-heading, .student-finance-actions { align-items: stretch; flex-direction: column; }
  .finance-command-actions { justify-content: stretch; }
  .finance-command-actions .button { flex: 1; }
  .finance-controls { position: static; }
  .filter-chips { justify-content: flex-start; }
  .finance-filter-grid { grid-template-columns: 1fr 1fr; }
  .finance-search { grid-column: 1/-1; }
  .finance-table-card .table-wrap { overflow: visible; }
  .finance-table, .finance-table tbody { display: block; }
  .finance-table thead { display: none; }
  .finance-table tbody { padding: 0 10px 10px; }
  .finance-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; padding: 12px; background: var(--surface); }
  .finance-table tbody tr:hover { background: var(--surface); }
  .finance-table td { display: grid; align-content: start; border: 0; padding: 0; }
  .finance-table td::before { content: attr(data-label); margin-bottom: 3px; color: var(--muted); font-size: .62rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
  .finance-table td[data-label="Aluno"], .finance-table td[data-label="Cobrança"] { grid-column: 1/-1; }
  .finance-table td[data-label="Ações"] { grid-column: 1/-1; }
  .finance-table td[data-label="Ações"] .row-actions { justify-content: flex-end; }
  .finance-table .person-cell { min-width: 0; }
  .student-finance-list-heading > p { max-width: none; text-align: left; }
  .student-finance-card > summary { grid-template-columns: 1fr 1fr; gap: 10px; }
  .student-finance-card > summary .person-cell { grid-column: 1/-1; }
  .student-finance-card > summary > span:nth-child(4) { display: none; }
  .student-finance-open { align-self: center; justify-self: end; }
  .student-finance-actions > div:last-child { justify-content: flex-start; }
  .student-finance-totals { grid-template-columns: 1fr 1fr; }
  .student-finance-card-body .table-wrap { overflow: visible; }
  .student-history-table, .student-history-table tbody { display: block; }
  .student-history-table thead { display: none; }
  .student-history-table tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; border: 1px solid var(--line); border-radius: 11px; margin-bottom: 8px; padding: 10px; }
  .student-history-table td { display: grid; border: 0; padding: 0; }
  .student-history-table td::before { content: attr(data-label); margin-bottom: 3px; color: var(--muted); font-size: .6rem; font-weight: 800; text-transform: uppercase; }
  .student-history-table td[data-label="Cobrança"] { grid-column: 1/-1; }
  .batch-filter-grid { grid-template-columns: 1fr; }
  .batch-selection-tools { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { min-height: 110px; padding: 15px; }
  .stat-card strong { font-size: 1.12rem; }
  .mini-stats { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-grid .button { grid-column: auto; }
  .quick-grid { grid-template-columns: 1fr 1fr; }
  .entity-meta { grid-template-columns: 1fr; }
  .teacher-card { flex-direction: column; }
  .system-grid { grid-template-columns: 1fr; }
  .portal-student-card { flex-direction: column; }
  .finance-kpis { grid-template-columns: 1fr; }
  .finance-filter-grid { grid-template-columns: 1fr; }
  .finance-search { grid-column: auto; }
  .finance-command-actions { flex-direction: column; }
  .finance-command-actions .button { width: 100%; }
  .finance-view-switch { width: 100%; }
  .finance-view-switch a { flex: 1; justify-content: center; }
  .student-finance-totals { grid-template-columns: 1fr; }
  .student-finance-actions > div:last-child { flex-direction: column; }
  .student-finance-actions .button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Referência visual oficial do SGE - aplicada a todas as abas administrativas */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #08142a;
  --muted: #64748b;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --sidebar: #111c31;
  --sidebar-2: #111c31;
  --success: #05a876;
  --warning: #f97316;
  --danger: #ef2f3c;
  --purple: #a855f7;
  --shadow: 0 1px 3px rgba(15, 23, 42, .10), 0 1px 2px rgba(15, 23, 42, .06);
  --radius: 12px;
}

.app-body { font-size: 12px; line-height: 1.4; }
.app-body h1 { font-size: 20px; letter-spacing: -.025em; }
.app-body h2 { font-size: 15px; }
.app-body h3 { font-size: 13px; }
.app-body .eyebrow { margin-bottom: 3px; font-size: 10px; letter-spacing: .05em; }
.app-body .button {
  min-height: 30px; border-radius: 5px; padding: 6px 12px;
  font-size: 11px; font-weight: 650; box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.app-body .button:hover { transform: none; filter: brightness(.98); }
.app-body .button-primary { background: #2563eb; }
.app-body .button-secondary { border-color: #dfe3e8; }
.app-body .button-danger { border-color: #fecaca; color: #ef2f3c; background: #fff; }
.app-body .icon-button {
  width: 30px; height: 30px; min-height: 30px; flex-basis: 30px;
  border-radius: 6px; font-size: 12px;
}
.app-body input,
.app-body select,
.app-body textarea {
  border-color: #dfe3e8; border-radius: 5px; padding: 7px 10px;
  font-size: 11px; background: #fff;
}
.app-body input,
.app-body select { min-height: 30px; }
.app-body label { gap: 3px; font-size: 10.5px; font-weight: 550; }
.app-body fieldset { border-radius: 8px; }
.app-body .form-grid { gap: 12px; }

.app-body .sidebar {
  width: 230px; padding: 0 12px 14px; color: #d9e2f0;
  background: #111c31; box-shadow: none;
}
.app-body .sidebar-brand {
  min-height: 73px; gap: 10px; margin: 0 -12px 19px;
  border-bottom: 1px solid rgba(148,163,184,.14); padding: 0 18px;
}
.brand-icon {
  display: grid; width: 32px; height: 32px; flex: 0 0 32px; place-items: center;
  border-radius: 9px; color: #fff; background: linear-gradient(145deg,#3b82f6,#2563eb);
  box-shadow: 0 6px 16px rgba(37,99,235,.28);
}
.brand-icon svg { width: 19px; height: 19px; }
.app-body .sidebar-brand strong { color: #fff; font-size: 14px; letter-spacing: .02em; }
.app-body .sidebar-brand small { color: #9db0cb; font-size: 8px; }
.app-body .sidebar-nav { gap: 3px; }
.app-body .sidebar-nav a,
.app-body .sidebar-footer a {
  min-height: 41px; gap: 11px; border-radius: 10px; padding: 8px 13px;
  color: #d9e2f0; font-size: 12px; font-weight: 600;
}
.app-body .sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.055); transform: none; }
.app-body .sidebar-nav a.active {
  color: #fff; background: linear-gradient(135deg,#3478ee,#2563eb);
  box-shadow: 0 7px 18px rgba(37,99,235,.32); transform: none;
}
.nav-icon { width: 17px; height: 17px; flex: 0 0 17px; color: #c3d0e1; }
.sidebar-nav a.active .nav-icon { color: #fff; }
.nav-chevron { display: none; margin-left: auto; color: #fff; font-size: 18px; font-weight: 400; line-height: 1; }
.sidebar-nav a.active .nav-chevron { display: block; }
.app-body .sidebar-footer {
  margin: 0 -12px; border-top-color: rgba(148,163,184,.14); padding: 12px 13px 0;
}
.app-body .sidebar-install { border-radius: 6px; padding: 8px 11px; font-size: 10px; }

.app-body .workspace { margin-left: 230px; }
.app-body .topbar {
  min-height: 53px; border-bottom: 1px solid #e5e7eb; padding: 0 27px;
  background: rgba(255,255,255,.97); backdrop-filter: blur(10px);
}
.app-body .page-heading h1 { font-size: 20px; }
.app-body .page-heading p { display: none; }
.topbar-icon {
  display: grid; width: 29px; height: 29px; place-items: center;
  border: 0; border-radius: 50%; color: #0f172a; background: transparent; cursor: pointer;
}
.topbar-icon:hover { background: #f1f5f9; }
.topbar-icon svg { width: 14px; height: 14px; }
.app-body .topbar-actions { gap: 10px; }
.app-body .user-chip { gap: 8px; border-left: 0; padding-left: 0; }
.app-body .user-chip > span {
  width: 29px; height: 29px; background: #2f6fea;
  box-shadow: none;
}
.app-body .user-chip > span svg { width: 14px; height: 14px; }
.app-body .user-chip strong { font-size: 11px; font-weight: 600; }
.app-body .user-chip small { font-size: 9px; line-height: 1.15; }
.app-body .content { max-width: none; padding: 26px; }
.app-body .app-footer { display: none; }

.app-body .card {
  border-color: #e5e7eb; border-radius: 12px; padding: 18px;
  box-shadow: var(--shadow);
}
.app-body .toolbar {
  margin-bottom: 18px; border: 1px solid #e5e7eb; border-radius: 12px;
  padding: 14px 18px; background: #fff; box-shadow: var(--shadow);
}
.app-body .stats-grid { gap: 18px; margin-bottom: 20px; }
.app-body .stat-card {
  min-height: 94px; border-radius: 12px; padding: 16px 18px;
  color: var(--text); background: #fff; box-shadow: var(--shadow);
}
.app-body .stat-card::after {
  content: ""; position: absolute; right: 18px; top: 19px; width: 43px; height: 43px;
  border-radius: 10px; background: currentColor; opacity: .09;
}
.app-body .stat-card p { margin-bottom: 7px; color: var(--muted); font-size: 10px; letter-spacing: .05em; text-transform: uppercase; }
.app-body .stat-card strong { color: var(--text); font-size: 22px; }
.app-body .stat-card small { margin-top: 4px; color: var(--muted); }
.app-body .stat-spark { display: none; }
.app-body .tone-blue { color: #2563eb; border-bottom: 3px solid #2563eb; }
.app-body .tone-purple { color: #a855f7; border-bottom: 3px solid #a855f7; }
.app-body .tone-green { color: #05a876; border-bottom: 3px solid #05a876; }
.app-body .tone-orange { color: #f97316; border-bottom: 3px solid #f97316; }
.app-body .tone-red { color: #ef2f3c; border-bottom: 3px solid #ef2f3c; }
.app-body .cards-grid { gap: 13px; }
.app-body .entity-card,
.app-body .teacher-card,
.app-body .notice-card { border-radius: 12px; }
.app-body .entity-icon,
.app-body .profile-avatar { border-radius: 10px; background: #dbeafe; color: #2563eb; }
.app-body .avatar {
  width: 40px; height: 40px; flex-basis: 40px; color: #2563eb;
  background: #dbeafe; font-size: 13px;
}
.app-body th { padding: 10px 12px; font-size: 9.5px; }
.app-body td { padding: 10px 12px; }
.app-body .badge { border-radius: 5px; padding: 3px 7px; font-size: 9px; }
.app-body .pagination { padding: 11px; }
.app-body .pagination a,
.app-body .pagination span { min-width: 30px; height: 30px; border-radius: 5px; }
.app-body .modal { border-radius: 12px; }
.app-body .modal-header { padding: 14px 18px; }
.app-body .modal-body { padding: 18px; }

/* Financeiro conforme a referência enviada */
.finance-reference-kpis {
  display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 19px;
  margin-bottom: 20px;
}
.finance-ref-kpi {
  position: relative; display: flex; min-height: 94px; align-items: center;
  justify-content: space-between; overflow: hidden; border: 1px solid #e9edf2;
  border-radius: 12px; padding: 15px 18px; background: #fff; box-shadow: var(--shadow);
}
.finance-ref-kpi::after { content: ""; position: absolute; right: 0; bottom: 0; left: 0; height: 3px; background: #2563eb; }
.finance-ref-kpi.kpi-received::after { background: #05b681; }
.finance-ref-kpi.kpi-pending::after { background: #f97316; }
.finance-ref-kpi.kpi-overdue::after { background: #ef2f3c; }
.finance-ref-kpi span { display: block; margin-bottom: 7px; color: #52627a; font-size: 10px; letter-spacing: .04em; text-transform: uppercase; }
.finance-ref-kpi strong { font-size: 24px; line-height: 1; }
.finance-kpi-icon { display: grid; width: 45px; height: 45px; place-items: center; border-radius: 10px; color: #fff; }
.finance-kpi-icon svg { width: 21px; height: 21px; }
.kpi-received .finance-kpi-icon { background: #08aa78; }
.kpi-pending .finance-kpi-icon { background: #fb6414; }
.kpi-overdue .finance-kpi-icon { background: #ee303d; }
.finance-filter-panel { margin-bottom: 19px; padding: 20px !important; }
.finance-reference-filter-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 14px; }
.finance-reference-filter-grid .finance-filter-type,
.finance-reference-filter-grid .finance-filter-period { grid-column: span 1; }
.finance-filter-bottom { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 13px; }
.finance-filter-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--muted); }
.finance-filter-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.finance-student-filter { position: relative; display: grid; align-content: start; gap: 3px; min-width: 0; font-size: 10.5px; }
.finance-student-filter > label { display: block; }
.finance-student-picker { position: relative; min-width: 0; }
.finance-student-results {
  position: absolute; z-index: 45; top: calc(100% + 5px); right: 0; left: 0;
  display: grid; max-height: 310px; gap: 3px; overflow-y: auto;
  border: 1px solid #dfe3e8; border-radius: 7px; padding: 5px;
  background: #fff; box-shadow: 0 14px 30px rgba(15,23,42,.17);
}
.finance-student-option {
  display: grid; width: 100%; gap: 1px; border: 1px solid transparent;
  border-radius: 6px; padding: 7px 8px; color: #0f172a; background: transparent;
  cursor: pointer; text-align: left;
}
.finance-student-option:hover,
.finance-student-option:focus,
.finance-student-option.selected { border-color: #bfdbfe; outline: 0; background: #eff6ff; }
.finance-student-option span { overflow: hidden; font-size: 10px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.finance-student-option small { overflow: hidden; color: #64748b; font-size: 8.5px; text-overflow: ellipsis; white-space: nowrap; }
.finance-student-empty { margin: 0; padding: 11px; color: #64748b; font-size: 9px; text-align: center; }
.button-purple { border-color: #e9d5ff; color: #a21caf; background: #fff; }
.button-outline-danger { border-color: #fecaca; color: #ef2f3c; background: #fff; }
.button svg,
.finance-card-action svg { width: 13px; height: 13px; }
.student-finance-list { gap: 13px; }
.student-finance-card {
  overflow: hidden; border: 1px solid #e5e7eb; border-radius: 12px;
  background: #fff; box-shadow: var(--shadow);
}
.student-finance-card-row {
  display: grid; grid-template-columns: minmax(320px,1fr) auto auto;
  align-items: center; gap: 16px; min-height: 82px; padding: 14px 18px 4px;
}
.student-finance-person { display: flex; min-width: 0; align-items: center; gap: 10px; }
.student-finance-person > div:last-child { display: grid; min-width: 0; }
.student-finance-person strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.student-finance-person small { margin-top: 2px; font-size: 9px; }
.student-course-line { color: #2563eb !important; font-size: 9px !important; text-transform: uppercase; }
.student-finance-inline-totals { display: flex; align-items: center; gap: 13px; }
.student-finance-inline-totals > div { display: grid; min-width: 58px; gap: 1px; }
.student-finance-inline-totals span { color: var(--muted); font-size: 8px; }
.student-finance-inline-totals strong { color: #2563eb; font-size: 10px; white-space: nowrap; }
.student-finance-inline-totals .paid strong { color: #059669; }
.student-finance-inline-totals .pending strong { color: #f97316; }
.student-finance-card-actions { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.student-finance-card-actions form { display: inline-flex; margin: 0; }
.finance-card-action {
  display: inline-flex; min-height: 27px; align-items: center; justify-content: center;
  gap: 6px; border: 1px solid #dfe3e8; border-radius: 5px; padding: 5px 10px;
  color: #0f172a; background: #fff; cursor: pointer; font: inherit; font-size: 9px; white-space: nowrap;
}
.finance-card-action.danger { border-color: #fecaca; color: #ef2f3c; }
.finance-card-action.blue { border-color: #dbeafe; color: #2563eb; }
.student-finance-helper { margin: 8px 0 17px; color: #64748b; font-size: 10px; text-align: center; }
.student-finance-card-body { border-top: 1px solid #edf0f3; padding: 13px 18px 16px; background: #fbfdff; }
.student-finance-card-body .student-history-table { border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden; }

/* Busca digitada de turmas em Notas e Presença */
.classroom-search-picker { position: relative; min-width: 230px; }
.classroom-search-results {
  position: absolute; z-index: 30; top: calc(100% + 5px); right: 0; left: 0;
  display: grid; max-height: 280px; gap: 4px; overflow-y: auto;
  border: 1px solid #dfe3e8; border-radius: 8px; padding: 6px;
  background: #fff; box-shadow: 0 14px 30px rgba(15,23,42,.16);
}
.classroom-search-result {
  display: grid; width: 100%; gap: 1px; border: 1px solid transparent;
  border-radius: 6px; padding: 8px 9px; color: var(--text);
  background: transparent; cursor: pointer; text-align: left;
}
.classroom-search-result:hover,
.classroom-search-result.selected { border-color: #bfdbfe; background: #eff6ff; }
.classroom-search-result span { font-size: 11px; font-weight: 700; }
.classroom-search-result small { color: var(--muted); font-size: 9px; }
.classroom-search-empty { margin: 0; padding: 11px; color: var(--muted); text-align: center; }
.academic-filter-actions { display: flex; align-items: center; gap: 7px; }
.academic-filter-actions .button { white-space: nowrap; }
.dark .classroom-search-results { border-color: var(--line); background: var(--surface); }
.dark .classroom-search-result:hover,
.dark .classroom-search-result.selected { border-color: #1d4ed8; background: rgba(37,99,235,.15); }

/* Gestão de Alunos conforme a referência enviada */
.students-page-intro {
  display: flex; min-height: 49px; align-items: center; justify-content: space-between;
  gap: 18px; margin-bottom: 19px;
}
.students-page-intro p { margin: 0; color: #52627a; font-size: 11px; }
.students-page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.students-page-actions .button { min-height: 30px; border-radius: 5px; padding: 6px 11px; font-size: 9.5px; }
.students-page-actions .button svg { width: 13px; height: 13px; }
.students-completed-report { border-color: #a7f3d0; color: #059669; background: #fff; }
.students-class-filter {
  display: inline-flex; align-items: center; gap: 7px; margin-top: 7px;
  border-radius: 999px; padding: 4px 9px; color: #1d4ed8; background: #dbeafe;
  font-size: 9px; font-weight: 700;
}
.students-class-filter a { color: inherit; font-size: 12px; line-height: 1; }
.app-body .students-table-card { padding: 0; }
.students-filter-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  min-height: 66px; padding: 14px 19px; background: #fff;
}
.students-search-box,
.students-status-filter {
  position: relative; display: flex; align-items: center; gap: 0; font-weight: 500;
}
.students-search-box { width: min(359px, 55%); }
.students-search-box svg {
  position: absolute; z-index: 1; left: 11px; width: 14px; height: 14px; color: #94a3b8;
}
.students-search-box input {
  height: 30px; border-radius: 5px; padding: 6px 10px 6px 32px;
  font-size: 9.5px; background: #f8fafc;
}
.students-status-filter { width: 144px; }
.students-status-filter svg {
  position: absolute; z-index: 1; left: 11px; width: 13px; height: 13px; color: #64748b;
}
.students-status-filter select {
  height: 30px; border-radius: 5px; padding: 5px 30px 5px 42px;
  font-size: 9.5px; background: #fff;
}
.students-reference-table { min-width: 920px; table-layout: fixed; }
.students-reference-table th:nth-child(1) { width: 9%; }
.students-reference-table th:nth-child(2) { width: 31%; }
.students-reference-table th:nth-child(3) { width: 14%; }
.students-reference-table th:nth-child(4) { width: 19%; }
.students-reference-table th:nth-child(5) { width: 10%; }
.students-reference-table th:nth-child(6) { width: 17%; }
.students-reference-table th {
  height: 38px; padding: 10px 19px; color: #334155; background: #f8fafc;
  font-size: 8.5px; font-weight: 650;
}
.students-reference-table td {
  height: 61px; padding: 9px 19px; color: #0f172a; font-size: 9.5px;
}
.student-click-row { cursor: pointer; outline: none; }
.student-click-row:hover,
.student-click-row:focus-visible { background: #f8fbff; }
.student-click-row:focus-visible { box-shadow: inset 3px 0 #2563eb; }
.student-enrollment-cell { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 9px !important; }
.student-name-cell strong {
  display: block; overflow: hidden; font-size: 11px; font-weight: 650;
  text-overflow: ellipsis; white-space: nowrap;
}
.student-name-cell small {
  display: block; overflow: hidden; margin-top: 1px; font-size: 8.5px;
  text-overflow: ellipsis; white-space: nowrap;
}
.students-row-actions { flex-wrap: nowrap; justify-content: flex-end; gap: 3px; }
.students-row-actions form { display: inline-flex; }
.students-action-icon {
  display: inline-grid; width: 26px; height: 26px; flex: 0 0 26px; place-items: center;
  border: 0; border-radius: 5px; padding: 0; color: #64748b; background: transparent;
  cursor: pointer;
}
.students-action-icon:hover { color: #2563eb; background: #eff6ff; }
.students-action-icon.danger:hover { color: #dc2626; background: #fef2f2; }
.students-action-icon svg { width: 13px; height: 13px; }
.student-quick-card { display: grid; gap: 18px; }
.student-quick-heading {
  display: flex; align-items: center; gap: 13px; border-bottom: 1px solid var(--line);
  padding-bottom: 16px;
}
.student-quick-avatar {
  display: grid; width: 54px; height: 54px; flex: 0 0 54px; place-items: center;
  border-radius: 12px; color: #2563eb; background: #dbeafe; font-size: 19px; font-weight: 800;
}
.student-quick-heading h3 { margin: 0 0 2px; font-size: 15px; }
.student-quick-heading p { margin: 0 0 5px; color: var(--muted); font-size: 10px; }
.student-quick-data {
  display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px;
  margin: 0;
}
.student-quick-data > div {
  min-width: 0; border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px;
  background: var(--surface-2);
}
.student-quick-data dt { margin-bottom: 2px; color: var(--muted); font-size: 8px; font-weight: 700; text-transform: uppercase; }
.student-quick-data dd { overflow-wrap: anywhere; margin: 0; font-size: 10px; font-weight: 600; }
.student-quick-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.student-quick-actions .button { min-height: 34px; border-radius: 6px; font-size: 10px; }
.student-quick-actions svg { width: 13px; height: 13px; }

.dark .app-body .topbar,
.dark .app-body .toolbar,
.dark .app-body .card,
.dark .app-body .stat-card,
.dark .finance-ref-kpi,
.dark .student-finance-card,
.dark .finance-card-action,
.dark .app-body input,
.dark .app-body select,
.dark .app-body textarea {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
}
.dark .student-finance-card-body { border-color: var(--line); background: var(--surface-2); }
.dark .topbar-icon { color: var(--text); }
.dark .topbar-icon:hover { background: var(--surface-2); }
.dark .button-purple,
.dark .button-outline-danger { background: var(--surface); }
.dark .students-page-intro p { color: var(--muted); }
.dark .students-completed-report,
.dark .students-filter-bar,
.dark .students-status-filter select,
.dark .students-search-box input { border-color: var(--line); color: var(--text); background: var(--surface); }
.dark .students-reference-table th { color: var(--muted); background: var(--surface-2); }
.dark .students-reference-table td { color: var(--text); }
.dark .student-click-row:hover,
.dark .student-click-row:focus-visible { background: rgba(37,99,235,.1); }
.dark .finance-student-results { border-color: var(--line); background: var(--surface); }
.dark .finance-student-option { color: var(--text); }
.dark .finance-student-option:hover,
.dark .finance-student-option:focus,
.dark .finance-student-option.selected { border-color: #1d4ed8; background: rgba(37,99,235,.15); }
.dark .finance-student-option small,
.dark .finance-student-empty { color: var(--muted); }

@media (max-width: 1180px) {
  .student-finance-card-row { grid-template-columns: minmax(260px,1fr) auto; }
  .student-finance-card-actions { grid-column: 1/-1; justify-content: flex-end; }
}

@media (max-width: 980px) {
  .app-body .workspace { margin-left: 0; }
  .app-body .sidebar { width: 230px; }
  .finance-reference-filter-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 720px) {
  .app-body .topbar { min-height: 53px; padding: 0 14px; }
  .app-body .content { padding: 14px; }
  .students-page-intro { align-items: stretch; flex-direction: column; }
  .students-page-actions { justify-content: stretch; }
  .students-page-actions .button { flex: 1; }
  .students-filter-bar { align-items: stretch; flex-direction: column; gap: 9px; }
  .students-search-box, .students-status-filter { width: 100%; }
  .student-quick-data { grid-template-columns: 1fr; }
  .student-quick-data .span-2 { grid-column: auto; }
  .student-quick-actions { flex-direction: column; }
  .student-quick-actions .button { width: 100%; }
  .finance-reference-kpis { grid-template-columns: 1fr; gap: 10px; }
  .finance-ref-kpi { min-height: 84px; }
  .finance-reference-filter-grid { grid-template-columns: 1fr; }
  .finance-filter-bottom { align-items: stretch; flex-direction: column; }
  .finance-filter-meta { align-items: stretch; }
  .finance-filter-meta .button { flex: 1; }
  .finance-filter-actions { justify-content: stretch; }
  .finance-filter-actions .button { flex: 1; }
  .student-finance-card-row { grid-template-columns: 1fr; padding: 14px; }
  .student-finance-inline-totals { justify-content: space-between; overflow-x: auto; }
  .student-finance-card-actions { grid-column: auto; justify-content: flex-start; overflow-x: auto; }
  .student-finance-helper { margin: 6px 14px 14px; text-align: left; }
  .academic-filter-actions { align-items: stretch; flex-direction: column; }
  .academic-filter-actions .button { width: 100%; }
}


/* =========================================================
   HOTFIX 1.3.6 - DARK THEME / CONSISTENCIA VISUAL
   Mantido no fim do arquivo de proposito: estas regras sao
   a camada final do tema e nao podem ser sobrescritas pelo
   bloco visual administrativo acima.
   ========================================================= */
html.dark {
  color-scheme: dark;
  --bg: #07101f;
  --surface: #0d1728;
  --surface-2: #121f33;
  --text: #e7edf6;
  --muted: #91a1b7;
  --line: #26364d;
  --primary: #4b8cff;
  --primary-dark: #3677eb;
  --sidebar: #081322;
  --sidebar-2: #0b1728;
  --success: #32c793;
  --warning: #f5a524;
  --danger: #ff6470;
  --purple: #b179ff;
  --shadow: 0 10px 28px rgba(0, 0, 0, .24);
}

html.dark,
html.dark body,
html.dark .app-body,
html.dark .portal-body,
html.dark .login-body,
html.dark .diagnostic-body {
  color: var(--text);
  background-color: var(--bg);
}

/* Estrutura administrativa */
html.dark .app-body .sidebar {
  color: #dce6f4;
  background: linear-gradient(180deg, var(--sidebar), var(--sidebar-2));
  border-right: 1px solid rgba(148, 163, 184, .10);
}
html.dark .app-body .sidebar-brand,
html.dark .app-body .sidebar-footer { border-color: rgba(148, 163, 184, .13); }
html.dark .app-body .sidebar-nav a,
html.dark .app-body .sidebar-footer a { color: #c3d0e1; }
html.dark .app-body .sidebar-nav a:hover { background: rgba(255,255,255,.055); }
html.dark .app-body .sidebar-nav a.active {
  color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  box-shadow: 0 7px 20px rgba(37,99,235,.24);
}
html.dark .app-body .workspace,
html.dark .app-body .content { background: var(--bg); }
html.dark .app-body .topbar {
  border-color: var(--line);
  background: rgba(13, 23, 40, .94);
  box-shadow: 0 1px 0 rgba(255,255,255,.02);
}
html.dark .app-body .topbar-icon { color: var(--text); }
html.dark .app-body .topbar-icon:hover { background: var(--surface-2); }
html.dark .app-body .user-chip strong { color: var(--text); }

/* Superficies: cobre dashboard e abas administrativas */
html.dark .app-body .card,
html.dark .app-body .toolbar,
html.dark .app-body .stat-card,
html.dark .app-body .modal,
html.dark .app-body .modal-header,
html.dark .app-body .sticky-form-actions,
html.dark .app-body .pagination,
html.dark .app-body .quick-grid a,
html.dark .app-body .mini-stat,
html.dark .app-body .entity-meta span,
html.dark .app-body .finance-kpi,
html.dark .app-body .finance-command-bar,
html.dark .app-body .finance-controls,
html.dark .app-body .finance-status-list a,
html.dark .app-body .finance-status-tabs a,
html.dark .app-body .finance-view-switch,
html.dark .app-body .form-section,
html.dark .app-body .batch-selection-tools,
html.dark .app-body .batch-students,
html.dark .finance-ref-kpi,
html.dark .student-finance-card,
html.dark .student-finance-card-body,
html.dark .student-finance-totals > div,
html.dark .student-history-table,
html.dark .students-filter-bar,
html.dark .student-quick-data > div,
html.dark .classroom-search-results,
html.dark .finance-student-results {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
}
html.dark .app-body .stat-card,
html.dark .app-body .toolbar,
html.dark .finance-ref-kpi,
html.dark .student-finance-card { box-shadow: var(--shadow); }
html.dark .app-body .quick-actions,
html.dark .app-body .finance-command-bar {
  background: linear-gradient(120deg, rgba(75,140,255,.08), var(--surface));
}
html.dark .app-body .form-section,
html.dark .student-finance-card-body,
html.dark .student-quick-data > div,
html.dark .app-body .finance-status-list a,
html.dark .app-body .finance-status-tabs a,
html.dark .app-body .finance-view-switch {
  background: var(--surface-2);
}

/* Formularios e controles */
html.dark .app-body input,
html.dark .app-body select,
html.dark .app-body textarea,
html.dark .login-body input,
html.dark .login-body select,
html.dark .login-body textarea,
html.dark .portal-body input,
html.dark .portal-body select,
html.dark .portal-body textarea {
  border-color: var(--line);
  color: var(--text);
  background: #0a1525;
}
html.dark input::placeholder,
html.dark textarea::placeholder { color: #71839c; opacity: 1; }
html.dark select option { color: var(--text); background: var(--surface); }
html.dark input:focus,
html.dark select:focus,
html.dark textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(75,140,255,.16);
}
html.dark .app-body .button-secondary,
html.dark .app-body .icon-button,
html.dark .login-body .icon-button,
html.dark .portal-body .icon-button,
html.dark .button-purple,
html.dark .button-outline-danger,
html.dark .finance-card-action,
html.dark .students-completed-report {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface);
}
html.dark .app-body .button-secondary:hover,
html.dark .app-body .icon-button:hover { background: var(--surface-2); }
html.dark .app-body .button-danger,
html.dark .button-outline-danger,
html.dark .finance-card-action.danger {
  border-color: rgba(255,100,112,.32);
  color: #ff8790;
  background: rgba(255,100,112,.06);
}
html.dark .button-purple { border-color: rgba(177,121,255,.35); color: #c69cff; }

/* Tabelas */
html.dark table { color: var(--text); }
html.dark th,
html.dark .students-reference-table th {
  border-color: var(--line);
  color: #9cafc5;
  background: var(--surface-2);
}
html.dark td,
html.dark .students-reference-table td { border-color: var(--line); color: var(--text); }
html.dark tbody tr:hover,
html.dark .student-click-row:hover,
html.dark .student-click-row:focus-visible { background: rgba(75,140,255,.075); }
html.dark .pagination a,
html.dark .pagination span { border-color: var(--line); color: var(--text); background: var(--surface); }

/* Cards e elementos especificos */
html.dark .app-body .entity-icon,
html.dark .app-body .profile-avatar,
html.dark .app-body .avatar,
html.dark .student-quick-avatar {
  color: #91bbff;
  background: rgba(59,130,246,.16);
}
html.dark .profile-avatar img { background: transparent; }
html.dark .finance-ref-kpi span,
html.dark .students-page-intro p,
html.dark .student-finance-helper,
html.dark .finance-student-option small,
html.dark .finance-student-empty { color: var(--muted); }
html.dark .finance-student-option,
html.dark .classroom-search-result { color: var(--text); }
html.dark .finance-student-option:hover,
html.dark .finance-student-option:focus,
html.dark .finance-student-option.selected,
html.dark .classroom-search-result:hover,
html.dark .classroom-search-result.selected {
  border-color: rgba(75,140,255,.48);
  background: rgba(75,140,255,.12);
}
html.dark .students-search-box input,
html.dark .students-status-filter select { border-color: var(--line); color: var(--text); background: #0a1525; }
html.dark .students-action-icon:hover { color: #79aaff; background: rgba(75,140,255,.12); }
html.dark .students-action-icon.danger:hover { color: #ff8790; background: rgba(255,100,112,.10); }
html.dark .students-class-filter { color: #93bdff; background: rgba(59,130,246,.15); }
html.dark .students-completed-report { color: #4ed5a5; background: rgba(50,199,147,.06); border-color: rgba(50,199,147,.30); }
html.dark .student-finance-card-body .student-history-table { border-color: var(--line); }
html.dark .finance-card-action.blue { border-color: rgba(75,140,255,.30); color: #91bbff; }
html.dark .finance-status-tabs a.active,
html.dark .finance-view-switch a.active { color: #fff; background: var(--primary); }
html.dark .finance-status-tabs a.active b,
html.dark .finance-view-switch a.active b,
html.dark .tab-count { color: var(--primary); background: #eaf2ff; }

/* Login */
html.dark .login-card {
  color: var(--text);
  background: var(--surface);
}
html.dark .login-card .school-logo { border-color: var(--line); background: var(--surface-2); }
html.dark .login-card .school-logo img { background: #fff; }
html.dark .login-card .link-button { color: #91bbff; }

/* Portal do aluno */
html.dark .portal-body { background: var(--bg); }
html.dark .portal-header {
  border-color: var(--line);
  color: var(--text);
  background: rgba(13,23,40,.95);
}
html.dark .portal-brand img,
html.dark .portal-brand > span { background: #eef4ff; }
html.dark .portal-tabs,
html.dark .portal-body .card { border-color: var(--line); color: var(--text); background: var(--surface); }
html.dark .portal-tabs button { color: var(--muted); }
html.dark .portal-tabs button.active { color: #fff; background: var(--primary); }
html.dark .history-list > div { border-color: var(--line); }

/* Scrollbars discretas em superficies escuras */
html.dark * { scrollbar-color: #33455e transparent; }
html.dark *::-webkit-scrollbar { width: 10px; height: 10px; }
html.dark *::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: #33455e; background-clip: padding-box; }
html.dark *::-webkit-scrollbar-track { background: transparent; }

/* Fixed visual: sidebar permanece fixa e o topo continua visivel sem cobrir conteudo. */
@media (min-width: 981px) {
  .app-body .sidebar { position: fixed; inset: 0 auto 0 0; }
  .app-body .topbar { position: sticky; top: 0; z-index: 40; }
  .app-body .sidebar-nav { overscroll-behavior: contain; }
}

@media (max-width: 980px) {
  html.dark .sidebar-overlay.show { background: rgba(0,0,0,.72); }
  html.dark .app-body .sidebar { box-shadow: 16px 0 36px rgba(0,0,0,.34); }
}

/* =========================================================
   HOTFIX 1.3.7 - SIDEBAR RECOLHIVEL + MOBILE FUNCIONAL
   Camada final intencional para prevalecer sobre o tema base.
   ========================================================= */
.sidebar-collapse-toggle {
  display: inline-grid;
  margin-left: auto;
  color: #d9e2f0;
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.10);
}
.sidebar-collapse-toggle svg { width: 16px; height: 16px; transition: transform .2s ease; }
.mobile-bottom-nav { display: none; }

@media (min-width: 981px) {
  .app-body .sidebar,
  .app-body .workspace { transition: width .22s ease, margin-left .22s ease; }
  .sidebar-brand-copy,
  .sidebar-nav a span,
  .sidebar-footer a span,
  .sidebar-install,
  .nav-chevron { transition: opacity .14s ease; }

  html.sidebar-collapsed .app-body .sidebar {
    width: 76px;
    padding-right: 10px;
    padding-left: 10px;
  }
  html.sidebar-collapsed .app-body .workspace { margin-left: 76px; }
  html.sidebar-collapsed .app-body .sidebar-brand {
    justify-content: center;
    margin-right: -10px;
    margin-left: -10px;
    padding-right: 10px;
    padding-left: 10px;
  }
  html.sidebar-collapsed .sidebar-brand-copy,
  html.sidebar-collapsed .sidebar-nav a span,
  html.sidebar-collapsed .sidebar-footer a span,
  html.sidebar-collapsed .sidebar-install,
  html.sidebar-collapsed .nav-chevron { display: none !important; }
  html.sidebar-collapsed .sidebar-collapse-toggle {
    position: absolute;
    top: 62px;
    right: -13px;
    z-index: 3;
    width: 27px;
    height: 27px;
    min-height: 27px;
    flex-basis: 27px;
    border-color: var(--line);
    color: var(--text);
    background: var(--surface);
    box-shadow: var(--shadow);
  }
  html.sidebar-collapsed .sidebar-collapse-toggle svg { transform: rotate(180deg); }
  html.sidebar-collapsed .sidebar-nav a,
  html.sidebar-collapsed .sidebar-footer a {
    justify-content: center;
    gap: 0;
    padding-right: 0;
    padding-left: 0;
  }
  html.sidebar-collapsed .sidebar-nav a.active { box-shadow: 0 7px 18px rgba(37,99,235,.23); }
  html.sidebar-collapsed .sidebar-nav .nav-icon,
  html.sidebar-collapsed .sidebar-footer .nav-icon {
    width: 19px;
    height: 19px;
    flex-basis: 19px;
  }
}

@media (max-width: 980px) {
  html.sidebar-collapsed .app-body .workspace { margin-left: 0; }
  .sidebar-collapse-toggle { display: none !important; }
  .app-body .sidebar {
    width: min(86vw, 320px) !important;
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    transform: translateX(-105%);
    box-shadow: 16px 0 36px rgba(2,6,23,.24);
  }
  .app-body .sidebar.open { transform: translateX(0); }
  .app-body .sidebar-brand { min-height: 66px; }
  .app-body .sidebar-nav a,
  .app-body .sidebar-footer a { min-height: 48px; font-size: 13px; }
  .app-body .sidebar-nav .nav-icon,
  .app-body .sidebar-footer .nav-icon { width: 19px; height: 19px; flex-basis: 19px; }
  body.sidebar-open { overflow: hidden; }
}

@media (max-width: 720px) {
  .app-body {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
    font-size: 13px;
  }
  .app-body .workspace { min-height: calc(100vh - 72px); }
  .app-body .content {
    padding: 14px 12px 24px;
    overflow-x: clip;
  }
  .app-body .topbar {
    position: sticky;
    z-index: 38;
    top: 0;
    min-height: 58px;
    padding: 7px 12px;
  }
  .app-body .menu-button { display: none !important; }
  .app-body .page-heading { min-width: 0; }
  .app-body .page-heading h1 {
    overflow: hidden;
    font-size: 18px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-body .topbar-actions { margin-left: auto; }
  .app-body .user-chip { display: none; }
  .app-body .topbar-icon,
  .app-body .icon-button {
    width: 42px;
    height: 42px;
    min-height: 42px;
    flex-basis: 42px;
  }
  .app-body .topbar-icon svg { width: 18px; height: 18px; }

  .app-body .button {
    min-height: 42px;
    padding: 9px 13px;
    font-size: 12px;
  }
  .app-body .button-small { min-height: 38px; }
  .app-body input,
  .app-body select,
  .app-body textarea {
    min-height: 44px;
    padding: 10px 11px;
    font-size: 16px;
  }
  .app-body textarea { min-height: 96px; }
  .app-body label { gap: 5px; font-size: 12px; }
  .app-body .form-grid { gap: 13px; }

  .app-body .card { border-radius: 13px; padding: 15px; }
  .app-body .table-card { padding: 0; }
  .app-body .table-card > .card-header { padding: 15px 15px 0; }
  .app-body .toolbar {
    gap: 10px;
    border-radius: 13px;
    padding: 12px;
  }
  .app-body .toolbar > .button { width: 100%; }
  .app-body .search-form {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .app-body .search-form > span { display: none; }
  .app-body .search-form > span + input { padding-left: 11px; }
  .app-body .search-form > input:not([type="hidden"]) { width: 100%; min-width: 0; }
  .app-body .search-form .button { min-width: 82px; }
  .app-body .search-form select { grid-column: 1 / -1; width: 100%; }

  .app-body .row-actions,
  .app-body .card-actions,
  .app-body .detail-actions { gap: 7px; }
  .app-body .row-actions .icon-button { width: 40px; height: 40px; min-height: 40px; flex-basis: 40px; }

  .app-body .table-wrap {
    position: relative;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }
  .app-body .table-wrap > table:not(.finance-table) { min-width: 680px; }
  .app-body .table-wrap th { white-space: nowrap; }
  .app-body .table-wrap td { vertical-align: middle; }
  .app-body .grade-table { min-width: 760px !important; }

  .app-body .stats-grid { gap: 10px; }
  .app-body .stat-card { min-height: 92px; padding: 13px; }
  .app-body .stat-card strong { font-size: 1.15rem; }
  .app-body .quick-actions { gap: 12px; }

  .app-body .modal {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 16px;
  }
  .app-body .modal.modal-lg { width: calc(100vw - 12px); }
  .app-body .modal-header { padding: 12px 14px; }
  .app-body .modal-body { padding: 14px; }
  .app-body .modal-header .icon-button { width: 40px; height: 40px; min-height: 40px; flex-basis: 40px; }
  .app-body .sticky-form-actions {
    margin: 12px -14px -14px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .app-body .tabs,
  .app-body .settings-tabs,
  .app-body .portal-tabs {
    margin-right: -12px;
    margin-left: -12px;
    padding-right: 12px;
    padding-left: 12px;
    scroll-snap-type: x proximity;
  }
  .app-body .tabs button { min-height: 40px; scroll-snap-align: start; }

  .mobile-bottom-nav {
    position: fixed;
    z-index: 44;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    min-height: calc(64px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 -10px 30px rgba(15,23,42,.10);
    backdrop-filter: blur(18px);
  }
  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    display: grid;
    min-width: 0;
    min-height: 52px;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    border-radius: 10px;
    padding: 5px 2px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font: inherit;
    font-size: 9px;
    font-weight: 700;
    line-height: 1.05;
  }
  .mobile-bottom-nav a.active,
  .mobile-bottom-nav button.active { color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, transparent); }
  .mobile-nav-icon { width: 20px; height: 20px; }
  .mobile-nav-menu-icon { font-size: 20px; line-height: 1; }

  .sidebar-overlay { z-index: 48; }
  .app-body .sidebar { z-index: 50; }
}

@media (max-width: 480px) {
  .app-body .content { padding-right: 10px; padding-left: 10px; }
  .app-body .toolbar { padding: 10px; }
  .app-body .search-form { grid-template-columns: 1fr; }
  .app-body .search-form .button { width: 100%; }
  .app-body .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .app-body .modal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .app-body .modal.modal-lg { width: 100vw; }
}

html.dark .mobile-bottom-nav {
  border-color: var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  box-shadow: 0 -12px 30px rgba(0,0,0,.26);
}
html.dark.sidebar-collapsed .sidebar-collapse-toggle {
  border-color: var(--line);
  color: var(--text);
  background: var(--surface-2);
}
