:root {
  --bg: #F7FAF8;
  --surface: #FFFFFF;
  --text: #15251D;
  --muted: #52645A;
  --brand: #166534;
  --brand-hover: #14532D;
  --brand-soft: #DCFCE7;
  --accent: #BEF264;
  --border: #D7E2DA;
  --control: #718278;
  --control-focus: #1D4ED8;
  --error: #B91C1C;
  --error-soft: #FEE2E2;
  --warn: #92400E;
  --warn-soft: #FEF3C7;
  --info: #1D4ED8;
  --info-soft: #DBEAFE;
  --shadow: 0 12px 32px rgba(21, 37, 29, 0.08);
  --shadow-sm: 0 1px 3px rgba(21, 37, 29, 0.04);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--brand);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
  transition: color 0.15s ease-in-out;
}

a:hover {
  color: var(--brand-hover);
}

a:focus-visible {
  outline: 3px solid var(--control-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Identidade Visual / Marca */
.brand {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.03em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background-color: var(--accent);
  color: #15251D;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  line-height: 1;
  box-shadow: 0 2px 4px rgba(21, 37, 29, 0.12);
}

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

.h1 {
  font-size: 28px;
  line-height: 1.25;
  margin: 4px 0 8px;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

/* Layout de Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 80% 15%, #dcfce7 0%, transparent 40%),
              radial-gradient(circle at 10% 85%, #f0fdf4 0%, transparent 50%),
              var(--bg);
}

.login-card {
  width: min(440px, 100%);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow);
}

/* Formulário e Controles */
.login-form {
  margin-top: 24px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.field label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input {
  width: 100%;
  border: 1.5px solid var(--control);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background-color: var(--surface);
  color: var(--text);
  font-size: 16px;
  min-height: 48px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.input:hover {
  border-color: #3b4e43;
}

.input:focus {
  outline: none;
  border-color: var(--control-focus);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.25);
}

.input.is-invalid {
  border-color: var(--error);
  background-color: #fffaf9;
}

.input.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.25);
}

.input:disabled {
  background-color: #f3f5f4;
  border-color: #d1d9d4;
  color: #8c9b92;
  cursor: not-allowed;
}

.field-error {
  color: var(--error);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

/* Opções de Checkbox e Esqueci Minha Senha */
.form-row-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 16px 0 24px;
  gap: 12px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  min-height: 44px; /* Acessibilidade touch target */
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1.5px solid var(--control);
  accent-color: var(--brand);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"]:focus-visible {
  outline: 3px solid var(--control-focus);
  outline-offset: 2px;
}

.link-subtle {
  font-size: 14px;
  color: var(--brand);
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease-in-out;
}

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

.btn-primary:hover:not(:disabled) {
  background-color: var(--brand-hover);
  color: #ffffff;
}

.btn-primary:active:not(:disabled) {
  background-color: #0f3d20;
}

.btn-primary:focus-visible {
  outline: 3px solid var(--control-focus);
  outline-offset: 3px;
}

.btn-primary:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text);
  border-color: var(--control);
}

.btn-secondary:hover:not(:disabled) {
  background-color: #f7faf8;
}

.btn-ghost {
  background-color: transparent;
  color: var(--brand);
}

.btn-ghost:hover {
  background-color: var(--brand-soft);
}

/* Spinner de Loading */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Notificações e Avisos */
.notice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.45;
}

.notice-error {
  background-color: var(--error-soft);
  color: #7f1d1d;
  border: 1px solid #fecaca;
}

.notice-warning {
  background-color: var(--warn-soft);
  color: var(--warn);
  border: 1px solid #fde68a;
}

.notice-success {
  background-color: var(--brand-soft);
  color: var(--brand-hover);
  border: 1px solid #bbf7d0;
}

.divider {
  height: 1px;
  background-color: var(--border);
  margin: 24px 0;
}

/* Bloco Informativo de Contas Demo */
.demo-accounts {
  background-color: #f4f8f5;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

.demo-accounts strong {
  color: var(--text);
}

.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.demo-item {
  background-color: #ffffff;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}

.demo-item:hover {
  border-color: var(--brand);
}

.demo-item code {
  font-size: 12px;
  color: var(--brand);
  font-weight: 600;
  display: block;
}

/* Área Logada (Shell) */
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #113e28;
  color: #fff;
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.sidebar .brand {
  color: #ffffff;
}

.nav a {
  display: flex;
  padding: 11px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: #e7f4eb;
  margin: 4px 0;
  font-weight: 500;
}

.nav a:hover, .nav a.active {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.sidebar-foot {
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 14px;
}

.content {
  padding: 32px;
  max-width: 1280px;
  width: 100%;
  /* Item de grade: sem isto, uma faixa rolável (abas, tabelas) alarga a página inteira. */
  min-width: 0;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
  gap: 16px;
}

.card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-2 {
  grid-template-columns: repeat(2, 1fr);
}

.metric {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-top: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background-color: #eef3ef;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.badge.success {
  background-color: var(--brand-soft);
  color: var(--brand-hover);
}

/* Área do Aluno */
.student-shell {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 96px;
}

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

/* Responsividade Mobile-First */
@media (max-width: 900px) {
  .app-shell {
    display: block;
  }
  .sidebar {
    height: auto;
    position: relative;
    padding: 16px;
  }
  /* CFIT2-88: a ação de sair continua visível no celular */
  .sidebar-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 12px;
    padding-top: 12px;
  }
  .sidebar-foot > div {
    margin-bottom: 0 !important;
  }
  .sidebar-foot form {
    margin-left: auto;
  }
  .sidebar-foot .btn {
    width: auto !important;
    min-height: 44px !important;
  }
  .content {
    padding: 20px;
  }
  .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 24px 18px;
    border-radius: 16px;
  }
  .h1 {
    font-size: 24px;
  }
  .form-row-actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .demo-grid {
    grid-template-columns: 1fr;
  }
}

/* Login aligned with the landing page brand. */
.login-brand-page {
  --brand: #133d2d;
  --brand-hover: #0e2c21;
  --brand-soft: #e8ebdf;
  --accent: #d8f28a;
  --text: #182b22;
  --muted: #617064;
  --border: #d8dcd1;
  background: radial-gradient(circle at 80% 15%, #e8ebdf 0%, transparent 40%), #f6f5ef;
}
.login-brand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}
.login-brand { flex-shrink: 0; }
.login-brand img {
  display: block;
  width: 210px;
  height: 56px;
  object-fit: cover;
}
@media (max-width: 380px) {
  .login-brand-header { gap: 8px; }
  .login-brand img { width: 165px; height: 44px; }
}

/* Shared identity for the Personal workspace and its dashboard. */
.personal-brand-page {
  --bg: #f6f5ef;
  --text: #182b22;
  --muted: #617064;
  --brand: #133d2d;
  --brand-hover: #0e2c21;
  --brand-soft: #e8ebdf;
  --accent: #d8f28a;
  --border: #d8dcd1;
}
.personal-brand-page .sidebar { background: var(--brand); }
.sidebar .app-brand {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-bottom: 24px;
  border-radius: 4px;
}
.app-brand img {
  display: block;
  width: 204px;
  max-width: 100%;
  height: 56px;
  object-fit: cover;
  filter: brightness(0) invert(1);
}
.personal-brand-page .nav a.active {
  background: var(--accent);
  color: var(--brand-hover);
  font-weight: 650;
}
.sidebar .app-brand:focus-visible { outline-color: var(--accent); }
@media (max-width: 900px) {
  .sidebar .app-brand { justify-content: flex-start; margin-bottom: 16px; }
  .app-brand img { width: 180px; height: 48px; }
}

.nav a { align-items: center; gap: 12px; }
.menu-icon { display: block; flex: 0 0 20px; }
.nav a span { min-width: 0; }
.sidebar-foot .btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; }

/* CFIT2-27: aviso de sessão encerrada ou renovada */
.session-notice {
  position: sticky;
  top: 8px;
  z-index: 60;
  align-items: center;
  flex-wrap: wrap;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}
.session-notice:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}
.session-notice-action {
  margin-left: auto;
  min-height: 44px;
}
button[aria-busy="true"] {
  opacity: 0.7;
  cursor: progress;
}

/* CFIT2-167 (F-26): menu recolhível no celular; sair e identificação sempre à mão */
.sidebar-head { display: block; }
.sidebar-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar-head .brand { margin-bottom: 0; }
  .js-nav .sidebar-toggle {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px;
    background: transparent; color: #fff; border: 1.5px solid rgba(255, 255, 255, 0.45);
    border-radius: var(--radius-sm); font-size: 15px; font-weight: 700; cursor: pointer;
  }
  .js-nav .sidebar-toggle:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
  .js-nav .sidebar:not(.is-open) .nav,
  .js-nav .sidebar:not(.is-open) .sidebar-foot { display: none !important; }
  .js-nav .sidebar.is-open .nav { margin-top: 12px; }
}

/* CFIT2-172 (F-31): alvos de toque de pelo menos 44 px em telas de toque */
@media (pointer: coarse), (max-width: 900px) {
  .btn-sm { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
  .nav a { min-height: 44px; }
}

/* Shared logo for onboarding, account, student, admin and legal pages. */
.brand-image {
  display: block;
  width: 180px;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}
.onboarding-topbar { gap: 16px; flex-wrap: wrap; }
.onboarding-topbar > .brand { flex-shrink: 0; }
@media (max-width: 480px) {
  .brand-image { width: 150px; }
}
