:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --surface-muted: #F1F5F9;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;
  --text: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;

  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --primary-soft: #EEF2FF;
  --primary-border: #C7D2FE;

  --emerald: #10B981;
  --emerald-soft: #ECFDF5;
  --emerald-text: #047857;

  --amber: #F59E0B;
  --amber-soft: #FFFBEB;
  --amber-text: #B45309;

  --rose: #F43F5E;
  --rose-soft: #FFF1F2;
  --rose-text: #BE123C;

  --teal: #0D9488;
  --teal-soft: #F0FDFA;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 18px 42px rgba(15, 23, 42, 0.12);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

/* =========================================================
   LOGIN SCREEN
   ========================================================= */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--surface);
}

.login-hero {
  background: linear-gradient(145deg, #312E81 0%, #4338CA 52%, #0F172A 100%);
  color: #FFFFFF;
  padding: 56px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-hero::after {
  content: "";
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(129, 140, 248, 0.25) 0%, transparent 70%);
  bottom: -140px;
  right: -100px;
  pointer-events: none;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
}

.login-hero-content {
  max-width: 480px;
  position: relative;
  z-index: 1;
}

.login-hero-content h1 {
  font-family: var(--font-display);
  font-size: 2.45rem;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 18px;
}

.login-hero-content p {
  color: #C7D2FE;
  font-size: 1.03rem;
  margin-bottom: 32px;
}

.hero-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.hero-pill {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.88rem;
  color: #E0E7FF;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.hero-pill strong {
  display: block;
  color: #FFFFFF;
  font-size: 0.92rem;
  margin-bottom: 2px;
}

.login-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 36px;
  box-shadow: var(--shadow-md);
}

.login-card h2 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.94rem;
  margin-bottom: 24px;
}

.matricula-input-wrap {
  position: relative;
}

.matricula-input {
  width: 100%;
  padding: 14px 16px 14px 44px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: border-color 0.18s, box-shadow 0.18s;
  background: var(--surface);
}

.matricula-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}

.matricula-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.quick-access-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.quick-access-divider::before,
.quick-access-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.quick-profiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-profile-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: left;
  transition: all 0.16s ease;
}

.quick-profile-btn:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.quick-profile-btn .qp-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.25;
}

.quick-profile-btn .qp-meta {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* =========================================================
   APP SHELL & SIDEBAR
   ========================================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 268px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 30;
  transition: transform 0.22s ease;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
}

.sidebar-brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-user {
  margin: 14px 14px 10px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 11px;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.78rem;
}

.sidebar-user-info {
  min-width: 0;
  flex: 1;
}

.sidebar-user-name {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 0.71rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 10px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
  text-align: left;
  transition: all 0.14s ease;
}

.nav-item:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-badge {
  margin-left: auto;
  background: var(--rose);
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.nav-badge.amber {
  background: var(--amber);
}

.sidebar-footer {
  padding: 14px 12px;
  border-top: 1px solid var(--border);
}

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

.topbar {
  height: 64px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mobile-menu-btn {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px;
  color: var(--text);
}

.page-title {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.main-content {
  padding: 28px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* =========================================================
   COMPONENTS: CARDS, BUTTONS, BADGES, FORMS
   ========================================================= */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-xs);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text-muted);
  font-size: 0.83rem;
  font-weight: 600;
}

.kpi-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.kpi-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.88rem;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

.btn-soft:hover {
  background: #E0E7FF;
}

.btn-emerald {
  background: var(--emerald);
  color: #FFFFFF;
}

.btn-emerald:hover {
  background: #059669;
}

.btn-danger-soft {
  background: var(--rose-soft);
  color: var(--rose-text);
  border-color: #FECDD3;
}

.btn-danger-soft:hover {
  background: #FFE4E6;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 13px 22px;
  font-size: 0.96rem;
  border-radius: var(--radius-md);
}

.btn-full {
  width: 100%;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-indigo { background: var(--primary-soft); color: var(--primary); }
.badge-emerald { background: var(--emerald-soft); color: var(--emerald-text); }
.badge-amber { background: var(--amber-soft); color: var(--amber-text); }
.badge-rose { background: var(--rose-soft); color: var(--rose-text); }
.badge-slate { background: var(--surface-muted); color: var(--text-secondary); }
.badge-teal { background: var(--teal-soft); color: var(--teal); }

/* Form fields */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.form-label {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.input, .select, .textarea {
  width: 100%;
  padding: 10px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 0.92rem;
  transition: border-color 0.16s, box-shadow 0.16s;
}

.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.textarea-mono {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  line-height: 1.6;
}

/* =========================================================
   SPLIT-SCREEN LATEX QUESTION EDITOR (PROFESSOR)
   ========================================================= */
.editor-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 22px;
  align-items: start;
}

.latex-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.latex-chip {
  padding: 4px 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all 0.12s;
}

.latex-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.editor-split .textarea-with-bar {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.live-preview-pane {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 1.5px solid var(--primary-border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.live-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  margin-bottom: 16px;
  border-bottom: 1px dashed var(--border-strong);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px;
  text-align: center;
  background: var(--bg);
  color: var(--text-muted);
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.16s;
}

.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

.image-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.image-thumb {
  position: relative;
  width: 96px;
  height: 76px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-muted);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.image-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.78);
  color: #FFFFFF;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.option-editor-row {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--bg);
}

.option-editor-row.is-correct {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.option-key-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.option-editor-row.is-correct .option-key-btn {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #FFFFFF;
}

/* =========================================================
   RICH LATEX CONTENT & QUESTION SOLVER (ALUNA)
   ========================================================= */
.latex-content {
  font-size: 0.98rem;
  line-height: 1.72;
  color: var(--text);
  word-wrap: break-word;
}

.latex-content p {
  margin-bottom: 10px;
}

.latex-content p:last-child {
  margin-bottom: 0;
}

.latex-content .katex-display {
  margin: 14px 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 6px 2px;
}

.question-images-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 16px 0;
}

.question-images-gallery img {
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: zoom-in;
  background: #FFFFFF;
  box-shadow: var(--shadow-xs);
}

.solver-container {
  max-width: 860px;
  margin: 0 auto;
}

.solver-option {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  margin-bottom: 10px;
  transition: all 0.15s ease;
  cursor: pointer;
}

.solver-option:hover:not(.disabled) {
  border-color: var(--primary);
  background: #FAFBFD;
}

.solver-option.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.solver-option.eliminated {
  opacity: 0.45;
  text-decoration: line-through;
  background: var(--surface-muted);
}

.solver-option.correct {
  border-color: var(--emerald);
  background: var(--emerald-soft);
}

.solver-option.wrong {
  border-color: var(--rose);
  background: var(--rose-soft);
}

.solver-option-letter {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.88rem;
  flex-shrink: 0;
  background: var(--surface);
}

.solver-option.selected .solver-option-letter {
  background: var(--primary);
  border-color: var(--primary);
  color: #FFFFFF;
}

.solver-option.correct .solver-option-letter {
  background: var(--emerald);
  border-color: var(--emerald);
  color: #FFFFFF;
}

.solver-option.wrong .solver-option-letter {
  background: var(--rose);
  border-color: var(--rose);
  color: #FFFFFF;
}

.eliminate-btn {
  margin-left: auto;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px;
  border-radius: 6px;
}

.eliminate-btn:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.confidence-group {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.confidence-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.confidence-pill.active[data-level="CERTEZA"] {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  color: var(--emerald-text);
}

.confidence-pill.active[data-level="DUVIDA"] {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber-text);
}

.confidence-pill.active[data-level="CHUTE"] {
  border-color: var(--rose);
  background: var(--rose-soft);
  color: var(--rose-text);
}

.explanation-box {
  margin-top: 20px;
  padding: 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--primary-border);
  background: #F8FAFF;
}

/* =========================================================
   FLASHCARDS
   ========================================================= */
.flashcard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 18px;
}

.flashcard-wrapper {
  perspective: 1000px;
  min-height: 230px;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 230px;
  transition: transform 0.55s cubic-bezier(0.22, 1, 0.36, 1);
  transform-style: preserve-3d;
  cursor: pointer;
}

.flashcard-wrapper.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.flashcard-back {
  transform: rotateY(180deg);
  background: linear-gradient(180deg, #F8FAFF 0%, #EEF2FF 100%);
  border-color: var(--primary-border);
}

/* =========================================================
   GRAPHIFY: KNOWLEDGE TREE & RELATIONSHIP SVG
   ========================================================= */
.knowledge-subject-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--bg);
  margin-bottom: 14px;
}

.knowledge-topics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.topic-node {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: 12px;
}

.topic-node.DOMINADO { border-left-color: var(--emerald); }
.topic-node.EVOLUCAO { border-left-color: var(--amber); }
.topic-node.ATENCAO { border-left-color: var(--rose); }
.topic-node.NAO_INICIADO { border-left-color: var(--border-strong); }

.progress-bar-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.4s ease;
}

.graph-svg-wrap {
  width: 100%;
  overflow-x: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

/* =========================================================
   TABLES & LISTS
   ========================================================= */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table th {
  text-align: left;
  padding: 11px 14px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td {
  border-bottom: none;
}

.empty-state {
  text-align: center;
  padding: 46px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 14px;
  border-radius: 16px;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state h3 {
  font-family: var(--font-display);
  color: var(--text);
  font-size: 1.05rem;
  margin-bottom: 6px;
}

/* =========================================================
   MODALS, TOASTS & LIGHTBOX
   ========================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
}

.modal-box {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 26px;
  box-shadow: var(--shadow-lg);
}

.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 100;
}

.toast {
  padding: 13px 18px;
  border-radius: var(--radius-md);
  background: #0F172A;
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.22s ease;
}

.toast.success { background: #065F46; }
.toast.error { background: #9F1239; }
.toast.info { background: #312E81; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.lightbox-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox-modal img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  background: #FFFFFF;
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 26px;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #FFFFFF;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  font-size: 1.6rem;
  line-height: 1;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 1080px) {
  .editor-split { grid-template-columns: 1fr; }
  .live-preview-pane { position: static; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 860px) {
  .login-page { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
  .main-area { margin-left: 0; }
  .mobile-menu-btn { display: inline-flex; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .main-content { padding: 18px; }
}
