/* ================================================================
   GESCLASS – Design System
   Cores extraídas da logo: Azul #1B2D6B | Teal #2ECBA1
================================================================ */

/* ── TEMA CLARO (padrão) ─────────────────────────────── */
:root {
  --navy:      #1B2D6B;
  --navy-dark: #111E4A;
  --navy-mid:  #2A3F8F;
  --primary:   #1B2D6B;
  --teal:      #2ECBA1;
  --teal-dark: #22A882;
  --teal-light:#E6F9F4;

  --bg:        #F4F6FB;
  --bg-card:   #FFFFFF;
  --bg-sidebar:#FFFFFF;
  --bg-topbar: #FFFFFF;
  --bg-input:  #F8FAFC;
  --bg-hover:  #F0F4FF;
  --bg-stripe: #F8FAFC;
  --bg-secondary:#F8FAFC;

  --text-primary:   #1B2D6B;
  --text-secondary: #5A6A8A;
  --text-muted:     #9AAAC4;
  --text-inverse:   #FFFFFF;

  --border:    #DDE4EE;
  --border-focus: #2ECBA1;

  --shadow-sm: 0 1px 3px rgba(27,45,107,.07), 0 1px 2px rgba(27,45,107,.04);
  --shadow-md: 0 4px 16px rgba(27,45,107,.10), 0 2px 6px rgba(27,45,107,.05);
  --shadow-lg: 0 10px 40px rgba(27,45,107,.14), 0 4px 12px rgba(27,45,107,.07);

  --ok:       #16A34A; --ok-bg:   #DCFCE7;
  --warn:     #D97706; --warn-bg: #FEF3C7;
  --err:      #DC2626; --err-bg:  #FEE2E2;
  --info:     #0284C7; --info-bg: #E0F2FE;

  --r:    12px;
  --rsm:   8px;
  --rlg:  20px;
  --rxl:  28px;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-heading: var(--font-sans);
  --type-tight: 1.15;
  --type-normal: 1.45;
}

/* TEMA SAAS ESCOLAR */
[data-theme="saas"] {
  --navy:      #1857D7;
  --navy-dark: #0B225C;
  --navy-mid:  #3478F6;
  --primary:   #1857D7;
  --teal:      #19B89A;
  --teal-dark: #0E9279;
  --teal-light:#DDF7F0;

  --bg:        #F5F8FD;
  --bg-card:   #FFFFFF;
  --bg-sidebar:#F8FBFF;
  --bg-topbar: rgba(255,255,255,.92);
  --bg-input:  #F8FAFE;
  --bg-hover:  #EAF2FF;
  --bg-stripe: #F3F7FC;
  --bg-secondary:#F7FAFF;

  --text-primary:   #102A56;
  --text-secondary: #58708F;
  --text-muted:     #94A5B8;
  --text-inverse:   #FFFFFF;

  --border:    #DCE6F3;
  --border-focus: #19B89A;

  --shadow-sm: 0 1px 2px rgba(16,42,86,.05), 0 8px 20px rgba(16,42,86,.04);
  --shadow-md: 0 12px 30px rgba(16,42,86,.08);
  --shadow-lg: 0 22px 54px rgba(16,42,86,.12);

  --ok:       #10A66E; --ok-bg:   #DDF7EA;
  --warn:     #D58912; --warn-bg: #FFF4D8;
  --err:      #D94444; --err-bg:  #FFE8E8;
  --info:     #1C75E8; --info-bg: #E5F0FF;

  --r:    10px;
  --rsm:   8px;
  --rlg:  16px;
  --rxl:  24px;
}

/* TEMA V2 EDU CENTER */
[data-theme="v2"] {
  --navy:      #5B4BDB;
  --navy-dark: #2C246E;
  --navy-mid:  #7C69F1;
  --primary:   #5B4BDB;
  --teal:      #31D0AA;
  --teal-dark: #12A987;
  --teal-light:#E8FBF6;

  --bg:        #F6F4FF;
  --bg-card:   #FFFFFF;
  --bg-sidebar:#4B3AC8;
  --bg-topbar: #FFFFFF;
  --bg-input:  #F8F7FF;
  --bg-hover:  #F1EEFF;
  --bg-stripe: #FAF9FF;
  --bg-secondary:#F7F5FF;

  --text-primary:   #242047;
  --text-secondary: #6F6A8F;
  --text-muted:     #A8A2C1;
  --text-inverse:   #FFFFFF;

  --border:    #E4DFF5;
  --border-focus: #31D0AA;

  --shadow-sm: 0 8px 26px rgba(72,58,180,.08);
  --shadow-md: 0 16px 42px rgba(72,58,180,.12);
  --shadow-lg: 0 28px 72px rgba(47,37,120,.20);

  --ok:       #13A876; --ok-bg:   #E8FBF2;
  --warn:     #F59E0B; --warn-bg: #FFF5DD;
  --err:      #EF476F; --err-bg:  #FFEAF0;
  --info:     #4A8DFF; --info-bg: #EAF2FF;

  --r:    18px;
  --rsm:  12px;
  --rlg:  22px;
  --rxl:  28px;
}

/* ── TEMA ESCURO ──────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #0B1220;
  --bg-card:   #121C31;
  --bg-sidebar:#0F1728;
  --bg-topbar: #111A2D;
  --bg-input:  #18243A;
  --bg-hover:  #22304A;
  --bg-stripe: #162238;
  --bg-secondary:#162238;

  --text-primary:   #F3F7FF;
  --text-secondary: #C7D2EA;
  --text-muted:     #93A7C8;

  --border:    #30415F;
  --border-focus: #2ECBA1;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 40px rgba(0,0,0,.5);

  --ok-bg:   #052e16; --warn-bg: #1c1000; --err-bg: #1c0000; --info-bg: #082035;
}

/* ── RESET & BASE ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text-primary);
  line-height: var(--type-normal);
  min-height: 100vh;
  transition: background .25s, color .25s;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1,h2,h3,h4,h5 { font-family: var(--font-heading); line-height: var(--type-tight); letter-spacing: 0; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: var(--font-sans); }
input, select, textarea { font-family: var(--font-sans); }

/* ── SCREENS ──────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: flex; }

/* ── LOGIN SCREEN ────────────────────────────────────── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 55%, var(--navy-mid) 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(46,203,161,.08);
  top: -180px; right: -180px;
}
.login-screen::after {
  content: '';
  position: absolute;
  width: 350px; height: 350px;
  border-radius: 50%;
  background: rgba(46,203,161,.05);
  bottom: -130px; left: -130px;
}
.login-card {
  background: var(--bg-card);
  border-radius: var(--rxl);
  padding: 44px 40px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}
.login-logo {
  display: flex; align-items: center; gap: 14px;
  justify-content: center; margin-bottom: 32px;
}
.login-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--navy), var(--navy-mid));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(27,45,107,.35);
  flex-shrink: 0;
}
.login-logo-icon svg { width: 30px; height: 30px; }
.login-logo-text h1 {
  font-size: 28px; font-weight: 700; letter-spacing: -.5px;
  color: var(--navy);
}
.login-logo-text h1 span { color: var(--teal); }
.login-logo-text p { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1.5px; }

/* ── FORM ELEMENTS ───────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 7px; }
.form-control {
  width: 100%; padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--rsm);
  font-size: 15px; color: var(--text-primary);
  background: var(--bg-input);
  outline: none;
  transition: border-color .2s, box-shadow .2s, background .25s;
}
.form-control:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(46,203,161,.15);
  background: var(--bg-card);
}
.form-control::placeholder { color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.password-field { position: relative; width: 100%; }
.password-field .form-control { padding-right: 76px; }
.password-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text-secondary);
  border-radius: 7px; padding: 5px 9px; font-size: 12px; font-weight: 600;
  cursor: pointer; min-height: 30px;
}
.password-toggle:hover { border-color: var(--teal); color: var(--navy); background: var(--teal-light); }

/* ── TABS ────────────────────────────────────────────── */
.login-tabs { display: flex; background: var(--bg); border-radius: var(--rsm); padding: 4px; margin-bottom: 28px; gap: 2px; }
.login-tab {
  flex: 1; padding: 9px 8px; border: none; background: transparent;
  border-radius: 6px; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer; transition: all .2s;
}
.login-tab.active { background: var(--bg-card); color: var(--navy); box-shadow: var(--shadow-sm); }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: var(--rsm);
  font-size: 13px; font-weight: 500; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.btn-primary {
  width: 100%; padding: 14px; justify-content: center;
  background: linear-gradient(135deg, var(--navy), var(--navy-mid));
  color: white; border: none; border-radius: var(--rsm);
  font-family: var(--font-sans); font-size: 15px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(27,45,107,.35);
  margin-top: 6px; cursor: pointer; transition: all .2s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(27,45,107,.40); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn-teal { background: var(--teal); color: var(--navy-dark); box-shadow: 0 2px 8px rgba(46,203,161,.35); }
.btn-teal:hover { background: var(--teal-dark); }
.btn-navy { background: var(--navy); color: white; box-shadow: 0 2px 8px rgba(27,45,107,.25); }
.btn-navy:hover { background: var(--navy-dark); }
.btn-outline { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border); }
.btn-outline:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger { background: var(--err-bg); color: var(--err); border-color: #fca5a5; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost { background: none; border: none; color: var(--text-secondary); padding: 6px 10px; }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-icon { width: 34px; height: 34px; padding: 0; justify-content: center; border-radius: var(--rsm); }

/* ── APP LAYOUT ──────────────────────────────────────── */
.app-layout { min-height: 100vh; flex-direction: column; }
.topbar {
  height: 64px; background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: background .25s, border-color .25s;
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.topbar-logo { display: flex; align-items: center; gap: 10px; }
.topbar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--navy), var(--navy-mid));
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.topbar-logo-icon svg { width: 20px; height: 20px; }
.topbar-logo-text { font-family: var(--font-sans); font-size: 18px; font-weight: 700; color: var(--navy); }
.topbar-logo-text span { color: var(--teal); }
.school-badge {
  background: var(--teal-light); color: var(--teal-dark);
  font-size: 12px; font-weight: 600; padding: 4px 12px;
  border-radius: 20px; border: 1px solid rgba(46,203,161,.25);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.menu-toggle { display: none; background: none; border: none; color: var(--text-secondary); padding: 8px; border-radius: var(--rsm); }
@media(max-width:768px) { .menu-toggle { display: flex; align-items: center; } }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 50px; padding: 5px 14px 5px 5px;
  cursor: pointer; font: inherit;
}
.user-chip:hover { border-color: var(--teal); background: var(--bg-hover); }
.user-chip:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.user-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: white; flex-shrink: 0;
}
.user-chip-name { font-size: 13px; font-weight: 500; color: var(--text-primary); }
.role-pill {
  font-size: 10px; font-weight: 700; padding: 3px 8px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .5px;
}
.role-pill.superadmin { background: linear-gradient(135deg,#7c3aed,#4f46e5); color: white; }
.role-pill.gestor { background: var(--navy); color: white; }
.role-pill.professor { background: linear-gradient(135deg, var(--teal-dark), var(--teal)); color: var(--navy-dark); }
.role-pill.aluno { background: var(--ok-bg); color: var(--ok); }

/* ── SIDEBAR ─────────────────────────────────────────── */
.app-body { display: flex; flex: 1; overflow: hidden; }
.sidebar {
  width: 240px; background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  padding: 16px 10px; overflow-y: auto;
  min-height: calc(100vh - 64px); flex-shrink: 0;
  transition: transform .3s, background .25s, border-color .25s;
}
@media(max-width:768px) {
  .sidebar {
    position: fixed; top: 64px; left: 0;
    height: calc(100vh - 64px); z-index: 200;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
}
.nav-group { margin-bottom: 22px; }
.nav-group-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.2px; color: var(--text-muted);
  padding: 0 12px; margin-bottom: 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--rsm);
  font-size: 14px; font-weight: 500; color: var(--text-secondary);
  border: none; background: none; width: 100%; text-align: left;
  cursor: pointer; transition: all .15s;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { background: linear-gradient(135deg, rgba(27,45,107,.1), rgba(46,203,161,.08)); color: var(--navy); }
[data-theme="dark"] .nav-item.active { background: rgba(46,203,161,.12); color: var(--teal); }
.nav-item.active svg { stroke: var(--teal); }
.nav-item-badge {
  margin-left: auto; background: var(--teal); color: var(--navy-dark);
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 20px;
}

/* ── MAIN CONTENT ────────────────────────────────────── */
.main-content { flex: 1; padding: 28px; overflow-y: auto; max-height: calc(100vh - 64px); }
@media(max-width:768px) { .main-content { padding: 16px; } }
.page { display: none; }
.page.active { display: block; }
.page-header { margin-bottom: 28px; }
.page-header h2 { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 3px; }
.page-header p { font-size: 14px; color: var(--text-muted); }
.aluno-profile-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.aluno-back-btn { min-width: 82px; }

/* ── CARDS ───────────────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--r);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  overflow: hidden; margin-bottom: 20px;
  transition: background .25s, border-color .25s;
}
.card-header {
  padding: 16px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.card-body { padding: 0; }
.card-padded { padding: 22px; }
.finance-report-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}
.finance-report-panel h3 {
  margin: 0 0 14px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.finance-report-preview {
  margin-top: 18px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.finance-student-report {
  margin-top: 18px;
}
.finance-student-report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.finance-student-report-head h3 {
  margin-bottom: 4px;
}
.finance-student-report-body {
  margin-top: 12px;
}
.finance-student-columns {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
  gap: 16px;
}
.finance-student-columns h3 {
  margin: 4px 0 10px;
  font-size: 14px;
}
.finance-report-print {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 18px;
}
.finance-report-print-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}
.finance-report-print-head h2 {
  margin: 0 0 4px;
  font-size: 18px;
  color: var(--text-primary);
}
.finance-report-print-head p,
.finance-report-print-head small {
  color: var(--text-muted);
  font-size: 12px;
}

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border-radius: var(--r);
  box-shadow: var(--shadow-sm); border: 1px solid var(--border);
  padding: 20px; display: flex; align-items: center; gap: 14px;
  transition: background .25s, border-color .25s;
}
.stat-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; }
.stat-info h3 { font-size: 24px; font-weight: 700; color: var(--text-primary); }
.stat-info p { font-size: 12px; color: var(--text-muted); font-weight: 500; }

@media (max-width: 900px) {
  .finance-student-report-head {
    display: block;
  }
  .finance-student-report-head .finance-actions {
    margin-top: 12px;
  }
  .finance-student-columns {
    grid-template-columns: 1fr;
  }
}

/* ── TABLE ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg-stripe); }
th {
  padding: 11px 18px; text-align: left; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
td {
  padding: 13px 18px; font-size: 14px; color: var(--text-primary);
  border-bottom: 1px solid var(--border); vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

/* ── BADGES ──────────────────────────────────────────── */
.nota-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; padding: 4px 10px; border-radius: 6px;
  font-size: 14px; font-weight: 700; font-family: var(--font-sans);
}
.nb-a { background: #DCFCE7; color: #15803D; }
.nb-b { background: #DBEAFE; color: #1D4ED8; }
.nb-c { background: #FEF9C3; color: #854D0E; }
.nb-d { background: #FEE2E2; color: #B91C1C; }
[data-theme="dark"] .nb-a { background: #052e16; color: #4ade80; }
[data-theme="dark"] .nb-b { background: #082035; color: #60a5fa; }
[data-theme="dark"] .nb-c { background: #1c1000; color: #fbbf24; }
[data-theme="dark"] .nb-d { background: #1c0000; color: #f87171; }

.sit-badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.sit-aprovado { background: var(--ok-bg); color: var(--ok); }
.sit-reprovado { background: var(--err-bg); color: var(--err); }
.sit-recuperacao { background: var(--warn-bg); color: var(--warn); }
.sit-cursando { background: rgba(27,45,107,.08); color: var(--navy); }
[data-theme="dark"] .sit-cursando { background: rgba(46,203,161,.1); color: var(--teal); }

/* ── NOTAS BOARD ────────────────────────────────────── */
.notas-board { display: grid; gap: 16px; }
.notas-aluno-card {
  border: 1px solid var(--border); border-radius: var(--rsm);
  background: var(--bg-card); overflow: hidden;
}
.notas-aluno-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--bg-stripe);
}
.notas-aluno-head h3 { margin: 0; color: var(--navy); font-size: 17px; }
.notas-aluno-head p { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.notas-materias { display: grid; gap: 12px; padding: 14px; }
.notas-materia-card {
  border: 1px solid var(--border); border-radius: var(--rsm);
  background: var(--bg-card); padding: 14px;
}
.notas-materia-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px; flex-wrap: wrap;
}
.notas-materia-head strong { color: var(--text-primary); font-size: 15px; }
.notas-materia-head div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.grade-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.grade-slot {
  min-height: 112px; border: 1px solid var(--border); border-radius: var(--rsm);
  padding: 11px; background: var(--bg-main); display: flex; flex-direction: column; gap: 9px;
}
.grade-slot.vazio { justify-content: center; color: var(--text-muted); }
.grade-slot.vazio strong { font-size: 13px; font-weight: 600; }
.grade-slot-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.grade-slot span:first-child { font-size: 12px; font-weight: 700; color: var(--text-muted); }
.grade-slot p {
  margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.4;
  min-height: 32px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.grade-actions { display: flex; gap: 6px; margin-top: auto; }
@media (max-width: 640px) {
  .notas-aluno-head { align-items: flex-start; flex-direction: column; }
  .grade-grid { grid-template-columns: 1fr; }
}

.tag {
  display: inline-flex; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.tag-teal { background: var(--teal-light); color: var(--teal-dark); }
.tag-navy { background: rgba(27,45,107,.08); color: var(--navy); }
[data-theme="dark"] .tag-navy { background: rgba(27,45,107,.4); color: #a5b4d8; }

/* ── MODAL ───────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(14,21,37,.55); z-index: 500;
  align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-card); border-radius: var(--rlg);
  width: 100%; max-width: 520px; box-shadow: var(--shadow-lg);
  overflow: hidden; transition: background .25s;
  max-height: 92vh; display: flex; flex-direction: column;
}
.modal-header {
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 17px; font-weight: 600; color: var(--text-primary); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; border-radius: 6px; }
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ── SEARCH ──────────────────────────────────────────── */
.search-bar {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--rsm); padding: 9px 14px;
  transition: border-color .2s, background .25s;
}
.search-bar:focus-within { border-color: var(--teal); background: var(--bg-card); }
.search-bar svg { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.search-bar input { background: none; border: none; outline: none; font-size: 14px; color: var(--text-primary); flex: 1; min-width: 0; }
.search-bar input::placeholder { color: var(--text-muted); }
.filter-select {
  padding: 9px 14px; border: 1.5px solid var(--border);
  border-radius: var(--rsm); font-size: 14px;
  color: var(--text-primary); background: var(--bg-input);
  outline: none; cursor: pointer; transition: border-color .2s, background .25s;
}
.filter-select:focus { border-color: var(--teal); background: var(--bg-card); }

/* ── ALERTS ──────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--rsm); font-size: 14px;
  margin-bottom: 16px; display: flex; align-items: center; gap: 10px;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.alert-danger { background: var(--err-bg); color: var(--err); border: 1px solid #fca5a5; }
.alert-success { background: var(--ok-bg); color: var(--ok); border: 1px solid #86efac; }
.alert-info { background: var(--info-bg); color: var(--info); border: 1px solid #7dd3fc; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 14px; opacity: .25; fill: none; stroke: var(--text-muted); stroke-width: 1.5; }
.empty-state h4 { font-size: 16px; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-muted); }

/* ── THEME TOGGLE ────────────────────────────────────── */
.theme-toggle {
  width: 38px; height: 38px; border-radius: var(--rsm); border: 1px solid var(--border);
  background: var(--bg-input); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .2s; color: var(--text-secondary);
}
.theme-toggle:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--teal); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

/* ── LOADER ──────────────────────────────────────────── */
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: white; border-radius: 50%; animation: spin .7s linear infinite; }
.loader-teal { border-color: rgba(46,203,161,.3); border-top-color: var(--teal); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay {
  position: fixed; inset: 0; background: rgba(14,21,37,.6);
  display: flex; align-items: center; justify-content: center; z-index: 9999;
  backdrop-filter: blur(4px);
}
.loading-box {
  background: var(--bg-card); border-radius: var(--r); padding: 32px 40px;
  text-align: center; box-shadow: var(--shadow-lg);
}
.loading-box .loader { width: 36px; height: 36px; border-width: 3px; margin: 0 auto 14px; display: block; }
.loading-box p { font-size: 15px; color: var(--text-secondary); }

/* ── PROFILE CARD (aluno) ────────────────────────────── */
.profile-hero {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy), var(--navy-mid));
  border-radius: var(--rlg); padding: 28px; color: white;
  margin-bottom: 20px; display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.profile-avatar-lg {
  width: 72px; height: 72px; border-radius: 50%;
  background: rgba(46,203,161,.2); border: 3px solid rgba(46,203,161,.5);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px; font-weight: 700; flex-shrink: 0;
}
.profile-info h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.profile-info p { opacity: .75; font-size: 14px; }
.profile-meta { display: flex; gap: 20px; margin-top: 12px; flex-wrap: wrap; }
.profile-meta-item span:first-child { font-size: 11px; opacity: .65; text-transform: uppercase; letter-spacing: .8px; display: block; }
.profile-meta-item span:last-child { font-size: 15px; font-weight: 600; }

/* ── SUBJECT CARDS ───────────────────────────────────── */
.subject-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.subject-card { background: var(--bg-card); border-radius: var(--r); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; transition: background .25s, border-color .25s; }
.subject-card-top {
  padding: 16px 20px;
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: white;
}
.subject-card-top h4 { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.subject-card-top span { font-size: 12px; opacity: .7; }
.subject-card-body { padding: 16px 20px; }
.nota-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.nota-row:last-child { border-bottom: none; }
.nota-row span { font-size: 13px; color: var(--text-secondary); }
.media-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; background: var(--bg-stripe);
  border-top: 1px solid var(--border);
}
.media-row span:first-child { font-size: 13px; font-weight: 600; color: var(--text-secondary); }

/* ── CALENDAR ────────────────────────────────────────── */
.cal-grid-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; }
@media(max-width:700px) { .cal-grid-layout { grid-template-columns: 1fr; } }
.calendar-grid-7 { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-header-day { font-size: 10px; font-weight: 700; text-align: center; color: var(--text-muted); padding: 8px 2px; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 8px; font-size: 13px; cursor: pointer; transition: all .15s;
  position: relative; min-height: 34px; border: 0; background: transparent; color: inherit; font-family: inherit;
}
.cal-day:hover { background: var(--bg-hover); }
.cal-day.today { background: var(--teal); color: white; font-weight: 700; }
.cal-day.has-event::after { content: ''; width: 5px; height: 5px; border-radius: 50%; background: var(--teal); position: absolute; bottom: 4px; }
.cal-day.today.has-event::after { background: white; }
.cal-day.other-month { color: var(--border); }
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.cal-nav h3 { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.cal-nav button { background: none; border: 1px solid var(--border); border-radius: 8px; padding: 6px 12px; cursor: pointer; color: var(--text-secondary); transition: all .15s; }
.cal-nav button:hover { background: var(--teal-light); color: var(--teal-dark); border-color: var(--teal); }
.event-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: var(--rsm); background: var(--bg); border: 1px solid var(--border); margin-bottom: 8px; transition: background .25s; }
.event-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; }
.event-item h5 { font-size: 13px; font-weight: 600; color: var(--text-primary); margin-bottom: 2px; }
.event-item p { font-size: 12px; color: var(--text-muted); }

/* ── BOLETIM PRINT ───────────────────────────────────── */
.boletim-wrap { max-width: 800px; margin: 0 auto; }
.boletim-card { background: var(--bg-card); border-radius: var(--r); box-shadow: var(--shadow-md); border: 1px solid var(--border); overflow: hidden; }
.boletim-header {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  color: white; padding: 24px 28px;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 16px;
}
.boletim-header-left { display: flex; align-items: center; gap: 14px; }
.boletim-logo-box {
  width: 48px; height: 48px; background: rgba(46,203,161,.2);
  border-radius: 12px; border: 2px solid rgba(46,203,161,.4);
  display: flex; align-items: center; justify-content: center;
}
.boletim-escola h2 { font-size: 16px; font-weight: 700; }
.boletim-escola p { font-size: 12px; opacity: .7; }
.boletim-aluno-info { text-align: right; }
.boletim-aluno-info h3 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.boletim-aluno-info p { font-size: 12px; opacity: .75; }
.boletim-body { padding: 24px 28px; }
.boletim-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.boletim-table th { padding: 10px 14px; background: var(--bg-stripe); font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .8px; border-bottom: 2px solid var(--border); }
.boletim-table td { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--border); color: var(--text-primary); }
.boletim-table th:not(:first-child), .boletim-table td:not(:first-child) { text-align: center; white-space: nowrap; }
.boletim-table td:first-child { min-width: 160px; }
.boletim-table tr:last-child td { border-bottom: none; }
.boletim-mobile-list { display: none; }
.boletim-footer { padding: 18px 28px; border-top: 2px solid var(--teal); background: var(--bg-stripe); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.boletim-footer p { font-size: 12px; color: var(--text-muted); }
.boletim-page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.print-actions { display: flex; gap: 10px; margin: 0; justify-content: flex-end; }

@media print {
  @page { margin: 10mm; }
  body { background: white !important; }
  body * { visibility: hidden !important; }
  .boletim-wrap, .boletim-wrap * { visibility: visible !important; }
  .boletim-wrap {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }
  .boletim-card {
    box-shadow: none !important;
    border-radius: 0 !important;
    border: 1px solid #d7dfed !important;
  }
  .boletim-header { background: var(--navy) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .boletim-table th { background: #f0f4ff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .nota-badge, .sit-badge { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ── OBS CARDS ───────────────────────────────────────── */
.obs-card { background: var(--bg-card); border-radius: var(--r); border: 1px solid var(--border); box-shadow: var(--shadow-sm); padding: 16px 20px; margin-bottom: 10px; transition: background .25s; }
.obs-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.obs-top h5 { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.obs-top span { font-size: 12px; color: var(--text-muted); }
.obs-card p { font-size: 14px; color: var(--text-secondary); line-height: 1.6; }

/* Student mobile navigation */
.student-mobile-nav { display: none; }
.student-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
}
.student-shortcuts button {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  border-radius: var(--r);
  padding: 14px;
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s, transform .2s, background .2s;
}
.student-shortcuts button:hover {
  border-color: var(--teal);
  background: var(--teal-light);
  transform: translateY(-1px);
}
.student-shortcuts span {
  display: block;
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 4px;
}
.student-shortcuts small {
  display: block;
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.3;
}

/* ── SUPERADMIN CARDS ────────────────────────────────── */
.escola-card {
  background: var(--bg-card); border-radius: var(--r); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); padding: 20px; display: flex; gap: 16px; align-items: center;
  transition: box-shadow .15s, background .25s, border-color .25s;
}
.escola-card:hover { box-shadow: var(--shadow-md); }
.escola-card-icon {
  width: 48px; height: 48px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--navy), var(--navy-mid));
  display: flex; align-items: center; justify-content: center;
}
.escola-card-icon svg { width: 24px; height: 24px; fill: none; stroke: white; stroke-width: 2; }
.escola-card-info h4 { font-size: 16px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.escola-card-info p { font-size: 13px; color: var(--text-muted); }
.escola-card-meta { margin-left: auto; text-align: right; flex-shrink: 0; }
.escola-status { display: inline-flex; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.status-ativo { background: var(--ok-bg); color: var(--ok); }
.status-inativo { background: var(--err-bg); color: var(--err); }

/* ── RESPONSIVE ──────────────────────────────────────── */
@media(max-width:600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .card-header { flex-direction: column; align-items: flex-start; }
  td, th { padding: 10px 12px; }
  .login-card { padding: 32px 24px; }
  .boletim-header { flex-direction: column; }
  .boletim-aluno-info { text-align: left; }
}

/* ── MOBILE APP POLISH ───────────────────────────────── */
@media(max-width:768px) {
  body { overflow-x: hidden; }
  #login-screen { padding: 14px; align-items: flex-start; padding-top: 34px; }
  .login-card { max-width: 100%; border-radius: 18px; padding: 30px 22px; }
  .login-logo { margin-bottom: 26px; }
  .login-logo-icon { width: 46px; height: 46px; border-radius: 12px; }
  .login-logo-text h1 { font-size: 26px; }
  .login-logo-text p { font-size: 10px; letter-spacing: 1px; }

  .topbar {
    height: 58px; padding: 0 10px; gap: 8px;
  }
  .topbar-left, .topbar-right { gap: 6px; min-width: 0; }
  .topbar-logo-icon { width: 32px; height: 32px; border-radius: 9px; }
  .topbar-logo-text { font-size: 16px; }
  .school-badge { display: none; }
  .theme-toggle { width: 34px; height: 34px; }
  .user-chip { padding: 4px; gap: 0; background: transparent; border: 0; }
  .user-chip-name, .role-pill { display: none; }
  .user-avatar { width: 31px; height: 31px; }
  .topbar-right .btn-outline { padding: 7px 10px; }

  .sidebar {
    top: 58px; width: min(82vw, 280px); height: calc(100vh - 58px);
    min-height: calc(100vh - 58px);
  }
  .app-body { overflow: visible; }
  .main-content {
    padding: 12px; max-height: none; min-height: calc(100vh - 58px);
    overflow: visible;
  }
  .page-header { margin-bottom: 14px; }
  .page-header h2 { font-size: 20px; line-height: 1.2; }
  .page-header p { font-size: 13px; line-height: 1.35; }
  .boletim-page-header { align-items: stretch; flex-direction: column; gap: 10px; }
  .boletim-page-header .print-actions { justify-content: flex-start; }
  .boletim-page-header .btn { width: 100%; }
  .aluno-profile-page-header { align-items: center; }
  .aluno-profile-page-header .aluno-back-btn { width: auto; flex: 0 0 auto; min-height: 36px; padding: 6px 12px; }

  .card { border-radius: 10px; margin-bottom: 14px; }
  .card-header { padding: 14px; gap: 10px; }
  .card-padded { padding: 16px; }
  .card-header > div { width: 100%; max-width: none !important; }
  .search-bar, .filter-select, .form-control { width: 100%; min-width: 0; }
  .card-header .btn, .card-padded .btn { width: 100%; justify-content: center; }
  .btn { min-height: 40px; justify-content: center; }
  .btn-sm { min-height: 34px; }
  .form-group { margin-bottom: 14px; }
  .form-group label {
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
  }
  .form-control {
    min-height: 44px;
    padding: 11px 13px;
    font-size: 16px;
    border-radius: 10px;
  }
  textarea.form-control {
    min-height: 96px;
    line-height: 1.45;
  }
  select.form-control {
    text-overflow: ellipsis;
  }
  .password-field .form-control {
    padding-right: 82px;
  }
  .password-toggle {
    min-height: 34px;
    padding: 6px 10px;
  }

  .stats-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
  .stat-card { padding: 14px; }
  .table-wrap { width: 100%; overflow: visible; }
  table.mobile-card-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0 10px;
  }
  table.mobile-card-table thead {
    display: none;
  }
  table.mobile-card-table,
  table.mobile-card-table tbody,
  table.mobile-card-table tr,
  table.mobile-card-table td {
    display: block;
    width: 100%;
  }
  table.mobile-card-table tr {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    padding: 10px 12px;
    margin-bottom: 10px;
  }
  table.mobile-card-table td {
    min-width: 0;
    border: 0;
    padding: 8px 0;
    color: var(--text-primary);
  }
  table.mobile-card-table td:not(:last-child) {
    border-bottom: 1px solid var(--border);
  }
  table.mobile-card-table td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 3px;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .45px;
  }
  table.mobile-card-table td:empty {
    display: none;
  }
  table.mobile-card-table td:last-child {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  table.mobile-card-table td:last-child::before {
    flex-basis: 100%;
  }
  table.mobile-card-table td:last-child .btn {
    width: auto;
    flex: 1 1 120px;
  }

  .finance-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin: 0 -12px 14px;
    padding-left: 12px;
    padding-right: 12px;
    scrollbar-width: none;
  }
  .finance-tabs::-webkit-scrollbar { display: none; }
  .finance-tab {
    flex: 0 0 auto;
    min-height: 38px;
    padding: 9px 13px;
    white-space: nowrap;
    border-radius: 999px;
  }
  table.finance-table.mobile-card-table tr {
    padding: 12px;
  }
  table.finance-table.mobile-card-table td {
    font-size: 14px;
    line-height: 1.35;
  }
  table.finance-table.mobile-card-table td.finance-main {
    padding-top: 2px;
  }
  table.finance-table.mobile-card-table td.finance-main strong,
  table.finance-table.mobile-card-table td.finance-main {
    font-size: 15px;
    font-weight: 800;
    color: var(--primary);
    overflow-wrap: anywhere;
  }
  table.finance-table.mobile-card-table td.finance-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--teal);
  }
  table.finance-table.mobile-card-table td small {
    display: block;
    margin-top: 3px;
    color: var(--text-muted);
    overflow-wrap: anywhere;
  }
  table.finance-table.mobile-card-table td.finance-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  table.finance-table.mobile-card-table td.finance-actions::before {
    grid-column: 1 / -1;
  }
  table.finance-table.mobile-card-table td.finance-actions .btn {
    width: 100%;
    min-width: 0;
    flex: none;
  }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    width: 100%;
    border-radius: 18px 18px 0 0;
    max-height: 94vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .modal-header {
    flex-shrink: 0;
    padding: 16px 16px 12px;
  }
  .modal-header h3 {
    font-size: 16px;
    line-height: 1.25;
  }
  .modal-close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    background: var(--bg-card);
  }
  .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 16px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .modal-footer {
    flex-shrink: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    background: var(--bg-card);
    box-shadow: 0 -8px 20px rgba(27,45,107,.08);
    flex-direction: column-reverse;
  }
  .modal-footer .btn { width: 100%; }
  .modal-body .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .modal-body .alert {
    align-items: flex-start;
    line-height: 1.35;
  }
  .modal-body input[type="file"].form-control {
    padding: 10px;
    min-height: 46px;
  }
  #aluno-foto-preview img {
    width: 64px !important;
    height: 64px !important;
    border-radius: 12px !important;
  }
  .inline-search-results,
  .top-search-results {
    max-height: 48vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .notas-aluno-head, .notas-materia-head { align-items: flex-start !important; }
  .notas-board { gap: 12px !important; }
  .notas-aluno-card,
  .notas-materia-card {
    border-radius: 12px !important;
  }
  .notas-aluno-head {
    padding: 14px !important;
  }
  .notas-aluno-head h3 {
    font-size: 16px !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere;
  }
  .notas-aluno-head p {
    font-size: 12px !important;
    line-height: 1.35 !important;
  }
  .notas-materias {
    padding: 10px !important;
    gap: 10px !important;
  }
  .notas-materia-card {
    padding: 12px !important;
  }
  .notas-materia-head {
    margin-bottom: 10px !important;
  }
  .notas-materia-head strong {
    font-size: 14px !important;
    line-height: 1.25 !important;
    overflow-wrap: anywhere;
  }
  .grade-grid {
    grid-template-columns: 1fr !important;
    gap: 9px !important;
  }
  .grade-slot {
    min-height: auto !important;
    border-radius: 11px !important;
    padding: 12px !important;
  }
  .grade-slot p {
    min-height: 0 !important;
    -webkit-line-clamp: 3 !important;
  }
  .grade-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
  }
  .grade-actions .btn {
    width: 100%;
    min-height: 36px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .freq-toolbar {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    box-shadow: var(--shadow-sm);
    margin-bottom: 12px;
  }
  .freq-toolbar strong {
    display: block;
    font-size: 16px;
    line-height: 1.25;
    color: var(--text-primary);
    overflow-wrap: anywhere;
  }
  .freq-toolbar p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
  }
  .freq-toolbar-actions {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 8px !important;
  }
  .freq-toolbar-actions .btn {
    width: 100%;
  }
  .freq-summary {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 8px;
    margin: 0 0 12px;
  }
  .freq-pill {
    min-width: 0;
    justify-content: center;
    text-align: center;
    border-radius: 999px;
    padding: 8px 8px;
    font-size: 11px;
    font-weight: 800;
  }
  .freq-feedback,
  .nota-feedback {
    border-radius: 12px;
    padding: 12px 14px;
    line-height: 1.35;
  }
  .freq-table.mobile-card-table tr {
    padding: 12px;
  }
  .freq-table.mobile-card-table td {
    padding: 9px 0;
  }
  .freq-table.mobile-card-table td:last-child {
    display: block;
  }
  .freq-table.mobile-card-table td:last-child::before {
    display: block;
  }
  .freq-table .freq-status,
  .freq-table .freq-obs {
    min-height: 42px;
  }

  .boletim-wrap { width: 100%; max-width: 100%; overflow: visible; }
  .boletim-card { width: 100%; min-width: 0; border-radius: 10px; }
  .boletim-header { padding: 18px; align-items: flex-start; }
  .boletim-body {
    padding: 12px;
    overflow: visible;
  }
  .boletim-table {
    display: none;
  }
  table.boletim-table.mobile-card-table {
    display: none;
  }
  .boletim-mobile-list {
    display: grid;
    gap: 10px;
  }
  .boletim-mobile-subject {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-card);
    padding: 12px;
  }
  .boletim-mobile-subject-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
  }
  .boletim-mobile-subject-head strong {
    display: block;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.25;
    overflow-wrap: anywhere;
  }
  .boletim-mobile-subject-head small {
    display: block;
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 12px;
  }
  .boletim-mobile-grades {
    display: grid;
    grid-template-columns: repeat(3,minmax(0,1fr));
    gap: 8px;
  }
  .boletim-mobile-grades div {
    min-height: 54px;
    border: 1px solid var(--border);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: var(--bg-stripe);
    text-align: center;
  }
  .boletim-mobile-grades span:first-child {
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .35px;
  }
  .muted-dash { color: var(--text-muted); }
  .boletim-footer { padding: 14px 16px; align-items: flex-start; }

  #aluno-app .sidebar { display: none; }
  #aluno-app .app-body { display: block; padding-bottom: 86px; }
  #aluno-app .main-content { width: 100%; padding-bottom: 98px; }
  #aluno-app .topbar {
    height: 56px;
    padding: 0 10px;
  }
  #aluno-app .topbar-left { flex: 1; min-width: 0; }
  #aluno-app .topbar-right { flex-shrink: 0; }
  #aluno-app .user-chip { display: none; }
  #aluno-app .topbar-right .btn-outline {
    min-height: 34px;
    padding: 6px 10px;
  }
  #aluno-app .page-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow-sm);
  }
  #aluno-app .page-header h2 {
    font-size: 18px;
  }
  #aluno-app .page-header p {
    margin-top: 4px;
  }
  #aluno-app .profile-hero {
    border-radius: 16px;
    padding: 18px;
    gap: 14px;
  }
  #aluno-app .profile-avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 18px;
  }
  #aluno-app .profile-info h2 {
    font-size: 19px;
    line-height: 1.2;
  }
  #aluno-app .profile-meta {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .student-shortcuts {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .student-shortcuts button {
    min-height: 86px;
    padding: 13px;
  }
  .student-mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 110;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(54px, 1fr));
    gap: 3px;
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px rgba(27,45,107,.12);
  }
  .student-mobile-nav button {
    min-width: 0;
    min-height: 56px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.1;
  }
  .student-mobile-nav button.active {
    background: var(--teal-light);
    color: var(--navy);
  }
  .student-mobile-nav svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
  }
  .student-mobile-nav button.active svg {
    stroke: var(--teal-dark);
  }
  .theme-toggle-aluno {
    bottom: 90px;
    width: 38px;
    height: 38px;
  }
}

@media(max-width:420px) {
  .topbar-logo-text { display: none; }
  .topbar-right .btn-outline { font-size: 12px; padding: 7px 8px; }
  .main-content { padding: 10px; }
  .page-header h2 { font-size: 19px; }
  .login-card { padding: 26px 18px; }
  .student-mobile-nav span { font-size: 10px; }
  .student-mobile-nav button { min-height: 52px; }
}

/* Typography polish: one professional voice across the system. */
body,
button,
input,
select,
textarea,
.btn,
.btn-primary,
.btn-secondary,
.nav-item,
.nav-group-title,
.topbar-logo-text,
.login-logo-text h1,
.card-header h3,
.page-header h2,
.modal-title,
.profile-info h2,
.stat-info h3,
.boletim-mobile-subject-head strong {
  font-family: var(--font-sans) !important;
}

h1,
h2,
h3,
h4,
h5,
.page-header h2,
.card-header h3,
.modal-title,
.login-logo-text h1,
.topbar-logo-text,
.profile-info h2 {
  font-weight: 700;
  letter-spacing: 0 !important;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.form-control,
.password-toggle,
.nav-item,
.tab-btn,
.login-tab {
  font-weight: 600;
  letter-spacing: 0 !important;
}

.sidebar-section-title,
.profile-meta-item span:first-child,
.boletim-table th,
.boletim-mobile-grades span:first-child,
.school-badge,
.role-pill,
.login-logo-text p {
  letter-spacing: .02em !important;
}

.login-logo-text p,
.sidebar-section-title,
.profile-meta-item span:first-child,
.boletim-table th,
.boletim-mobile-grades span:first-child {
  font-weight: 700 !important;
}

.stat-info h3,
.profile-meta-item span:last-child,
.metric-value,
.summary-number {
  font-weight: 700 !important;
}

/* SaaS school theme components shared by panel and student portal. */
[data-theme="saas"] body {
  background:
    radial-gradient(circle at 16% 0%, rgba(25,184,154,.12), transparent 30%),
    linear-gradient(180deg,#F8FBFF 0%,#F4F7FC 100%);
}

[data-theme="saas"] .topbar {
  background:var(--bg-topbar);
  border-bottom:1px solid rgba(24,87,215,.12);
  box-shadow:0 12px 28px rgba(16,42,86,.06);
  backdrop-filter:blur(14px);
}

[data-theme="saas"] .sidebar {
  background:linear-gradient(180deg,#FFFFFF 0%,#F7FAFF 100%);
  border-right:1px solid rgba(24,87,215,.11);
}

[data-theme="saas"] .topbar-logo-icon,
[data-theme="saas"] .login-logo-icon {
  background:linear-gradient(135deg,#1857D7,#19B89A);
  box-shadow:0 12px 24px rgba(24,87,215,.24);
}

[data-theme="saas"] .topbar-logo-text,
[data-theme="saas"] .login-logo-text h1,
[data-theme="saas"] .page-header h2,
[data-theme="saas"] .card-header h3 {
  color:#102A56;
}

[data-theme="saas"] .school-badge,
[data-theme="saas"] .role-pill,
[data-theme="saas"] .tag-teal {
  background:#E8F8F4;
  color:#087864;
  border-color:#BFEDE2;
}

[data-theme="saas"] .nav-item,
[data-theme="saas"] .nav-group-toggle {
  color:#4F6684;
}

[data-theme="saas"] .nav-item:hover,
[data-theme="saas"] .nav-group-toggle:hover,
[data-theme="saas"] .nav-group.open .nav-group-toggle {
  background:#EDF5FF;
  color:#1857D7;
}

[data-theme="saas"] .nav-item.active,
[data-theme="saas"] .nav-group-items .nav-item.active {
  background:#EAF2FF;
  color:#1857D7;
  box-shadow:inset 3px 0 0 #19B89A;
}

[data-theme="saas"] .card,
[data-theme="saas"] .stat-card,
[data-theme="saas"] .modal-content,
[data-theme="saas"] .login-card {
  border-color:rgba(24,87,215,.12);
  box-shadow:var(--shadow-sm);
}

[data-theme="saas"] .form-control,
[data-theme="saas"] .filter-select,
[data-theme="saas"] .search-bar,
[data-theme="saas"] .topbar-search input {
  background:#F8FAFE;
  border-color:#DCE6F3;
}

[data-theme="saas"] .form-control:focus,
[data-theme="saas"] .topbar-search:focus-within {
  border-color:#19B89A;
  box-shadow:0 0 0 4px rgba(25,184,154,.14);
}

[data-theme="saas"] .btn-primary,
[data-theme="saas"] .btn-teal {
  background:linear-gradient(135deg,#1857D7,#19B89A);
  color:#fff;
  border:0;
  box-shadow:0 12px 24px rgba(24,87,215,.18);
}

[data-theme="saas"] .btn-outline,
[data-theme="saas"] .theme-toggle,
[data-theme="saas"] .topbar-message-btn,
[data-theme="saas"] .password-toggle {
  background:#fff;
  color:#1857D7;
  border-color:#D7E4F5;
}

[data-theme="saas"] .theme-toggle,
[data-theme="saas"] .theme-toggle-aluno {
  position:relative;
}

[data-theme="saas"] .theme-toggle::after,
[data-theme="saas"] .theme-toggle-aluno::after {
  content:"";
  position:absolute;
  right:7px;
  top:7px;
  width:7px;
  height:7px;
  border-radius:50%;
  background:#19B89A;
  box-shadow:0 0 0 3px rgba(25,184,154,.14);
}
