:root {
  --bg: #f4f8fa;
  --card: #ffffff;
  --ink: #17313a;
  --muted: #647887;
  --line: #d9e4ea;
  --brand: #15586a;
  --brand-2: #0f4656;
  --ok: #dff0d8;
  --warn: #fff1c9;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  background: var(--brand);
  color: #fff;
}

header a {
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.brand-area {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.brand-link {
  flex: 0 0 auto;
}

.session-badge {
  min-width: 0;
  max-width: 260px;
  overflow: hidden;
  color: rgba(255, 255, 255, .76);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

nav {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
}

nav a,
nav summary {
  color: #fff;
  font-weight: 650;
  opacity: .92;
  text-decoration: none;
}

.nav-group {
  position: relative;
}

.nav-group summary {
  display: block;
  list-style: none;
  cursor: pointer;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-submenu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 50;
  display: grid;
  gap: 4px;
  min-width: 210px;
  padding: 8px;
  border: 1px solid rgba(21, 88, 106, .18);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 70, 86, .18);
}

.nav-submenu a {
  display: block;
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--brand-2);
  white-space: nowrap;
}

.nav-submenu a:hover {
  background: #eef6f8;
}

.logout-form {
  display: inline;
  justify-self: end;
}

.logout-form button {
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 4px 10px;
  color: white;
  background: transparent;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.logout-form button:hover {
  background: rgba(255, 255, 255, 0.12);
}

@media (max-width: 900px) {
  header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 12px;
  }

  .brand-area {
    align-items: center;
    justify-content: center;
    width: 100%;
  }

  .session-badge {
    max-width: calc(100vw - 170px);
  }

  .logout-form {
    justify-self: center;
  }
}

main {
  width: min(1760px, calc(100% - 32px));
  margin: 24px auto 64px;
}

.hero,
.toolbar,
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(23, 49, 58, .07);
}

.hero {
  padding: 34px;
}

.hero,
.toolbar,
.card {
  width: 100%;
}

.toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 24px;
  margin-bottom: 18px;
}

.toolbar-actions {
  display: grid;
  gap: 10px;
}

.compact-toolbar {
  box-shadow: none;
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: .92rem;
}

.inline-check input {
  min-width: auto;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3.4rem);
  line-height: 1;
}

h2 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
  font-weight: 800;
}

.button.secondary {
  background: #e5eef2;
  color: var(--brand-2);
}

.button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

.compact-button {
  min-width: 92px;
  padding: 8px 11px;
  font-size: .86rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.card {
  padding: 20px;
}

.metric strong {
  font-size: 2.4rem;
  color: var(--brand);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 700;
}

input {
  min-width: min(360px, 72vw);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
}

select,
textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  background: #fff;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.status {
  margin: 12px 0;
  color: var(--muted);
}

.status.warn-text {
  color: #795a00;
  font-weight: 800;
}

.search-results {
  display: grid;
  gap: 8px;
}

.search-results p {
  margin: 0;
}

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: #fbfdfe;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.search-result:hover,
.search-result:focus {
  border-color: #8bc486;
  background: #eef8eb;
  outline: none;
}

.search-result span {
  display: grid;
  gap: 2px;
}

.search-result small,
.search-result em {
  color: var(--muted);
  font-size: .82rem;
  font-style: normal;
}

.result-actions {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.result-actions em {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #fff;
  color: var(--brand-2);
  font-weight: 800;
}

.result-actions em:hover {
  border-color: #8bc486;
  background: #eef8eb;
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid #8bc486;
  border-radius: 999px;
  padding: 8px 10px;
  background: #eef8eb;
  color: #27612c;
  font-size: .92rem;
}

.selected-chip.preferencial {
  border-color: #79a7df;
  background: #eaf3ff;
  color: #234d82;
}

.selected-chip.interesse {
  border-color: #8bc486;
  background: #eef8eb;
  color: #27612c;
}

.selected-chip em {
  border-radius: 999px;
  padding: 2px 7px;
  background: rgba(255, 255, 255, .7);
  font-size: .76rem;
  font-style: normal;
  font-weight: 900;
}

.selected-chip button {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: #d4ecd0;
  color: #27612c;
  cursor: pointer;
  font-weight: 900;
}

.document-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.fpa-document {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(23, 49, 58, .07);
  padding: 34px;
}

.doc-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  border-bottom: 2px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 22px;
}

.doc-section {
  break-inside: avoid;
  border-bottom: 1px solid var(--line);
  padding: 16px 0;
}

.doc-section ul {
  margin: 8px 0 0;
  padding-left: 22px;
}

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 0;
}

.doc-grid div {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.doc-grid dt {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-grid dd {
  margin: 4px 0 0;
  font-weight: 750;
}

.doc-signatures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 36px;
  margin-top: 56px;
}

.doc-signatures span {
  display: block;
  border-bottom: 1px solid var(--ink);
  height: 38px;
}

.doc-signatures p {
  margin: 8px 0 0;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(23, 49, 58, .07);
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #e8f1f5;
  color: var(--brand-2);
}

.muted-row {
  opacity: .68;
  background: #f8fafb;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .82rem;
  font-weight: 800;
}

.pill.ok {
  background: var(--ok);
  color: #27612c;
}

.pill.warn {
  background: var(--warn);
  color: #795a00;
}

.button.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--line);
}

.action-cell {
  display: grid;
  gap: 8px;
  min-width: 130px;
}

.wide-table small {
  color: var(--muted);
  line-height: 1.4;
}

.compact-list {
  margin: 0;
  padding-left: 18px;
}

.compact-list small {
  color: var(--muted);
}

.offer-list {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.offer-card table {
  margin-top: 14px;
  box-shadow: none;
}

.assignment-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.assignment-form label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.assignment-form input {
  min-width: 150px;
}

.assignment-form button {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 8px 12px;
}

.assignment-preview {
  font-size: 0.82rem;
}

.assignment-alerts {
  color: #92400e;
  margin: 4px 0 0;
  padding-left: 18px;
}

.hint {
  color: var(--muted);
}

.ok-text {
  color: #2f7d32;
}

button.button {
  border: 0;
  cursor: pointer;
}

.form-shell {
  display: grid;
  grid-template-columns: minmax(210px, 280px) 1fr;
  gap: 18px;
  align-items: start;
}

.steps {
  position: sticky;
  top: 16px;
  background: #e8f1f5;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
}

.steps ol {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
}

.steps li {
  margin: 10px 0;
}

.steps .active {
  color: var(--brand);
  font-weight: 900;
}

.fpa-form {
  display: grid;
  gap: 16px;
}

.form-section {
  display: grid;
  gap: 16px;
}

.form-grid,
.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.choice-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.day-choice,
.check-card,
.discipline-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: #fbfdfe;
  color: var(--ink);
}

.day-choice input,
.check-card input,
.discipline-list input {
  min-width: auto;
}

.day-choice:has(input:checked),
.check-card:has(input:checked),
.discipline-list label:has(input:checked) {
  border-color: #8bc486;
  background: #eef8eb;
}

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

.review-box {
  border-left: 5px solid var(--brand);
  border-radius: 12px;
  padding: 12px 16px;
  background: #f0f7f9;
}

.rule-note {
  border: 1px solid #f0d48a;
  border-radius: 14px;
  padding: 12px 14px;
  background: #fff7dc;
  color: #6b5200;
}

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.period-matrix {
  min-width: 620px;
  box-shadow: none;
  border-radius: 0;
}

.period-matrix th,
.period-matrix td {
  text-align: center;
  vertical-align: middle;
}

.period-matrix th:first-child {
  text-align: left;
}

.period-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 98px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px;
  background: #fbfdfe;
  color: var(--muted);
  cursor: pointer;
}

.period-cell input {
  min-width: auto;
}

.period-cell:has(input:checked) {
  background: #eef8eb;
  border-color: #8bc486;
  color: #27612c;
  font-weight: 900;
}

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

  .steps {
    position: static;
  }

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

@media print {
  body {
    background: #fff;
  }

  header,
  .document-actions {
    display: none !important;
  }

  main {
    width: auto;
    margin: 0;
  }

  .fpa-document {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}

.help-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 110;
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  box-shadow: 0 12px 30px rgba(15, 70, 86, .28);
  font: inherit;
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
}

.help-fab:hover {
  background: var(--brand-2);
}

.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: none;
  background: rgba(9, 28, 35, .28);
}

body.help-open .help-overlay {
  display: block;
}

.help-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 130;
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(420px, 26vw);
  min-width: 340px;
  height: 100dvh;
  border-left: 1px solid var(--line);
  background: #fff;
  box-shadow: -16px 0 40px rgba(15, 70, 86, .22);
  transform: translateX(105%);
  transition: transform .18s ease;
}

body.help-open .help-drawer {
  transform: translateX(0);
}

.help-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.help-drawer-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.help-drawer-head p {
  margin: 4px 0 0;
  font-size: .86rem;
}

.help-close {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fbfc;
  color: var(--brand-2);
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.help-content {
  overflow: auto;
  padding: 14px 20px 26px;
}

.help-section {
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.help-section:last-child {
  border-bottom: 0;
}

.help-section h3 {
  margin: 0 0 8px;
  color: var(--brand-2);
  font-size: .95rem;
}

.help-section ul,
.help-section ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.help-section li {
  margin: 5px 0;
  line-height: 1.35;
}

.help-section strong {
  color: var(--ink);
}

@media (max-width: 900px) {
  .help-drawer {
    width: min(92vw, 420px);
    min-width: 0;
  }
}

@media print {
  .help-fab,
  .help-overlay,
  .help-drawer {
    display: none !important;
  }
}
