:root {
  --green: #048c34;
  --green-dark: #0f6b3d;
  --green-deep: #143c23;
  --gold: #f0c32c;
  --yellow: #f4af16;
  --orange: #ff7f00;
  --blue: #143c23;
  --blue-soft: #f0f7f2;
  --ink: #1a2e1f;
  --muted: #5a6b5e;
  --line: #d6e5da;
  --soft: #f6fbf4;
  --white: #ffffff;
  --danger: #b42318;
  --shadow: 0 18px 48px rgba(10, 40, 20, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Nunito Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--white);
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
h1, h2, h3, h4, h5, h6 { font-family: Cabin, "Nunito Sans", sans-serif; }
p { margin-top: 0; }

.gov-bar {
  background: var(--blue);
  color: #fff;
  font-size: 13px;
}
.gov-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px clamp(16px, 4vw, 56px);
}
.gov-id {
  font-family: Cabin, "Nunito Sans", sans-serif;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.gov-brasao {
  color: var(--gold);
  font-size: 16px;
}
.a11y-bar {
  display: flex;
  align-items: center;
  gap: 4px;
}
.a11y-bar button,
.a11y-bar a {
  background: none;
  border: 1px solid rgba(255,255,255,.35);
  color: #fff;
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}
.a11y-bar button:hover,
.a11y-bar a:hover {
  background: rgba(255,255,255,.2);
}
.a11y-sep {
  color: rgba(255,255,255,.35);
  margin: 0 2px;
}

body.high-contrast {
  --bg: #000 !important;
  --text: #ffff00 !important;
  --muted: #cccc00 !important;
  --soft: #222 !important;
  --line: #555 !important;
  --border: #666 !important;
  background: #000 !important;
  color: #ffff00 !important;
}
body.high-contrast .topbar {
  background: #111 !important;
  border-color: #555 !important;
}
body.high-contrast .hero {
  background: #111 !important;
}
body.high-contrast .panel,
body.high-contrast .card,
body.high-contrast .form-shell,
body.high-contrast fieldset {
  background: #111 !important;
  border-color: #555 !important;
  color: #ffff00 !important;
}
body.high-contrast a {
  color: #00ffff !important;
}
body.high-contrast .button.primary {
  background: #ffff00 !important;
  color: #000 !important;
}
body.high-contrast .footer {
  background: #111 !important;
  color: #ffff00 !important;
}
body.high-contrast input,
body.high-contrast select,
body.high-contrast textarea {
  background: #222 !important;
  color: #ffff00 !important;
  border-color: #666 !important;
}
body.high-contrast .sidebar {
  background: #111 !important;
  border-color: #555 !important;
}
body.high-contrast .gov-bar {
  background: #000 !important;
  border-bottom: 2px solid #ffff00;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px clamp(16px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  min-width: 230px;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  border-radius: 8px;
  font-weight: 900;
}

.brand-logo {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background: #fff;
}

.brand-logo img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.footer-logo {
  display: block;
  width: min(220px, 100%);
  margin-bottom: 12px;
}

.footer-logo img {
  display: block;
  max-width: 100%;
  max-height: 74px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 700;
  line-height: 1.25;
}

.nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.nav a,
.nav button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  padding: 0 11px;
  color: #1a2e1f;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-family: Cabin, "Nunito Sans", sans-serif;
  font-size: .92rem;
  font-weight: 700;
  white-space: nowrap;
}

.nav a:hover,
.nav button:hover {
  background: var(--soft);
}

.hero {
  min-height: 72vh;
  display: grid;
  align-items: end;
  padding: clamp(52px, 8vw, 108px) clamp(18px, 5vw, 72px) 28px;
  color: #fff;
  background:
    linear-gradient(135deg, rgba(20, 60, 35, .95), rgba(4, 140, 52, .88)),
    radial-gradient(circle at 85% 15%, rgba(240, 195, 44, .18), transparent 30%);
}

.hero-content {
  width: min(860px, 100%);
}

.official-badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 8px 12px 8px 8px;
  border: 1px solid rgba(255, 255, 255, .34);
  border-radius: 8px;
  background: rgba(255, 255, 255, .13);
  color: #fff;
  box-shadow: 0 12px 26px rgba(0, 0, 0, .12);
}

.official-badge span {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 7px;
  color: var(--green-deep);
  background: var(--gold);
  font-weight: 950;
}

.official-badge strong {
  min-width: 0;
  font-size: .9rem;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

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

.hero .eyebrow {
  color: var(--gold);
}

.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(3.2rem, 8vw, 6.8rem);
  line-height: .94;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.hero-subtitle,
.hero p {
  width: min(760px, 100%);
  margin-bottom: 26px;
  color: rgba(255, 255, 255, .93);
  font-size: clamp(1.08rem, 2.2vw, 1.42rem);
  line-height: 1.45;
}

.hero-actions,
.form-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.trust-note {
  margin-top: 14px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, .82);
  font-size: .95rem;
  font-weight: 800;
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.quick-filters .button {
  min-height: 38px;
  padding: 0 13px;
}

.quick-filters .is-active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.compact {
  margin-bottom: 16px;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-box {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chart-box h3 {
  margin: 0 0 14px;
  font-size: 1.05rem;
}

.bar-row {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #27354f;
  font-size: .9rem;
  font-weight: 800;
}

.bar-label span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.bar-label strong {
  color: var(--blue);
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef6;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.bar-track.success span { background: #12a05c; }
.bar-track.warning span { background: var(--orange); }
.bar-track.blue span { background: var(--blue); }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 900;
  line-height: 1.1;
  text-align: center;
  white-space: normal;
}

.button:disabled {
  cursor: wait;
  opacity: .78;
}

.button.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.primary {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 10px 24px rgba(4, 140, 52, .22);
}

.primary:hover { background: var(--green-dark); }
.secondary { color: var(--blue); background: #fff; border-color: var(--line); }
.ghost { color: #fff; border-color: rgba(255,255,255,.38); background: rgba(255,255,255,.12); }
.whatsapp-button {
  color: #fff;
  background: #128c4a;
  border-color: #128c4a;
  box-shadow: 0 10px 24px rgba(18, 140, 74, .18);
}
.whatsapp-button:hover { background: #0f7a40; }

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  width: min(780px, 100%);
  margin-top: 56px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px;
  background: rgba(255,255,255,.18);
}

.status-strip article {
  min-width: 0;
  padding: 18px;
  background: rgba(20, 60, 35, .25);
}

.status-strip strong {
  display: block;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1;
}

.status-strip span {
  display: block;
  margin-top: 5px;
  color: rgba(255,255,255,.88);
  line-height: 1.25;
}

.section,
.admin-layout,
.intro-section {
  padding: clamp(42px, 6vw, 82px) clamp(18px, 5vw, 72px);
}

.quick-start {
  display: grid;
  grid-template-columns: minmax(220px, .34fr) minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  padding: 22px clamp(18px, 5vw, 72px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.quick-start h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.6vw, 2rem);
  line-height: 1.1;
}

.quick-category-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-category-grid a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid #bdd8ca;
  border-radius: 8px;
  color: #063d25;
  background: #f0fbf5;
  font-weight: 900;
  line-height: 1.15;
}

.quick-category-grid a:hover {
  border-color: var(--green);
  background: #e3f7ed;
}

.intro-section {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
  gap: 28px;
  align-items: start;
}

.intro-section h2,
h1.page-title,
h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.intro-section p,
.section-heading p,
.helper,
.empty {
  color: var(--muted);
  line-height: 1.65;
}

.muted { background: var(--soft); }
.section-heading { width: min(840px, 100%); margin-bottom: 26px; }

.steps-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.step-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.step-card span {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  margin-bottom: 12px;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-weight: 950;
}

.step-card strong {
  display: block;
  margin-bottom: 6px;
  line-height: 1.25;
}

.step-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.form-shell,
.panel,
.login-box,
.lookup-result {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: clamp(18px, 3vw, 30px);
  box-shadow: var(--shadow);
}

.form-step-indicator {
  display: none;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #cfe0f5;
  border-radius: 8px;
  background: #f6f9ff;
}

.step-indicator-text {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.step-count {
  color: var(--blue);
  font-size: .86rem;
  font-weight: 950;
  white-space: nowrap;
}

.step-title {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.step-progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe7f7;
}

.step-progress span {
  display: block;
  width: var(--step-progress, 20%);
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width .22s ease;
}

.step-prev,
.step-next {
  display: none;
}

.is-step-ready .form-step-indicator {
  display: grid;
}

.is-step-ready [data-step] {
  display: none;
}

.is-step-ready [data-step].is-active-step {
  display: block;
}

.is-step-ready .step-final-extra,
.is-step-ready .submit-button {
  display: none;
}

.is-step-ready.is-last-step .step-final-extra {
  display: grid;
}

.is-step-ready.is-last-step .submit-button {
  display: inline-flex;
}

.is-step-ready .step-prev,
.is-step-ready .step-next {
  display: inline-flex;
}

.is-step-ready.is-first-step .step-prev,
.is-step-ready.is-last-step .step-next {
  display: none;
}

.category-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.category-choice {
  min-width: 0;
  min-height: 92px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #24324c;
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.category-choice strong,
.category-choice span {
  display: block;
}

.category-choice strong {
  line-height: 1.25;
}

.category-choice span {
  margin-top: 6px;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 750;
  line-height: 1.3;
}

.category-choice:hover,
.category-choice.is-selected {
  border-color: var(--green);
  background: #f0fbf5;
  box-shadow: 0 10px 20px rgba(0, 143, 76, .1);
}

.category-choice.is-selected strong {
  color: #063d25;
}

.is-step-ready .category-choice.is-extra-category {
  display: none;
}

.is-step-ready.is-showing-all-categories .category-choice.is-extra-category {
  display: block;
}

.category-more {
  display: none;
  min-height: 40px;
  margin-top: 12px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--blue);
  background: #fff;
  cursor: pointer;
  font-weight: 900;
}

.is-step-ready .category-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.category-select-fallback {
  margin-top: 14px;
}

.is-step-ready .category-select-fallback {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

fieldset {
  min-width: 0;
  margin: 0 0 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

legend {
  padding: 0 8px;
  font-weight: 900;
}

.grid { display: grid; gap: 14px; }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-two { grid-column: 1 / -1; }

label {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: #24324c;
  font-weight: 800;
  line-height: 1.25;
}

.field-hint {
  color: var(--muted);
  font-size: .86rem;
  font-weight: 650;
  line-height: 1.4;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd8e5;
  border-radius: 8px;
  outline: none;
}

textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(4,140,52,.14); }

.description-help {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
  color: var(--muted);
  font-size: .92rem;
}
.description-help p { margin: 0; }

.anonymous-option {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid #b8d8c8;
  border-radius: 8px;
  background: #f0fbf5;
  color: var(--ink);
}

.anonymous-option input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
  accent-color: var(--green);
}

.anonymous-option strong,
.anonymous-option small {
  display: block;
}

.anonymous-option small {
  margin-top: 4px;
  color: #315846;
  font-weight: 650;
  line-height: 1.45;
}

.is-anonymous .identity-field {
  opacity: .52;
}

.is-anonymous .identity-field input {
  background: #f3f6f9;
  color: var(--muted);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.upload-slot {
  min-height: 130px;
  place-content: center;
  justify-items: center;
  padding: 16px;
  border: 1px dashed #a8b5c7;
  border-radius: 8px;
  background: #f8fafc;
  text-align: center;
  cursor: pointer;
}

.upload-slot:hover {
  border-color: var(--green);
  background: #f0fbf5;
}

.upload-slot span {
  font-weight: 900;
}

.upload-slot small {
  max-width: 100%;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.upload-slot em {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  margin-top: 4px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--blue);
  background: #fff;
  font-size: .86rem;
  font-style: normal;
  font-weight: 900;
}

.upload-slot input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  border: 0;
  clip: rect(0 0 0 0);
}

.consent {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.5;
}

.consent input {
  width: 18px;
  min-height: 18px;
  margin-top: 3px;
}

.notice {
  border-left: 6px solid var(--orange);
  background: #fff7ed;
  padding: 22px;
  border-radius: 8px;
}

.notice p { margin: 8px 0 0; color: #69410f; }

.notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.notice-actions .button {
  min-height: 40px;
  padding: 0 14px;
  color: #5f370e;
  background: #fff;
  border-color: #fdba74;
}

.notice-actions .button:hover {
  border-color: var(--orange);
}

.alert {
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 16px;
  font-weight: 700;
}
.alert.error { color: #7a271a; background: #ffede8; border: 1px solid #fecdca; }
.alert.success { color: #05603a; background: #ecfdf3; border: 1px solid #abefc6; }

.inline-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.cards,
.service-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.card,
.service-card {
  min-width: 0;
  min-height: 112px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.service-card {
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.service-card:hover {
  border-color: rgba(0, 143, 76, .45);
  box-shadow: 0 14px 28px rgba(13, 33, 69, .1);
  transform: translateY(-2px);
}

.card b {
  display: block;
  margin-top: 8px;
  color: var(--blue);
  font-size: 2rem;
}

.service-card strong,
.service-card span {
  display: block;
}

.service-card strong {
  line-height: 1.25;
}

.service-card span {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.admin-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 24px;
  background: #f8fafc;
}

.sidebar {
  align-self: start;
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.sidebar a {
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 800;
}
.sidebar a:hover,
.sidebar-logout button:hover { background: var(--soft); }

.sidebar-logout {
  margin: 0;
}

.sidebar-logout button {
  width: 100%;
  min-height: 40px;
  padding: 10px 12px;
  color: #24324c;
  background: transparent;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  position: relative;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

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

th {
  color: #41506b;
  background: var(--soft);
  font-size: .86rem;
}

.pill {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 900;
  font-size: .85rem;
}

.history-text {
  margin: 0;
  min-width: 260px;
  line-height: 1.45;
}

.history-edit-form {
  display: none;
  min-width: 320px;
}

.history-edit-form textarea {
  min-height: 92px;
}

.history-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.history-edit-actions .button,
.history-edit-toggle {
  min-height: 36px;
  padding: 0 12px;
  font-size: .86rem;
}

.is-editing-history .history-text {
  display: none;
}

.is-editing-history .history-edit-form {
  display: block;
}

.is-editing-history .history-edit-toggle {
  display: none;
}

.footer-stripe {
  display: flex;
  height: 6px;
  line-height: 0;
}
.footer-stripe span {
  flex: 1;
}
.footer-stripe span:nth-child(1) { background: #048c34; }
.footer-stripe span:nth-child(2) { background: #f4af16; }
.footer-stripe span:nth-child(3) { background: #e8792f; }
.footer-stripe span:nth-child(4) { background: #f0c32c; }
.footer-stripe span:nth-child(5) { background: #0721a4; }

.footer {
  display: grid;
  grid-template-columns: minmax(220px, .9fr) minmax(260px, 1.1fr);
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 30px clamp(18px, 5vw, 72px);
  color: #fff;
  background: var(--blue);
}

.footer strong,
.footer span,
.footer small,
.footer a {
  display: block;
}

.footer span,
.footer small,
.footer a {
  margin-top: 5px;
  color: rgba(255, 255, 255, .82);
  line-height: 1.35;
}

.footer-brand strong {
  font-size: 1.18rem;
}

.footer-brand small {
  color: rgba(255, 255, 255, .7);
}

.footer-details {
  display: grid;
  justify-items: end;
  text-align: right;
}

.footer-details strong {
  max-width: 420px;
}

.footer-details a {
  color: #fff;
  font-weight: 850;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-legal {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-top: 0;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, .2);
  grid-column: 1 / -1;
}

.footer-legal a,
.footer-legal span {
  color: rgba(255, 255, 255, .78);
  font-size: .86rem;
  line-height: 1.4;
}

.footer-legal a {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.footer-legal a:hover {
  color: #fff;
}

.legal-page {
  max-width: 860px;
}

.legal-page h2 {
  margin-top: 32px;
  font-size: 1.25rem;
}

.legal-page ul {
  padding-left: 20px;
  line-height: 1.7;
}

.legal-page p {
  line-height: 1.65;
}

.lgpd-relatorio {
  width: 100%;
  font-family: monospace;
  font-size: 13px;
  line-height: 1.5;
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  resize: vertical;
  cursor: text;
}
.lgpd-consulta {
  max-width: 480px;
  margin: 28px 0;
  padding: 20px 24px;
  background: #f2f5f9;
  border-radius: 12px;
}
.lgpd-consulta h3 { margin: 0 0 12px; }
.lgpd-resultado { margin-top: 20px; }
.lgpd-resultado .status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 14px;
  background: var(--border);
}
.lgpd-resultado .status-badge.respondida { background: #d1fae5; color: #065f46; }
.lgpd-resultado .status-badge.concluida { background: #dbeafe; color: #1e40af; }
.lgpd-resultado .status-badge.analise { background: #fef3c7; color: #92400e; }
.lgpd-resultado .status-badge.recebida { background: #f3f4f6; color: #374151; }
.consent a {
  color: var(--green);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 980px) {
  .topbar,
  .admin-layout,
  .intro-section,
  .quick-start,
  .inline-form {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .cards,
  .steps-grid,
  .service-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .gov-bar-inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    font-size: 12px;
    padding: 6px 12px;
  }
  .gov-id {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.2;
  }
  .a11y-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    width: 100%;
  }
  .a11y-bar button,
  .a11y-bar a {
    justify-content: center;
    min-height: 36px;
    padding: 5px 8px;
    font-size: 12px;
  }
  .a11y-sep {
    display: none;
  }
  .topbar {
    position: relative;
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 16px;
  }

  .brand {
    min-width: 0;
  }

  .brand small {
    font-size: .76rem;
  }

  .nav {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav form {
    flex: 0 0 auto;
  }

  .nav a,
  .nav button {
    width: auto;
    min-height: 44px;
    flex: 0 0 auto;
    padding: 0 14px;
    background: var(--soft);
    font-size: .88rem;
    white-space: nowrap;
  }

  .nav a[href="?p=home#servicos"] {
    display: none;
  }

  .nav a:last-of-type {
    color: var(--blue);
    background: var(--blue-soft);
  }

  .hero {
    min-height: auto;
    padding: 28px 18px 16px;
    align-items: start;
  }

  .hero h1 {
    max-width: 420px;
    margin-bottom: 10px;
    font-size: clamp(2.25rem, 10vw, 3rem);
    line-height: 1;
  }

  .hero-subtitle,
  .hero p {
    margin-bottom: 16px;
    font-size: .98rem;
    line-height: 1.42;
  }

  .hero-actions,
  .form-actions,
  .actions {
    display: grid;
    width: 100%;
  }

  .hero-actions {
    grid-template-columns: 1fr;
    margin-top: 12px;
  }

  .hero-actions .ghost {
    display: none;
  }

  .button {
    width: 100%;
  }

  .quick-filters {
    gap: 6px;
  }

  .quick-filters .button {
    width: auto !important;
    min-height: 36px;
    padding: 0 12px;
    font-size: .85rem;
  }

  .actions {
    display: flex !important;
    flex-wrap: wrap;
  }

  .actions .button {
    width: auto !important;
  }

  .grid.three {
    grid-template-columns: 1fr 1fr;
  }

  .grid.three button,
  .grid.three .button {
    grid-column: 1 / -1;
  }

  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .charts-grid {
    grid-template-columns: 1fr !important;
  }

  .admin-layout .sidebar {
    order: -1;
  }

  .hero-actions .button {
    min-height: 50px;
    font-size: 1rem;
  }

  .hero-actions .secondary {
    color: #fff;
    background: rgba(255,255,255,.16);
    border-color: rgba(255,255,255,.45);
  }

  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-top: 18px;
  }

  .status-strip article {
    padding: 10px 8px;
    text-align: center;
  }

  .status-strip strong {
    font-size: 1.35rem;
  }

  .status-strip span {
    font-size: .76rem;
  }

  .two,
  .three,
  .cards,
  .charts-grid,
  .steps-grid,
  .service-grid,
  .upload-grid,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .span-two {
    grid-column: auto;
  }

  fieldset {
    padding: 16px;
  }

  .section,
  .admin-layout,
  .quick-start,
  .intro-section {
    padding: 30px 18px;
  }

  .quick-start {
    gap: 12px;
    padding-top: 22px;
    padding-bottom: 22px;
  }

  .quick-start .eyebrow {
    margin-bottom: 6px;
  }

  .quick-category-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .quick-category-grid a {
    min-height: 48px;
  }

  .form-step-indicator {
    gap: 6px;
  }

  .step-indicator-text {
    align-items: flex-start;
    display: grid;
  }

  .step-title {
    text-align: left;
  }

  .category-choice-grid {
    grid-template-columns: 1fr;
  }

  .category-choice {
    min-height: 76px;
  }

  .intro-section {
    gap: 14px;
  }

  .intro-section h2 {
    font-size: 1.45rem;
  }

  .intro-section p,
  .notice p {
    line-height: 1.5;
  }

  .notice {
    padding: 16px;
  }

  #abrir {
    padding-top: 26px;
  }

  #abrir .section-heading {
    margin-bottom: 16px;
  }

  #abrir .section-heading .eyebrow {
    display: none;
  }

  #abrir .section-heading h2 {
    font-size: 1.65rem;
  }

  .form-shell,
  .panel,
  .login-box,
  .lookup-result {
    padding: 18px;
  }

  .footer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .footer-details {
    justify-items: start;
    text-align: left;
  }

  .footer-legal {
    display: grid;
    gap: 8px;
  }

  table .button,
  table a.button {
    min-height: 40px;
    padding: 0 14px;
    font-size: .85rem;
  }

  .sidebar {
    padding: 12px;
  }

  .sidebar a {
    min-height: 44px;
    padding: 12px 14px;
    font-size: .95rem;
  }

  .sidebar-logout button {
    min-height: 44px;
  }
}

[vw],
[vw].enabled {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  bottom: 18px;
  right: 14px;
  z-index: 9999;
}
[vw-access-button],
[vw-access-button].active,
[vw] [vw-access-button],
[vw] [vw-access-button].active {
  position: fixed !important;
  top: auto !important;
  left: auto !important;
  bottom: 18px;
  right: 14px;
}

[vw-plugin-wrapper] {
  top: auto !important;
  left: auto !important;
  right: 14px !important;
  bottom: 76px !important;
}

@media (max-width: 640px) {
  [vw],
  [vw].enabled {
    top: auto !important;
    left: auto !important;
    bottom: 76px !important;
    right: 10px !important;
    transform: scale(.86);
    transform-origin: bottom right;
  }
  [vw-access-button],
  [vw-access-button].active,
  [vw] [vw-access-button],
  [vw] [vw-access-button].active {
    top: auto !important;
    left: auto !important;
    bottom: 76px !important;
    right: 10px !important;
    transform: scale(.86);
    transform-origin: bottom right;
  }
  [vw-plugin-wrapper] {
    top: auto !important;
    left: auto !important;
    right: 10px !important;
    bottom: 132px !important;
  }
}

@media (max-width: 380px) {
  .hero h1 {
    font-size: clamp(2.35rem, 12vw, 2.8rem);
  }

  .brand strong {
    font-size: .95rem;
  }

  .brand small {
    font-size: .68rem;
  }
}

/* === PWA: modo standalone (instalado como app) === */
@media (display-mode: standalone) {
  .gov-bar { display: none; }
  .topbar {
    position: sticky;
    top: 0;
    padding-top: max(env(safe-area-inset-top, 0px), 8px);
  }
  .hero {
    min-height: 60vh;
    padding-top: clamp(36px, 6vw, 72px);
  }
  body {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .footer-legal a[href*="admin/login"] {
    display: none;
  }
}

/* PWA install button styling */
.pwa-install-btn {
  animation: pwa-pulse 2s ease-in-out 3s 2;
}
@keyframes pwa-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .6; border-color: var(--gold); color: var(--gold); }
}

.pwa-ios-tip {
  font-size: .88rem;
  margin-top: 10px;
}
.pwa-ios-tip strong {
  text-decoration: underline;
  text-underline-offset: 2px;
}
