/* ================================================================
   CSS GLOBAL — temas, layout, botões, cards, utilitários
   Aplicação do Design System MS (https://www.designsystem.ms.gov.br/)
   ================================================================ */

/* --- Variáveis e temas — DS MS tokens -------------------------- */
:root {
  color-scheme: light;

  /* Brand Colors (DS MS) */
  --ds-primary: #004F9F;
  --ds-primary-dark: #003D7A;
  --ds-secondary: #007F31;
  --ds-secondary-dark: #006828;
  --ds-tertiary: #FFD500;

  /* Complementary (DS MS) */
  --ds-green-600: #28A44C;
  --ds-blue-600: #0D99F7;
  --ds-red-600: #DA1E28;
  --ds-yellow-600: #F9BB00;
  --ds-orange-600: #FF832B;
  --ds-purple-600: #7C3ED0;

  /* Neutral Scale (DS MS) */
  --ds-neutral-900: #1D1D1B;
  --ds-neutral-800: #30302E;
  --ds-neutral-700: #565654;
  --ds-neutral-600: #686867;
  --ds-neutral-500: #7B7B7A;
  --ds-neutral-400: #8E8E8D;
  --ds-neutral-300: #B2B2B2;
  --ds-neutral-200: #D5D5D5;
  --ds-neutral-100: #F9F9F9;

  /* Spacing tokens (DS MS — base: 4px) */
  --ms-spacing-0: 0px;
  --ms-spacing-1: 1px;
  --ms-spacing-2: 2px;
  --ms-spacing-4: 4px;
  --ms-spacing-8: 8px;
  --ms-spacing-12: 12px;
  --ms-spacing-16: 16px;
  --ms-spacing-20: 20px;
  --ms-spacing-24: 24px;
  --ms-spacing-32: 32px;
  --ms-spacing-40: 40px;
  --ms-spacing-48: 48px;

  /* Semânticas — mapeamento DS MS → variáveis do app */
  --bg: #F9F9F9;
  --surface: #ffffff;
  --surface-2: #F9F9F9;
  --surface-3: #D5D5D5;
  --text: #1D1D1B;
  --muted: #686867;
  --border: #D5D5D5;
  --primary: #004F9F;
  --primary-2: #003D7A;
  --primary-soft: rgba(0, 79, 159, .08);
  --success: #007F31;
  --success-soft: rgba(0, 127, 49, .08);
  --warning: #F9BB00;
  --warning-soft: rgba(249, 187, 0, .10);
  --danger: #DA1E28;
  --danger-soft: rgba(218, 30, 40, .08);
  --info: #0D99F7;
  --info-soft: rgba(13, 153, 247, .08);
  --purple: #7C3ED0;

  /* Sombras, bordas e layout */
  --shadow-sm: 0 1px 3px rgba(29, 29, 27, .06);
  --shadow-md: 0 8px 24px rgba(29, 29, 27, .10);
  --radius: 12px;
  --radius-sm: 8px;
  --header: 76px;
  --font-heading: "Avenir Next LT Pro", "Avenir Next", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  --font: "Open Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}


/* --- Reset e base -------------------------------------------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
}
h1, h2, h3, h4, h5, h6 { font-family: var(--font-heading); }
button, input, select { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* --- App shell ------------------------------------------------- */
.app-shell { min-height: 100vh; }

/* --- Navegação principal -------------------------------------- */
.top-nav {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding-right: 10px; border-right: 1px solid var(--border);
}
.nav-btn {
  display: flex; align-items: center; gap: 7px; padding: 8px 11px;
  border: 1px solid transparent; border-radius: 999px; background: transparent; cursor: pointer;
  color: var(--muted); text-align: left; font-size: 13px; font-weight: 600; transition: .18s ease;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary); border-color: color-mix(in srgb, var(--primary) 18%, var(--border)); }
.nav-icon { text-align: center; font-size: 16px; }

/* --- Topbar ---------------------------------------------------- */
.main { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 30; min-height: var(--header);
  display: flex; align-items: center; justify-content: space-between;
  gap: 20px; padding: 14px 26px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 320px;
  max-width: 430px;
  padding-right: 18px;
  border-right: 1px solid var(--border);
}
.brand-logo {
  width: 128px;
  height: 48px;
  flex: 0 0 128px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--border);
  overflow: hidden;
}
.brand-logo img {
  width: auto;
  height: 100%;
  object-fit: contain;
  padding: 4px 6px;
  display: block;
}
.brand-copy {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand-copy strong {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.1;
}
.brand-copy span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.page-heading { min-width: 190px; flex: 1 1 auto; }
.page-heading h1 { margin: 0; font-size: 20px; line-height: 1.2; letter-spacing: -.01em; font-family: var(--font-heading); }
.page-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 660px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.info-btn { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 25%, var(--border)); }

/* --- Conteúdo -------------------------------------------------- */
.content { width: 100%; margin: 0 auto; padding: 22px 26px 44px; }
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 26px 18px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 72%, var(--bg));
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.app-footer strong {
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}
.page { display: none; animation: fadeIn .18s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* --- Botões ---------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); cursor: pointer; font-weight: 600; transition: .16s ease;
  text-decoration: none; font-size: 14px;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: color-mix(in srgb, var(--primary) 38%, var(--border)); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, var(--border)); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 32px; padding: 5px 10px; font-size: 12px; }
.icon-btn { width: 40px; height: 40px; padding: 0; font-size: 17px; }
.chart-mode-toggle {
  display: inline-flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  flex-shrink: 0;
}
.chart-mode-btn {
  min-height: 28px; border: 0; border-radius: 6px; padding: 4px 10px;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600;
}
.chart-mode-btn:hover { color: var(--text); background: var(--surface-3); }
.chart-mode-btn.active { background: var(--primary); color: #fff; }
.mobile-menu { display: none; }

/* --- Cards ----------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--ms-spacing-16); padding: var(--ms-spacing-16) var(--ms-spacing-20) 0; }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; font-family: var(--font-heading); font-weight: 700; }
.card-header p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.card-body { padding: var(--ms-spacing-16) var(--ms-spacing-20) var(--ms-spacing-20); }
.section-title { display: flex; justify-content: space-between; gap: var(--ms-spacing-16); align-items: center; flex-wrap: nowrap; margin: var(--ms-spacing-24) 0 var(--ms-spacing-12); }
.section-title:first-child { margin-top: 0; }
.section-title h2 { margin: 0; font-size: 16px; letter-spacing: -.01em; font-family: var(--font-heading); font-weight: 700; }
.section-title p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.section-title > div:first-child { min-width: 0; }

/* --- KPIs de resumo -------------------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  align-items: stretch;
  margin-bottom: var(--ms-spacing-24);
}
.kpi {
  display: flex;
  align-items: flex-start;
  gap: var(--ms-spacing-12);
  min-width: 0;
  min-height: 86px;
  padding: var(--ms-spacing-12) var(--ms-spacing-16);
}
.kpi-icon {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  font-size: 15px;
  font-weight: 850;
  line-height: 1;
}
.kpi-info {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 3px;
}
.kpi-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  overflow-wrap: anywhere;
  font-family: var(--font-heading);
}
.kpi-label {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.kpi-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.kpi[data-tone] {
  border-color: color-mix(in srgb, var(--kpi-tone) 20%, var(--border));
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--kpi-soft) 68%, transparent), transparent 72%),
    var(--surface);
}
.kpi[data-tone] .kpi-icon {
  background: var(--kpi-soft);
  color: var(--kpi-tone);
}
.kpi[data-tone] .kpi-value { color: var(--kpi-tone); }
.kpi[data-tone="danger"] { --kpi-tone: var(--danger); --kpi-soft: var(--danger-soft); }
.kpi[data-tone="success"] { --kpi-tone: var(--success); --kpi-soft: var(--success-soft); }
.kpi[data-tone="warning"] { --kpi-tone: var(--warning); --kpi-soft: var(--warning-soft); }
.kpi[data-tone="info"] { --kpi-tone: var(--info); --kpi-soft: var(--info-soft); }
.kpi[data-tone="primary"] { --kpi-tone: var(--primary); --kpi-soft: var(--primary-soft); }
/* --- Mini KPI cards (modal do aluno) -------------------------- */
.kpi-mini-group { }
.kpi-mini-group-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: var(--ms-spacing-4); padding-left: var(--ms-spacing-2);
}
.kpi-mini-grid {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.kpi-mini {
  display: flex; align-items: center; gap: var(--ms-spacing-8);
  padding: var(--ms-spacing-4) var(--ms-spacing-8); border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  min-width: 80px; flex: 0 0 auto;
}
.kpi-mini-icon {
  font-size: 14px; flex-shrink: 0; line-height: 1;
}
.kpi-mini-body {
  display: flex; flex-direction: column; gap: 1px; min-width: 0;
}
.kpi-mini-value {
  font-size: 16px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; color: var(--text);
  font-family: var(--font-heading);
}
.kpi-mini-label {
  font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.kpi-mini-detail {
  font-size: 9px; color: var(--muted); white-space: nowrap; opacity: .8;
}

/* --- Gráficos -------------------------------------------------- */
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.chart-card { min-height: 360px; }
.chart-card.tall { min-height: 430px; }
.chart-wrap { position: relative; height: 285px; }
.chart-card.tall .chart-wrap { min-height: 380px; }
canvas { max-width: 100%; }
.class-list-card { min-height: 0; }
.absence-list { display: grid; gap: 8px; }
.absence-list-item {
  display: grid; grid-template-columns: 34px 1fr; gap: var(--ms-spacing-10); align-items: center;
  padding: var(--ms-spacing-8) var(--ms-spacing-12); border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
}
.absence-list-rank {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--muted); font-size: 12px; font-weight: 700;
}
.absence-list-main { min-width: 0; }
.absence-list-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.absence-list-top strong { font-size: 13px; overflow-wrap: anywhere; }
.absence-list-top span { font-size: 13px; font-weight: 850; color: var(--danger); white-space: nowrap; }
.absence-list-meta { margin-top: 2px; color: var(--muted); font-size: 11px; }
.absence-list-bar { height: 6px; margin-top: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.absence-list-bar span { display: block; height: 100%; border-radius: inherit; background: var(--danger); }
.empty-inline { padding: 18px; color: var(--muted); text-align: center; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface-2); }

/* --- Insights -------------------------------------------------- */
.insights-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.insight { padding: 16px; display: flex; gap: 12px; }
.insight-icon { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 11px; background: var(--primary-soft); color: var(--primary); }
.insight h3 { margin: 0 0 5px; font-size: 13px; }
.insight p { margin: 0; color: var(--muted); font-size: 12px; }

/* --- Agrupamentos de KPIs compartilhados ---------------------- */
.context-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 14px;
  margin-bottom: 18px;
}
.context-group { min-width: 0; }
.context-group-head {
  min-height: 43px;
  display: grid;
  align-content: end;
  gap: 3px;
  margin-bottom: 8px;
  padding: 0 2px;
}
.context-group-head h3 {
  margin: 0;
  font-size: 14px;
  letter-spacing: -.01em;
}
.context-group-head p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}
.context-group-kpis.kpi-grid {
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 10px;
}
/* --- Toolbar --------------------------------------------------- */
.toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.toolbar .field { min-width: 170px; }
.toolbar-spacer { flex: 1; }

/* --- Page with right-side nav ---------------------------------- */
.page-with-nav { display: flex; gap: 0; align-items: flex-start; }
.page-nav-body { flex: 1; min-width: 0; }
.page-section { scroll-margin-top: 80px; margin-bottom: 32px; }
.page-section:last-child { margin-bottom: 0; }
.page-sidenav {
  width: 170px; flex-shrink: 0;
  position: sticky; top: calc(var(--header) + 12px);
  max-height: calc(100vh - var(--header) - 24px);
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 3px;
  padding: 4px 0 4px 14px;
  border-left: 1px solid var(--border);
  margin-left: 18px;
}
.page-nav-item {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 10px; border-radius: 9px;
  background: transparent; border: 0;
  color: var(--muted); font-size: 12px; font-weight: 650;
  cursor: pointer; text-align: left; width: 100%;
  transition: .15s ease;
}
.page-nav-item:hover { background: var(--surface-3); color: var(--text); }
.page-nav-item.active { background: var(--primary-soft); color: var(--primary); }
.tabulator-host { min-height: 360px; }
.table-card .card-body { padding-top: 12px; }
.table-card-header { align-items: end; }
.table-card-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 8px;
  flex: 1 1 430px;
  min-width: min(100%, 360px);
}
.table-search-field {
  display: grid;
  gap: 4px;
  flex: 1 1 360px;
  max-width: 520px;
}
.table-search-field label {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}
.table-search-field input {
  width: 100%;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
}
.table-search-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent);
}

/* --- Diario ---------------------------------------------------- */
#diaryTable {
  overflow: visible;
}
#ravTable {
  overflow: visible;
}
.diary-completion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.diary-completion-card {
  min-width: 0;
}
.diary-completion-card .card-body {
  padding-top: 12px;
}
.diary-completion-list {
  display: grid;
  gap: 8px;
}
.diary-completion-item {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  align-items: center;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
}
.diary-completion-rank {
  width: 48px;
  min-height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}
.diary-completion-main {
  min-width: 0;
}
.diary-completion-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.diary-completion-top strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.diary-completion-period {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.7;
  white-space: nowrap;
}
.diary-completion-meta {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}
.diary-completion-bar {
  height: 5px;
  margin-top: 6px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.diary-completion-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
}
.diary-completion-item[data-tone="success"] .diary-completion-rank,
.diary-completion-item[data-tone="success"] .diary-completion-bar span {
  background: var(--success);
  color: #fff;
}
.diary-completion-item[data-tone="warning"] .diary-completion-rank,
.diary-completion-item[data-tone="warning"] .diary-completion-bar span {
  background: var(--warning);
  color: #fff;
}
.diary-completion-item[data-tone="danger"] .diary-completion-rank,
.diary-completion-item[data-tone="danger"] .diary-completion-bar span {
  background: var(--danger);
  color: #fff;
}
.diary-period-action {
  width: 100%;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
  border-radius: 9px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.diary-period-action:hover {
  background: var(--primary);
  color: #fff;
}
.diary-period-action span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.diary-period-action i {
  flex: 0 0 auto;
  font-style: normal;
  font-weight: 900;
}
.diary-record-modal {
  width: min(1480px, 100%);
  height: min(92vh, 900px);
  max-height: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.diary-record-modal .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.diary-record-chips {
  flex: 0 0 auto;
  margin-bottom: 12px;
}
#diaryRecordTable {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-width: 100%;
  overflow: hidden;
}
#diaryRecordTable .tabulator {
  width: 100%;
  height: 100%;
}
#diaryRecordTable .tabulator-tableholder {
  overflow-y: auto !important;
}
.diary-record-student-info {
  gap: 4px;
  padding-block: 2px;
}
.diary-record-student-info strong {
  font-size: 12px;
}
.diary-record-student-info small {
  font-size: 10px;
}
#diaryRecordTable .tabulator-row.diary-record-row-missing-grade,
#diaryRecordTable .tabulator-row.diary-record-row-missing-grade:nth-child(even) {
  background: var(--warning-soft);
}
#diaryRecordTable .tabulator-row.diary-record-row-missing-grade:hover {
  background: color-mix(in srgb, var(--warning-soft) 72%, #fff4b8);
}
#diaryRecordTable .tabulator-row.diary-record-row-missing-grade .tabulator-cell {
  border-right-color: color-mix(in srgb, var(--warning) 18%, var(--border));
}
.diary-pending-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 86px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 800;
}
.diary-pending-cell span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.diary-pending-cell[data-tone="success"] {
  background: var(--success-soft);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 24%, var(--border));
}
.diary-pending-cell[data-tone="warning"] {
  background: var(--warning-soft);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 28%, var(--border));
}
.diary-pending-cell[data-tone="danger"] {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 28%, var(--border));
}
.diary-completion-percentage {
  display: inline-flex;
  min-width: 66px;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: #40536b;
  font-size: 11px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.diary-completion-percentage[data-tone="success"] {
  border-color: color-mix(in srgb, var(--success) 20%, var(--border));
  background: color-mix(in srgb, var(--success-soft) 68%, #fff);
  color: var(--success);
}
.diary-completion-percentage[data-tone="warning"] {
  border-color: color-mix(in srgb, var(--warning) 20%, var(--border));
  background: color-mix(in srgb, var(--warning-soft) 62%, #fff);
  color: var(--warning-foreground);
}
.diary-completion-percentage[data-tone="danger"] {
  border-color: color-mix(in srgb, var(--danger) 18%, var(--border));
  background: color-mix(in srgb, var(--danger-soft) 58%, #fff);
  color: var(--danger);
}
.table-grouped-info {
  min-width: 0;
  display: grid;
  gap: 3px;
  line-height: 1.25;
}
.table-grouped-info strong {
  color: #24364f;
  font-size: 12px;
  font-weight: 850;
  overflow-wrap: anywhere;
}
.table-grouped-info small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

/* --- RAV ------------------------------------------------------- */
.rav-panorama-chart {
  height: 420px;
}
.rav-insight-panel {
  overflow: hidden;
  border: 1px solid #d6e2ee;
  border-radius: 16px;
  background: #f4f8fc;
  box-shadow: 0 6px 18px rgba(30, 64, 110, .06);
}
.rav-insight-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #dbe5ef;
  background: rgba(255, 255, 255, .82);
}
.rav-insight-copy {
  min-width: 240px;
}
.rav-insight-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .1em;
  line-height: 1.2;
  text-transform: uppercase;
}
.rav-insight-copy h2 {
  margin: 0;
  color: #12396f;
  font-size: 21px;
  line-height: 1.2;
}
.rav-insight-copy p {
  max-width: 620px;
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.rav-insight-controls {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}
.rav-analysis-dimension-nav {
  min-height: 40px;
  padding: 4px;
  gap: 3px;
  border: 1px solid #d4dfeb;
  border-radius: 10px;
  background: #edf3f9;
  flex-wrap: nowrap;
}
.rav-analysis-dimension-nav .chart-mode-btn {
  min-height: 32px;
  padding: 5px 14px;
  border-radius: 7px;
  font-size: 12px;
  white-space: nowrap;
}
.rav-analysis-dimension-nav .chart-mode-btn.active {
  box-shadow: 0 3px 9px rgba(0, 75, 141, .18);
}
.rav-analysis-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.rav-analysis-sort-field {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 4px 5px 4px 11px;
  border: 1px solid #d4dfeb;
  border-radius: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .02em;
  white-space: nowrap;
}
.rav-analysis-sort-field select {
  width: 148px;
  min-height: 30px;
  padding: 4px 26px 4px 8px;
  border: 0;
  border-left: 1px solid #e2e8f0;
  border-radius: 0 6px 6px 0;
  outline: 0;
  background: #fff;
  color: #173c6d;
  font: inherit;
  font-size: 11px;
  letter-spacing: 0;
  cursor: pointer;
}
.rav-analysis-sort-field:focus-within {
  border-color: color-mix(in srgb, var(--primary) 54%, #d4dfeb);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}
.rav-analysis-icon-btn {
  display: inline-flex;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid #d4dfeb;
  border-radius: 9px;
  background: #fff;
  color: #173c6d;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}
.rav-analysis-icon-btn:hover {
  border-color: color-mix(in srgb, var(--primary) 46%, #d4dfeb);
  background: var(--primary-soft);
}
.rav-analysis-value-toggle {
  position: relative;
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  gap: 8px;
  padding: 5px 11px;
  border: 1px solid #d4dfeb;
  border-radius: 9px;
  background: #fff;
  color: #51647c;
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.rav-analysis-value-toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.rav-analysis-value-toggle i {
  position: relative;
  width: 34px;
  height: 18px;
  border-radius: 999px;
  background: #bdcad8;
  transition: background .18s ease;
}
.rav-analysis-value-toggle i::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
  transition: transform .18s ease;
}
.rav-analysis-value-toggle input:checked + i {
  background: var(--primary);
}
.rav-analysis-value-toggle input:checked + i::after {
  transform: translateX(16px);
}
.rav-analysis-value-toggle input:focus-visible + i {
  outline: 3px solid color-mix(in srgb, var(--primary) 20%, transparent);
  outline-offset: 2px;
}
.rav-analysis-export-btn {
  min-height: 40px;
  padding: 7px 14px;
  border-color: #cbd9e7;
  background: #fff;
  color: #12396f;
  white-space: nowrap;
}
.rav-insight-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px 0;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
}
.rav-insight-meta .badge {
  min-height: 24px;
  align-items: center;
  padding-inline: 10px;
}
.rav-panorama-meta-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.rav-panorama-meta-actions .btn {
  min-height: 30px;
  padding: 5px 10px;
}
.rav-insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
  padding: 14px 24px 22px;
}
.rav-insight-card {
  min-width: 0;
  padding: 18px 19px 20px;
  border: 1px solid #d9e3ed;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(30, 64, 110, .045);
  transition: border-color .16s ease, box-shadow .16s ease;
}
.rav-insight-card:hover {
  border-color: #b9cbdd;
  box-shadow: 0 6px 15px rgba(30, 64, 110, .08);
}
.rav-insight-card-header {
  display: flex;
  min-height: 45px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 17px;
  padding-bottom: 13px;
  border-bottom: 1px solid #edf1f5;
}
.rav-insight-card-header h3 {
  min-width: 0;
  margin: 0;
  color: #12396f;
  font-size: 15px;
  font-weight: 850;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.rav-insight-base {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  background: #eef3f8;
  color: #5b6b7e;
  font-size: 9px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
}
.rav-insight-metrics {
  display: grid;
  gap: 13px;
}
.rav-insight-metric {
  display: grid;
  grid-template-columns: 86px minmax(70px, 1fr) 58px;
  align-items: center;
  gap: 10px;
}
.rav-panorama-card .rav-insight-metric {
  grid-template-columns: minmax(0, 1fr);
  gap: 7px;
}
.rav-panorama-metric-head {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}
.rav-panorama-metric-value {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}
.rav-panorama-metric-value strong {
  color: #173c7b;
  font-size: 16px;
  font-weight: 900;
}
.rav-panorama-metric-value small {
  color: #64748b;
  font-size: 10px;
  font-weight: 750;
}
.rav-panorama-card .rav-insight-track {
  height: 12px;
}
.rav-insight-metric-label {
  color: #65758a;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: .045em;
  line-height: 1.2;
  text-transform: uppercase;
}
.rav-insight-track {
  display: block;
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e8eef4;
}
.rav-insight-fill {
  display: block;
  min-width: 0;
  height: 100%;
  border-radius: inherit;
  background: #728197;
}
.rav-insight-value {
  color: #334155;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}
.rav-insight-metric--recuperou .rav-insight-fill,
.rav-insight-summary-item--recuperou i {
  background: #15905d;
}
.rav-insight-metric--recuperou .rav-insight-value {
  color: #087849;
}
.rav-insight-metric--nao_avancou .rav-insight-fill,
.rav-insight-summary-item--nao_avancou i {
  background: #d62849;
}
.rav-insight-metric--nao_avancou .rav-insight-value {
  color: #c41438;
}
.rav-insight-metric--sem_nota .rav-insight-fill,
.rav-insight-summary-item--sem_nota i {
  background: #7c8ba0;
}
.rav-insight-metric--sem_nota .rav-insight-value {
  color: #607087;
}
.rav-insight-metric--nao_precisava .rav-insight-fill,
.rav-insight-summary-item--nao_precisava i {
  background: #176fba;
}
.rav-insight-metric--nao_precisava .rav-insight-value {
  color: #125c9c;
}
.rav-insight-empty {
  grid-column: 1 / -1;
  display: flex;
  min-height: 220px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  border: 1px dashed #c8d5e3;
  border-radius: 12px;
  background: rgba(255, 255, 255, .65);
  color: var(--muted);
  text-align: center;
}
.rav-insight-empty strong {
  color: #294b73;
  font-size: 14px;
}
.rav-insight-empty span {
  font-size: 11px;
}
.rav-insight-footer {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 13px 24px;
  border-top: 1px solid #dbe5ef;
  background: rgba(255, 255, 255, .76);
}
.rav-insight-summary {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.rav-insight-summary-total {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding-right: 14px;
  border-right: 1px solid #d9e2eb;
  color: #12396f;
}
.rav-insight-summary-total small {
  color: #6c7b8e;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: .035em;
  text-transform: uppercase;
}
.rav-insight-summary-total strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.rav-insight-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #5d6c80;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}
.rav-insight-summary-item i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #7c8ba0;
}
.rav-insight-summary-item strong {
  color: #263b55;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 1180px) {
  .rav-insight-header {
    align-items: flex-start;
    flex-direction: column;
  }
  .rav-insight-controls {
    width: 100%;
    align-items: flex-start;
  }
  .rav-analysis-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 760px) {
  .rav-insight-header {
    gap: 17px;
    padding: 18px 16px 15px;
  }
  .rav-insight-copy h2 {
    font-size: 18px;
  }
  .rav-insight-panel,
  .rav-insight-header > *,
  .rav-insight-controls,
  .rav-analysis-actions,
  .rav-analysis-sort-field,
  .rav-analysis-value-toggle {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }
  .rav-analysis-dimension-nav {
    width: 100%;
  }
  .rav-analysis-dimension-nav .chart-mode-btn {
    flex: 1 1 0;
    padding-inline: 7px;
  }
  .rav-analysis-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
  }
  .rav-analysis-sort-field {
    padding-left: 5px;
  }
  .rav-analysis-sort-field > span {
    display: none;
  }
  .rav-analysis-sort-field select {
    width: 100%;
    min-width: 0;
    flex: 1 1 auto;
    border-left: 0;
  }
  .rav-analysis-value-toggle,
  .rav-analysis-export-btn {
    grid-column: 1 / -1;
    justify-content: center;
  }
  .rav-insight-meta {
    min-width: 0;
    padding: 12px 16px 0;
  }
  .rav-insight-meta > * {
    min-width: 0;
  }
  .rav-insight-meta > :last-child {
    text-align: right;
  }
  .rav-insight-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 12px 16px 17px;
  }
  .rav-insight-card {
    padding-inline: 16px;
  }
  .rav-insight-metric {
    grid-template-columns: 80px minmax(54px, 1fr) 56px;
    gap: 8px;
  }
  .rav-insight-footer {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }
  .rav-insight-summary {
    gap: 9px 12px;
  }
}
.rav-detail-modal {
  width: min(1180px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.rav-detail-modal .modal-body {
  min-height: 0;
  overflow: auto;
}
.rav-detail-chips {
  margin-bottom: 12px;
}
.rav-detail-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.rav-detail-group {
  --rav-detail-tone: var(--primary);
  --rav-detail-soft: var(--primary-soft);
  min-width: 0;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--rav-detail-tone) 22%, var(--border));
  border-radius: 12px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--rav-detail-soft) 65%, transparent), transparent 76%),
    var(--surface-2);
}
.rav-detail-group-success { --rav-detail-tone: var(--success); --rav-detail-soft: var(--success-soft); }
.rav-detail-group-warning { --rav-detail-tone: var(--warning); --rav-detail-soft: var(--warning-soft); }
.rav-detail-group-info { --rav-detail-tone: var(--info); --rav-detail-soft: var(--info-soft); }
.rav-detail-group-danger { --rav-detail-tone: var(--danger); --rav-detail-soft: var(--danger-soft); }
.rav-detail-group strong {
  display: block;
  font-size: 12px;
  line-height: 1.25;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.rav-detail-group-metric {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.rav-detail-group-metric span {
  color: var(--rav-detail-tone);
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}
.rav-detail-group-metric small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}
.rav-detail-group ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 11px;
}
.rav-detail-group li {
  margin-bottom: 3px;
  overflow-wrap: anywhere;
}
.rav-detail-group--danger {
  min-height: 60px;
}
.rav-detail-group--danger li {
  break-inside: avoid;
}
.rav-detail-group--danger ul {
  column-count: 2;
  column-gap: 32px;
}

/* --- Estado vazio ---------------------------------------------- */
.empty-state { min-height: calc(100vh - 145px); display: grid; place-items: center; padding: 24px; }
.empty-panel { width: min(760px, 100%); padding: var(--ms-spacing-32); text-align: center; }
.empty-illustration { width: 92px; height: 92px; margin: 0 auto var(--ms-spacing-20); display: grid; place-items: center; border-radius: var(--radius); font-size: 42px; background: var(--primary-soft); }
.empty-panel h2 { margin: 0; font-size: 24px; letter-spacing: -.02em; font-family: var(--font-heading); font-weight: 700; }
.empty-panel p { max-width: 590px; margin: 10px auto 22px; color: var(--muted); }
.empty-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

/* --- Dropzone -------------------------------------------------- */
.dropzone {
  display: grid; place-items: center; min-height: 80px; padding: var(--ms-spacing-12) var(--ms-spacing-16); text-align: center;
  border: 2px dashed color-mix(in srgb, var(--primary) 35%, var(--border));
  border-radius: var(--radius); background: color-mix(in srgb, var(--primary-soft) 44%, var(--surface));
  transition: .18s ease; cursor: pointer;
}
.dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); }
.dropzone-icon { font-size: 24px; }
.dropzone h3 { margin: 4px 0 0; font-size: 14px; }
.dropzone p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.import-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 340px); gap: 16px; align-items: start; }
.file-list { display: grid; gap: 4px; max-height: 180px; overflow: auto; padding-right: 2px; margin-top: 10px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.file-item-main { min-width: 0; flex: 1; }
.file-item strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.file-item span { color: var(--muted); font-size: 11px; }
.file-status { font-size: 14px; flex-shrink: 0; }
.file-item .btn-remove { flex-shrink: 0; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; }
.file-item .btn-remove:hover { background: var(--danger-soft); color: var(--danger); }
.file-empty { padding: 10px 12px; border: 1px dashed var(--border); border-radius: 8px; color: var(--muted); font-size: 12px; background: var(--surface-2); text-align:center; }
.info-box { padding: 13px 14px; border-radius: 11px; background: var(--info-soft); color: var(--info); font-size: 12px; }
.warning-box { padding: 13px 14px; border-radius: 11px; background: var(--warning-soft); color: var(--warning); font-size: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; }
.import-status-card .card-body { display: grid; gap: 10px; }
.import-status-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.import-status-head strong { font-size: 13px; }
.import-status-head span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.import-status-message { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.import-status-meta { display: grid; gap: 6px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.import-status-pill { padding: 9px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; color: var(--muted); }
.privacy-dialog { width: min(560px, 100%); }
.privacy-dialog .card-body { padding-top: 16px; }
.privacy-content { display: grid; gap: 14px; }
.privacy-content p { margin: 0; color: var(--text); font-size: 13px; line-height: 1.6; }
.privacy-note-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.privacy-note {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.privacy-note strong { font-size: 12px; }
.privacy-note span { color: var(--muted); font-size: 12px; line-height: 1.45; }
.privacy-footnote {
  padding: 11px 12px;
  border-radius: 10px;
  background: var(--info-soft);
  color: var(--info) !important;
  font-size: 12px !important;
}

/* --- Períodos -------------------------------------------------- */
.period-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.period-card { padding: 15px; }
.period-card .period-name { color: var(--muted); font-size: 11px; font-weight: 800; }
.period-card .period-value { margin-top: 5px; font-size: 23px; font-weight: 820; }
.period-card .period-note { margin-top: 2px; color: var(--muted); font-size: 11px; }

/* --- Heatmap --------------------------------------------------- */
.heatmap-wrap { overflow: auto; border: 1px solid var(--border); border-radius: 12px; }
.heatmap { width: 100%; border-collapse: collapse; min-width: 650px; }
.heatmap th, .heatmap td { padding: 10px 12px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-size: 12px; }
.heatmap th:first-child, .heatmap td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); z-index: 1; }
.heatmap thead th { background: var(--surface-2); color: var(--muted); font-weight: 800; }
.heatmap tbody tr:last-child td { border-bottom: 0; }
.heat-cell { font-weight: 800; border-radius: 6px; }

/* --- Qualidade ------------------------------------------------- */
.quality-score { display: flex; align-items: center; gap: 20px; }
.score-ring { --score: 0; width: 112px; height: 112px; flex: 0 0 112px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--primary) calc(var(--score) * 1%), var(--surface-3) 0); position: relative; }
.score-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.score-ring strong { position: relative; z-index: 1; font-size: 26px; letter-spacing: -.04em; }
.quality-list { display: grid; gap: 8px; flex: 1; }
.quality-row { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.quality-row:last-child { border-bottom: 0; padding-bottom: 0; }
.quality-row span { color: var(--muted); }

/* --- Badges ---------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: var(--ms-spacing-2) var(--ms-spacing-8); border-radius: 999px; font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--muted); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: var(--surface-3); color: var(--muted); }
.badge-filter {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid color-mix(in srgb, var(--primary) 18%, var(--border));
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }

/* --- Modal ----------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 22px; background: rgba(7, 12, 22, .62); backdrop-filter: blur(4px); }
.modal { width: min(1050px, 100%); max-height: min(88vh, 900px); overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; gap: 20px; padding: 18px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; font-size: 18px; }
.modal-header p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.modal-body { padding: 20px; }
.student-profile-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
#studentKpisBimestre {
  display: grid !important;
  grid-template-columns: 1fr !important;
  gap: 12px;
  margin-bottom: 14px;
}
#studentKpisBimestre .kpi-mini-group { min-width: 0; margin-bottom: 0 !important; }
#studentKpisBimestre .kpi-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
  gap: 8px;
  align-items: stretch;
}
#studentKpisBimestre .kpi-mini {
  width: 100%;
  min-width: 0;
  min-height: 58px;
  align-items: flex-start;
}
#studentKpisBimestre .kpi-mini-body { min-width: 0; }
#studentKpisBimestre .kpi-mini-value,
#studentKpisBimestre .kpi-mini-label,
#studentKpisBimestre .kpi-mini-detail {
  white-space: normal;
  overflow-wrap: anywhere;
}
#studentBimestreDetails { display: grid; gap: 10px; }
#studentBimestreDetails .card { min-width: 0; }
#studentBimestreDetails .card-body {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)) !important;
  gap: 12px !important;
  padding: 14px 16px 16px;
}
#studentBimestreDetails .card-body > div { min-width: 0; }

/* --- Modal perfil do aluno (com nav lateral) ------------------- */
.student-modal { display: flex; flex-direction: column; height: min(92vh, 960px); max-height: none; overflow: hidden; width: min(1200px, 100%); }
.modal-with-nav { display: flex; flex: 1; min-height: 0; overflow: hidden; }
.modal-sidenav { width: 185px; flex-shrink: 0; display: flex; flex-direction: column; gap: 3px; padding: 14px 10px; border-right: 1px solid var(--border); background: var(--surface-2); overflow-y: auto; }
.modal-nav-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; background: transparent; border: 0; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; text-align: left; transition: .15s ease; width: 100%; }
.modal-nav-item:hover { background: var(--surface-3); color: var(--text); }
.modal-nav-item.active { background: var(--primary-soft); color: var(--primary); }
.student-modal .modal-body { flex: 1; overflow-y: auto; padding: 20px; }
.modal-section { margin-bottom: 26px; scroll-margin-top: 16px; }
.modal-section:last-child { margin-bottom: 0; }

/* Forçar empilhamento vertical dos blocos analíticos dentro do modal */
.modal .chart-grid { grid-template-columns: 1fr !important; gap: 14px; }
.compare-card { min-height: 0; }
.compare-panel { display: grid; gap: 14px; }
.compare-legend { display: flex; flex-wrap: wrap; gap: 7px; }
.compare-legend span,
.compare-values span {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2);
  font-size: 11px; font-weight: 750; color: var(--text);
}
.compare-legend i,
.compare-values i {
  width: 18px; height: 18px; display: grid; place-items: center; border-radius: 999px;
  color: #fff; font-size: 9px; font-style: normal; font-weight: 900;
}
.compare-grid { display: grid; gap: 10px; }
.compare-period-card {
  padding: 13px 14px 12px; border: 1px solid var(--border); border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--surface-2) 85%, transparent), var(--surface)),
    var(--surface);
  box-shadow: 0 10px 26px rgba(15, 23, 42, .05);
}
.compare-period-card header { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; margin-bottom: 10px; }
.compare-period-card header strong { font-size: 13px; letter-spacing: -.01em; }
.compare-period-card header span { font-size: 11px; color: var(--muted); font-weight: 700; }
.compare-track-wrap { position: relative; padding-top: 4px; }
.compare-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 10px; font-weight: 700; margin-bottom: 3px; }
.compare-track {
  --marker-size: 25px;
  --marker-inset: 4px;
  position: relative; height: 86px; border-radius: 18px; overflow: hidden;
  background:
    linear-gradient(90deg, rgba(239,68,68,.13), rgba(245,158,11,.14) 50%, rgba(34,197,94,.16)),
    repeating-linear-gradient(90deg, transparent 0, transparent calc(10% - 1px), rgba(100,116,139,.18) calc(10% - 1px), rgba(100,116,139,.18) 10%);
  border: 1px solid var(--border);
}
.compare-track::before {
  content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 2px;
  background: rgba(100,116,139,.28); transform: translateY(-50%);
}
.compare-marker {
  position: absolute;
  left: calc(var(--marker-inset) + (var(--pos) * (100% - var(--marker-size) - (var(--marker-inset) * 2))));
  top: var(--lane);
  width: var(--marker-size); height: var(--marker-size);
  display: grid; place-items: center; border-radius: 999px; color: #fff;
  font-size: 10px; font-weight: 900; box-shadow: 0 5px 13px rgba(15, 23, 42, .2);
  border: 2px solid var(--surface);
}
.compare-values { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.compare-empty { color: var(--muted); font-size: 12px; padding: 10px; border: 1px dashed var(--border); border-radius: 12px; background: var(--surface-2); }

/* Ajustes para impressão: mostrar modal sem backdrop e manter estilos */
@media print {
  .topbar-actions, .top-nav, .filters-card, .toolbar, .btn { display: none !important; }
  .modal-backdrop, .modal-backdrop.hidden { display: grid !important; }
  .modal-backdrop { position: static !important; background: transparent !important; padding: 0 !important; box-shadow: none !important; }
  .modal { position: static !important; width: 100% !important; max-width: 100% !important; max-height: none !important; border-radius: 0 !important; box-shadow: none !important; border: none !important; overflow: visible !important; }
  .modal-header { position: static !important; border-bottom: 1px solid #e6e6e6 !important; background: transparent !important; }
  .modal-body { padding: 12px !important; }
  .modal .chart-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .modal .chart-wrap { height: auto !important; min-height: 180px !important; }
  .modal .card { box-shadow: none !important; border: 1px solid #e6e6e6 !important; }
  .modal .btn, .modal .icon-btn, #printStudentBtn { display: none !important; }
  .card { break-inside: avoid; page-break-inside: avoid; }
  body { background: #fff !important; color: #111 !important; }
}

/* Classe utilitária para esconder elementos na impressão */
@media print {
  .no-print { display: none !important; }
}

/* Garantir que cada card dentro do modal ocupe 100% da coluna */
.modal .chart-grid > article.card { width: 100% !important; grid-column: 1 / -1 !important; }

/* Impressão: tornar títulos do modal em bloco para evitar junção de textos */
@media print {
  .modal .section-title { display: block !important; margin: 12px 0 !important; }
  .modal .section-title > div { display: block !important; }
  .modal .section-title h2 { margin-bottom: 6px !important; }

  /* Tabulator dentro do modal: garantir largura e evitar overflow em impressão */
  .modal .tabulator, .modal .tabulator-host, .modal #studentDetailTable {
    overflow: visible !important; width: 100% !important; max-width: 100% !important;
    page-break-inside: avoid !important; break-inside: avoid !important;
  }

  /* Evitar que linhas de tabela sejam divididas de forma estranha nas quebras de página */
  .modal .tabulator .tabulator-row, .modal .tabulator tbody tr { page-break-inside: avoid !important; }
}

/* --- Loading --------------------------------------------------- */
.loading-overlay { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; background: rgba(10,15,25,.65); backdrop-filter: blur(5px); }
.loading-panel { width: min(440px, calc(100% - 32px)); padding: var(--ms-spacing-24); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md); text-align: center; }
.spinner { width: 42px; height: 42px; margin: 0 auto 14px; border: 4px solid var(--surface-3); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.progress { height: 7px; margin-top: 14px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress-bar { width: 0; height: 100%; background: var(--primary); transition: width .2s ease; }

/* --- Toast ----------------------------------------------------- */
.toast-container { position: fixed; z-index: 300; right: 18px; bottom: 18px; display: grid; gap: 8px; width: min(380px, calc(100% - 36px)); }
.toast { padding: var(--ms-spacing-12) var(--ms-spacing-16); border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); display: flex; gap: var(--ms-spacing-10); align-items: flex-start; animation: toastIn .2s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }
.toast.success { border-left: 4px solid var(--success); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.error { border-left: 4px solid var(--danger); }
.toast strong { display: block; font-size: 12px; }
.toast span { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

/* --- Tabulator (adaptado ao tema) ------------------------------ */
.tabulator { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); color: var(--text); font-size: 12px; }
.tabulator .tabulator-header { background: var(--surface-2); color: var(--text); border-bottom: 1px solid var(--border); }
.tabulator .tabulator-header .tabulator-col { background: var(--surface-2); border-right: 1px solid var(--border); height: auto !important; min-height: 38px; }
.tabulator .tabulator-header .tabulator-col-content { min-height: 38px; display: flex; align-items: center; }
.tabulator .tabulator-header .tabulator-col-title {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  overflow-wrap: normal;
  word-break: normal;
  line-height: 1.2;
}
.tabulator .tabulator-header .tabulator-col-title-holder { width: 100%; }
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover { background: var(--surface-3); }
.tabulator-row { background: var(--surface); border-bottom: 1px solid var(--border); }
.tabulator-row:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 48%, var(--surface)); }
.tabulator-row.tabulator-selectable:hover { background: var(--primary-soft); }
.tabulator-row .tabulator-cell { border-right: 1px solid var(--border); }
.tabulator-row .tabulator-cell.cell-wrap,
.table-text-wrap {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
  line-height: 1.25;
}
.student-table-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 4px 0;
  line-height: 1.25;
}
#studentsTable {
  overflow-x: auto;
}
#studentsTable .tabulator {
  min-width: 980px;
}
.student-detail-thumb {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--primary) 28%, var(--border));
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
  font-weight: 900;
  cursor: pointer;
}
.student-detail-thumb:hover {
  background: var(--primary);
  color: #fff;
}
.student-table-text {
  width: max-content;
  max-width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.student-table-main {
  display: block;
  font-size: 13px;
  font-weight: 820;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: normal;
}
.student-table-detail {
  display: block;
  width: 0;
  min-width: 100%;
  max-width: 100%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tabulator .tabulator-footer { background: var(--surface-2); border-top: 1px solid var(--border); color: var(--text); }
.tabulator .tabulator-footer .tabulator-page { color: var(--text); border-color: var(--border); background: var(--surface); }
.tabulator .tabulator-footer .tabulator-page.active { background: var(--primary); color: #fff; }
.tabulator .tabulator-placeholder { background: var(--surface); color: var(--muted); }

/* --- Filtros colapsáveis --------------------------------------- */
.filters-card { margin-bottom: 18px; }
.filters-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.filters-top strong { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.filter-count { color: var(--muted); font-size: 12px; font-weight: 500; }
.filter-toggle-icon { display: inline-block; transition: transform .2s ease; font-size: 12px; }
.filters-card.collapsed .filter-toggle-icon { transform: rotate(-90deg); }
.filters-card.collapsed .filters-grid-wrap { display: none; }
.filters-grid-wrap { overflow: visible; }
.filters-grid { display: grid; grid-template-columns: repeat(9, minmax(100px, 1fr)); gap: 8px; padding: 10px 12px 12px; }
.field-comp-curricular { grid-column: span 2; }
.filter-active-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 0; min-height: 0; flex: 1; min-width: 0; }
.filters-card:not(.collapsed) .filter-active-tags { display: none; }
.filter-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 10px; font-weight: 700; background: var(--primary-soft); color: var(--primary); white-space: nowrap; }
.filter-tag .tag-remove { cursor: pointer; opacity: .6; font-size: 12px; line-height: 1; }
.filter-tag .tag-remove:hover { opacity: 1; }
.filter-tag-more { display: inline-flex; align-items: center; padding: 2px 6px; border-radius: 999px; font-size: 10px; font-weight: 700; background: var(--surface-3); color: var(--muted); }

/* --- Select múltiplo custom ------------------------------------ */
.multiselect-field { position: relative; }
.multiselect-field .ms-selected {
  display: flex; flex-wrap: nowrap; gap: 4px; padding: 6px 8px; min-height: 36px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface-2);
  cursor: pointer; align-items: center; font-size: 12px; overflow: hidden;
}
.multiselect-field .ms-selected .ms-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px;
  border-radius: 6px; background: var(--primary-soft); color: var(--primary); font-size: 11px;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto;
}
.multiselect-field .ms-selected .ms-tag .ms-remove { cursor: pointer; opacity: .6; font-size: 12px; }
.multiselect-field .ms-selected .ms-placeholder { color: var(--muted); font-size: 12px; }
.multiselect-field .ms-dropdown {
  display: none; position: absolute; z-index: 999; top: 100%; left: 0;
  min-width: 100%; width: max-content; max-width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); box-shadow: var(--shadow-md); margin-top: 4px; padding: 6px;
}
.multiselect-field.open .ms-dropdown { display: block; }
.multiselect-field .ms-search-wrap { position: sticky; top: 0; z-index: 1; background: var(--surface); padding-bottom: 5px; }
.multiselect-field .ms-search {
  width: 100%; min-width: 220px; min-height: 34px; padding: 7px 9px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none; font-size: 12px;
}
.multiselect-field .ms-search:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.multiselect-field .ms-options { max-height: 230px; overflow-y: auto; }
.multiselect-field .ms-option {
  display: flex; align-items: center; gap: 8px; min-height: 30px; padding: 5px 8px;
  cursor: pointer; font-size: 12px; border-radius: 7px; transition: .12s ease;
}
.multiselect-field .ms-option:hover { background: var(--primary-soft); }
.multiselect-field .ms-option input { width: 15px; height: 15px; flex: 0 0 15px; accent-color: var(--primary); }
.multiselect-field .ms-option label {
  cursor: pointer; flex: 1; min-width: 0; white-space: nowrap;
}
.multiselect-field .ms-empty { padding: 9px; color: var(--muted); font-size: 12px; }
.multiselect-field .hidden { display: none !important; }

/* --- Field ----------------------------------------------------- */
.field { display: grid; gap: 5px; min-width: 0; }
.field label { color: var(--muted); font-size: 11px; font-weight: 750; }
.field input, .field select {
  width: 100%; min-height: 36px; padding: 7px 9px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); outline: none;
}
.field input:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 14%, transparent); }
.field-wide { grid-column: span 2; }
.check-field { display: flex; align-items: end; }
.check-label { min-height: 38px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); font-weight: 650; }
.check-label input { width: 17px; height: 17px; accent-color: var(--primary); }

/* --- Responsivo ------------------------------------------------ */
@media (max-width: 1380px) {
  .filters-grid { grid-template-columns: repeat(5, minmax(110px, 1fr)); }
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .chart-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1040px) {
  .context-summary-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .topbar-left { align-items: flex-start; flex-direction: column; gap: 9px; }
  .brand-block { width: 100%; max-width: none; padding-right: 0; border-right: 0; }
  .page-heading { min-width: 0; width: 100%; }
  .top-nav { padding-left: 0; border-left: 0; flex-wrap: wrap; }
  .insights-grid { grid-template-columns: 1fr; }
  .diary-completion-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {

  .topbar { padding: 12px 15px; gap: 12px; }
  .brand-block { min-width: 0; }
  .brand-logo { width: 150px; height: 42px; flex-basis: 130px; }
  .brand-copy span { font-size: 10px; }
  .nav-btn { padding: 7px 9px; font-size: 12px; }
  .topbar-actions .hide-mobile { display: none; }
  .content { padding: 16px 14px 34px; }
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-wide { grid-column: span 2; }
  .field-comp-curricular { grid-column: span 2; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-grid, .chart-grid.three { grid-template-columns: 1fr; }
  .period-grid { grid-template-columns: repeat(2, 1fr); }
  .student-profile-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid { grid-template-columns: 1fr; }
  .table-card-header { align-items: stretch; flex-direction: column; }
  .table-card-actions { width: 100%; min-width: 0; flex-wrap: wrap; justify-content: stretch; }
  .table-search-field { max-width: none; }
  .table-card-actions .btn { flex: 1 1 150px; }
  .quality-score { align-items: flex-start; flex-direction: column; }
  .page-heading p { max-width: 220px; }
  .app-footer { align-items: flex-start; flex-direction: column; padding: 12px 15px 16px; }
  .app-footer strong { text-align: left; }
}
@media (max-width: 480px) {
  .filters-grid, .kpi-grid, .period-grid { grid-template-columns: 1fr; }
  .mapa-picker-search { flex-direction: column; }
  .mapa-picker-select-all { width: 100%; }
  .privacy-note-grid { grid-template-columns: 1fr; }
  .field-wide, .field-comp-curricular { grid-column: span 1; }
  .empty-panel { padding: 24px 18px; }
  .topbar-actions .btn-primary { width: 38px; padding: 0; }
  .topbar-actions .btn-primary span { display: none; }
}
/* ================================================================
   MAPA — tabela de diagnóstico e modal de seleção
   ================================================================ */
.mapa-table {
  width: 100%;
  border-collapse: separate !important;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 0.88rem;
}
.mapa-table thead th {
  background: #fbfafb;
  color: #475569;
  font-weight: 800;
  font-size: 0.75rem;
  letter-spacing: .04em;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: normal;
}
.mapa-table tbody tr { background: var(--surface); box-shadow: none; }
.mapa-table tbody tr + tr td { border-top: 1px solid #e5e7eb; }
.mapa-table td {
  padding: 1rem;
  border: none;
  vertical-align: top;
  font-size: 0.88rem;
}
.mapa-table td:first-child,
.mapa-table td:last-child { border-radius: 0; }
.mapa-table input[type="text"],
.mapa-table textarea,
.mapa-table .mapa-editable {
  width: 100%;
  border: 1px solid #cfd6e0;
  padding: 0.7rem 0.75rem;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.42;
  background: var(--surface);
  border-radius: 6px;
  resize: vertical;
  min-height: 180px;
  color: #0f172a;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.mapa-editable {
  outline: none;
  word-break: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
}
.mapa-editable strong { font-weight: 800; color: #0f172a; }
.mapa-editable:empty::before { content: attr(data-placeholder); color: #64748b; font-style: normal; }
.mapa-table input:hover,
.mapa-table textarea:hover,
.mapa-table .mapa-editable:hover { border-color: #aeb8c6; }
.mapa-table input:focus,
.mapa-table textarea:focus,
.mapa-table .mapa-editable:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(0,79,159,.12);
}
.mapa-student-cardlet, .mapa-component-title { min-width: 0; }
.mapa-student-id {
  display: block;
  margin-bottom: 0.45rem;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 650;
}
.mapa-student-name, .mapa-component-title {
  display: block;
  color: #0f172a;
  font-weight: 850;
  font-size: 1.05rem;
  line-height: 1.35;
}
.mapa-student-meta {
  display: block;
  margin-top: 0.4rem;
  color: #334155;
  font-size: 0.86rem;
  line-height: 1.35;
}
.mapa-absence-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  color: #b91c1c;
  background: transparent;
  border: none;
  font-size: 1.35rem;
  font-weight: 900;
  line-height: 1;
}
.mapa-absence-pill--muted { color: #0f172a; font-size: 1rem; }
.mapa-context-actions {
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin-bottom: 0.45rem;
}
.mapa-cell-action-btn {
  appearance: none;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 42px;
  padding: 0.45rem 0.65rem;
  border-radius: 5px;
  border: 1px solid #d1d5db;
  background: #f7f5f7;
  color: #0f172a;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
}
.mapa-cell-action-btn span:first-child { font-size: 1rem; line-height: 1; }
.mapa-cell-action-btn:hover { background: #eef2f7; border-color: #b7c0cc; }
.mapa-action-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--primary);
  font: inherit;
  font-size: 0.74rem;
  font-weight: 800;
  cursor: pointer;
}
.mapa-action-chip:hover { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); }
.mapa-subject-line,
.mapa-comp-estudante {
  display: grid;
  align-items: center;
  gap: 0.48rem;
  min-height: 30px;
  margin-bottom: 0.28rem;
  padding: 0.28rem 0.48rem;
  border: 1px solid #e5e7eb;
  border-radius: 5px;
  cursor: pointer;
}
.mapa-subject-line { grid-template-columns: auto minmax(0, 1fr) auto auto; }
.mapa-comp-estudante { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.mapa-subject-line--danger,
.mapa-subject-line--warning,
.mapa-subject-line--success,
.mapa-subject-line--neutral { background: #f8fafc; }
.mapa-subject-line--covered {
  background: #eff6ff !important;
  border-color: #93c5fd !important;
  box-shadow: inset 3px 0 0 #2563eb;
}
.mapa-subject-line--covered .mapa-subject-name,
.mapa-subject-line--covered .mapa-comp-student-name { color: #1d4ed8; }
.mapa-subject-line input[type="checkbox"],
.mapa-comp-estudante input[type="checkbox"] {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  accent-color: #111827;
}
.mapa-subject-main { display: contents; }
.mapa-comp-student-main { display: flex; min-width: 0; flex-direction: column; gap: 0.08rem; }
.mapa-subject-name, .mapa-comp-student-name {
  min-width: 0;
  color: #0f172a;
  font-size: 0.9rem;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.mapa-subject-detail, .mapa-comp-student-meta {
  color: #334155;
  font-size: 0.78rem;
  white-space: nowrap;
}
.mapa-grade-badge, .mapa-manual-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0.24rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.1;
  white-space: nowrap;
}
.mapa-grade-badge--danger { background: #fff1f2; color: #b91c1c; border-color: #fecaca; }
.mapa-grade-badge--warning { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.mapa-grade-badge--success { background: #ecfdf5; color: #15803d; border-color: #bbf7d0; }
.mapa-grade-badge--neutral { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }
.mapa-manual-badge { background: #64748b; color: #fff; }
.mapa-delete-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #dc2626;
  cursor: pointer;
  font-size: 1rem;
}
.mapa-delete-btn:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 18%, transparent); }
.mapa-empty-note { display: inline-flex; color: var(--muted); font-size: 0.82rem; padding: 0.35rem 0; }
.mapa-coletivo-resumo {
  min-height: 120px;
  padding: 0.7rem 0.8rem;
  border: 1px solid #cfd6e0;
  border-radius: 6px;
  background: #f8fafc;
  color: #0f172a;
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-wrap;
}
.mapa-student-group-head { padding: 0 !important; }
.mapa-student-head-grid {
  padding: 0.75rem 1rem;
  align-items: center;
}
.mapa-student-record-cell { padding: 0 !important; }
.mapa-student-record {
  background: var(--surface);
  box-shadow: inset 4px 0 0 #2563eb;
}
.mapa-student-record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: 0.68rem 1rem;
  background: #eaf2ff;
  border-bottom: 1px solid #b8d0f0;
}
.mapa-student-heading {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  min-width: 0;
  flex: 1 1 auto;
}
.mapa-student-record .mapa-student-id {
  display: inline-flex;
  flex: 0 0 auto;
  margin: 0;
  color: #475569;
  font-size: 0.76rem;
  white-space: nowrap;
}
.mapa-student-record .mapa-student-name {
  display: inline-block;
  min-width: 7rem;
  max-width: 34rem;
  overflow: hidden;
  color: #123f7a;
  font-size: 0.98rem;
  font-weight: 850;
  line-height: 1.18;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mapa-student-record .mapa-student-meta {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  margin: 0;
  color: #475569;
  font-size: 0.78rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mapa-student-total-faltas {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  flex: 0 0 auto;
  color: #991b1b;
  line-height: 1;
  white-space: nowrap;
}
.mapa-student-total-faltas strong { font-size: 1.42rem; font-weight: 900; }
.mapa-student-total-faltas small { color: #7f1d1d; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
.mapa-student-row-grid {
  display: grid;
  grid-template-columns: minmax(330px, 1.35fr) minmax(220px, 1fr) minmax(220px, 1fr) 42px;
  gap: 0.75rem;
  min-width: 0;
}
.mapa-student-work-grid {
  align-items: stretch;
  padding: 0.78rem 1rem 0.9rem;
}
.mapa-student-components-cell,
.mapa-student-field-cell,
.mapa-student-action-cell { min-width: 0; }
.mapa-student-components-cell .mapa-subject-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.24rem 0.42rem;
  align-content: start;
}
.mapa-student-components-cell .mapa-subject-grid--empty { grid-template-columns: 1fr; }
.mapa-student-components-cell .mapa-subject-line {
  min-height: 26px;
  margin: 0;
  padding: 0.2rem 0.38rem;
  gap: 0.34rem;
  border-radius: 5px;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
}
.mapa-student-components-cell .mapa-subject-name {
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mapa-student-components-cell .mapa-subject-detail { font-size: 0.72rem; }
.mapa-student-components-cell .mapa-grade-badge {
  padding: 0.2rem 0.38rem;
  font-size: 0.66rem;
}
.mapa-student-record .mapa-context-actions { margin-bottom: 0.38rem; }
.mapa-student-record .mapa-cell-action-btn {
  min-height: 36px;
  padding: 0.38rem 0.55rem;
  font-size: 0.72rem;
}
.mapa-student-record .mapa-editable {
  min-height: 112px;
  padding: 0.62rem 0.68rem;
}
.mapa-student-action-cell {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 0.15rem;
}

@media (max-width: 980px) {
  .mapa-student-heading { flex-wrap: wrap; }
  .mapa-component-record-header { flex-wrap: wrap; }
  .mapa-student-record .mapa-student-name { max-width: 100%; white-space: normal; }
  .mapa-student-row-grid { grid-template-columns: 1fr; }
  .mapa-student-head-grid span:not(:first-child) { display: none; }
  .mapa-student-components-cell .mapa-subject-grid { grid-template-columns: 1fr; }
  .mapa-student-action-cell { justify-content: flex-start; }
}
.mapa-linked-work-grid {
  grid-template-rows: auto 1fr;
  align-items: start;
}
.mapa-linked-work-grid > .mapa-student-components-cell,
.mapa-linked-work-grid > .mapa-component-students-cell {
  grid-column: 1;
  grid-row: 1 / span 2;
}
.mapa-linked-work-grid > .mapa-linked-action-cell {
  grid-column: 2 / span 2;
  grid-row: 1;
  min-width: 0;
}
.mapa-linked-work-grid > .mapa-student-field-cell:nth-of-type(3),
.mapa-linked-work-grid > .mapa-component-field-cell:nth-of-type(3) {
  grid-column: 2;
  grid-row: 2;
}
.mapa-linked-work-grid > .mapa-student-field-cell:nth-of-type(4),
.mapa-linked-work-grid > .mapa-component-field-cell:nth-of-type(4) {
  grid-column: 3;
  grid-row: 2;
}
.mapa-linked-work-grid > .mapa-student-action-cell {
  grid-column: 4;
  grid-row: 1 / span 2;
}
.mapa-linked-action-cell .mapa-context-actions { margin-bottom: 0; }
.mapa-linked-action-btn {
  min-height: 32px;
  grid-template-columns: auto auto;
  justify-content: center;
}
.mapa-student-components-cell .mapa-subject-grid {
  gap: 0.16rem 0.26rem;
}
.mapa-student-components-cell .mapa-subject-line {
  min-height: 22px;
  padding: 0.13rem 0.26rem;
  gap: 0.24rem;
  align-items: start;
}
.mapa-student-components-cell .mapa-subject-name {
  font-size: 0.78rem;
  line-height: 1.15;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}
.mapa-student-components-cell .mapa-subject-detail {
  align-self: center;
  font-size: 0.68rem;
}
.mapa-student-components-cell .mapa-grade-badge {
  align-self: center;
  padding: 0.16rem 0.3rem;
  font-size: 0.62rem;
}
.mapa-linked-entry {
  display: block;
  min-height: 70px;
  margin: 0 0 0.55rem;
  padding: 0.58rem 0.62rem 0.62rem;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  background: #ffffff;
}
.mapa-linked-entry legend {
  width: auto;
  max-width: calc(100% - 0.6rem);
  padding: 0 0.28rem;
  margin-left: -0.18rem;
  color: #475569;
  background: #ffffff;
  font-size: 0.68rem;
  font-weight: 850;
  line-height: 1.15;
  white-space: normal;
}
.mapa-linked-entry--deficit legend { color: #991b1b; }
.mapa-linked-entry--intervencao legend { color: #1d4ed8; }
.mapa-linked-body {
  min-height: 38px;
  outline: none;
}
.mapa-linked-entry--intervencao {
  border-color: #bfdbfe;
  background: #f8fbff;
}
.mapa-linked-entry--intervencao:focus-within {
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.10);
}
.mapa-linked-entry:last-child { margin-bottom: 0; }
.mapa-component-group-head { padding: 0 !important; }
.mapa-component-head-grid {
  padding: 0.75rem 1rem;
  align-items: center;
}
.mapa-component-record-cell { padding: 0 !important; }
.mapa-component-record {
  background: var(--surface);
  box-shadow: inset 4px 0 0 #0f766e;
}
.mapa-component-record-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: 0.68rem 1rem;
  background: #eaf7f4;
  border-bottom: 1px solid #b7ddd4;
}
.mapa-component-record-header .mapa-component-title {
  margin: 0;
  min-width: 0;
  color: #0f5b55;
  font-size: 1rem;
  font-weight: 850;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.mapa-component-total-faltas {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  flex: 0 0 auto;
  color: #991b1b;
  line-height: 1;
  white-space: nowrap;
}
.mapa-component-total-faltas strong { font-size: 1.42rem; font-weight: 900; }
.mapa-component-total-faltas small { color: #7f1d1d; font-size: 0.72rem; font-weight: 800; text-transform: uppercase; }
#mapaStudentsBody tr + tr td,
#mapaCompBody tr + tr td {
  border-top: 6px solid #d9e3ed;
}
.mapa-component-row-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.35fr) minmax(220px, 1fr) minmax(220px, 1fr);
  gap: 0.75rem;
  min-width: 0;
  padding: 0.78rem 1rem 0.9rem;
}
.mapa-component-students-cell,
.mapa-component-field-cell { min-width: 0; }
.mapa-component-student-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.24rem 0.42rem;
  align-content: start;
}
.mapa-component-record .mapa-component-student-item {
  grid-template-columns: 16px minmax(0, 1fr) auto;
  grid-template-areas: "check identity utility";
  align-items: start;
  min-height: 54px;
  margin: 0;
  padding: 0.52rem 0.62rem;
  gap: 0.62rem;
  border-radius: 8px;
  background: #f8fafc;
}
.mapa-component-record .mapa-comp-est-check { grid-area: check; }
.mapa-component-record .mapa-comp-student-main { grid-area: identity; gap: 0.16rem; }
.mapa-component-record .mapa-comp-student-name {
  font-size: 0.84rem;
  line-height: 1.2;
}
.mapa-component-record .mapa-comp-student-metrics {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
}
.mapa-component-record .mapa-comp-student-meta { font-size: 0.76rem; line-height: 1.15; }
.mapa-component-record .mapa-grade-badge,
.mapa-component-record .mapa-manual-badge {
  padding: 0.26rem 0.42rem;
  font-size: 0.68rem;
}
.mapa-component-record .mapa-comp-student-metrics .mapa-grade-badge { margin-left: auto; }
.mapa-component-record .mapa-comp-student-utility {
  grid-area: utility;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  justify-self: end;
}
.mapa-component-record .mapa-comp-student-utility:empty { display: none; }
.mapa-component-record .mapa-comp-student-utility .mapa-delete-btn {
  width: 26px;
  height: 26px;
}
.mapa-component-record .mapa-editable {
  min-height: 112px;
  padding: 0.62rem 0.68rem;
}

/* O Foco individual usa os mesmos blocos de estudante do Foco em Componente. */
.mapa-student-components-cell .mapa-individual-component-item {
  position: relative;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  min-height: 54px;
  margin-bottom: 0.38rem;
  padding: 0.52rem 0.62rem;
  gap: 0.62rem;
  border-radius: 8px;
  background: #f8fafc;
}
.mapa-student-components-cell .mapa-individual-component-item .mapa-subj-check {
  align-self: center;
}
.mapa-student-components-cell .mapa-individual-component-item .mapa-grade-badge {
  position: absolute;
  right: 0.62rem;
  bottom: 0.52rem;
  padding: 0.26rem 0.42rem;
  font-size: 0.68rem;
}
@media (max-width: 980px) {
  .mapa-linked-work-grid > .mapa-student-components-cell,
  .mapa-linked-work-grid > .mapa-component-students-cell,
  .mapa-linked-work-grid > .mapa-linked-action-cell,
  .mapa-linked-work-grid > .mapa-student-field-cell:nth-of-type(3),
  .mapa-linked-work-grid > .mapa-student-field-cell:nth-of-type(4),
  .mapa-linked-work-grid > .mapa-component-field-cell:nth-of-type(3),
  .mapa-linked-work-grid > .mapa-component-field-cell:nth-of-type(4),
  .mapa-linked-work-grid > .mapa-student-action-cell {
    grid-column: 1;
    grid-row: auto;
  }
  .mapa-component-row-grid { grid-template-columns: 1fr; }
  .mapa-component-head-grid span:not(:first-child) { display: none; }
}
@media (max-width: 640px) {
  .mapa-component-student-grid { grid-template-columns: 1fr; }
}
.cell-center { text-align: center; }
.cell-wrap { word-break: break-word; }/* ================================================================
   P2P — Compartilhamento colaborativo do Mapa
   ================================================================ */

/* Indicador de campo bloqueado por outro usuário */
.p2p-field-locked {
  border-color: var(--p2p-user-color, var(--purple)) !important;
  background: var(--surface-2) !important;
  cursor: not-allowed !important;
  opacity: 0.78;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.p2p-lock-cell { position: relative; }

.p2p-lock-indicator {
  position: absolute;
  top: 2px;
  right: 4px;
  z-index: 3;
  max-width: calc(100% - 8px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--p2p-user-color, #64748b);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  pointer-events: none;
  animation: p2p-fade-in 0.2s ease;
}
@keyframes p2p-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tabela bloqueada (somente leitura para guests) */
.p2p-locked {
  opacity: 0.7;
}

.p2p-locked .mapa-editable,
.p2p-locked textarea {
  background: var(--surface-2) !important;
  cursor: not-allowed !important;
}

/* Status de conexão inline */
#mapaOnlineStatus {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 600;
}

/* Badge de controller */
#mapaControllerBadge {
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
}

/* Modal de compartilhamento: área do link */
#mapaShareLinkInput {
  font-family: monospace;
  font-size: 0.82rem;
}

/* Animação de entrada do overlay */
#mapaJoinOverlay {
  animation: p2p-overlay-in 0.25s ease;
}

@keyframes p2p-overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Modal de seleção de alunos (mapa) */
.mapa-picker-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1050;
  display: flex;
  justify-content: center;
  align-items: center;
}
.mapa-picker-dialog {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 680px;
  width: 95%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}
.mapa-picker-dialog h3 { margin-bottom: 0.25rem; font-size: 1.1rem; }
.mapa-picker-search {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  margin-bottom: 0.75rem;
}
.mapa-picker-search input {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 42px;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.2;
  background: var(--surface);
}
.mapa-picker-select-all {
  flex: 0 0 auto;
  height: 42px;
  white-space: nowrap;
  border: 1px solid var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}
.mapa-picker-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 50vh;
}
.mapa-picker-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}
.mapa-picker-item:hover { background: var(--primary-soft); }
.mapa-picker-item input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; }
.mapa-picker-info { flex: 1; }
.mapa-picker-name { font-weight: 600; font-size: 0.9rem; }
.mapa-picker-meta { font-size: 0.78rem; color: var(--muted); }
.mapa-picker-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

@media print {
  .topbar-actions, .top-nav, .filters-card, .toolbar, .btn { display: none !important; }
  .main { margin: 0; }
  .topbar { position: static; padding: 10px 0; }
  .content { width: 100%; padding: 0; }
  .page { display: none !important; }
  .page.active { display: block !important; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; color: #111; }
  .mapa-table input, .mapa-table textarea, .mapa-table .mapa-editable { border: none !important; resize: none !important; box-shadow: none !important; background: transparent !important; }
  .mapa-subj-check, .mapa-context-actions, .mapa-delete-btn, .mapa-comp-est-check { display: none !important; }
  .mapa-student-row-grid, .mapa-component-row-grid { grid-template-columns: 42% 29% 29% !important; }
  .mapa-student-action-cell { display: none !important; }
  .mapa-student-record .mapa-editable { min-height: auto !important; }
}

/* Ajuste compacto das linhas de componentes no Foco Individual */
.mapa-student-components-cell .mapa-subject-line {
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
}
.mapa-student-components-cell .mapa-subject-main {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 0.08rem;
}
.mapa-student-components-cell .mapa-subject-name {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  overflow-wrap: anywhere;
}
/* Blocos de seção para as páginas com navegação lateral */
.page-nav-body .page-section > .section-title {
  margin: 0 0 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  align-items: flex-start;
  flex-wrap: wrap;
}
.page-nav-body > .page-section > .section-title > div:first-child {
  flex: 1 1 360px;
}
.page-nav-body > .page-section > .section-title > div + div {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 0.35rem;
}

/* Componentes em texto corrido, sem badge ocupando largura */
.mapa-student-components-cell .mapa-subject-line {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
}
.mapa-subject-summary {
  display: block;
  min-width: 0;
  color: #334155;
  font-size: 0.78rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.mapa-subject-summary .mapa-subject-name {
  display: inline;
  color: #0f172a;
  font-size: inherit;
  font-weight: 750;
}
.mapa-subject-summary .mapa-subject-detail {
  display: inline;
  color: #475569;
  font-size: inherit;
  white-space: normal;
}
.mapa-inline-media { color: #475569; white-space: nowrap; }
.mapa-inline-media strong { font-weight: 850; }
.mapa-inline-grade--danger { color: #b91c1c; }
.mapa-inline-grade--warning { color: #c2410c; }
.mapa-inline-grade--success { color: #15803d; }
.mapa-inline-grade--neutral { color: #475569; }

@media (max-width: 760px) {
  .page-nav-body > .page-section > .section-title > div + div {
    width: 100%;
    justify-content: flex-start;
  }
}
/* ================================================================
   APPI UI REFINEMENT 20260713 — shell analítico e layout responsivo
   ================================================================ */
:root {
  --bg: #f4f7fb;
  --surface-2: #f6f8fb;
  --surface-3: #e8edf3;
  --border: #d7dee8;
  --muted: #5f6b7a;
  --warning-foreground: #805600;
  --orange-foreground: #9a3e00;
  --content-max: 1760px;
  --page-rail: 216px;
  --header: 72px;
  --shadow-sm: 0 1px 2px rgba(15, 35, 60, .05), 0 8px 22px rgba(15, 35, 60, .035);
  --shadow-md: 0 18px 46px rgba(15, 35, 60, .14);
}

html { scroll-padding-top: calc(var(--header) + 18px); }
body { font-size: 14px; background: var(--bg); }
button, input, select, summary { -webkit-tap-highlight-color: transparent; }
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
[contenteditable="true"]:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent);
  outline-offset: 2px;
}

.topbar {
  min-height: var(--header);
  padding: 10px 24px;
  gap: 24px;
  background: color-mix(in srgb, #fff 96%, transparent);
  box-shadow: 0 1px 0 rgba(15, 35, 60, .03);
}
.topbar-left { flex: 0 0 auto; gap: 0; }
.brand-block {
  min-width: 282px;
  max-width: 382px;
  gap: 10px;
  padding-right: 0;
  border-right: 0;
}
.brand-logo {
  width: 148px;
  height: 46px;
  flex-basis: 148px;
  border: 0;
  border-radius: 6px;
}
.brand-copy strong { color: var(--primary-2); font-size: 14px; letter-spacing: .02em; }
.brand-copy span { max-width: 210px; font-size: 10px; line-height: 1.25; }
.topbar-actions { flex: 1 1 auto; justify-content: flex-end; min-width: 0; }
.top-nav {
  gap: 2px;
  margin-right: auto;
  padding-right: 0;
  border-right: 0;
}
.nav-btn {
  position: relative;
  min-height: 42px;
  padding: 9px 13px;
  border: 0;
  border-radius: 8px;
  color: #30394a;
  font-size: 14px;
  font-weight: 650;
}
.nav-btn::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 2px;
  left: 12px;
  height: 2px;
  border-radius: 999px;
  background: transparent;
}
.nav-btn:hover { background: var(--primary-soft); color: var(--primary-2); }
.nav-btn.active { background: transparent; color: var(--primary-2); border-color: transparent; }
.nav-btn.active::after { background: var(--primary); }
.nav-icon {
  width: 20px;
  color: currentColor;
  font-family: "Segoe UI Symbol", sans-serif;
  font-size: 15px;
}
.info-btn { color: var(--primary); background: transparent; border-color: transparent; }
.info-btn:hover { background: var(--primary-soft); }

.content {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 24px 24px 56px;
}
.page-hero {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  min-height: 92px;
  padding: 4px 2px 22px;
}
.page-heading { min-width: 0; flex: 1 1 auto; }
.page-eyebrow {
  display: block;
  margin-bottom: 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.page-heading h1 {
  margin: 0;
  color: #102a56;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -.025em;
  font-weight: 750;
}
.page-heading p {
  max-width: 780px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  white-space: normal;
  overflow: visible;
}
.page-hero-context {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,.72);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.page-context-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

.card { border-color: var(--border); border-radius: 12px; box-shadow: var(--shadow-sm); }
.card-header { padding: 18px 20px 0; }
.card-header h2,
.card-header h3 { color: #172a46; font-size: 16px; }
.card-header p { margin-top: 5px; font-size: 12px; line-height: 1.45; }
.card-body { padding: 16px 20px 20px; }

.btn {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: none;
}
.btn:hover { transform: none; box-shadow: none; }
.btn-sm { min-height: 36px; padding: 6px 11px; font-size: 12px; }
.btn-primary { box-shadow: 0 5px 14px rgba(0,79,159,.16); }
.btn-secondary { background: var(--surface); color: var(--primary-2); border-color: color-mix(in srgb, var(--primary) 35%, var(--border)); }
.btn-secondary:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-collaboration { background: var(--purple); color: #fff; border-color: var(--purple); }
.btn-symbol { font-family: "Segoe UI Symbol", sans-serif; font-size: 16px; line-height: 1; }
.room-code-btn { font-weight: 850; letter-spacing: .08em; }
.icon-btn { width: 40px; padding: 0; }

.filters-card { margin-bottom: 24px; overflow: visible; }
.filters-top { min-height: 48px; padding: 11px 16px; }
.filters-top strong { color: #1b2d47; font-size: 13px; }
.filters-grid {
  grid-template-columns: repeat(6, minmax(132px, 1fr));
  gap: 12px;
  padding: 14px 16px 18px;
}
.filter-group-label {
  grid-column: 1 / -1;
  margin: 1px 0 -3px;
  color: var(--primary-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .055em;
  text-transform: uppercase;
}
.filter-group-conditions { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.field-comp-curricular { grid-column: span 2; }
.field label { color: #536174; font-size: 11px; font-weight: 750; }
.field input,
.field select,
.multiselect-field .ms-selected { min-height: 40px; background: var(--surface); }
.check-label { min-height: 40px; }

.page-with-nav { display: flex; align-items: flex-start; gap: 24px; }
.page-nav-body { flex: 1 1 auto; min-width: 0; order: 2; }
.page-sidenav {
  order: 1;
  width: var(--page-rail);
  flex: 0 0 var(--page-rail);
  position: sticky;
  top: calc(var(--header) + 18px);
  max-height: calc(100vh - var(--header) - 36px);
  margin: 0;
  padding: 0 18px 8px 0;
  border: 0;
  border-right: 1px solid var(--border);
}
.page-sidenav-head {
  display: grid;
  gap: 2px;
  margin-bottom: 12px;
  padding: 5px 10px 12px;
  border-bottom: 1px solid var(--border);
}
.page-sidenav-head strong { color: #173c7b; font-size: 14px; line-height: 1.25; }
.page-sidenav-head span { color: var(--muted); font-size: 10px; line-height: 1.35; }
.page-nav-item {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 8px;
  color: #465365;
  font-size: 12px;
  font-weight: 700;
}
.page-nav-item:hover { background: var(--primary-soft); color: var(--primary-2); }
.page-nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 5px 14px rgba(0,79,159,.14);
}
.page-section { margin-bottom: 34px; scroll-margin-top: calc(var(--header) + 20px); }
.section-title,
.page-nav-body > .page-section > .section-title {
  margin: 0 0 12px;
  padding: 0 2px;
  border: 0;
  border-left: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  align-items: end;
  flex-wrap: wrap;
}
.section-title h2,
.page-nav-body .page-section > .section-title h2 {
  color: #102f68;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 750;
}
.section-title p { max-width: 820px; margin-top: 5px; font-size: 12px; line-height: 1.45; }
.analysis-grid { display: grid; gap: 18px; min-width: 0; }
.analysis-grid-two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.analysis-grid > .page-section { min-width: 0; margin-bottom: 34px; }
.analysis-grid .class-list-card { height: calc(100% - 58px); }

.kpi-grid { gap: 12px; margin-bottom: 26px; }
.kpi {
  position: relative;
  min-height: 104px;
  padding: 16px 18px;
  overflow: hidden;
  background: var(--surface);
}
.kpi::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--kpi-tone, var(--primary));
  opacity: .9;
}
.kpi-value { color: #102f68; font-size: 28px; font-weight: 780; letter-spacing: -.03em; }
.kpi-label { font-size: 12px; font-weight: 750; }
.kpi-note { font-size: 11px; line-height: 1.4; }
.kpi[data-tone="warning"] { --kpi-tone: var(--warning-foreground); }
.badge-warning { color: var(--warning-foreground); }
.context-summary-grid { gap: 16px; margin-bottom: 24px; }
.context-group-head { min-height: 48px; }
.context-group-head h3 { color: #173c7b; font-size: 15px; }
.context-group-head p { font-size: 11px; }

.rav-overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 8fr) minmax(300px, 4fr);
  gap: 18px;
  align-items: start;
}
.rav-overview-chart { min-width: 0; }
.rav-overview-kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 0;
}
.rav-overview-kpis .context-group-kpis.kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rav-overview-kpis .context-group-head { min-height: auto; margin-bottom: 8px; }
.rav-status-filter { min-width: 210px; }
.table-card { overflow: hidden; }
.table-card-header { padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.table-card .card-body { padding: 0; }
.table-search-field input { background: #fff; }
.infinite-table-status {
  min-height: 38px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  background: #f8fafc;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}
.infinite-table-status[data-loading="true"]::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 7px;
  vertical-align: -2px;
  border: 2px solid #b9cbe0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.tabulator { border: 0; border-radius: 0; font-size: 12px; }
.tabulator .tabulator-header .tabulator-col { min-height: 44px; background: #f3f6fa; }
.tabulator .tabulator-header .tabulator-col-content { min-height: 44px; }
.tabulator .tabulator-header .tabulator-col-title { color: #26364d; font-weight: 800; }
.tabulator-row .tabulator-cell { padding-top: 9px; padding-bottom: 9px; }
.tabulator-row:nth-child(even) { background: #fbfcfe; }
.tabulator-row.tabulator-selectable:hover { background: #edf5fd; }

.mapa-instructions {
  margin-bottom: 20px;
  overflow: hidden;
  border-color: color-mix(in srgb, var(--primary) 24%, var(--border));
  background: color-mix(in srgb, var(--primary-soft) 58%, #fff);
  box-shadow: none;
}
.mapa-instructions summary {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  color: var(--primary-2);
  cursor: pointer;
  list-style: none;
}
.mapa-instructions summary::-webkit-details-marker { display: none; }
.mapa-instructions summary > span:first-child { display: grid; gap: 2px; }
.mapa-instructions summary strong { font-size: 14px; }
.mapa-instructions summary small { color: var(--muted); font-size: 11px; font-weight: 600; }
.mapa-instructions .card-body { padding: 0 18px 16px; border-top: 1px solid color-mix(in srgb, var(--primary) 14%, var(--border)); }
.mapa-instructions ul { margin: 12px 0 0 18px; padding: 0; font-size: 12px; line-height: 1.55; }
.mapa-instructions-chevron { font-size: 20px; transition: transform .18s ease; }
.mapa-instructions:not([open]) .mapa-instructions-chevron { transform: rotate(-90deg); }
.mapa-command-card {
  margin-bottom: 22px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.mapa-command-grid {
  display: grid;
  grid-template-columns: minmax(190px, 240px) minmax(170px, 210px) minmax(0, 1fr);
  gap: 12px;
  align-items: end;
}
.mapa-command-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; align-items: center; }
.required-mark { color: var(--danger); }
.field-note { display: none; font-size: 11px; font-weight: 700; }
.field-note.visible { display: block; }
.field-note-danger { color: var(--danger); }
.mapa-command-grid > .field .field-note {
  display: block;
  min-height: 14px;
  line-height: 14px;
  visibility: hidden;
}
.mapa-command-grid > .field .field-note.visible {
  visibility: visible;
}
.mapa-status-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 24px; }
.page-block-tabs,
.mapa-analysis-tabs {
  position: sticky;
  top: var(--section-anchor-offset);
  z-index: 8;
  display: flex;
  align-items: stretch;
  gap: 4px;
  margin: 0 0 6px;
  padding: 3px;
  border: 1px solid #cad8e7;
  border-radius: 8px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 7px 18px rgba(30, 64, 110, .09);
}
.page-block-tablist,
.mapa-analysis-tablist {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  flex: 1 1 auto;
  min-width: 0;
  gap: 4px;
}
.page-block-tab-shell {
  position: relative;
  min-width: 0;
  display: flex;
}
.page-block-tab-shell > .page-block-tab {
  width: 100%;
  padding-right: 36px;
}
.page-block-tab-shell:has(> .page-block-tab.hidden) {
  display: none;
}
.page-block-info-btn {
  position: absolute;
  top: 50%;
  right: 4px;
  z-index: 2;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  transform: translateY(-50%);
  border: 1px solid #b9cce1;
  border-radius: 50%;
  background: #f7faff;
  color: #49627f;
  box-shadow: 0 1px 3px rgba(30, 64, 110, .12);
  cursor: pointer;
}
.page-block-info-btn:hover {
  transform: translateY(-50%) scale(1.05);
  border-color: #8eacd0;
  background: #eaf3ff;
  color: #173c7b;
}
.page-block-info-btn:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 24%, transparent);
  outline-offset: 1px;
}
.page-block-info-btn .app-icon {
  width: 14px;
  height: 14px;
}
.page-block-tab.active + .page-block-info-btn {
  border-color: #9dbbe0;
  color: #123f7a;
}
.mapa-analysis-tab[aria-disabled="true"] {
  cursor: default;
  opacity: .68;
}
.mapa-analysis-tab.active[aria-disabled="true"] {
  opacity: 1;
}
.page-block-tab,
.mapa-analysis-tab {
  min-width: 0;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #45566f;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
}
.page-block-tab:hover,
.mapa-analysis-tab:hover {
  border-color: #c5d5e6;
  background: #f4f8fc;
  color: #173c7b;
}
.page-block-tab.active,
.mapa-analysis-tab.active {
  border-color: #9dbbe0;
  background: #e9f2ff;
  color: #123f7a;
  box-shadow: inset 0 -3px 0 #2563eb;
}
.mapa-analysis-tab[aria-disabled="true"]:not(.active):hover {
  border-color: transparent;
  background: transparent;
  color: #45566f;
  box-shadow: none;
}
.page-block-action,
.mapa-analysis-filter {
  flex: 0 0 112px;
  border-color: #b9cce1;
  background: #f7faff;
  color: #173c7b;
}
[data-analysis-legend] {
  flex-basis: 164px;
}
.page-block-action:hover,
.mapa-analysis-filter:hover {
  border-color: #8eacd0;
  background: #eaf3ff;
}
.page-block-tab:focus-visible,
.mapa-analysis-tab:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 22%, transparent);
  outline-offset: 1px;
}
.page-block-tab .app-icon,
.mapa-analysis-tab .app-icon { flex: 0 0 auto; }
.page-with-nav { display: block; }
.page-nav-body { width: 100%; order: initial; }
#page-mapa .mapa-tab-panel { margin-bottom: 0; }
.page-hero { margin-left: 0; }
.section-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty-inline.spacious { padding: 28px; }
.table-wrap { max-width: 100%; overflow-x: auto; border-radius: 12px; }

.student-modal { width: min(1440px, 96vw); height: min(94vh, 1000px); }
.student-modal .modal-header { padding: 18px 22px; background: #fff; border-bottom: 1px solid var(--border); }
.student-modal .modal-header h2 { color: #102f68; font-size: 22px; }
.modal-sidenav { width: 208px; padding: 18px 12px; background: #f4f7fb; }
.modal-nav-item { min-height: 40px; padding: 9px 11px; }
.modal-nav-item.active { background: var(--primary); color: #fff; }
.student-modal .modal-body {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  align-content: start;
  padding: 22px;
}
.student-modal .modal-section { min-width: 0; margin: 0; }
#sm-indicadores,
#sm-radar,
#sm-comparativo,
#sm-faltas,
#sm-aproveitamento,
#sm-detalhamento,
#sm-registros { grid-column: 1 / -1; }
.student-modal .chart-card { min-height: 0; }
.student-modal .section-title { margin-bottom: 10px; }

.app-footer {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 18px 24px 22px;
  background: transparent;
  color: #6b7583;
}
.app-footer strong { color: #173c7b; letter-spacing: .02em; }

@media (max-width: 1380px) {
  .filters-grid { grid-template-columns: repeat(4, minmax(128px, 1fr)); }
  .rav-overview-grid { grid-template-columns: minmax(0, 7fr) minmax(280px, 5fr); }
  .brand-copy { display: none; }
  .brand-block { min-width: 148px; }
}

@media (max-width: 1199px) {
  .topbar { align-items: center; }
  .topbar-left { flex-direction: row; align-items: center; }
  .page-with-nav { display: flex; flex-direction: column; }
  .page-nav-body { width: 100%; }
  .page-sidenav {
    width: 100%;
    flex: 0 0 auto;
    max-width: none;
    max-height: none;
    position: sticky;
    top: var(--header);
    z-index: 20;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    margin: 0 0 22px;
    padding: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: color-mix(in srgb, #fff 96%, transparent);
    box-shadow: var(--shadow-sm);
  }
  .page-sidenav-head { display: none; }
  .page-nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .rav-overview-kpis { margin-top: 0; }
}

@media (max-width: 1040px) {
  .topbar { align-items: center; }
  .topbar-left { flex-direction: row; gap: 0; }
  .top-nav { flex-wrap: nowrap; overflow-x: auto; }
  .page-heading { width: auto; }
  .filters-grid { grid-template-columns: repeat(3, minmax(128px, 1fr)); }
  .analysis-grid-two,
  .rav-overview-grid { grid-template-columns: 1fr; }
  .rav-overview-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapa-command-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapa-command-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .student-modal .modal-body { grid-template-columns: 1fr; }
  #sm-indicadores,
  #sm-radar,
  #sm-comparativo,
  #sm-faltas,
  #sm-aproveitamento,
  #sm-detalhamento,
  #sm-registros { grid-column: 1; }
}

@media (max-width: 760px) {
  .page-block-tabs,
  .mapa-analysis-tabs {
    display: flex;
    overflow-x: auto;
    scrollbar-width: thin;
  }
  .page-block-tab,
  .mapa-analysis-tab {
    flex: 0 0 min(58vw, 200px);
    justify-content: flex-start;
  }
  .page-block-tab-shell {
    flex: 0 0 min(58vw, 200px);
  }
  .page-block-tab-shell > .page-block-tab {
    flex: 1 1 auto;
  }
  .mapa-analysis-tablist .page-block-tab-shell {
    flex-basis: min(72vw, 230px);
  }
  .mapa-analysis-tab { flex-basis: min(72vw, 230px); }
  .page-block-tablist,
  .mapa-analysis-tablist {
    display: flex;
    flex: 0 0 auto;
    gap: 4px;
  }
  .page-block-action,
  .mapa-analysis-filter { flex-basis: 112px; }
  [data-analysis-legend] { flex-basis: 154px; }
  :root { --header: 116px; }
  .topbar { min-height: auto; padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .topbar-left { flex: 1 1 auto; }
  .topbar-actions { width: 100%; gap: 4px; }
  .top-nav { flex: 1 1 auto; margin: 0; }
  .nav-btn { min-height: 38px; padding: 7px 9px; font-size: 12px; }
  .nav-icon { display: none; }
  .content { padding: 16px 12px 36px; }
  .page-hero { min-height: 82px; padding: 2px 1px 18px; }
  .page-heading h1 { font-size: 24px; }
  .page-heading p { max-width: none; font-size: 13px; }
  .page-hero-context { display: none; }
  .filters-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 12px; }
  .field-comp-curricular { grid-column: span 2; }
  .page-sidenav { top: var(--header); margin-bottom: 18px; }
  .section-title h2,
  .page-nav-body > .page-section > .section-title h2 { font-size: 18px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-height: 96px; padding: 14px; }
  .kpi-value { font-size: 24px; }
  .rav-overview-kpis { grid-template-columns: 1fr; }
  .mapa-command-grid { grid-template-columns: 1fr; }
  .mapa-command-actions { grid-column: 1; }
  .mapa-status-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-with-nav { flex-direction: column; }
  .modal-sidenav {
    width: 100%;
    flex-direction: row;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .modal-nav-item { width: auto; flex: 0 0 auto; white-space: nowrap; }
  .student-modal { width: 100vw; height: 100dvh; border-radius: 0; }
  .student-modal .modal-body { padding: 16px 12px 24px; }
  .app-footer { padding: 16px 12px 20px; }
}

@media (max-width: 480px) {
  .topbar-actions .btn-primary span { display: none; }
  .topbar-actions .btn-primary .btn-symbol { display: inline !important; }
  .filters-grid,
  .kpi-grid,
  .mapa-status-bar { grid-template-columns: 1fr; }
  .field-comp-curricular { grid-column: span 1; }
  .mapa-command-actions .btn { flex: 1 1 140px; }
  .rav-overview-kpis .context-group-kpis.kpi-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* APPI scroll affordance: keep horizontal navigation usable without native bars */
.app-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.top-nav,
.page-sidenav { scrollbar-width: none; }
.top-nav::-webkit-scrollbar,
.page-sidenav::-webkit-scrollbar { display: none; }

/* --- Cabeçalhos integrados aos blocos de análise --------------- */
.page-nav-body > .page-section > .section-title {
  margin: 0;
  padding: 18px 20px 16px;
  border: 1px solid #d6e2ee;
  border-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 6px 18px rgba(30, 64, 110, .05);
  align-items: flex-end;
}
.page-nav-body > .page-section > .section-title h2 {
  color: #12396f;
  font-size: 21px;
  line-height: 1.2;
}
.page-nav-body .page-section > .section-title p {
  max-width: 760px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.page-nav-body .page-section > .section-title + .card,
.page-nav-body .page-section > .section-title + .rav-insight-panel {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-color: #d6e2ee;
}
.page-nav-body .page-section > .section-title + .chart-card,
.page-nav-body .page-section > .section-title + .table-card {
  box-shadow: 0 6px 18px rgba(30, 64, 110, .05);
}
.page-nav-body .page-section > .section-title + .diary-completion-grid {
  margin: 0;
  padding: 14px 20px 20px;
  border: 1px solid #d6e2ee;
  border-top: 0;
  border-radius: 0 0 16px 16px;
  background: #f4f8fc;
}
.page-nav-body .table-card > .card-body {
  padding: 14px 20px 20px;
}
.page-nav-body .table-card > .card-body .tabulator {
  border: 1px solid var(--border);
  border-radius: 12px;
}

@media (max-width: 760px) {
  .page-nav-body .page-section > .section-title {
    padding: 16px 16px 14px;
  }
  .page-nav-body .page-section > .section-title h2 {
    font-size: 18px;
  }
  .page-nav-body .table-card > .card-body,
  .page-nav-body .page-section > .section-title + .diary-completion-grid {
    padding: 12px 16px 18px;
  }
}

/* --- Gaveta de filtros globais -------------------------------- */
.filter-drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(8, 15, 28, .38);
  opacity: 0;
  transition: opacity .22s ease;
}
.filter-drawer-backdrop.open { opacity: 1; }
.filter-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 190;
  width: min(470px, calc(100vw - 24px));
  pointer-events: none;
}
.filter-drawer-panel {
  display: flex;
  width: 100%;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid #d3deea;
  background: #f7fafc;
  box-shadow: 18px 0 40px rgba(15, 23, 42, .18);
  transform: translateX(-104%);
  transition: transform .24s ease;
  pointer-events: auto;
}
.filter-drawer.open .filter-drawer-panel { transform: translateX(0); }
.filter-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 16px;
  border-bottom: 1px solid #dbe5ef;
  background: #fff;
}
.filter-drawer-eyebrow {
  display: block;
  margin-bottom: 3px;
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.filter-drawer-header h2 {
  margin: 0;
  color: #12396f;
  font-size: 22px;
  line-height: 1.15;
}
.filter-drawer-header .filter-count {
  display: block;
  margin-top: 5px;
  font-size: 12px;
}
.filter-drawer-content.filters-card {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.filter-drawer-tags {
  min-height: 38px;
  padding: 12px 20px 0;
}
.filter-drawer .filter-active-tags {
  display: flex !important;
  gap: 5px;
}
.filter-drawer .filter-tag {
  min-height: 24px;
  padding: 3px 9px;
  font-size: 10px;
}
.filter-drawer .filters-grid {
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px 20px 24px;
}
.filter-drawer .filter-group-label,
.filter-drawer .field-comp-curricular,
.filter-drawer .field-wide,
.filter-drawer .ignored-subjects-panel {
  grid-column: 1 / -1;
}
.filter-drawer .filter-group-label {
  margin-top: 4px;
}
.filter-drawer .filter-group-conditions {
  margin-top: 8px;
}
.filter-drawer .multiselect-field .ms-dropdown {
  position: static;
  width: 100%;
  max-width: 100%;
  margin-top: 6px;
  box-shadow: 0 8px 20px rgba(30, 64, 110, .08);
}
.filter-drawer .multiselect-field .ms-search {
  min-width: 0;
}
.ignored-subjects-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d8e3ef;
  border-radius: 10px;
  background: #fff;
}
.ignored-subjects-panel strong {
  color: #173c7b;
  font-size: 12px;
}
.ignored-subjects-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ignored-subject-tag,
.ignored-subject-empty {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 750;
  line-height: 1.2;
}
.ignored-subject-tag {
  gap: 6px;
  padding: 3px 4px 3px 9px;
  background: #eef3f8;
  color: #405168;
}
.ignored-subject-remove {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 18px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #dce5ef;
  color: #52657c;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.ignored-subject-remove:hover,
.ignored-subject-remove:focus-visible {
  background: var(--danger);
  color: #fff;
  outline: none;
}
.ignored-subject-empty {
  color: var(--muted);
}
.filter-drawer-empty {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}
.filter-drawer-empty strong {
  color: #173c7b;
  font-size: 14px;
}
.filter-drawer-empty span {
  max-width: 300px;
  font-size: 12px;
  line-height: 1.45;
}
.filter-drawer-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #dbe5ef;
  background: #fff;
}
.filter-drawer-footer .btn {
  min-height: 38px;
}

/* --- Panorama do RAV em gráficos ------------------------------ */
.rav-panorama-panel {
  min-height: 0;
}
.rav-panorama-panel .rav-insight-meta {
  padding-top: 14px;
}
.rav-panorama-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: stretch;
}
.rav-panorama-chart-card {
  display: flex;
  min-height: 430px;
  flex-direction: column;
  border-top: 3px solid color-mix(in srgb, var(--primary) 78%, #fff);
}
.rav-panorama-chart-card .rav-insight-card-header {
  min-height: 54px;
  margin-bottom: 8px;
}
.rav-panorama-chart-card .rav-insight-card-header > div {
  min-width: 0;
}
.rav-panorama-chart-card .rav-insight-card-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.4;
}
.rav-panorama-chart-frame {
  position: relative;
  min-width: 0;
  height: 340px;
  flex: 1 1 auto;
}
.rav-panorama-chart-frame canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
.rav-panorama-bar-frame {
  min-height: 390px;
}
.rav-pie-of-pie {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 30px;
  min-width: 0;
  height: 285px;
}
.rav-pie-of-pie-chart {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  height: 285px;
}
.rav-pie-of-pie-chart canvas {
  display: block;
  width: 100% !important;
  height: 258px !important;
}
.rav-pie-of-pie-chart small {
  color: #64748b;
  font-size: 9px;
  font-weight: 850;
  line-height: 1.2;
  text-align: center;
}
.rav-pie-of-pie-connectors {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  transition: opacity .12s ease;
}
.rav-pie-of-pie-connectors line {
  stroke: #9aa8b8;
  stroke-width: 1.1;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}
.rav-hierarchy-legend {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.rav-hierarchy-legend-group {
  min-width: 0;
  padding: 9px;
  border: 1px solid #e0e8f1;
  border-radius: 9px;
  background: #f8fafc;
}
.rav-hierarchy-legend-group > strong {
  display: block;
  min-height: 24px;
  margin-bottom: 7px;
  color: #173c7b;
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .045em;
  line-height: 1.35;
  text-transform: uppercase;
}
.rav-hierarchy-legend-group > div {
  display: grid;
  gap: 6px;
}
.rav-hierarchy-legend-item {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: start;
  gap: 6px;
}
.rav-hierarchy-legend-item > i {
  width: 8px;
  height: 8px;
  margin-top: 3px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(23, 60, 123, .08);
}
.rav-hierarchy-legend-item b,
.rav-hierarchy-legend-item small {
  display: block;
}
.rav-hierarchy-legend-item b {
  color: #334155;
  font-size: 9px;
  line-height: 1.25;
}
.rav-hierarchy-legend-item small {
  margin-top: 2px;
  color: #64748b;
  font-size: 8px;
  font-weight: 700;
  line-height: 1.3;
}

/* --- Análise dinâmica de frequência ---------------------------- */
.attendance-analysis-panel {
  min-width: 0;
}
.attendance-analysis-header .rav-insight-copy {
  min-width: 260px;
}
.attendance-analysis-table-wrap {
  min-width: 0;
  padding: 14px 24px 22px;
}
.attendance-analysis-table {
  height: auto;
  max-height: none;
}
.attendance-analysis-table .tabulator {
  height: auto;
  border-radius: 12px;
}
.attendance-analysis-total-cell {
  font-variant-numeric: tabular-nums;
}
.attendance-analysis-total-value {
  display: inline-block;
  min-width: 54px;
  text-align: center;
}

/* --- Análise dinâmica do RAV em tabela ------------------------ */
.rav-analysis-scope-note {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 24px 0;
}
.rav-analysis-scope-note .badge {
  min-height: 26px;
  padding: 5px 10px;
  font-size: 10px;
  font-weight: 850;
}
.rav-analysis-table-wrap {
  min-width: 0;
  padding: 10px 24px 22px;
}
.rav-analysis-table {
  height: auto;
  max-height: none;
  overflow-x: auto;
}
.rav-analysis-table .tabulator {
  height: auto;
  border-radius: 12px;
}
.rav-analysis-status-col {
  font-variant-numeric: tabular-nums;
}
.rav-analysis-status-cell {
  display: inline-flex;
  min-width: 78px;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}
.rav-analysis-status-cell--recuperou {
  background: color-mix(in srgb, var(--success) 12%, #fff);
  color: #087849;
}
.rav-analysis-status-cell--nao_avancou {
  background: color-mix(in srgb, var(--danger) 11%, #fff);
  color: #b91c1c;
}
.rav-analysis-status-cell--sem_nota {
  background: #eef2f7;
  color: #526071;
}

/* --- Análise dinâmica do diário ------------------------------- */
.diary-analysis-panel {
  min-width: 0;
}
.diary-analysis-header .rav-insight-copy {
  min-width: 280px;
}
.diary-analysis-period-nav {
  max-width: min(520px, 100%);
  justify-content: flex-end;
  flex-wrap: wrap;
}
.diary-analysis-period-empty {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.diary-analysis-table-wrap {
  min-width: 0;
  padding: 14px 24px 22px;
}
.diary-analysis-table {
  height: auto;
  max-height: none;
  overflow-x: auto;
}
.diary-analysis-table .tabulator {
  height: auto;
  border-radius: 12px;
}
.diary-analysis-percent-cell {
  font-variant-numeric: tabular-nums;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.diary-analysis-pct {
  display: block;
  font-size: 13px;
  font-weight: 950;
  line-height: 1.15;
}

/* --- Barras compactas das análises dinâmicas ------------------ */
.attendance-analysis-header,
.diary-analysis-header,
#rav-analise .rav-insight-header {
  gap: 18px;
  padding: 16px 20px 14px;
}
.attendance-analysis-header .rav-insight-controls,
.diary-analysis-header .rav-insight-controls,
#rav-analise .rav-insight-controls {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}
.attendance-analysis-actions {
  flex-wrap: nowrap;
}
.analysis-inline-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px 0;
}
.analysis-toolbar-label {
  flex: 0 0 auto;
  color: #53657b;
  font-size: 11px;
  font-weight: 850;
}
.rav-analysis-toolbar {
  justify-content: flex-end;
  flex-wrap: wrap;
}
.rav-analysis-option-nav {
  min-height: 36px;
  padding: 3px;
  border-color: #d4dfeb;
  background: #edf3f9;
}
.rav-analysis-option-nav .chart-mode-btn {
  min-height: 28px;
  padding: 4px 11px;
  white-space: nowrap;
}
.diary-analysis-period-toolbar {
  justify-content: space-between;
}
.diary-analysis-period-toolbar .diary-analysis-period-nav {
  max-width: calc(100% - 78px);
}
.page-nav-dialog-item {
  margin-top: 8px;
  box-shadow: inset 0 1px 0 var(--border);
}

/* --- Modal de legendas analíticas ----------------------------- */
.analysis-legend-dialog {
  width: min(720px, 100%);
}
.analysis-legend-content {
  background: #f6f9fc;
}
.section-info-dialog {
  width: min(620px, 100%);
  overflow: hidden;
}
.section-info-page {
  display: block;
  margin-bottom: 4px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.section-info-content {
  background: #f7f9fc;
}
.section-info-content p {
  margin: 0;
  color: #34465f;
  font-size: 15px;
  line-height: 1.65;
}
.analysis-legend-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.analysis-legend-item {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 14px;
  border: 1px solid #d6e2ee;
  border-radius: 10px;
  background: #fff;
}
.analysis-legend-item .badge {
  min-width: 78px;
  justify-content: center;
}
.analysis-legend-item > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}
.analysis-legend-item strong {
  color: #173c7b;
  font-size: 12px;
  line-height: 1.3;
}
.analysis-legend-item div span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.analysis-legend-grid--rav .analysis-legend-item:last-child {
  grid-column: 1 / -1;
}

@media (max-width: 760px) {
  .filter-drawer {
    width: 100vw;
  }
  .filter-drawer-header {
    padding: 16px 16px 14px;
  }
  .filter-drawer .filters-grid {
    grid-template-columns: 1fr;
    padding: 12px 16px 20px;
  }
  .filter-drawer-tags {
    padding-inline: 16px;
  }
  .filter-drawer-footer {
    padding: 12px 16px;
  }
  .filter-drawer-footer .btn {
    flex: 1 1 0;
  }
  .rav-panorama-grid {
    grid-template-columns: 1fr;
    padding-inline: 16px;
  }
  .rav-panorama-chart-card {
    min-height: 390px;
  }
  .rav-panorama-chart-frame {
    height: 310px;
  }
  .rav-pie-of-pie {
    gap: 16px;
    height: 260px;
  }
  .rav-pie-of-pie-chart {
    height: 260px;
  }
  .rav-pie-of-pie-chart canvas {
    height: 235px !important;
  }
  .rav-hierarchy-legend {
    grid-template-columns: 1fr;
  }
  .rav-hierarchy-legend-group > strong {
    min-height: 0;
  }
  .attendance-analysis-table-wrap {
    padding: 12px 16px 18px;
  }
  .rav-analysis-scope-note {
    padding: 10px 16px 0;
  }
  .rav-analysis-table-wrap {
    padding: 10px 16px 18px;
  }
  .rav-analysis-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }
  .rav-analysis-value-toggle,
  .rav-analysis-base-toggle,
  .rav-analysis-export-btn {
    width: 100%;
    justify-content: center;
  }
  .diary-analysis-table-wrap {
    padding: 12px 16px 18px;
  }
  .attendance-analysis-header .rav-insight-controls,
  .diary-analysis-header .rav-insight-controls,
  #rav-analise .rav-insight-controls {
    width: 100%;
  }
  .attendance-analysis-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
  }
  .analysis-inline-toolbar {
    padding: 10px 16px 0;
  }
  .rav-analysis-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .rav-analysis-option-nav,
  .diary-analysis-period-toolbar .diary-analysis-period-nav {
    width: 100%;
    max-width: 100%;
  }
  .rav-analysis-option-nav .chart-mode-btn,
  .diary-analysis-period-nav .chart-mode-btn {
    flex: 1 1 auto;
  }
  .diary-analysis-period-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .analysis-legend-grid {
    grid-template-columns: 1fr;
  }
  .analysis-legend-grid--rav .analysis-legend-item:last-child {
    grid-column: auto;
  }
  .analysis-legend-item {
    padding: 12px;
  }
}

/* --- Análise dinâmica de risco -------------------------------- */
.student-dynamic-analysis-panel {
  min-width: 0;
}
.student-dynamic-analysis-header {
  gap: 18px;
  padding: 16px 20px 14px;
}
.student-dynamic-analysis-header .rav-insight-copy {
  min-width: 280px;
}
.student-dynamic-analysis-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
}
.student-dynamic-analysis-value-nav {
  min-height: 36px;
  padding: 3px;
  border-color: #d4dfeb;
  background: #edf3f9;
}
.student-dynamic-analysis-value-nav .chart-mode-btn {
  min-height: 28px;
  padding: 4px 11px;
  white-space: nowrap;
}
.student-dynamic-analysis-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.student-dynamic-analysis-table-wrap {
  min-width: 0;
  padding: 14px 24px 22px;
}
.student-dynamic-analysis-table {
  height: auto;
  max-height: none;
  overflow-x: auto;
}
.student-dynamic-analysis-table .tabulator {
  height: auto;
  border-radius: 12px;
}
.student-dynamic-analysis-period-toolbar {
  justify-content: flex-start;
  gap: 10px;
  padding-top: 8px;
}
.student-dynamic-analysis-period-nav {
  min-height: 36px;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: flex-start;
  padding: 3px;
  border-color: #d4dfeb;
  background: #edf3f9;
}
.student-dynamic-analysis-period-nav .chart-mode-btn {
  min-height: 28px;
  padding: 4px 11px;
  white-space: nowrap;
}
.student-dynamic-analysis-period-nav .chart-mode-btn:disabled {
  opacity: .38;
  cursor: not-allowed;
  background: transparent;
  color: var(--muted);
}
.student-risk-toolbar-legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-left: auto;
}
.student-risk-toolbar-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  color: #40536b;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}
.student-risk-toolbar-tag[title] {
  cursor: help;
}
.student-risk-toolbar-tag i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}
.student-risk-toolbar-tag--high i,
.student-risk-toolbar-tag--critical i { background: var(--danger); }
.student-risk-toolbar-tag--low i,
.student-risk-toolbar-tag--average i { background: #087849; }
.student-risk-toolbar-tag--below i { background: #efa400; }
.student-analysis-intensity-badge {
  min-width: 52px;
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border: 1px solid var(--intensity-border);
  border-radius: 999px;
  background: var(--intensity-bg);
  color: var(--intensity-color);
  font-size: 11px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  box-shadow: none;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.student-analysis-category-value {
  min-width: 54px;
  min-height: 27px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: #40536b;
  font-size: 11px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.student-analysis-category-value--high,
.student-analysis-category-value--critical {
  border-color: #f5c2cb;
  background: #fff1f3;
  color: #a61b32;
}
.student-analysis-category-value--low,
.student-analysis-category-value--average {
  border-color: #bfe5d1;
  background: #edf9f3;
  color: #087849;
}
.student-analysis-category-value--below {
  border-color: #f1d595;
  background: #fff8e6;
  color: #8a5700;
}
.student-analysis-distribution-cell {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
}
.student-analysis-distribution-stack {
  width: 100%;
  min-width: 380px;
}
.student-analysis-distribution-bar {
  width: 100%;
  height: 30px;
  display: flex;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--border) 82%, transparent);
  border-radius: 999px;
  background: #e8edf3;
  box-shadow: inset 0 1px 2px rgba(30, 50, 80, .10);
}
.student-analysis-distribution-segment {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: width .2s ease;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.student-analysis-distribution-segment strong {
  display: block;
  max-width: 100%;
  padding: 0 4px;
  overflow: hidden;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}
.student-analysis-distribution-segment--high,
.student-analysis-distribution-segment--critical {
  background: #c92b3a;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .28);
}
.student-analysis-distribution-segment--low,
.student-analysis-distribution-segment--average {
  background: #087849;
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .25);
}
.student-analysis-distribution-segment--below {
  background: #efa400;
  color: #322000;
  text-shadow: 0 1px 0 rgba(255, 255, 255, .28);
}
@media (max-width: 760px) {
  .student-dynamic-analysis-header .rav-insight-controls,
  .student-dynamic-analysis-dimension-nav,
  .student-dynamic-analysis-value-nav,
  .student-dynamic-analysis-distribution-nav,
  .student-dynamic-analysis-period-nav,
  .student-dynamic-analysis-actions {
    width: 100%;
  }
  .student-dynamic-analysis-dimension-nav .chart-mode-btn,
  .student-dynamic-analysis-value-nav .chart-mode-btn,
  .student-dynamic-analysis-distribution-nav .chart-mode-btn,
  .student-dynamic-analysis-period-nav .chart-mode-btn,
  .student-dynamic-analysis-actions .btn {
    flex: 1 1 auto;
  }
  .student-dynamic-analysis-toolbar,
  .student-dynamic-analysis-period-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .student-dynamic-analysis-period-nav {
    max-width: 100%;
  }
  .student-risk-toolbar-legend {
    width: 100%;
    margin-left: 0;
  }
  .student-dynamic-analysis-actions {
    margin-left: 0;
  }
  .student-dynamic-analysis-table-wrap {
    padding: 12px 16px 18px;
  }
}
/* --- Risco por estudante e tabela em um único bloco ------------ */
.student-analysis-card {
  min-width: 0;
  min-height: 0;
  height: clamp(440px, calc(100dvh - 325px), 600px);
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
}
#students-list .student-analysis-card {
  overflow: hidden;
}
.student-risk-overview {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  background: #f7fafe;
  overflow: hidden;
}
.student-profile-table-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.student-profile-table-toolbar h3 {
  margin: 0;
  color: #173c7b;
  font-size: 14px;
  line-height: 1.3;
}
.student-profile-table-toolbar p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}
.student-risk-filter-clear {
  flex: 0 0 auto;
  border-color: color-mix(in srgb, var(--primary) 24%, var(--border));
  background: var(--primary-soft);
  color: var(--primary-2);
  white-space: nowrap;
}
.student-analysis-titlebar {
  align-items: center;
}
.student-risk-title-inline {
  min-width: min(100%, 390px);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
  padding-left: 18px;
  border-left: 1px solid var(--border);
  text-align: left;
}
.student-risk-title-inline .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}
.student-risk-bar-wrap {
  min-height: 0;
  height: 280px;
  max-height: 280px;
  align-self: start;
  margin-top: 8px;
  overflow: hidden;
}
.student-profile-table-pane {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
  overflow: hidden;
}
.student-profile-table-toolbar {
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.student-profile-table-toolbar > div:first-child {
  min-width: 220px;
}
.student-profile-table-toolbar .table-card-actions {
  min-width: min(100%, 380px);
}
#studentsTable.student-profile-table {
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: visible;
}
#studentsTable.student-profile-table .tabulator {
  height: 100%;
}
.student-profile-table-pane > .card-body {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 20px;
}
#studentsTable .tabulator-header {
  position: relative;
  top: auto;
  z-index: 12;
}
#studentsTable .tabulator-header .tabulator-col.tabulator-frozen {
  z-index: 14;
  background: #f3f6fa;
}
#studentsTable .tabulator-tableholder {
  min-height: 0;
  overflow: auto;
}

/* --- Navegação lateral recolhida com expansão por hover -------- */
@media (min-width: 1200px) {
  :root {
    --page-rail: 56px;
    --page-nav-expanded: 216px;
  }
  .page-sidenav {
    width: var(--page-rail);
    flex: 0 0 auto;
    z-index: 30;
    margin: 0;
    padding: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: color-mix(in srgb, #fff 96%, transparent);
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
    transition: width .2s ease, margin-right .2s ease, box-shadow .2s ease;
  }
  .page-sidenav:hover,
  .page-sidenav:focus-within {
    width: var(--page-nav-expanded);
    margin-right: calc(var(--page-rail) - var(--page-nav-expanded));
    box-shadow: 0 18px 38px rgba(25, 50, 85, .16);
  }
  .page-sidenav-head {
    width: calc(var(--page-nav-expanded) - 18px);
    max-height: 0;
    margin: 0;
    padding: 0 10px;
    overflow: hidden;
    border: 0;
    opacity: 0;
    transition: max-height .2s ease, margin .2s ease, padding .2s ease, opacity .15s ease;
  }
  .page-sidenav:hover .page-sidenav-head,
  .page-sidenav:focus-within .page-sidenav-head {
    max-height: 72px;
    margin-bottom: 10px;
    padding: 5px 10px 11px;
    border-bottom: 1px solid var(--border);
    opacity: 1;
  }
  .page-sidenav .page-nav-item {
    width: calc(var(--page-nav-expanded) - 18px);
    min-width: calc(var(--page-nav-expanded) - 18px);
    gap: 14px;
    padding: 9px 12px;
    overflow: hidden;
    white-space: nowrap;
  }
  .page-sidenav .page-nav-label {
    min-width: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-4px);
    transition: opacity .12s ease .06s, transform .16s ease .04s, visibility 0s linear .2s;
  }
  .page-sidenav:hover .page-nav-label,
  .page-sidenav:focus-within .page-nav-label {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    transition-delay: .05s, .04s, 0s;
  }
}

@media (max-width: 760px) {
  .student-profile-table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .student-risk-filter-clear {
    align-self: flex-start;
  }
  .student-risk-title-inline {
    width: 100%;
    min-width: 0;
    justify-content: space-between;
    margin-left: 0;
    padding: 8px 0 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }
  .student-profile-table-toolbar .table-card-actions {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 900px) {
  .student-analysis-card {
    height: min(740px, calc(100dvh - 170px));
    min-height: 430px;
    grid-template-columns: 1fr;
    grid-template-rows: 190px minmax(0, 1fr);
  }
  .student-risk-overview {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .student-risk-bar-wrap {
    height: 126px;
  }
}

/* --- Hero compacto e ancoragem precisa das seções ------------- */
:root {
  --section-anchor-offset: calc(var(--header) + 1px);
  --section-visible-height: calc(100dvh - var(--section-anchor-offset) - 12px);
}
html,
body,
.app-shell { height: 100%; }
body { overflow: hidden; }
.main {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.topbar,
.app-footer { flex: 0 0 auto; }
.content {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding-top: 14px;
  padding-bottom: 10px;
}
.page-block-tabs {
  position: static;
  top: auto;
  flex: 0 0 auto;
}
.page-hero { flex: 0 0 auto; }
.page.active {
  flex: 1 1 auto;
  min-height: 0;
  padding-right: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}
.page-hero {
  min-height: 0;
  margin: 0 0 12px;
  padding: 7px 0 10px;
  align-items: flex-start;
  gap: 12px;
}
.page-eyebrow,
.page-hero-context {
  display: none;
}
.page-heading h1 {
  font-size: 22px;
  line-height: 1.12;
  letter-spacing: 0;
}
.page-heading p {
  max-width: 760px;
  margin-top: 3px;
  font-size: 12px;
  line-height: 1.35;
}
.page-section {
  scroll-margin-top: var(--section-anchor-offset);
}
.page-nav-body > .page-section {
  max-height: none;
  overflow-y: visible;
  overscroll-behavior: auto;
  scroll-margin-top: var(--section-anchor-offset);
}
.page-nav-body > .page-section > .section-title {
  position: static;
}
.page-nav-body > .student-analysis-section {
  height: auto;
  max-height: none;
  display: block;
  overflow: visible;
}
.page-nav-body > .student-analysis-section > .section-title {
  position: static;
  flex: 0 0 auto;
}
.page-nav-body > .student-analysis-section > .student-analysis-card {
  min-height: 0;
}

/* --- Cabeçalhos persistentes nas tabelas da página ------------ */
.page .table-card,
.page .rav-insight-panel,
.page .tabulator-host,
.page .tabulator {
  overflow: visible;
}
.page .tabulator .tabulator-header {
  position: sticky;
  top: 0;
  z-index: 12;
  box-shadow: 0 2px 0 rgba(26, 58, 99, .08);
}
.page .tabulator .tabulator-tableholder {
  max-height: none;
  overflow-x: auto;
  overflow-y: visible;
}
.page .mapa-table thead {
  position: sticky;
  top: 0;
  z-index: 12;
}

@media (min-width: 901px) {
  .student-risk-overview {
    position: sticky;
    top: 0;
    z-index: 5;
    align-self: stretch;
  }
}

/* --- Foco de seção em tela cheia ------------------------------- */
body.section-fullscreen-open {
  overflow: hidden !important;
}
body.section-fullscreen-open .modal-backdrop:not(.hidden) {
  z-index: 1100;
}
.section-expandable {
  position: relative;
}
.section-expand-btn {
  position: static;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #cbd9e7;
  border-radius: 8px;
  background: rgba(255, 255, 255, .96);
  color: #173c7b;
  box-shadow: 0 4px 12px rgba(30, 64, 110, .10);
  cursor: pointer;
}
.section-expand-btn svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}
.section-expand-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary-2);
}
.section-expand-btn:focus-visible,
.section-fullscreen-close:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--primary) 22%, transparent);
  outline-offset: 2px;
}
.section-title.section-expand-host,
.rav-insight-header.section-expand-host,
.card-header.section-expand-host {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 12px;
}
.section-expand-host > :nth-child(2) {
  min-width: 0;
}
.rav-insight-meta.section-expand-host {
  display: grid;
  grid-template-columns: 36px auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}
.rav-insight-meta.section-expand-host > :last-child {
  justify-self: end;
}
.section-expand-standalone {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 10px;
}
body .section-fullscreen-active {
  position: fixed !important;
  inset: 0 !important;
  z-index: 1000 !important;
  width: 100vw !important;
  height: 100dvh !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 56px 24px 24px !important;
  overflow: auto !important;
  overscroll-behavior: contain;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--bg) !important;
  box-shadow: none !important;
  scroll-margin-top: 0 !important;
}
body .section-fullscreen-active.page-section {
  display: flex;
  flex-direction: column;
}
body .section-fullscreen-active > .section-title,
body .section-fullscreen-active > .rav-insight-panel > .rav-insight-header,
body .section-fullscreen-active > .rav-insight-panel > .analysis-inline-toolbar,
body .section-fullscreen-active > .rav-insight-panel > .rav-insight-footer,
body .section-fullscreen-active > .table-card > .card-header {
  flex: 0 0 auto;
}
body .section-fullscreen-active > .rav-insight-panel,
body .section-fullscreen-active > .card {
  flex: 1 1 auto;
  min-height: 0;
}
body .section-fullscreen-active > .rav-insight-panel,
body .section-fullscreen-active > .table-card,
body .section-fullscreen-active > .chart-card {
  display: flex;
  flex-direction: column;
}
body .section-fullscreen-active > .student-analysis-card {
  display: grid;
}
body .section-fullscreen-active .attendance-analysis-table-wrap,
body .section-fullscreen-active .diary-analysis-table-wrap,
body .section-fullscreen-active .rav-analysis-table-wrap,
body .section-fullscreen-active .student-dynamic-analysis-table-wrap,
body .section-fullscreen-active > .table-card > .card-body,
body .section-fullscreen-active > .chart-card > .card-body {
  flex: 1 1 auto;
  min-height: 0;
}
body .section-fullscreen-active .attendance-analysis-table-wrap,
body .section-fullscreen-active .diary-analysis-table-wrap,
body .section-fullscreen-active .rav-analysis-table-wrap,
body .section-fullscreen-active .student-dynamic-analysis-table-wrap,
body .section-fullscreen-active > .table-card > .card-body {
  display: flex;
  flex-direction: column;
}
body .section-fullscreen-active .attendance-analysis-table,
body .section-fullscreen-active .diary-analysis-table,
body .section-fullscreen-active .rav-analysis-table,
body .section-fullscreen-active .student-dynamic-analysis-table,
body .section-fullscreen-active > .table-card .tabulator-host,
body .section-fullscreen-active > .chart-card .chart-wrap {
  flex: 1 1 auto;
  height: 100% !important;
  max-height: none !important;
  min-height: 0 !important;
}
body #students-analysis.section-fullscreen-active {
  overflow: hidden !important;
}
body #students-analysis.section-fullscreen-active > .student-dynamic-analysis-panel,
body #students-analysis.section-fullscreen-active .student-dynamic-analysis-table-wrap,
body #students-analysis.section-fullscreen-active .student-dynamic-analysis-table {
  min-height: 0;
  overflow: hidden;
}
body #students-analysis.section-fullscreen-active .student-dynamic-analysis-table .tabulator {
  height: 100% !important;
  max-height: 100% !important;
}
body #students-analysis.section-fullscreen-active .student-dynamic-analysis-table .tabulator-tableholder {
  min-height: 0;
  max-height: none !important;
  overflow: auto !important;
  overscroll-behavior: contain;
}
#studentContextKpis.section-fullscreen-active {
  align-content: start;
  grid-auto-rows: max-content;
}
body .section-fullscreen-active.student-analysis-section {
  overflow-x: hidden !important;
  overflow-y: auto !important;
}
body .section-fullscreen-active > .section-title {
  position: static !important;
}
body .section-fullscreen-active .section-expand-btn,
body .section-fullscreen-active > .section-expand-standalone {
  display: none !important;
}
body .section-fullscreen-active .section-expand-host {
  grid-template-columns: minmax(0, 1fr) auto;
}
.section-fullscreen-close {
  position: fixed;
  top: 12px;
  right: 16px;
  z-index: 1002;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #cbd9e7;
  border-radius: 8px;
  background: #fff;
  color: #173c7b;
  box-shadow: 0 8px 22px rgba(15, 35, 60, .16);
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}
.section-fullscreen-close:hover {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

@media (max-width: 1199px) {
  .content {
    padding-top: 12px;
  }
  .page-hero {
    margin-left: 0;
    margin-bottom: 10px;
    padding: 6px 0 10px;
  }
  .page-nav-dialog-item {
    margin-top: 0;
    box-shadow: none;
  }
  .section-title.section-expand-host,
  .rav-insight-header.section-expand-host,
  .card-header.section-expand-host {
    grid-template-columns: 36px minmax(0, 1fr);
  }
  .section-title.section-expand-host > :last-child:nth-child(3),
  .rav-insight-header.section-expand-host > :last-child:nth-child(3),
  .card-header.section-expand-host > :last-child:nth-child(3) {
    grid-column: 2;
    justify-self: stretch;
  }
}

@media (max-width: 760px) {
  .content {
    padding-top: 10px;
  }
  .page-hero {
    min-height: 0;
    padding: 4px 0 8px;
  }
  .page-heading h1 {
    font-size: 20px;
  }
  .page-heading p {
    font-size: 12px;
    line-height: 1.3;
  }
  body .section-fullscreen-active {
    padding: 56px 12px 12px !important;
  }
  .section-fullscreen-close {
    right: 12px;
  }
}

@media print {
  html,
  body,
  .app-shell,
  .main {
    height: auto !important;
    overflow: visible !important;
  }
  .main,
  .content { display: block !important; }
  .content,
  .page.active {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }
  .page-hero {
    margin-left: 0;
  }
  .section-expand-host {
    grid-template-columns: minmax(0, 1fr) auto !important;
  }
  .page-nav-body > .page-section {
    max-height: none;
    overflow: visible;
  }
  .page-nav-body > .page-section > .section-title {
    position: static;
  }
  .page-nav-body > .student-analysis-section {
    height: auto;
  }
}
