:root {
  --navy: #0e2438;
  --navy-2: #16324f;
  --blue: #1a5fb4;
  --blue-soft: #e8f0fa;
  --red: #b83228;
  --red-hover: #9e2a22;
  --bg: #eef2f6;
  --card: #ffffff;
  --line: #d7e0ea;
  --line-strong: #c2cedb;
  --text: #142433;
  --muted: #5a6b7c;
  --ok: #1b6b3a;
  --bad: #a61b12;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(14, 36, 56, 0.04), 0 8px 24px rgba(14, 36, 56, 0.06);
  --font: "DM Sans", system-ui, sans-serif;
  --display: "Manrope", "DM Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 420px at 10% -10%, rgba(26, 95, 180, 0.08), transparent 60%),
    radial-gradient(700px 380px at 100% 0%, rgba(184, 50, 40, 0.05), transparent 55%),
    linear-gradient(180deg, #e8eef5 0%, var(--bg) 45%, #e9eef4 100%);
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.portal-header {
  background: linear-gradient(180deg, #0c1f31 0%, var(--navy) 100%);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.portal-header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.portal-brand-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}
.portal-brand {
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.02em;
  color: #fff !important;
  text-decoration: none !important;
}
.portal-brand span { color: #8ec0ff; }
.portal-beta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.16rem 0.42rem;
  border-radius: 5px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1;
  color: #0c1f31;
  background: #f0b429;
  border: 1px solid rgba(255, 255, 255, 0.2);
  user-select: none;
}
.alert.info {
  background: #eef5fb;
  color: #1a3a55;
  border: 1px solid #c5d8ea;
  line-height: 1.45;
}
.level-unlock-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.85rem 1.25rem;
  margin: 0 0 1.15rem;
}
.level-unlock-alert h2 {
  margin: 0;
  font-size: 1.05rem;
}
.level-unlock-alert p {
  margin: 0.3rem 0 0;
}
.level-unlock-alert .btn {
  flex: 0 0 auto;
}
.messages-purpose { margin-top: 0.15rem; }
.input-readonly {
  background: #f3f6f9 !important;
  color: var(--ink) !important;
  cursor: default;
  font-weight: 600;
}
.portal-user {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  font-size: 0.9rem;
}
.portal-user a { color: #cfe0ff !important; }
.portal-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1.6rem 1.25rem 3.5rem;
}
body.area-admin .portal-main,
body.area-admin .portal-header-inner {
  max-width: 1280px;
}
.portal-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.5rem;
}
h1, h2, h3 { font-family: var(--display); margin: 0 0 0.6rem; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.55rem, 2.4vw, 1.9rem); }
.lead { color: var(--muted); margin: 0 0 1.25rem; line-height: 1.45; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 800px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem 1.25rem;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; }
.stat {
  font-size: 1.8rem;
  font-weight: 800;
  font-family: var(--display);
  color: var(--navy);
}
.muted { color: var(--muted); font-size: 0.92rem; }

/* —— Botões —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.7rem 1.15rem;
  min-height: 44px;
  font: inherit;
  font-weight: 650;
  font-size: 0.94rem;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none !important;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--red);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 6px 16px rgba(184, 50, 40, 0.22);
}
.btn-primary:hover {
  background: var(--red-hover);
  color: #fff;
}
.btn-secondary {
  background: var(--navy);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255,255,255,0.08) inset, 0 6px 16px rgba(14, 36, 56, 0.18);
}
.btn-secondary:hover {
  background: var(--navy-2);
  color: #fff;
}
.btn-ghost {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(14, 36, 56, 0.04);
}
.btn-ghost:hover {
  border-color: #9eb4cc;
  background: #f7fafc;
  color: var(--text);
}
.btn-small {
  padding: 0.45rem 0.85rem;
  min-height: 36px;
  font-size: 0.86rem;
  border-radius: 8px;
}
.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}

.form-row { margin-bottom: 0.95rem; }
label { display: block; font-weight: 600; margin-bottom: 0.35rem; font-size: 0.9rem; }
input:not([type]),
input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="search"], input[type="url"], input[type="time"], input[type="month"],
input[type="week"], input[type="datetime-local"],
input[type="date"], input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: #7aa3d4;
  box-shadow: 0 0 0 3px rgba(26, 95, 180, 0.15);
}
input:disabled {
  background: #f3f6f9;
  color: var(--muted);
  cursor: not-allowed;
}
textarea { min-height: 110px; resize: vertical; }

.auth-wrap { max-width: 420px; margin: 2.5rem auto; }
.nav-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1.25rem;
}
.nav-tabs a {
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none !important;
}
.nav-tabs a.active, .nav-tabs a:hover {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
table.data th, table.data td {
  text-align: left;
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.data th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}
.badge-ok { background: #e7f6ed; color: var(--ok); }
.badge-off { background: #fdeceb; color: var(--bad); }
.badge-wait { background: #fff3df; color: #8a5a00; }
.badge-hold { background: #eef1f6; color: #3d4d63; }
.alert {
  padding: 0.8rem 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-weight: 500;
}
.alert.ok { background: #e7f6ed; color: var(--ok); border: 1px solid #b6dfc6; }
.alert.err { background: #fdeceb; color: var(--bad); border: 1px solid #f0bfb8; }
.section-title { font-size: 1.15rem; margin: 1.4rem 0 0.75rem; }

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
}
.level-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  min-height: 132px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
a.level-card:hover {
  border-color: #9db7de;
  box-shadow: var(--shadow);
}
.level-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(26, 95, 180, 0.16);
}
.level-card.locked {
  opacity: 0.62;
  background: #f7f9fc;
  cursor: not-allowed;
}
.level-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.level-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  flex: 1;
}
.level-cta { font-size: 0.86rem; font-weight: 700; color: var(--blue); }
.level-cta.muted { color: var(--muted); font-weight: 600; }
.level-units-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.85rem;
  flex-wrap: wrap;
  margin: 0.25rem 0 1.1rem;
}
.book-progress-inline {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.55rem;
}
.book-progress-inline .progress-bar {
  width: 140px;
  max-width: 140px;
  margin: 0;
}

.unit-list { display: grid; gap: 0.65rem; }
.unit-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 1px 2px rgba(14, 36, 56, 0.03);
}
.unit-item.locked {
  background: #f7f9fb;
  border-style: dashed;
}
.unit-item .meta {
  color: var(--muted);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.2rem;
}
.unit-item-main { flex: 1; min-width: 0; }
.unit-item-main strong {
  font-family: var(--display);
  font-size: 1.02rem;
  letter-spacing: -0.01em;
}
.unit-item-action {
  flex-shrink: 0;
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.unit-lock {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #eef2f6;
  color: #7a8a9a;
}
.ico-lock {
  width: 14px;
  height: 14px;
  display: inline-block;
  vertical-align: -2px;
}
.progress-bar {
  height: 8px;
  background: #e4ebf3;
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.45rem;
  max-width: 200px;
}
.progress-bar > span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #1a5fb4, #3d7fd0);
  border-radius: inherit;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.login-hero { text-align: center; margin-bottom: 1.25rem; }
.login-hero p { color: var(--muted); }
.chip-soon {
  font-size: 0.72rem;
  background: #eef2f8;
  color: var(--muted);
  padding: 0.1rem 0.45rem;
  border-radius: 6px;
  margin-left: 0.35rem;
}
.empty-state {
  text-align: center;
  padding: 2rem 1.25rem;
  color: var(--muted);
}

/* —— Nav aluno —— */
.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-items: center;
  flex: 1;
  justify-content: center;
}
.portal-nav-link {
  color: #b9cce4 !important;
  text-decoration: none !important;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.42rem 0.8rem;
  border-radius: 8px;
}
.portal-nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff !important;
}
.portal-nav-link.active {
  background: rgba(255,255,255,0.14);
  color: #fff !important;
}
.portal-avatar-link { text-decoration: none !important; }
.portal-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255,255,255,0.28);
}
.portal-avatar-fallback {
  background: #1a5fb4;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  font-family: var(--display);
}
.portal-user-name { color: #e8eef8; font-weight: 600; }
.portal-logout {
  color: #93a9c4 !important;
  font-size: 0.86rem;
  text-decoration: none !important;
}
.portal-logout:hover { color: #fff !important; }

.eyebrow {
  margin: 0 0 0.3rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--blue);
}

/* —— Hero —— */
.aluno-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
  padding: 1.35rem 1.4rem;
  border-radius: 16px;
  background:
    radial-gradient(90% 120% at 100% 0%, rgba(142, 192, 255, 0.18), transparent 50%),
    linear-gradient(135deg, #0c1f31 0%, #153450 58%, #123049 100%);
  color: #fff;
  box-shadow: 0 12px 32px rgba(12, 31, 49, 0.22);
}
.aluno-hero h1 { color: #fff; margin-bottom: 0.3rem; }
.aluno-hero .lead { color: #b7c9df; margin: 0; }
.aluno-hero .eyebrow { color: #8ec0ff; }
.aluno-hero-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.28);
  flex-shrink: 0;
  box-shadow: 0 6px 18px rgba(0,0,0,0.2);
}
.aluno-hero-avatar-fallback {
  display: grid;
  place-items: center;
  background: #1a5fb4;
  font-family: var(--display);
  font-weight: 800;
  font-size: 1.2rem;
}

/* —— Continuar —— */
.continue-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
  padding: 1.15rem 1.25rem;
  border: 1px solid #c5d8ef;
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f5f9ff 0%, #fff 70%);
  box-shadow: var(--shadow);
}
.continue-card h2 { margin: 0 0 0.15rem; font-size: 1.15rem; }
.continue-card-body { min-width: 0; flex: 1; }

/* —— Livros —— */
.lang-switch {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.28rem;
  margin: 0.15rem 0 0.85rem;
  border-radius: 999px;
  background: #e4ebf3;
  border: 1px solid #d0dae6;
}
.lang-switch-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 7.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.92rem;
  color: #4a5d72 !important;
  text-decoration: none !important;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
.lang-switch-btn:hover {
  color: var(--navy) !important;
  background: rgba(255, 255, 255, 0.55);
}
.lang-switch-btn.active {
  background: #fff;
  color: var(--navy) !important;
  box-shadow: 0 2px 8px rgba(14, 36, 56, 0.1);
}

.lang-section { margin: 0.35rem 0 0.35rem; }
.lang-section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.lang-section-head h2 { margin: 0; font-size: 1.25rem; }
.lang-count {
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 600;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
  align-items: stretch;
}
.book-card {
  position: relative;
  display: flex;
  min-height: 176px;
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: inherit;
  text-decoration: none !important;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
a.book-card:hover {
  transform: translateY(-3px);
  border-color: #9eb8d8;
  box-shadow: 0 14px 30px rgba(14, 36, 56, 0.12);
}
.book-spine {
  width: 8px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #1a5fb4, #0e2438);
}
.book-card-es .book-spine {
  background: linear-gradient(180deg, #c45a2a, #8a3518);
}
.book-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 1rem 1rem 1rem 0.95rem;
  flex: 1;
  min-width: 0;
}
.book-card.locked {
  background: #f6f8fb;
  box-shadow: none;
}
.book-card.locked .book-spine {
  background: linear-gradient(180deg, #a8b5c4, #7d8b9a);
  opacity: 0.7;
}
.book-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.45rem;
}
.book-lang-pill {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.18rem 0.42rem;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
}
.book-card-es .book-lang-pill {
  background: #f8ebe4;
  color: #9a3f1c;
}
.book-status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.book-status.open { color: var(--ok); }
.book-status.locked { color: #6d7d8d; }
.book-title {
  font-size: 1.2rem;
  font-family: var(--display);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.book-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
  flex: 1;
}
.book-cta {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--blue);
  margin-top: 0.15rem;
}
a.book-card:hover .book-cta { text-decoration: underline; }
.book-cta.muted { color: var(--muted); font-weight: 600; }

.progress-bar.big {
  max-width: none;
  height: 10px;
  margin-top: 0.75rem;
}
.progress-book { margin-bottom: 1rem; }
.progress-book-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.progress-book-head h2,
.progress-book-head h3 { margin: 0 0 0.2rem; font-size: 1.12rem; }

/* Progresso: cards iguais ao início + painel expansível */
.progress-book-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.progress-book-item {
  display: contents;
}
button.book-card.progress-book-toggle {
  width: 100%;
  font: inherit;
  text-align: left;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}
button.book-card.progress-book-toggle:hover,
button.book-card.progress-book-toggle.is-open {
  transform: translateY(-3px);
  border-color: #9eb8d8;
  box-shadow: 0 14px 30px rgba(14, 36, 56, 0.12);
}
button.book-card.progress-book-toggle.is-open {
  border-color: var(--blue);
}
.progress-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
}
button.book-card.progress-book-toggle.is-open .progress-chevron {
  transform: rotate(180deg);
}
.progress-book-panel {
  grid-column: 1 / -1;
  margin: 0.15rem 0 0.35rem;
  padding: 1rem 1.1rem 1.15rem;
  animation: progress-panel-in 0.18s ease;
}
.progress-book-panel[hidden] {
  display: none !important;
}
@keyframes progress-panel-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Progresso: cards iguais à home + painel expansível */
.progress-book-grid .progress-item {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 0;
}
.progress-book-grid .progress-item.open {
  grid-column: 1 / -1;
}
.progress-book-grid button.book-card {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font: inherit;
  appearance: none;
  -webkit-appearance: none;
}
.progress-book-grid button.book-card:hover {
  transform: translateY(-3px);
  border-color: #9eb8d8;
  box-shadow: 0 14px 30px rgba(14, 36, 56, 0.12);
}
.progress-book-grid button.book-card:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
.progress-item.open > .book-card {
  max-width: 280px;
}
.progress-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  padding: 1rem 1.05rem 1.1rem;
}
.progress-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.progress-panel-head h3 {
  margin: 0 0 0.2rem;
  font-size: 1.12rem;
}

/* —— Perfil —— */
.perfil-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1rem;
}
.perfil-course-card { grid-column: 1 / -1; }
.perfil-photo-wrap { display: flex; justify-content: center; margin: 0.35rem 0 1rem; }
.perfil-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #e2eaf2;
  box-shadow: 0 8px 20px rgba(14, 36, 56, 0.1);
}
.perfil-photo-fallback {
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  font-family: var(--display);
  font-weight: 800;
  font-size: 2rem;
}
.perfil-dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.85rem 1.25rem;
  margin: 0;
}
.perfil-dl dt {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}
.perfil-dl dd { margin: 0; font-weight: 600; }
.perfil-photo-form .btn,
.perfil-grid .btn { margin-top: 0.15rem; }
.perfil-grid form .btn-row,
.perfil-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

/* Onboarding + modais */
.onboarding-card { max-width: 560px; }
.onboarding-form .field-hint {
  margin: 0.35rem 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
}
.onboarding-avatar-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.onboarding-avatar-row .perfil-photo {
  width: 72px;
  height: 72px;
  margin: 0;
}
.portal-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(12, 31, 49, 0.55);
  backdrop-filter: blur(2px);
}
.portal-modal {
  width: min(100%, 460px);
  margin: 0;
  box-shadow: 0 18px 40px rgba(12, 31, 49, 0.28);
}
.portal-modal h2 {
  margin: 0 0 0.65rem;
  font-size: 1.35rem;
}
.portal-modal p {
  margin: 0 0 0.75rem;
  color: var(--ink);
  line-height: 1.5;
}
.portal-modal .btn { margin-top: 0.35rem; }

/* —— Ranking —— */
.rank-rules {
  margin-bottom: 1rem;
  padding: 0.95rem 1.1rem;
  border-left: 4px solid var(--blue);
}
.rank-scope { margin-bottom: 0.85rem; }
.rank-class-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}
.rank-class-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink) !important;
  text-decoration: none !important;
  font-size: 0.86rem;
  font-weight: 600;
}
.rank-class-pill.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff !important;
}
.rank-me {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  padding: 0.95rem 1.1rem;
  background: linear-gradient(135deg, #f3f8ff 0%, #fff 70%);
  border: 1px solid #c9dbef;
}
.rank-me-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.rank-me-badge {
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--blue);
}
.rank-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid #d7e3f0;
  flex-shrink: 0;
  background: #e8eef5;
}
.rank-avatar-fallback {
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(145deg, #1a5fb4, #0e2438);
  border-color: transparent;
}
.rank-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin: 0.35rem 0 1.15rem;
}
.rank-podium[data-count="1"] { grid-template-columns: minmax(0, 280px); justify-content: center; }
.rank-podium[data-count="2"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.rank-podium-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  text-align: center;
  padding: 1.1rem 0.75rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow);
}
.rank-podium-card .rank-avatar {
  width: 64px;
  height: 64px;
}
.rank-podium-card .rank-name {
  font-size: 0.92rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rank-podium-card .rank-points {
  font-weight: 800;
  color: var(--navy);
  font-size: 0.95rem;
}
.rank-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  background: #e8eef5;
  color: var(--navy);
}
.rank-podium-card.place-1 {
  padding-top: 1.45rem;
  background: linear-gradient(180deg, #fff8e8 0%, #fff 55%);
  border-color: #e2c56a;
  transform: translateY(-8px);
}
.rank-podium-card.place-1 .rank-medal { background: #f0c14b; color: #0c1f31; }
.rank-podium-card.place-2 { background: linear-gradient(180deg, #f4f7fb 0%, #fff 60%); }
.rank-podium-card.place-2 .rank-medal { background: #c5d0dc; color: #0c1f31; }
.rank-podium-card.place-3 { background: linear-gradient(180deg, #fbf4ef 0%, #fff 60%); }
.rank-podium-card.place-3 .rank-medal { background: #d4a07a; color: #0c1f31; }
.rank-podium-card.is-me,
.rank-row.is-me {
  outline: 2px solid rgba(26, 95, 180, 0.35);
}
.rank-list-card { padding: 0.85rem 0.35rem 0.55rem; }
.rank-list-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.25rem 0.85rem 0.75rem;
}
.rank-list-head h2 { margin: 0; font-size: 1.1rem; }
.rank-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rank-row {
  display: grid;
  grid-template-columns: 2.6rem 48px 1fr auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-top: 1px solid var(--line);
}
.rank-place {
  font-weight: 800;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.rank-row-main {
  min-width: 0;
  display: grid;
  gap: 0.1rem;
}
.rank-row-main .rank-name {
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rank-row .rank-points {
  font-weight: 800;
  color: var(--navy);
  white-space: nowrap;
}

@media (max-width: 860px) {
  .portal-header-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand user"
      "nav nav";
    align-items: center;
    gap: 0.7rem 0.75rem;
    padding: 0.7rem 0.85rem 0.8rem;
  }
  .portal-brand-wrap {
    grid-area: brand;
    min-width: 0;
  }
  .portal-brand {
    font-size: 1.02rem;
  }
  .portal-user {
    grid-area: user;
    gap: 0.55rem;
    justify-self: end;
  }
  .portal-user-name { display: none; }
  .portal-logout {
    font-size: 0.82rem;
    font-weight: 650;
    color: #cfe0ff !important;
    text-decoration: none !important;
    padding: 0.3rem 0.45rem;
  }
  .portal-nav {
    grid-area: nav;
    order: unset;
    width: 100%;
    flex: none;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem;
    overflow: visible;
    padding: 0;
    margin: 0;
    justify-content: stretch;
  }
  .portal-nav-link {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 100%;
    min-height: 2.35rem;
    white-space: nowrap;
    font-size: 0.78rem;
    font-weight: 650;
    padding: 0.4rem 0.25rem;
    border-radius: 9px;
    background: rgba(255, 255, 255, 0.07);
    color: #d7e6f8 !important;
    text-align: center;
  }
  .portal-nav-link.active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff !important;
  }
  .portal-nav-link:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff !important;
  }
  .perfil-grid { grid-template-columns: 1fr; }
  .aluno-hero { align-items: flex-start; }
  .continue-card { align-items: stretch; }
  .continue-card .btn,
  .continue-card .btn-row { width: 100%; }
  .continue-card .btn-row .btn { flex: 1; }
  .unit-item { align-items: flex-start; }
  .rank-podium {
    grid-template-columns: 1fr;
  }
  .rank-podium-card.place-1,
  .rank-podium-card.place-2,
  .rank-podium-card.place-3 {
    order: unset;
    transform: none;
  }
  .rank-me { flex-wrap: wrap; }
}

@media (max-width: 380px) {
  .portal-beta { display: none; }
  .portal-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-nav-link { font-size: 0.76rem; }
}

/* —— Admin dashboard —— */
.dash-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.dash-head h1 { margin: 0 0 0.25rem; font-family: var(--display); letter-spacing: -0.02em; }
.dash-period {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  max-width: max-content;
  width: auto;
  font-size: 0.82rem;
}
.dash-period label {
  font-size: 0.75rem;
  margin: 0;
}
.dash-period select,
.dash-period input[type="date"] {
  font: inherit;
  font-size: 0.82rem;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0.22rem 0.4rem;
  background: #fff;
  color: var(--text);
  height: 1.85rem;
  line-height: 1.2;
  max-width: 9.5rem;
}
.dash-period input[type="date"] {
  max-width: 8.2rem;
  padding: 0.18rem 0.3rem;
}
.dash-period .btn-small {
  padding: 0.22rem 0.55rem;
  font-size: 0.78rem;
  height: 1.85rem;
}
.dash-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
a.dash-kpi { text-decoration: none; color: inherit; }
a.dash-kpi:hover { text-decoration: none; }
.dash-kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-height: 5.5rem;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
a.dash-kpi:hover {
  border-color: #9eb6d0;
  transform: translateY(-1px);
}
.dash-kpi strong {
  font-family: var(--display);
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--navy);
}
.dash-kpi strong.ok { color: var(--ok); }
.dash-kpi strong.bad { color: var(--bad); }
.dash-kpi-profit { gap: 0.35rem; }
.dash-profit-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.6rem;
}
.dash-profit-line span { color: var(--muted, #5c6b7a); font-size: 0.82rem; }
.dash-kpi-profit .dash-profit-line strong { font-size: 1.05rem; }
.dash-kpi-profit .dash-profit-line.total strong { font-size: 1.28rem; }
.dash-sub, .dash-delta { font-size: 0.8rem; color: var(--muted); }
.dash-delta.up { color: var(--ok); }
.dash-delta.down { color: var(--bad); }
.dash-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 1rem;
  align-items: start;
}
.dash-main { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.dash-side { display: flex; flex-direction: column; gap: 1rem; }
.dash-card { margin: 0; }
.dash-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.dash-card-head h2 { margin: 0; }
.dash-exports { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.dash-engage {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}
.dash-engage > div {
  background: var(--blue-soft);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.dash-engage strong {
  font-family: var(--display);
  font-size: 1.25rem;
  color: var(--navy);
}
.dash-engage em {
  font-style: normal;
  font-size: 0.8rem;
  color: var(--muted);
}
.dash-goals .form-row { margin-bottom: 0.5rem; }
.dash-goal-progress {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0.75rem 0 1rem;
}
.dash-goal-progress > div span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}
.dash-goal-progress em {
  font-style: normal;
  font-size: 0.8rem;
  color: var(--muted);
}
.dash-bar {
  height: 8px;
  background: #e2eaf2;
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 0.2rem;
}
.dash-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), #3d7ea6);
  border-radius: 99px;
}
.dash-bar.danger i { background: linear-gradient(90deg, var(--red), #d97840); }
.dash-alerts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.dash-alerts li a {
  display: block;
  padding: 0.7rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #f7fafc;
  text-decoration: none;
  color: inherit;
}
.dash-alerts li a:hover { border-color: #9eb6d0; }
.dash-alerts li strong { display: block; font-size: 0.92rem; margin-bottom: 0.15rem; }
.dash-alerts li span { font-size: 0.8rem; color: var(--muted); }
.dash-alerts li.tone-danger a { border-color: #f0c4bf; background: #fff5f4; }
.dash-alerts li.tone-warning a { border-color: #ecd9a8; background: #fffbf0; }
.dash-alerts li.tone-info a { border-color: #c5d8ef; background: #f3f8fd; }
.dash-mod-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.dash-mod-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.dash-mod-list li:last-child { border-bottom: 0; }
.dash-side .btn { width: 100%; justify-content: center; }
.dash-side p { margin: 0 0 0.45rem; }

@media (max-width: 1100px) {
  .dash-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-layout { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .dash-kpis { grid-template-columns: 1fr; }
  .dash-engage { grid-template-columns: 1fr; }
}
