:root {
  --fatipi: #26225b;
  --fatipi-2: #383179;
  --fatipi-soft: #eeeef8;
  --ink: #1f2633;
  --muted: #687384;
  --line: #dfe4ed;
  --field: #ffffff;
  --page: #f5f6fa;
  --success: #16803c;
  --success-soft: #eaf7ef;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --shadow: 0 18px 48px rgba(30, 36, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(38, 34, 91, 0.05), transparent 260px),
    var(--page);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  color: #fff;
  background: linear-gradient(180deg, var(--fatipi), #1d1a49);
}

.brand,
.flag-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  padding: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  padding: 5px;
  background: #fff;
  border-radius: 8px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  font-weight: 700;
}

.brand strong,
.brand small,
.flag-card strong,
.flag-card small {
  display: block;
}

.brand small,
.flag-card small,
.orientation p {
  color: rgba(255, 255, 255, 0.74);
}

.flag-card {
  padding: 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
}

.flag-portugal {
  position: relative;
  display: block;
  width: 58px;
  height: 38px;
  overflow: hidden;
  background: linear-gradient(90deg, #046a38 0 40%, #da291c 40% 100%);
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 4px;
}

.flag-portugal span {
  position: absolute;
  left: 34%;
  top: 50%;
  width: 13px;
  height: 13px;
  background: #ffcd00;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 48px;
  padding: 11px 12px;
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.nav-item span {
  display: grid;
  width: 27px;
  height: 27px;
  place-items: center;
  color: var(--fatipi);
  background: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.34);
}

.orientation {
  margin-top: auto;
}

.orientation h2 {
  margin: 8px 0 10px;
  font-size: 22px;
}

.content {
  width: min(1120px, 100%);
  padding: 30px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  letter-spacing: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
}

.status-pill {
  padding: 8px 12px;
  color: var(--fatipi);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.portugal-warning {
  margin-bottom: 18px;
  padding: 15px 16px;
  color: var(--danger);
  background:
    linear-gradient(90deg, rgba(180, 35, 24, 0.08), rgba(180, 35, 24, 0.02)),
    #fff;
  border: 1px solid #ffb4ab;
  border-left: 6px solid var(--danger);
  border-radius: 8px;
  line-height: 1.45;
}

.portugal-warning strong {
  display: block;
  margin-bottom: 4px;
}

.form-panel {
  min-height: 540px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-step {
  display: none;
}

.form-step.active {
  display: block;
}

.compact-step {
  max-width: 680px;
  margin: 42px auto 0;
}

.section-heading {
  margin-bottom: 22px;
}

.section-heading h2 {
  margin: 6px 0 8px;
  color: var(--fatipi);
  font-size: 24px;
}

.section-heading p:last-child {
  max-width: 660px;
  color: var(--muted);
  line-height: 1.5;
}

.grid,
.document-start {
  display: grid;
  gap: 16px;
  margin-bottom: 18px;
}

.grid.two,
.document-start {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

label {
  display: grid;
  gap: 7px;
  color: #313847;
  font-size: 14px;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
}

.field-hint.success {
  color: var(--success);
  font-weight: 700;
}

.field-hint.error {
  color: var(--danger);
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 45px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid #cfd6e2;
  border-radius: 8px;
  outline: none;
}

input::placeholder {
  color: #98a2b3;
}

input:focus,
select:focus {
  border-color: var(--fatipi);
  box-shadow: 0 0 0 3px rgba(38, 34, 91, 0.14);
}

.full {
  grid-column: 1 / -1;
}

.wide {
  grid-column: span 2;
}

.course-box,
.summary-box {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.course-box div,
.summary-box div {
  display: grid;
  gap: 5px;
  min-width: 0;
  padding: 14px;
  background: linear-gradient(180deg, #ffffff, #fafbfe);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.course-box span,
.summary-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.course-box strong,
.summary-box strong {
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.actions.split {
  justify-content: space-between;
}

.primary,
.secondary {
  min-height: 45px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

.primary {
  color: #fff;
  background: var(--fatipi);
  box-shadow: 0 8px 18px rgba(38, 34, 91, 0.18);
}

.primary:hover {
  background: var(--fatipi-2);
}

.secondary {
  color: var(--fatipi);
  background: #fff;
  border-color: #cfd6e2;
}

.hidden-field {
  display: none;
}

dialog {
  width: min(500px, calc(100% - 28px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(18, 24, 40, 0.24);
}

dialog::backdrop {
  background: rgba(14, 18, 36, 0.52);
}

.dialog-content {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.dialog-content h2 {
  margin-bottom: 0;
  color: var(--fatipi);
}

.dialog-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.success-dialog {
  border-top: 7px solid var(--success);
}

.success-badge {
  width: fit-content;
  padding: 7px 11px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
}

.contact-box {
  display: grid;
  gap: 6px;
  padding: 14px;
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid #bde6c8;
  border-radius: 8px;
}

.contact-box.compact {
  color: var(--fatipi);
  background: var(--fatipi-soft);
  border-color: #d8d6ef;
}

.contact-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.contact-box a {
  color: inherit;
  font-weight: 700;
  text-decoration: none;
}

.contact-box a:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(380px, calc(100% - 40px));
  padding: 13px 16px;
  color: #fff;
  background: var(--success);
  border-radius: 8px;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

@media (max-width: 940px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
  }

  .orientation {
    margin-top: 0;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-item {
    justify-content: center;
  }
}

@media (max-width: 720px) {
  .content,
  .sidebar,
  .form-panel {
    padding: 20px;
  }

  .content {
    padding-top: 18px;
  }

  h1 {
    font-size: 25px;
  }

  .section-heading h2 {
    font-size: 21px;
  }

  .nav-list {
    grid-template-columns: 1fr 1fr;
  }

  .nav-item {
    justify-content: flex-start;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .grid.two,
  .grid.three,
  .document-start,
  .course-box,
  .summary-box {
    grid-template-columns: 1fr;
  }

  .wide {
    grid-column: 1;
  }

  .compact-step {
    margin-top: 10px;
  }

  .actions,
  .actions.split {
    flex-direction: column-reverse;
  }

  .primary,
  .secondary {
    width: 100%;
  }
}

@media (max-width: 420px) {
  .brand,
  .flag-card {
    align-items: flex-start;
  }

  .portugal-warning {
    font-size: 14px;
  }

  .form-panel {
    min-height: auto;
  }
}
