:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-alt: #edf2f7;
  --text: #1e293b;
  --muted: #64748b;
  --line: #d7dee8;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --accent: #0f766e;
  --warning: #d97706;
  --danger: #dc2626;
  --success: #15803d;
  --info: #0369a1;
  --sidebar: #243447;
  --sidebar-soft: #31465f;
  --shadow: 0 12px 30px rgba(30, 41, 59, 0.08);
  --shadow-soft: 0 6px 18px rgba(30, 41, 59, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 20px 16px;
  background: var(--sidebar);
  color: #f8fafc;
  overflow-y: auto;
}

.brand {
  display: grid;
  gap: 8px;
  padding: 2px 4px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-logo {
  display: block;
  width: min(228px, 100%);
  height: auto;
  max-height: 108px;
  object-fit: contain;
}

.brand-app-name,
.brand-school-name {
  display: block;
}

.brand-app-name {
  color: #f8fafc;
  font-size: 0.96rem;
  font-weight: 800;
}

.brand-school-name {
  color: #cbd5e1;
  font-size: 0.84rem;
}

.nav-menu {
  display: grid;
  gap: 4px;
  margin-top: 18px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e5eef7;
  cursor: pointer;
  text-align: left;
}

.nav-item svg,
.btn svg,
.report-tile svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.nav-item:hover,
.nav-item.active {
  background: var(--sidebar-soft);
}

.nav-item.active {
  box-shadow: inset 3px 0 0 #f8fafc;
}

.main {
  min-width: 0;
  padding: 22px 24px 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 1.7rem;
  line-height: 1.15;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.02rem;
}

#lastUpdated {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-actions,
.filter-actions,
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 9px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover {
  background: var(--primary-strong);
}

.btn.secondary,
.btn.compact {
  background: var(--surface);
  border-color: var(--line);
}

.btn.secondary:hover,
.btn.compact:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* Botao principal em tamanho compacto (ex.: Salvar regras): .compact vem depois de
   .primary e pintava o fundo de branco, deixando o texto branco invisivel. */
.btn.primary.compact {
  background: var(--primary);
  border-color: transparent;
  color: #fff;
}

.btn.primary.compact:hover {
  background: var(--primary-strong);
  color: #fff;
}

.btn.ghost {
  background: transparent;
  border-color: var(--line);
}

.btn.compact {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.filters-panel,
.panel,
.metric-card,
.report-tile,
.command-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.command-strip {
  display: grid;
  grid-template-columns: 1.2fr repeat(4, minmax(140px, 1fr));
  gap: 0;
  margin-bottom: 14px;
  overflow: hidden;
}

.command-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 14px 16px;
  border-right: 1px solid var(--line);
}

.command-item:last-child {
  border-right: 0;
}

.command-item svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.command-item strong,
.command-item span {
  display: block;
}

.command-item strong {
  color: var(--text);
  font-size: 1.02rem;
}

.command-item span {
  color: var(--muted);
  font-size: 0.8rem;
}

.command-item.priority svg,
.command-item.priority strong {
  color: var(--danger);
}

.command-item.warning svg,
.command-item.warning strong {
  color: var(--warning);
}

.command-item.success svg,
.command-item.success strong {
  color: var(--success);
}

.filters-panel {
  margin-bottom: 18px;
  padding: 14px;
}

.filters-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.filters-header h2 {
  margin: 0 0 4px;
}

.filters-header span {
  color: var(--muted);
  font-size: 0.86rem;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quick-filter {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.quick-filter svg {
  width: 15px;
  height: 15px;
  color: var(--warning);
}

.quick-filter:hover,
.quick-filter.active {
  border-color: var(--primary);
  color: var(--primary);
  background: #eff6ff;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(126px, 1fr));
  gap: 10px;
}

label,
.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(37, 99, 235, 0.14);
}

.filter-actions {
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}

.active-filter-summary {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.filter-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  max-width: 240px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3730a3;
  font-size: 0.78rem;
  font-weight: 700;
}

.status-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.status-banner.error {
  background: #fef2f2;
  color: #991b1b;
  border-color: #fecaca;
}

.status-banner.warning {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.compact-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 108px;
  padding: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}

.metric-card.tone-danger::before {
  background: var(--danger);
}

.metric-card.tone-warning::before {
  background: var(--warning);
}

.metric-card.tone-success::before {
  background: var(--success);
}

.metric-card.tone-info::before {
  background: var(--info);
}

.metric-card.tone-muted::before {
  background: #94a3b8;
}

.metric-icon {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary);
}

.tone-danger .metric-icon {
  background: #fef2f2;
  color: var(--danger);
}

.tone-warning .metric-icon {
  background: #fffbeb;
  color: var(--warning);
}

.tone-success .metric-icon {
  background: #ecfdf5;
  color: var(--success);
}

.metric-icon svg {
  width: 18px;
  height: 18px;
}

.metric-content {
  min-width: 0;
}

.metric-card span {
  display: block;
  min-height: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  color: var(--text);
  margin-top: 6px;
  font-size: 1.55rem;
  line-height: 1.2;
}

.metric-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
}

.chart-grid,
.two-column {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  min-width: 0;
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 12px;
}

.panel-header h2 {
  margin: 0;
}

.panel-subtitle {
  margin: -8px 0 12px;
  color: var(--muted);
  font-size: 0.86rem;
}

canvas {
  width: 100% !important;
  height: 310px !important;
}

.student-layout,
.observation-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.8fr) minmax(0, 1.2fr);
  gap: 18px;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.table-toolbar input {
  max-width: 320px;
}

.column-picker {
  position: relative;
}

.column-picker summary {
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  list-style: none;
}

.column-picker[open] summary {
  border-color: var(--primary);
}

.column-picker-menu {
  position: absolute;
  right: 0;
  z-index: 20;
  display: grid;
  gap: 8px;
  min-width: 210px;
  max-height: 260px;
  overflow: auto;
  margin-top: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.column-picker-menu label {
  grid-template-columns: auto 1fr;
  align-items: center;
  color: var(--text);
  font-weight: 500;
}

.column-picker-menu input {
  width: auto;
  min-height: auto;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  background: #f1f5f9;
  color: #334155;
  font-size: 0.78rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
}

td {
  color: #334155;
}

tr:hover td {
  background: #f8fafc;
}

.row-risk-critical td {
  background: #fff7f7;
}

.row-risk-moderate td {
  background: #fffbeb;
}

.row-muted td {
  color: var(--muted);
}

.data-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.76rem;
  font-weight: 800;
}

.data-badge.danger {
  background: #fee2e2;
  color: #991b1b;
}

.data-badge.warning {
  background: #fef3c7;
  color: #92400e;
}

.data-badge.success {
  background: #dcfce7;
  color: #166534;
}

.data-badge.info {
  background: #e0f2fe;
  color: #075985;
}

.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.student-summary {
  position: relative;
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 0 0 16px;
  border-bottom: 1px solid var(--line);
}

.student-profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.student-name {
  display: block;
  color: var(--text);
  font-size: 1.28rem;
  line-height: 1.2;
}

.student-meta {
  display: block;
  margin-top: 6px;
  color: #334155;
}

.student-risk-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.student-risk-chip.danger {
  background: #fee2e2;
  color: #991b1b;
}

.student-risk-chip.warning {
  background: #fef3c7;
  color: #92400e;
}

.student-risk-chip.success {
  background: #dcfce7;
  color: #166534;
}

.student-risk-chip.info {
  background: #e0f2fe;
  color: #075985;
}

.student-kpi-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.student-kpi {
  display: grid;
  gap: 3px;
  min-height: 58px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 800;
}

.student-kpi b {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.student-interpretation {
  margin: 0;
  padding: 12px;
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  background: #fffbeb;
  color: #334155;
  line-height: 1.55;
}

.student-section-head,
.student-bars-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.student-section-head b,
.student-bars-header strong {
  color: var(--text);
}

.student-section-head span,
.student-bars-header span,
.student-scale {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.pill-list {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.danger {
  background: #fee2e2;
  color: #991b1b;
}

.pill.warning {
  background: #fef3c7;
  color: #92400e;
}

.pill.success {
  background: #dcfce7;
  color: #166534;
}

.pill.info {
  background: #e0f2fe;
  color: #075985;
}

.student-bars {
  display: grid;
  gap: 11px;
}

.student-bars-header {
  margin-bottom: 2px;
}

.student-bars-header div {
  display: grid;
  gap: 3px;
}

.student-scale {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
}

.student-bar-row {
  display: grid;
  gap: 6px;
}

.student-bar-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.student-bar-meta span {
  overflow: hidden;
  color: #334155;
  font-size: 0.86rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.student-bar-meta b {
  color: var(--text);
  font-size: 0.88rem;
}

.student-bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.student-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--info);
}

.student-bar-row.tone-danger .student-bar-fill {
  background: var(--danger);
}

.student-bar-row.tone-warning .student-bar-fill {
  background: var(--warning);
}

.student-bar-row.tone-success .student-bar-fill {
  background: var(--success);
}

.student-bar-row.tone-muted .student-bar-fill {
  background: #94a3b8;
}

.student-empty {
  margin: 0;
  color: var(--muted);
}

.reports-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.report-tile {
  display: grid;
  gap: 9px;
  min-height: 145px;
  padding: 18px;
  color: var(--text);
  text-decoration: none;
}

.report-tile:hover {
  border-color: var(--primary);
}

.report-tile svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
}

.report-tile span {
  color: var(--muted);
  line-height: 1.4;
}

.settings-form {
  max-width: 960px;
}

.integration-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.integration-panel > *,
.integration-grid > *,
.switch-setting > span,
#activesoftRunsTable {
  min-width: 0;
}

.integration-heading {
  align-items: flex-start;
  margin-bottom: 0;
}

.integration-heading > div {
  min-width: 220px;
}

.integration-heading h2 {
  margin-bottom: 4px;
}

.integration-heading > div > span,
.field small,
.switch-setting small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.integration-status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 800;
}

.integration-status.ready,
.integration-status.completed {
  border-color: #86efac;
  background: #f0fdf4;
  color: #166534;
}

.integration-status.processing,
.integration-status.queued {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}

.integration-status.warning {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.integration-status.error {
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.switch-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--text);
}

.switch-setting > span {
  display: grid;
  gap: 3px;
}

.switch-setting input {
  appearance: none;
  position: relative;
  width: 44px;
  min-width: 44px;
  min-height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: #cbd5e1;
  cursor: pointer;
  transition: background 0.18s ease;
}

.switch-setting input::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.24);
  content: "";
  transition: transform 0.18s ease;
}

.switch-setting input:checked {
  background: var(--primary);
}

.switch-setting input:checked::after {
  transform: translateX(20px);
}

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.integration-advanced {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.integration-advanced summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.integration-advanced summary::-webkit-details-marker {
  display: none;
}

.integration-advanced summary svg {
  width: 17px;
  height: 17px;
  color: var(--accent);
}

.integration-advanced[open] {
  padding-bottom: 14px;
}

.advanced-grid {
  margin-bottom: 12px;
}

.integration-actions {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.integration-progress {
  display: grid;
  gap: 8px;
  padding: 12px 0;
}

.integration-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.86rem;
}

.progress-track {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
  transition: width 0.25s ease;
}

.integration-progress p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.integration-summary {
  display: grid;
  gap: 5px;
  min-height: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.integration-summary:empty {
  display: none;
}

.integration-summary strong {
  color: var(--text);
}

.subsection-title {
  margin: 0 0 10px;
  font-size: 0.9rem;
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.settings-section:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.settings-section h3 {
  margin: 0 0 4px;
  color: var(--text);
  font-size: 0.96rem;
}

.settings-section > div > span {
  color: var(--muted);
  font-size: 0.84rem;
}

.composition-section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.composition-rules-table table {
  min-width: 860px;
  table-layout: fixed;
}

.composition-rules-table th:nth-child(1) { width: 24%; }
.composition-rules-table th:nth-child(2) { width: 10%; }
.composition-rules-table th:nth-child(3) { width: 18%; }
.composition-rules-table th:nth-child(4) { width: 24%; }
.composition-rules-table th:nth-child(5) { width: 18%; }
.composition-rules-table th:nth-child(6) { width: 6%; }

.composition-rules-table input:not([type="checkbox"]) {
  width: 100%;
  min-width: 0;
  padding: 8px 9px;
}

.composition-rules-table .composition-components-input {
  min-width: 0;
}

.icon-only {
  width: 36px;
  padding: 7px;
}

.icon-only svg {
  margin: auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.checkbox-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.checkbox-row label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 800;
}

.checkbox-row input {
  width: 16px;
  min-height: 16px;
}

.rules-filter-grid {
  grid-template-columns: minmax(180px, 260px) minmax(220px, 1fr);
  margin-bottom: 12px;
}

.rule-bulk-actions {
  display: flex;
  align-items: end;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.rule-bulk-actions .field {
  min-width: 240px;
}

.rule-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.rule-control input {
  width: 18px;
  min-height: 18px;
}

.status-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #075985;
  font-size: 0.76rem;
  font-weight: 800;
}

.status-tag.warning {
  background: #fef3c7;
  color: #92400e;
}

.settings-form,
#observationForm {
  display: grid;
  gap: 14px;
}

.theme-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  gap: 12px;
  background: rgba(244, 247, 251, 0.82);
  color: var(--text);
  backdrop-filter: blur(2px);
}

.loader {
  width: 42px;
  height: 42px;
  border: 4px solid #cbd5e1;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1180px) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .command-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-item {
    border-bottom: 1px solid var(--line);
  }

  .metric-grid,
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .reports-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    height: auto;
    padding: 14px;
  }

  .nav-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 16px;
  }

  .topbar,
  .filters-header,
  .integration-heading,
  .chart-grid,
  .two-column,
  .student-layout,
  .observation-layout {
    grid-template-columns: 1fr;
    display: grid;
  }

  .integration-heading,
  .switch-setting {
    grid-template-columns: minmax(0, 1fr);
  }

  .switch-setting input {
    justify-self: start;
  }

  .topbar-actions {
    width: 100%;
  }

  .quick-filters,
  .active-filter-summary,
  .filter-chips {
    justify-content: flex-start;
  }

  .student-kpi-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .filter-grid,
  .metric-grid,
  .compact-metrics,
  .reports-grid,
  .settings-grid,
  .integration-grid,
  .command-strip,
  .theme-row {
    grid-template-columns: 1fr;
  }

  .integration-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .command-item {
    border-right: 0;
  }

  .nav-menu {
    grid-template-columns: 1fr;
  }

  .btn {
    width: 100%;
  }

  .table-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .student-profile-header,
  .student-section-head,
  .student-bars-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .student-risk-chip {
    white-space: normal;
  }

  canvas {
    height: 260px !important;
  }
}

/* Ano letivo -------------------------------------------------------------- */

.year-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: #eff6ff;
  color: var(--primary-strong);
  font-size: 0.8rem;
  font-weight: 800;
  white-space: nowrap;
}

.year-picker select {
  width: auto;
  min-height: 30px;
  padding: 4px 8px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.year-picker select:focus {
  outline-offset: 2px;
}

/* Filtros ------------------------------------------------------------------ */

.advanced-filters {
  margin-top: 10px;
}

.advanced-filters summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 32px;
  color: var(--primary);
  font-size: 0.84rem;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.advanced-filters summary::-webkit-details-marker {
  display: none;
}

.advanced-filters summary svg {
  width: 16px;
  height: 16px;
}

.advanced-filters[open] summary {
  margin-bottom: 8px;
}

button.filter-chip {
  gap: 6px;
  border: 0;
  cursor: pointer;
}

button.filter-chip span {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
}

button.filter-chip:hover,
button.filter-chip:focus-visible {
  background: #e0e7ff;
}

button.filter-chip:hover span {
  opacity: 1;
}

/* Cards clicaveis ------------------------------------------------------------ */

.metric-card.is-link {
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.metric-card.is-link:hover,
.metric-card.is-link:focus-visible {
  border-color: var(--success);
  transform: translateY(-1px);
}

.pill.current {
  box-shadow: inset 0 0 0 2px currentColor;
}

/* Aluno destaque ------------------------------------------------------------- */

.destaque-intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.destaque-intro h2 {
  margin-bottom: 10px;
}

.destaque-intro .panel-subtitle {
  margin: 0;
  max-width: 820px;
}

.destaque-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.destaque-group-card {
  display: grid;
  gap: 10px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-top: 4px solid var(--success);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.destaque-group-head strong,
.destaque-group-head span {
  display: block;
}

.destaque-group-head span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.destaque-count {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.destaque-count b {
  color: var(--success);
  font-size: 2rem;
  line-height: 1;
}

.destaque-count span {
  color: var(--muted);
  font-size: 0.86rem;
}

.destaque-rule {
  margin: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--surface-alt);
  font-size: 0.84rem;
  font-weight: 700;
}

.destaque-excluded {
  color: var(--muted);
  font-size: 0.78rem;
}

.destaque-empty {
  grid-column: 1 / -1;
  color: var(--muted);
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  border-radius: 9px;
  background: var(--surface-alt);
}

.segment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.segment:hover {
  color: var(--text);
}

.segment.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-soft);
}

.segment-count {
  min-width: 24px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #334155;
  font-size: 0.76rem;
  text-align: center;
}

.segment.active .segment-count {
  background: var(--primary);
  color: #fff;
}

#destaqueTabHint {
  margin: 0 0 12px;
}

#destaqueTable tbody tr[data-index] {
  cursor: pointer;
}

#destaqueTable td:last-child {
  min-width: 240px;
}

.row-highlight td:first-child {
  box-shadow: inset 3px 0 0 var(--success);
}

.cell-note {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
}

.destaque-config {
  padding: 0;
}

.destaque-config > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  cursor: pointer;
  list-style: none;
}

.destaque-config > summary::-webkit-details-marker {
  display: none;
}

.destaque-config > summary strong,
.destaque-config > summary small {
  display: block;
}

.destaque-config > summary small {
  margin-top: 3px;
  color: var(--muted);
}

.destaque-config > summary svg {
  width: 18px;
  height: 18px;
  transition: transform 0.15s ease;
}

.destaque-config[open] > summary svg {
  transform: rotate(180deg);
}

.destaque-config[open] > summary {
  border-bottom: 1px solid var(--line);
}

#destaqueConfigEditor,
.destaque-config .integration-actions {
  padding: 16px;
}

.destaque-config .integration-actions {
  align-items: center;
  padding-top: 0;
}

.destaque-config-help {
  margin: 0 0 14px;
}

.destaque-group-editor {
  display: grid;
  gap: 14px;
  margin: 0 0 14px;
  padding: 14px 16px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.destaque-group-editor legend {
  padding: 0 6px;
  color: var(--text);
  font-weight: 800;
}

.destaque-editor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.field > span small,
.field small.cell-note {
  color: var(--muted);
  font-weight: 600;
}

.check-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 5px 10px 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.check-chip input {
  width: 16px;
  min-height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

.check-chip:has(input:checked) {
  border-color: var(--primary);
  background: #eff6ff;
}

.check-chip small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.check-chip.disabled {
  cursor: not-allowed;
  opacity: 0.6;
  border-style: dashed;
}

.check-chip-empty {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.group-editor-actions {
  display: flex;
  justify-content: flex-end;
}

.dirty-hint {
  color: var(--warning);
  font-size: 0.86rem;
  font-weight: 800;
}

/* Dialogo de importacao ------------------------------------------------------ */

.app-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.app-dialog form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.app-dialog h2 {
  margin: 0;
}

.dialog-file {
  margin: 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--surface-alt);
  font-size: 0.86rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.dialog-hint,
.dialog-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.dialog-hint.warning {
  padding: 8px 10px;
  border: 1px solid #fde68a;
  border-radius: 7px;
  background: #fffbeb;
  color: #92400e;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

@media (max-width: 880px) {
  .destaque-intro {
    flex-direction: column;
  }

  .year-picker {
    justify-content: space-between;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .segmented,
  .segment {
    width: 100%;
  }

  .segment {
    justify-content: space-between;
  }

  .dialog-actions {
    flex-direction: column-reverse;
  }
}

/* Risco de reprovacao -------------------------------------------------------- */

.nav-badge {
  min-width: 22px;
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
}

.login-page { display: grid; place-items: center; min-height: 100dvh; padding: 24px; background: linear-gradient(145deg, #243447, #0f766e); }
.login-card { width: min(100%, 460px); border-radius: 24px; overflow: hidden; background: var(--surface); box-shadow: 0 24px 80px #0003; }
.login-brand { display: grid; justify-items: center; gap: 14px; padding: 32px; background: var(--sidebar); color: white; font-size: 18px; font-weight: 700; }
.login-brand img { width: 230px; max-width: 100%; }
.login-form { display: grid; gap: 22px; padding: 32px; }
.login-form h1 { font-size: 26px; margin: 8px 0; }
.login-form label, .account-form label, #userForm label { display: grid; gap: 8px; font-weight: 600; }
.login-form .btn { justify-content: center; }
.password-input { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.password-input input { min-width: 0; border: 0; flex: 1; }
.password-input button { border: 0; background: var(--surface-alt); padding: 0 12px; color: var(--text); cursor: pointer; }
.login-help { font-size: 13px; color: var(--muted); line-height: 1.6; margin: 0; }
.form-error { color: var(--danger); font-size: 14px; margin: 0; }
.sidebar-account { display: grid; gap: 8px; border-top: 1px solid #ffffff25; margin-top: 20px; padding: 20px 4px 0; }
#signedInName { font-weight: 600; overflow-wrap: anywhere; }
#signedInRole { color: #cbd5e1; font-size: 13px; }
.account-panel { margin-bottom: 20px; }
.destaque-export-summary { color: var(--muted); font-size: 13px; line-height: 1.6; margin: 0 0 18px; }
#destaqueReviewDialog { width: min(660px, calc(100% - 32px)); max-height: calc(100dvh - 48px); }
#destaqueReviewForm > label:not(.review-check) { display: grid; gap: 7px; }
#destaqueReviewForm .review-check { display: flex; align-items: flex-start; gap: 12px; padding: 14px; background: var(--surface-alt); border-radius: 10px; line-height: 1.5; cursor: pointer; }
.review-check input { width: 18px; height: 18px; flex: 0 0 18px; margin: 2px 0 0; }
.review-inherited { padding: 12px; border-radius: 8px; color: #92400e; background: #fffbeb; font-size: 13px; line-height: 1.6; }
.review-history summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.review-history-item { border-top: 1px solid var(--line); padding: 12px 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
.review-history-item p { margin: 6px 0 0; }
.account-form { display: grid; gap: 18px; margin-top: 18px; }
.account-form > button { justify-self: start; }
.password-section { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.password-section summary { cursor: pointer; font-weight: 600; }
.users-heading, .users-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.users-toolbar { margin: 20px 0 12px; }
.users-toolbar input { flex: 1; min-width: 0; }
.users-toolbar select { width: auto; }
#userDialog { width: min(560px, calc(100% - 32px)); }
@media (max-width: 600px) { .users-heading, .users-toolbar { align-items: stretch; flex-direction: column; } .login-form { padding: 24px; } }

.risk-rules {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 7px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  max-width: 820px;
}

.risk-alerts {
  border-color: #fecaca;
  background: #fffafa;
}

.risk-alerts h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #991b1b;
}

.risk-alerts h2 svg {
  width: 18px;
  height: 18px;
}

#approvalRiskAlertsList {
  display: grid;
  gap: 10px;
}

.risk-alert-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--warning);
  border-radius: 8px;
  background: var(--surface);
}

.risk-alert-item.level-critico {
  border-left-color: var(--danger);
}

.risk-alert-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.risk-alert-head span {
  color: var(--muted);
  font-size: 0.82rem;
}

.risk-alert-item ul {
  margin: 8px 0 6px;
  padding-left: 18px;
  font-size: 0.86rem;
}

.risk-alert-item small {
  color: var(--muted);
}

.risk-alert-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 0 0 auto;
}

.student-risk-list {
  display: grid;
  gap: 6px;
}

.student-risk-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 0.86rem;
}

.student-risk-row span {
  color: var(--muted);
}

.student-approval-risk:empty {
  display: none;
}

.check-chip small {
  margin-left: 2px;
}

@media (max-width: 880px) {
  .risk-alert-item {
    flex-direction: column;
  }

  .risk-alert-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
}
