:root {
  --bg: #f3f5f7; --surface: #fff; --ink: #18232e; --muted: #56677a; --line: #d3dbe3;
  --accent: #0b5fa5; --accent-hover: #094d86; --on-accent: #fff; --accent-soft: rgba(11,95,165,.09);
  --ok: #047857; --warn-bg: #fff4e0; --warn: #8a4b08; --error: #b91c1c; --error-bg: #fdecec;
  --radius: 8px;
}
[data-theme="dark"] {
  --bg: #0f1620; --surface: #19232f; --ink: #eef3f8; --muted: #9bacbd; --line: #2c3a4b;
  --accent: #5cc4fb; --accent-hover: #8dd6fc; --on-accent: #08202f; --accent-soft: rgba(92,196,251,.13);
  --ok: #34d399; --warn-bg: #3a2a10; --warn: #f5c16c; --error: #ff8a8a; --error-bg: #3a1a1a;
}
[data-theme="sepia"] {
  --bg: #f1e8d2; --surface: #fcf8ee; --ink: #3f3120; --muted: #75634c; --line: #dfd0b6;
  --accent: #9c4112; --accent-hover: #7b330d; --accent-soft: rgba(156,65,18,.09); --ok: #3b6b44;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-padding-top: 1rem; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); line-height: 1.55; font-size: 1rem;
}
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip-link { position: absolute; top: -48px; left: 0; background: var(--accent); color: var(--on-accent); padding: .5rem 1rem; z-index: 100; }
.skip-link:focus { top: 0; }

.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem 1rem; }
.gate-container, .success-container {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1.25rem, 4vw, 2.5rem); max-width: 600px; width: 100%;
}
.institutional-badge { font-size: .875rem; font-weight: 600; color: var(--accent); margin-bottom: 1rem; }
h1 { font-size: clamp(1.5rem, 5vw, 2rem); line-height: 1.2; margin-bottom: .5rem; }
.success-container h2 { font-size: 1.6rem; margin-bottom: .5rem; }
.gate-desc, .success-desc, .success-instruction { color: var(--muted); margin-bottom: 1.25rem; max-width: 60ch; }

/* Cards de edital */
.edital-cards { list-style: none; display: grid; gap: .625rem; margin-bottom: 1.5rem; }
.edital-cards button {
  width: 100%; text-align: left; background: var(--surface); color: var(--ink); cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); padding: .875rem 1rem;
  display: grid; gap: .125rem; font: inherit;
}
.edital-cards button:hover { border-color: var(--accent); background: var(--accent-soft); }
.edital-cards span { font-size: .875rem; color: var(--muted); }

.input-group { display: flex; gap: .5rem; margin-top: .375rem; }
.input-group input { flex: 1; min-width: 0; }
.lgpd-notice { font-size: .75rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1.5rem; }

/* Botões */
.btn-primary, .btn-secondary {
  min-height: 44px; padding: .625rem 1.25rem; border-radius: var(--radius);
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid var(--accent);
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: transparent; color: var(--accent); }
.btn-secondary:hover { background: var(--accent-soft); }
button:disabled { opacity: .55; cursor: not-allowed; }

/* Header */
header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  background: var(--surface); border-bottom: 1px solid var(--line); padding: .75rem clamp(1rem, 4vw, 2rem);
}
.header-left { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.brand-logo { flex: none; width: 36px; height: 36px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; border-radius: var(--radius); }
.brand-name { font-weight: 600; font-size: .9375rem; }
.header-right { display: flex; gap: .5rem; align-items: center; }
.header-right .btn-secondary { padding: .5rem .875rem; }
.theme-menu { position: relative; }
.theme-menu summary { list-style: none; display: flex; align-items: center; }
.theme-menu summary::-webkit-details-marker { display: none; }
.theme-dropdown {
  position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: 0 6px 20px rgba(0,0,0,.15); display: flex; flex-direction: column; padding: .375rem; z-index: 10; min-width: 140px;
}
.theme-dropdown button { background: none; border: 0; text-align: left; padding: .625rem; color: var(--ink); cursor: pointer; border-radius: 6px; font: inherit; }
.theme-dropdown button:hover { background: var(--bg); }

/* Formulário */
.progress-bar-container { height: 6px; background: var(--line); }
#progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .3s ease; }
.form-container {
  max-width: 720px; margin: 1.5rem auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: clamp(1.25rem, 4vw, 2.5rem);
}
.edital-meta { margin-bottom: 1.25rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.edital-meta h2 { font-size: 1.5rem; line-height: 1.25; }
.edital-meta p { color: var(--muted); font-size: .9375rem; }
.deadline-badge { display: inline-block; background: var(--accent-soft); color: var(--accent) !important; padding: .25rem .625rem; border-radius: 999px; font-size: .8125rem !important; font-weight: 600; margin-top: .5rem; }
.nav-help { margin-top: .75rem; font-size: .875rem; color: var(--accent); }
.nav-help summary { cursor: pointer; }
.nav-help p { margin-top: .5rem; }
.step-row { display: flex; justify-content: space-between; gap: 1rem; font-size: .875rem; color: var(--muted); margin-bottom: .75rem; }
#save-status { color: var(--ok); }

.section-title { font-size: 1.375rem; margin-bottom: 1.5rem; outline: none; }
.question-group { margin-bottom: 1.5rem; }
.question-group fieldset { border: 0; min-width: 0; }
.question-label { display: block; font-weight: 600; margin-bottom: .375rem; padding: 0; }
.req-star { color: var(--error); }
.opt-tag { font-weight: 400; font-size: .8125rem; color: var(--muted); }
.question-hint { font-size: .875rem; color: var(--muted); margin-bottom: .5rem; }

input[type="text"], textarea {
  width: 100%; padding: .75rem; border: 1px solid var(--muted); background: var(--surface);
  color: var(--ink); border-radius: var(--radius); font: inherit;
}
textarea { resize: vertical; min-height: 6rem; }
.has-error input[type="text"], .has-error textarea { border-color: var(--error); border-width: 2px; }
.has-error .opt-item { border-color: var(--error); }
.field-error { color: var(--error); font-size: .875rem; margin-top: .375rem; min-height: 0; }
.field-error:empty { display: none; }

.options-list { display: grid; gap: .5rem; }
.opt-item {
  display: flex; align-items: flex-start; gap: .75rem; padding: .75rem .875rem; min-height: 44px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; background: var(--surface);
}
.opt-item:hover { border-color: var(--accent); }
.opt-item.selected { background: var(--accent-soft); border-color: var(--accent); }
.opt-item input { flex: none; width: 1.25rem; height: 1.25rem; margin-top: .125rem; accent-color: var(--accent); cursor: pointer; }

.banner { padding: .875rem 1rem; border-radius: var(--radius); margin-top: 1.5rem; font-weight: 500; }
.banner.error { background: var(--error-bg); color: var(--error); border: 1px solid var(--error); }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn); }

.form-actions {
  display: flex; justify-content: space-between; gap: .75rem; margin-top: 2rem; border-top: 1px solid var(--line); padding-top: 1.25rem;
}
.form-actions .btn-primary { margin-left: auto; }

/* Sucesso */
.success-icon { width: 52px; height: 52px; background: var(--ok); color: #fff; border-radius: 50%; display: grid; place-items: center; font-size: 1.75rem; margin-bottom: 1rem; }
.protocol-box { background: var(--bg); border: 1px solid var(--line); padding: 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; text-align: center; display: grid; gap: .5rem; justify-items: center; }
.protocol-label { font-size: .8125rem; color: var(--muted); }
.protocol-box strong { font-size: 1.25rem; color: var(--accent); word-break: break-all; user-select: all; }

/* Etapas */
#drawer-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 999; }
.drawer {
  position: fixed; top: 0; right: 0; width: min(340px, 100%); height: 100%; background: var(--surface);
  border-left: 1px solid var(--line); z-index: 1000; padding: 1.25rem; display: flex; flex-direction: column;
}
.drawer-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; padding-bottom: .75rem; border-bottom: 1px solid var(--line); }
.btn-close { background: none; border: 0; font-size: 1.75rem; line-height: 1; cursor: pointer; color: var(--ink); width: 44px; height: 44px; }
#summary-list { list-style: none; overflow-y: auto; }
#summary-list button {
  display: flex; align-items: center; gap: .75rem; width: 100%; text-align: left; background: none; border: 0;
  padding: .625rem; border-radius: var(--radius); cursor: pointer; color: var(--ink); font: inherit;
}
#summary-list button:hover { background: var(--bg); }
#summary-list button[aria-current] { background: var(--accent-soft); font-weight: 600; }
.dot { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); display: grid; place-items: center; font-size: .8125rem; }
.dot.ok { background: var(--ok); border-color: var(--ok); color: #fff; }

@media (max-width: 560px) {
  .brand-name { display: none; }
  .input-group { flex-direction: column; }
  .form-actions { position: sticky; bottom: 0; background: var(--surface); margin: 2rem -1rem -1rem; padding: .75rem 1rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
