@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --text: #111827;
  --muted: #6b7280;
  --border: #dce1e7;
  --primary: #39a900;
  --primary-dark: #2a7d00;
  --teal: #047857;
  --amber: #b45309;
  --red: #b91c1c;
  --gray: #4b5563;
  --radius: 16px;
  --shadow: 0 10px 40px -20px rgba(57, 169, 0, .2);
  --focus: 0 0 0 3px rgba(57, 169, 0, .25);
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select { font: inherit; }

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

nav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 64px;
  padding: 10px 28px;
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-right: auto;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #f0fdf4;
  border: 1px solid #c4e5ad;
  border-radius: 50%;
  color: var(--primary);
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-text strong {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-dark);
  line-height: 1.1;
}

.brand-text span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.05em;
}

nav button {
  padding: 9px 13px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
}

nav button:hover {
  background: var(--surface-2);
  color: var(--text);
}

nav button.active {
  background: #eaf6e1;
  border-color: #c4e5ad;
  color: var(--primary-dark);
}

main {
  width: min(1200px, calc(100% - 64px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.page { display: none; }
.page.active { display: block; }

.ficha-bar,
.filters,
.panel,
.table-wrap,
.import-card,
.modal,
.study-card,
.study-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.ficha-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 24px;
  border-left: 4px solid var(--primary);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.ficha-bar:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 24px -10px rgba(57, 169, 0, 0.25);
  border-color: rgba(57, 169, 0, 0.4);
  border-left-color: var(--primary);
}

.ficha-bar label,
.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ficha-bar select,
.filters input,
.filters select {
  min-height: 38px;
  padding: 8px 11px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: all 0.2s;
}

.ficha-bar select:hover,
.filters input:hover,
.filters select:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.ficha-bar select:focus,
.filters input:focus,
.filters select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(57, 169, 0, 0.15);
  outline: none;
}

.ficha-bar select { min-width: 360px; }
.ficha-info { margin-left: auto; color: var(--muted); font-size: 13px; }

.form-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
textarea.form-input { resize: vertical; }

.form-input:hover {
  border-color: var(--primary-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(57, 169, 0, 0.15);
  outline: none;
  transform: translateY(-2px);
}

.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 8px 0 18px;
}

.section-heading h1,
.import-card h1 {
  margin-top: 3px;
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.kpi-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-grid.didactic-mode {
  margin-top: 60px;
  margin-bottom: 60px;
  gap: 24px;
}

.kpi-grid.didactic-mode .kpi {
  flex: 1 1 240px;
  max-width: 320px;
  padding: 30px 24px;
}

.kpi-grid.didactic-mode .kpi .val {
  font-size: 42px;
}

.kpi {
  flex: 1 1 200px;
  max-width: 280px;
  padding: 15px 15px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
  cursor: default;
}

.kpi:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 24px -10px rgba(57, 169, 0, 0.3);
  border-color: rgba(57, 169, 0, 0.4);
}

.kpi .val {
  margin-bottom: 5px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.kpi .lbl {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.kpi.primary { border-left: 4px solid var(--primary); }
.kpi.teal { border-left: 4px solid var(--teal); }
.kpi.amber { border-left: 4px solid var(--amber); }
.kpi.red { border-left: 4px solid var(--red); }

.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

.panel {
  padding: 24px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.panel:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 24px -10px rgba(57, 169, 0, 0.25);
  border-color: rgba(57, 169, 0, 0.4);
}
.panel-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.panel-title h2,
.study-card h3 {
  font-size: 15px;
  font-weight: 800;
}

.chart-wrap {
  position: relative;
  height: 260px;
}

.chart-tall { min-height: 360px; }

.analytics-section {
  margin-top: 18px;
}

.analytics-heading {
  margin-top: 20px;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.insight-strip div {
  min-height: 92px;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
  cursor: default;
}

.insight-strip div:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 24px -10px rgba(57, 169, 0, 0.3);
  border-color: rgba(57, 169, 0, 0.4);
}

.insight-strip strong {
  display: block;
  margin-bottom: 7px;
  font-size: 26px;
  line-height: 1;
  font-weight: 800;
}

.insight-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.analytics-panel {
  min-width: 0;
}

.rank-list {
  display: grid;
  gap: 9px;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 6px;
}

.rank-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fbfcfd;
  border: 1px solid #eef1f4;
  border-radius: var(--radius);
}

.rank-num {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  background: #e8f0fe;
  border: 1px solid #c8d8f6;
  border-radius: 50%;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 800;
}

.rank-main {
  min-width: 0;
}

.rank-main strong {
  display: block;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.3;
}

.rank-main small {
  display: block;
  margin: 3px 0 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.rank-value {
  min-width: 46px;
  color: var(--primary-dark);
  font-weight: 800;
  text-align: right;
}

.rank-value.warn {
  color: var(--amber);
}

.rank-value.risk {
  color: var(--red);
}

.rank-side {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.risk-reason {
  margin: 0 0 8px;
  color: #991b1b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.peer-pending-list {
  display: grid;
  gap: 6px;
  margin: 8px 0;
}

.peer-pending-list div {
  padding: 8px;
  background: #fff;
  border: 1px solid #fee2e2;
  border-radius: var(--radius);
}

.peer-pending-list strong {
  font-size: 12px;
  font-weight: 800;
}

.peer-pending-list span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.mini-bar {
  height: 7px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.mini-bar div {
  height: 100%;
  border-radius: inherit;
}

.mini-bar .ok {
  background: var(--teal);
}

.mini-bar .mid {
  background: var(--amber);
}

.mini-bar .low {
  background: var(--red);
}

.analytics-empty {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

.analytics-bottom {
  align-items: stretch;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) repeat(5, minmax(150px, 1fr)) auto;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  background: #f0fdf4;
  border-color: #c4e5ad;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 13px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
  white-space: nowrap;
}

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

.btn-primary:hover { background: var(--primary-dark); }

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.full { width: 100%; }
.compact-btn { min-height: 31px; padding: 5px 10px; font-size: 12px; }

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.summary-strip div {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.03);
  cursor: default;
}

.summary-strip div:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 24px -10px rgba(57, 169, 0, 0.25);
  border-color: rgba(57, 169, 0, 0.4);
}

.summary-strip div:nth-child(1) { border-left: 4px solid var(--primary); }
.summary-strip div:nth-child(2) { border-left: 4px solid var(--primary-light); }
.summary-strip div:nth-child(3) { border-left: 4px solid var(--teal); }
.summary-strip div:nth-child(4) { border-left: 4px solid var(--amber); }

.summary-strip strong { display: block; font-size: 26px; font-weight: 800; margin-bottom: 4px; }
.summary-strip span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }

.table-wrap { overflow: hidden; }

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.table-header .title { font-weight: 800; }
.table-header .count { color: var(--muted); font-size: 13px; }
.table-scroll { overflow-x: auto; overflow-y: auto; max-height: 60vh; }
.table-scroll.compact { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: none; }

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #eef1f4;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #eaf6e1;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  position: sticky;
  top: 0;
  z-index: 10;
}

td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

tbody tr:nth-child(even) td {
  background: #f8fafc;
}

tbody tr {
  transition: background-color 0.2s;
}
tbody tr:hover td { background: #f0fdf4 !important; }
.ok { color: var(--teal); font-weight: 800; }
.warn { color: var(--amber); font-weight: 800; }

.group-row { cursor: pointer; }
.toggle-icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 22px;
  transition: transform .18s ease;
}

.group-row.open .toggle-icon { transform: rotate(90deg); }
.detail-row { display: none; }
.detail-row.open { display: table-row; }
.detail-row > td { padding: 0; background: #fbfcfd; }

.detail-panel {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.competence-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.competence-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 13px;
  background: #f7f8fa;
  border-bottom: 1px solid var(--border);
}

.competence-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.result-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border);
}

.result-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #fff;
}

.result-item small {
  color: var(--muted);
  font-size: 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #e5e7eb; color: #374151; }

.bar-wrap {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
}

.bar-bg {
  flex: 1;
  height: 9px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: var(--teal);
  border-radius: inherit;
}

.bar-fill.mid { background: var(--amber); }
.bar-fill.low { background: var(--red); }
.bar-pct { width: 44px; text-align: right; font-size: 12px; font-weight: 800; }

.loading {
  padding: 34px;
  color: var(--muted);
  text-align: center;
  font-weight: 600;
}

.loading.small { padding: 16px; }

.import-card {
  max-width: 660px;
  margin: 34px auto;
  padding: 28px;
}

.import-card p {
  margin: 10px 0 18px;
  color: var(--muted);
}

.drop-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 180px;
  margin-bottom: 14px;
  padding: 26px;
  background: #f8fafc;
  border: 2px dashed #b9c2cf;
  border-radius: var(--radius);
  cursor: pointer;
}

.drop-zone.over,
.drop-zone:hover {
  background: #eff6ff;
  border-color: var(--primary);
}

.drop-zone .icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  background: #e8f5ee;
  border: 1px solid #b7dfc7;
  border-radius: var(--radius);
  color: var(--teal);
  font-weight: 800;
}

#drop-filename { margin: 0; color: var(--primary); font-weight: 700; }
#file-input { display: none; }

.progress-bar {
  display: none;
  height: 9px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #e5e7eb;
  border-radius: 999px;
}

.progress-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--teal));
}

.result-box {
  display: none;
  margin-top: 14px;
  padding: 13px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
  color: #065f46;
}

.result-box.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(17, 24, 39, .62);
}

.modal-overlay.open { display: flex; }

.modal {
  width: min(1360px, 100%);
  max-height: calc(100vh - 44px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}

.modal-header h2 { margin-top: 2px; font-size: 18px; }

.modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-weight: 800;
}

.modal-close:hover {
  background: #fee2e2;
  color: var(--red);
}

.modal-body {
  overflow-y: auto;
  padding: 16px;
}

.student-study {
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 14px;
}

.study-side {
  padding: 14px;
  box-shadow: none;
}

.score-ring {
  height: 170px;
  margin-bottom: 12px;
}

.mini-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mini-kpis div,
.status-box {
  padding: 11px;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mini-kpis strong {
  display: block;
  font-size: 20px;
  font-weight: 800;
}

.mini-kpis span,
.status-box span,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.status-box {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.status-box strong { font-size: 14px; }
.status-box.ok { border-color: #86efac; background: #f0fdf4; }
.status-box.mid { border-color: #fde68a; background: #fffbeb; }
.status-box.risk { border-color: #fecaca; background: #fef2f2; }

.study-main { min-width: 0; }

.study-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.45fr) minmax(260px, .75fr);
  gap: 14px;
  margin-bottom: 12px;
}

.study-card {
  padding: 14px;
  box-shadow: none;
}

.study-card h3 { margin-bottom: 10px; }
.modal-bars { min-height: 260px; }

.alert-item {
  display: grid;
  gap: 5px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.alert-item:last-child { border-bottom: none; }
.alert-item span { color: var(--amber); font-size: 12px; font-weight: 700; }

.modal-filters {
  grid-template-columns: minmax(240px, 1fr) 180px auto;
  box-shadow: none;
}

#modal-count {
  align-self: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .analytics-grid { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr 1fr 1fr; }
  .study-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  nav {
    overflow-x: auto;
    padding: 10px 14px;
  }

  .brand { min-width: 180px; }
  main { width: min(100% - 24px, 1480px); }
  .ficha-bar,
  .section-heading,
  .student-study {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .ficha-bar { display: grid; }
  .ficha-bar select { min-width: 0; width: 100%; }
  .ficha-info { margin-left: 0; }
  .section-heading { display: grid; }
  .charts-row,
  .summary-strip,
  .insight-strip,
  .analytics-grid,
  .student-study {
    grid-template-columns: 1fr;
  }

  .kpi-grid,
  .filters,
  .modal-filters {
    grid-template-columns: 1fr;
  }

  .summary-strip div {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .summary-strip div:last-child { border-bottom: none; }
  .modal-overlay { padding: 10px; }
  .modal { max-height: calc(100vh - 20px); }
}

/* AI Styles */
.ai-btn {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  color: white;
}
.ai-btn:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
}
.ai-box {
  background: #f8fafc;
  border: 1px solid #c7d2fe;
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  font-size: 13px;
  line-height: 1.5;
  color: #334155;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}
.ai-box.loading {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
  text-align: center;
  font-weight: 600;
}
.ai-box.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.ai-box h3 {
  font-size: 14px;
  margin-bottom: 8px;
  color: #1e3a8a;
}
.ai-box pre {
  font-family: inherit;
  white-space: pre-wrap;
  margin-bottom: 0;
}
.ai-copy-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: white;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  color: #475569;
}
.ai-copy-btn:hover {
  background: #f1f5f9;
}

.heading-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-box-dashboard {
  display: block;
  padding: 0;
  margin-bottom: 14px;
  overflow: hidden;
  background: #fff;
  border-color: #c7d2fe;
}

.ai-box-dashboard.loading {
  text-align: left;
  font-weight: inherit;
}

.ai-dashboard-shell {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.ai-dashboard-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
}

.ai-dashboard-head h2 {
  margin: 2px 0 4px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.2;
}

.ai-dashboard-head p {
  color: var(--muted);
  font-size: 13px;
}

.ai-kicker {
  color: #4f46e5;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.ai-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ai-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  color: #3730a3;
  font-size: 12px;
  font-weight: 800;
}

.ai-status-pill::before {
  content: "";
  width: 8px;
  height: 8px;
  background: #6366f1;
  border-radius: 50%;
  box-shadow: 0 0 0 5px rgba(99, 102, 241, .14);
}

.ai-loading-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 10px;
}

.ai-skeleton {
  min-height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, #eef2ff 0%, #f8fafc 48%, #eef2ff 100%);
  background-size: 220% 100%;
  animation: aiPulse 1.2s ease-in-out infinite;
}

.ai-skeleton.wide { grid-column: 1 / -1; }
.ai-skeleton.tall { min-height: 88px; }

@keyframes aiPulse {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.ai-helper {
  color: var(--muted);
  font-size: 12px;
}

.ai-metric-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid #e0e7ff;
  border-radius: var(--radius);
  overflow: hidden;
  background: #f8fafc;
}

.ai-metric-strip div {
  padding: 11px 13px;
  border-right: 1px solid #e0e7ff;
}

.ai-metric-strip div:last-child {
  border-right: none;
}

.ai-metric-strip strong {
  display: block;
  color: #312e81;
  font-size: 19px;
  font-weight: 800;
}

.ai-metric-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ai-readable {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.ai-section {
  padding: 13px;
  background: #fbfcff;
  border: 1px solid #e0e7ff;
  border-radius: var(--radius);
}

.ai-section:first-child {
  grid-column: 1 / -1;
  background: #f5f7ff;
}

.ai-section h3 {
  margin-bottom: 7px;
  color: #312e81;
  font-size: 13px;
  font-weight: 800;
}

.ai-section p {
  margin: 0 0 7px;
  color: #334155;
  font-size: 13px;
}

.ai-section p:last-child {
  margin-bottom: 0;
}

.ai-box-dashboard.error {
  border-color: #fecaca;
  background: #fff;
  color: inherit;
}

.ai-box-dashboard.error .ai-kicker,
.ai-box-dashboard.error h2 {
  color: #991b1b;
}

/* --- Estilos para Reportes PDF --- */
.pdf-report {
  padding: 40px;
  background: #ffffff;
  color: #111827;
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
  width: 100%;
}

.pdf-header {
  border-bottom: 2px solid #1f6feb;
  padding-bottom: 15px;
  margin-bottom: 25px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.pdf-brand {
  font-weight: 800;
  font-size: 14px;
  color: #6b7280;
  letter-spacing: 0.05em;
}

.pdf-title {
  font-size: 24px;
  font-weight: 800;
  color: #111827;
}

.pdf-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
  background: #f9fafb;
  padding: 15px;
  border-radius: 8px;
  margin-bottom: 25px;
  font-size: 13px;
}

.pdf-section-title {
  font-size: 16px;
  font-weight: 800;
  color: #1f6feb;
  margin: 25px 0 15px;
  border-left: 4px solid #1f6feb;
  padding-left: 10px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.pdf-kpi-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.pdf-kpi-container .kpi {
  padding: 12px;
  border: 1px solid #dce1e7;
  box-shadow: none;
}

.pdf-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.pdf-chart-item {
  text-align: center;
}

.pdf-chart-item p {
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 10px;
}

.pdf-rank-list {
  display: grid;
  gap: 8px;
}

.pdf-rank-list .rank-item {
  box-shadow: none;
  background: #fff;
  border: 1px solid #eef1f4;
}

.pdf-rank-list .btn { display: none; } /* Ocultar botones en PDF */

.pdf-footer {
  margin-top: 40px;
  padding-top: 15px;
  border-top: 1px solid #dce1e7;
  font-size: 11px;
  color: #9ca3af;
  text-align: center;
}

/* Estilos específicos para reporte de estudiante */
.pdf-two-cols {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 30px;
}

.pdf-mini-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 15px;
}

.pdf-mini-stats div {
  padding: 8px;
  background: #f3f4f6;
  border-radius: 6px;
  text-align: center;
}

.pdf-mini-stats strong { display: block; font-size: 16px; }
.pdf-mini-stats span { font-size: 10px; color: #6b7280; }

.pdf-alerts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.alert-item {
  padding: 10px;
  background: #fff5f5;
  border: 1px solid #feb2b2;
  border-radius: 6px;
}

.alert-item strong { display: block; font-size: 12px; }
.alert-item span { font-size: 11px; color: #c53030; }

.pdf-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.pdf-table-wrap th {
  background: #f3f4f6;
  text-align: left;
  padding: 8px;
  border-bottom: 2px solid #d1d5db;
}

.pdf-table-wrap td {
  padding: 8px;
  border-bottom: 1px solid #e5e7eb;
}

/* ============================================================
   MÓDULO DE FASES DEL PROYECTO FORMATIVO
   ============================================================ */

.fases-overview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 16px;
  margin-bottom: 32px;
}

.fases-placeholder {
  grid-column: 1 / -1;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
}

.fase-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.fase-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
  border-color: var(--primary);
}

.fase-card.active {
  border: 2px solid var(--primary);
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.15);
}

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

.fase-card-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: var(--text);
  margin: 0;
  line-height: 1.3;
}

.fase-pct {
  font-size: 16px;
  font-weight: 800;
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 6px;
}

.fase-prog-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 18px;
}

.fase-prog-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.fase-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.fase-meta span {
  display: flex;
  align-items: center;
  line-height: 1.4;
}

.fases-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 20px;
}

.fases-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
}

.btn-danger {
  border-color: #fecaca;
  color: #b91c1c;
  background: #fff;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.asignar-comp-header {
  background: #f1f5f9;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #334155;
  border-radius: 6px;
  margin: 16px 0 8px 0;
}

.asignar-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  transition: background 0.15s;
  border-radius: 6px;
}

.asignar-item:hover {
  background: #f8fafc;
}

.asignar-item input[type="checkbox"] {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

.asignar-item.otro-fase {
  background: #fffbeb;
  opacity: 0.75;
  cursor: not-allowed;
  border-color: #fde68a;
}

.asignar-resultado {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: block;
}

.asignar-comp {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: #b45309;
  margin-top: 3px;
}

@media (max-width: 960px) {
  .fases-grid {
    grid-template-columns: 1fr;
  }
}

/* ========================= PAGE BIENVENIDA ========================= */
#page-bienvenida {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 60px 20px;
  margin-top: 20px;
}

#page-bienvenida.active {
  display: flex;
}

#page-bienvenida h1 {
  font-size: 42px;
  color: var(--primary-dark);
  margin-bottom: 24px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

#page-bienvenida p {
  font-size: 18px;
  color: var(--muted);
  max-width: 600px;
  margin-bottom: 40px;
  line-height: 1.6;
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: var(--radius);
}

/* Custom scrollbars */
.table-scroll::-webkit-scrollbar,
.rank-list::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.table-scroll::-webkit-scrollbar-track,
.rank-list::-webkit-scrollbar-track {
  background: transparent;
}

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

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(57, 169, 0, 0.4); }
  70% { box-shadow: 0 0 0 12px rgba(57, 169, 0, 0); }
  100% { box-shadow: 0 0 0 0 rgba(57, 169, 0, 0); }
}

#page-bienvenida.active {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: fixed;
  inset: 0;
  top: 64px;
  background: var(--bg);
  z-index: 50;
  overflow: hidden;
}

.auth-card {
  max-width: 680px;
  width: 100%;
  padding: 20px;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: slideUpFade 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.auth-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: #f0fdf4;
  color: var(--primary);
  border-radius: 16px;
  margin-bottom: 24px;
}

.auth-eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 12px;
}

.auth-title {
  color: var(--text-dark);
  font-size: 32px;
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 20px;
}

.auth-desc {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 32px;
  max-width: 580px;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-size: 15px;
  border-radius: 999px;
  width: 100%;
  max-width: 240px;
  margin-bottom: 24px;
  transition: all 0.25s ease;
  animation: pulseGlow 2.5s infinite;
}

.auth-btn:hover {
  animation: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px -6px rgba(57, 169, 0, 0.4);
}

.auth-footer {
  color: var(--muted);
  font-size: 12px;
  opacity: 0.8;
  margin: 0;
}
.table-scroll::-webkit-scrollbar-thumb,
.rank-list::-webkit-scrollbar-thumb {
  background: #dce1e7;
  border-radius: 10px;
}
.table-scroll::-webkit-scrollbar-thumb:hover,
.rank-list::-webkit-scrollbar-thumb:hover {
  background: #a0aab5;
}
