/* ===========================================================================
   PERFIL — ficha de preparação
   ========================================================================== */
.pf-main {
  min-height: 100vh;
  background: #f5f6fa;
}

.pf-page {
  width: min(1100px, 100%);
  margin: 0 auto;
  padding-bottom: 44px;
  color: #202a43;
}

.pf-page *,
.pf-page *::before,
.pf-page *::after { box-sizing: border-box; }

.pf-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
  padding: 12px 0 22px;
  border-bottom: 1px solid #d9dfeb;
}

.pf-head .ep-eyebrow { color: #4058c6; letter-spacing: .13em; }
.pf-head h1 {
  max-width: 18ch;
  margin-top: 9px;
  color: #202a43;
  font: var(--esp-weight-bold) var(--esp-type-display)/.98 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.064em;
  text-wrap: balance;
}
.pf-head p {
  max-width: 60ch;
  margin-top: 13px;
  color: #657189;
  font: var(--esp-weight-regular) var(--esp-type-body)/1.58 var(--esp-ui, Inter, sans-serif);
}

.pf-back,
.pf-actions a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: #405bd7;
  font-size: var(--esp-type-support);
  font-weight: var(--esp-weight-bold);
  text-decoration: none;
}
.pf-back:hover,
.pf-actions a:hover { text-decoration: underline; text-underline-offset: 4px; }
.pf-back:focus-visible,
.pf-actions a:focus-visible,
.pf-save:focus-visible,
.pf-logout:focus-visible,
.pf-failure button:focus-visible { outline: 3px solid var(--accent-ring); outline-offset: 3px; }

.pf-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(270px, .78fr);
  grid-template-areas: "form summary";
  gap: 16px;
  align-items: start;
}

.pf-form,
.pf-identity {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d9dfeb;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(31, 42, 67, .035);
}

.pf-form {
  grid-area: form;
  container: profile-form / inline-size;
  padding: 31px 33px 28px;
}

.pf-identity {
  position: sticky;
  top: 24px;
  grid-area: summary;
  padding: 25px 23px 22px;
}

.pf-account {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 13px;
  padding-bottom: 22px;
  border-bottom: 1px solid #dfe4ed;
}
.pf-account > div:last-child { min-width: 0; }
.pf-avatar {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid #bfcaf3;
  border-radius: 50%;
  background: #f0f3ff;
  color: #4d64cf;
  font: var(--esp-weight-bold) var(--esp-type-body)/1 var(--esp-display, Manrope, sans-serif);
}

.pf-account span,
.pf-route-title,
.pf-form-head > div > span,
.pf-section-head > span,
.pf-explainer > span {
  font-family: var(--esp-micro, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: var(--esp-type-caption);
  font-weight: var(--esp-weight-bold);
  letter-spacing: .08em;
}
.pf-account span { color: #77839a; }
.pf-account h2 {
  margin-top: 4px;
  overflow: visible;
  color: #202a43;
  font: var(--esp-weight-bold) var(--esp-type-body)/1.18 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.025em;
  overflow-wrap: anywhere;
  white-space: normal;
}
.pf-account p {
  margin-top: 3px;
  overflow: visible;
  color: #77839a;
  font-size: var(--esp-type-caption);
  overflow-wrap: anywhere;
  white-space: normal;
}

.pf-route-wrap { margin-top: 18px; border-bottom: 1px solid #dfe4ed; }
.pf-route-title {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #4058c6;
  cursor: pointer;
  list-style: none;
}
.pf-route-title::-webkit-details-marker { display: none; }
.pf-route-title::after {
  content: "+";
  color: #6072ca;
  font: var(--esp-weight-regular) 1.25rem/1 var(--esp-ui, Inter, sans-serif);
}
.pf-route-wrap[open] .pf-route-title::after { content: "−"; }
.pf-route-title:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 3px;
  border-radius: 4px;
}
.pf-route { display: grid; margin: 0; padding: 0; list-style: none; }
.pf-route li {
  position: relative;
  min-width: 0;
  padding: 15px 0 15px 17px;
  border-top: 1px solid #e3e7ef;
}
.pf-route li::before {
  content: "";
  position: absolute;
  top: 20px;
  left: 0;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7a8add;
}
.pf-route li:last-child::before { background: #8fc83e; }
.pf-route span { display: block; color: #78849a; font-size: var(--esp-type-caption); }
.pf-route strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  color: #202a43;
  font: var(--esp-weight-bold) var(--esp-type-support)/1.35 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.015em;
}
.pf-route small { display: block; margin-top: 3px; color: #6d788e; font-size: var(--esp-type-caption); line-height: 1.45; }

.pf-identity-foot { margin-top: 10px; padding-top: 12px; }
.pf-identity-foot > small { display: block; color: #6d788e; font-size: var(--esp-type-caption); line-height: 1.55; }
.pf-logout {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  margin-top: 7px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #405bd7;
  font: var(--esp-weight-bold) var(--esp-type-caption)/1 var(--esp-ui, Inter, sans-serif);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(64, 91, 215, .25);
  text-underline-offset: 4px;
}
.pf-logout:hover { text-decoration-color: currentColor; }

.pf-form-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 23px;
  border-bottom: 1px solid #d9dfeb;
}
.pf-form-head > div > span,
.pf-section-head > span { color: #4058c6; }
.pf-form-head h2 {
  margin-top: 6px;
  color: #202a43;
  font: var(--esp-weight-bold) var(--esp-type-heading)/1.08 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.045em;
}
.pf-status {
  max-width: 24ch;
  min-height: 24px;
  padding: 5px 9px;
  border-radius: 8px;
  background: #eff7e3;
  color: #4b721c;
  font-size: var(--esp-type-caption);
  font-weight: var(--esp-weight-bold);
  line-height: 1.35;
  text-align: right;
}
.pf-status:empty { min-height: 0; padding: 0; background: transparent; }

.pf-form-section {
  display: grid;
  grid-template-columns: minmax(145px, .52fr) minmax(0, 1.48fr);
  gap: 27px;
  padding: 25px 0;
  border-bottom: 1px solid #e0e5ee;
}
.pf-section-head > span { display: block; margin-bottom: 8px; }
.pf-section-head h3 {
  color: #202a43;
  font: var(--esp-weight-bold) var(--esp-type-body)/1.3 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.02em;
}
.pf-section-head p { max-width: 27ch; margin-top: 5px; color: #6b778e; font-size: var(--esp-type-caption); line-height: 1.5; }

.pf-field { display: grid; min-width: 0; gap: 8px; }
.pf-field > span { color: #202a43; font-size: var(--esp-type-support); font-weight: var(--esp-weight-bold); }
.pf-field input,
.pf-field select {
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0 15px;
  border: 1px solid #d1d8e5;
  border-radius: 11px;
  background: #f8f9fc;
  color: #202a43;
  font: var(--esp-weight-medium) var(--esp-type-body)/1 var(--esp-ui, Inter, sans-serif);
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.pf-field input::placeholder { color: #727e94; opacity: 1; }
.pf-field select { cursor: pointer; }
.pf-field input:hover,
.pf-field select:hover { border-color: #aeb9cf; background: #fff; }
.pf-field input:focus,
.pf-field select:focus {
  outline: none;
  border-color: #6378da;
  background: #fff;
  box-shadow: 0 0 0 4px rgba(64, 91, 215, .12);
}
.pf-field input[aria-invalid="true"],
.pf-field select[aria-invalid="true"] { border-color: #c43f50; box-shadow: 0 0 0 4px rgba(196, 63, 80, .1); }
.pf-field small { color: #68748a; font-size: var(--esp-type-caption); line-height: 1.48; }
.pf-field-grid {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1.35fr) minmax(140px, .65fr);
  gap: 14px;
}

@container profile-form (max-width: 650px) {
  .pf-form-section,
  .pf-explainer { grid-template-columns: minmax(0, 1fr); gap: 13px; }
  .pf-form-section--exam .pf-field-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .pf-section-head p { max-width: 48ch; }
}

.pf-explainer {
  display: grid;
  grid-template-columns: minmax(145px, .52fr) minmax(0, 1.48fr);
  gap: 27px;
  margin-top: 22px;
  padding: 16px 17px;
  border: 1px solid #d7e7bb;
  border-radius: 11px;
  background: #f5faeb;
}
.pf-explainer > span { color: #557622; }
.pf-explainer b { color: #354b20; font-size: var(--esp-type-support); }
.pf-explainer p { max-width: 49ch; margin-top: 4px; color: #60704f; font-size: var(--esp-type-caption); line-height: 1.5; }

.pf-error {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid #f1ccd1;
  border-radius: 10px;
  background: #fff1f3;
  color: #b93647;
  font-size: var(--esp-type-support);
  line-height: 1.5;
}
.pf-error:focus { outline: 3px solid rgba(196, 63, 80, .2); outline-offset: 3px; }

.pf-actions { display: flex; align-items: center; gap: 19px; margin-top: 24px; }
.pf-save,
.pf-failure button {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: #a9e84b;
  color: #213014;
  box-shadow: none;
  font: var(--esp-weight-bold) var(--esp-type-support)/1 var(--esp-ui, Inter, sans-serif);
  cursor: pointer;
  transition: background .18s ease, transform .18s ease;
}
.pf-save:hover,
.pf-failure button:hover { background: #9ddd3f; transform: translateY(-1px); }
.pf-save:active,
.pf-failure button:active { transform: translateY(0); }
.pf-save:disabled { cursor: wait; opacity: .65; transform: none; }

.pf-loading {
  display: grid;
  width: min(1100px, 100%);
  min-height: 60vh;
  margin: 0 auto;
  padding: 12px 0 42px;
  align-content: start;
  gap: 24px;
  color: #657189;
}
.pf-loading-head { display: grid; gap: 10px; padding: 10px 0 20px; border-bottom: 1px solid #d9dfeb; }
.pf-loading-head span,
.pf-loading-head b,
.pf-loading-head i,
.pf-loading-card > * {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 999px;
  background: #e3e7f0;
}
.pf-loading-head span { width: 130px; height: 10px; }
.pf-loading-head b { width: min(430px, 70%); height: 46px; border-radius: 10px; }
.pf-loading-head i { width: min(520px, 82%); height: 14px; }
.pf-loading-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.62fr) minmax(270px, .78fr);
  grid-template-areas: "form summary";
  gap: 16px;
}
.pf-loading-card {
  display: grid;
  min-height: 470px;
  align-content: start;
  gap: 18px;
  padding: 30px 28px;
  border: 1px solid #d9dfeb;
  border-radius: 17px;
  background: #fff;
}
.pf-loading-form { grid-area: form; }
.pf-loading-identity { grid-area: summary; }
.pf-loading-card span { width: 46%; height: 12px; }
.pf-loading-card b { width: 72%; height: 32px; border-radius: 9px; }
.pf-loading-card i { width: 100%; height: 72px; border-radius: 11px; }
.pf-loading-card i:nth-of-type(2) { width: 91%; }
.pf-loading-card i:nth-of-type(3) { width: 82%; }
.pf-loading-card em { width: 42%; height: 50px; margin-top: 9px; border-radius: 10px; }
.pf-loading-head > *::after,
.pf-loading-card > *::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent);
  transform: translateX(-100%);
  animation: pf-shimmer 1.25s ease-in-out infinite;
}
.pf-loading p { justify-self: center; margin-top: -8px; font-size: var(--esp-type-support); }
@keyframes pf-shimmer { to { transform: translateX(100%); } }

.pf-failure {
  width: min(620px, 100%);
  margin: 8vh auto 0;
  padding: 32px;
  border: 1px solid #e5c8ce;
  border-radius: 17px;
  background: #fff;
}
.pf-failure h1 {
  margin-top: 8px;
  color: #202a43;
  font: var(--esp-weight-bold) var(--esp-type-heading)/1.05 var(--esp-display, Manrope, sans-serif);
  letter-spacing: -.05em;
}
.pf-failure p { margin: 10px 0 22px; color: #69758c; line-height: 1.6; }

@media (max-width: 1100px) {
  .pf-layout { display: flex; flex-direction: column; }
  .pf-form { order: 1; width: 100%; }
  .pf-identity { position: static; order: 2; width: 100%; }
  .pf-loading-layout { display: flex; flex-direction: column; }
  .pf-loading-form { order: 1; }
  .pf-loading-identity { order: 2; }
}

@media (max-width: 720px) {
  .pf-head { grid-template-columns: minmax(0, 1fr); align-items: start; }
  .pf-back { display: none; }
}

@media (max-width: 560px) {
  .pf-main { padding-right: 14px; padding-left: 14px; }
  .pf-head { margin-bottom: 16px; padding: 7px 0 18px; }
  .pf-head h1 { max-width: 13ch; font-size: var(--esp-type-heading); }
  .pf-head p { font-size: var(--esp-type-support); line-height: 1.52; }
  .pf-layout, .pf-loading-layout { gap: 12px; }
  .pf-form, .pf-identity, .pf-loading-card { border-radius: 15px; }
  .pf-form { padding: 24px 19px 22px; }
  .pf-form-head { display: block; padding-bottom: 19px; }
  .pf-status { display: inline-flex; max-width: 100%; margin-top: 10px; text-align: left; }
  .pf-status:not(:empty) {
    position: fixed;
    z-index: var(--z-overlay, 200);
    right: 14px;
    bottom: calc(78px + env(safe-area-inset-bottom));
    left: 14px;
    justify-content: center;
    margin: 0;
    padding: 12px 15px;
    border: 1px solid #d5e6b8;
    border-radius: 11px;
    background: #f3f9e9;
    text-align: center;
  }
  .pf-form-section, .pf-explainer { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pf-form-section { padding: 21px 0; }
  .pf-field-grid { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .pf-explainer { margin-top: 20px; padding: 16px 14px; }
  .pf-actions { align-items: stretch; flex-direction: column; gap: 8px; }
  .pf-save, .pf-actions a { width: 100%; justify-content: center; }
  .pf-identity { padding: 23px 20px 20px; }
  .pf-avatar { width: 46px; height: 46px; }
  .pf-loading { gap: 18px; padding-top: 7px; }
  .pf-loading-head b { height: 38px; }
  .pf-loading-card { min-height: 330px; padding: 24px 20px; }
}

@media (max-width: 340px) {
  .pf-main { padding-right: 10px; padding-left: 10px; }
  .pf-form, .pf-identity { padding-right: 15px; padding-left: 15px; }
  .pf-account { gap: 10px; }
  .pf-head h1 { max-width: none; font-size: var(--esp-type-heading); }
}

@media (prefers-reduced-motion: reduce) {
  .pf-save,
  .pf-failure button,
  .pf-field input,
  .pf-field select { transition: none; }
  .pf-loading-head > *::after,
  .pf-loading-card > *::after { animation: none; }
}
