:root {
  --am-primary: #0d6cdd;
  --am-primary-dark: #0759bd;
  --am-primary-soft: #eaf3ff;
  --am-text: #172033;
  --am-muted: #667085;
  --am-border: #dfe7f2;
  --am-bg: #f0f3f8;
  --am-surface: #ffffff;
  --am-danger: #c62828;
  --am-warning: #a15c00;
  --am-success: #18794e;
  --am-radius: 16px;
  --am-shadow: 0 8px 24px rgba(28, 47, 74, 0.09);
}

* { box-sizing: border-box; }

body[data-documento-publico],
body[data-pagina-aceite],
body.am-preview-admin {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
  color: var(--am-text);
  background: var(--am-bg);
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.6;
}

body[data-pagina-aceite] { padding-bottom: 132px; }

:is(body[data-documento-publico], body[data-pagina-aceite], body.am-preview-admin, #documentos-legais) :is(button, input, select) { font: inherit; }
:is(body[data-documento-publico], body[data-pagina-aceite], body.am-preview-admin, #documentos-legais) :is(button, a) { -webkit-tap-highlight-color: transparent; }

.am-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #e4e9f1;
  background: #fff;
  box-shadow: 0 5px 16px rgba(24, 39, 61, 0.10);
}

.am-topbar__inner {
  width: min(1160px, calc(100% - 32px));
  min-height: 70px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.am-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--am-primary);
  text-decoration: none;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.am-brand__mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 2px solid var(--am-primary);
  border-radius: 12px;
  background: var(--am-primary);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.am-brand__logo {
  width: 42px;
  height: 42px;
  display: block;
  object-fit: cover;
  border: 2px solid #cfe0f5;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(8, 76, 163, .14);
}

.am-secure-label {
  color: var(--am-muted);
  font-size: 13px;
  font-weight: 700;
}

.am-topbar__link {
  color: var(--am-primary);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  padding: 9px 13px;
  border: 1px solid #d4dfed;
  border-radius: 10px;
}

.am-topbar__link:hover { background: var(--am-primary-soft); }

.am-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 38px auto 54px;
}

.am-hero {
  margin-bottom: 20px;
  padding: 26px 28px;
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  background: #fff;
  box-shadow: var(--am-shadow);
}

.am-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--am-primary);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.am-title {
  margin: 0;
  color: #14213d;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.16;
  letter-spacing: -0.8px;
}

.am-subtitle {
  max-width: 760px;
  margin: 10px 0 0;
  color: var(--am-muted);
}

.am-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 18px;
}

.am-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 11px;
  border: 1px solid #cfe0f5;
  border-radius: 999px;
  background: #fff;
  color: #3e5878;
  font-size: 13px;
  font-weight: 700;
}

.am-badge--draft {
  border-color: #f2d39f;
  background: #fff5df;
  color: var(--am-warning);
}

.am-badge--success {
  border-color: #b9e0ce;
  background: #eefaf4;
  color: var(--am-success);
}

.am-card {
  border: 1px solid var(--am-border);
  border-radius: var(--am-radius);
  background: var(--am-surface);
  box-shadow: var(--am-shadow);
  overflow: hidden;
}

body[data-pagina-aceite] .am-card { overflow: visible; }

/* Preview administrativo: usa o shell real do painel Super Admin. */
.am-preview-admin { padding-bottom: 0; }
.am-preview-admin .agenda-app-shell { background: var(--am-bg); }
.am-preview-admin .sidebar-item { text-decoration: none; }
.am-preview-admin .am-menu-glyph {
  width: 52px;
  flex: 0 0 52px;
  color: inherit;
  text-align: center;
  font-size: 20px;
  line-height: 1;
}
.am-preview-admin .cabecalho-esquerda { flex-direction: row; align-items: center; gap: 12px; }
.am-preview-admin .cabecalho-data-grupo { min-width: 0; }
.am-admin-content { width: min(1080px, calc(100% - 44px)); margin: 30px auto 44px; }
#documentos-legais { min-width: 0; }
.am-legal-admin-tab {
  min-width: 0;
  padding-right: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.am-legal-admin-tab .am-hero { flex: 0 0 auto; margin-bottom: 0; }
.am-legal-admin-tab .am-card { flex: 0 0 auto; }
.am-document-placeholder { margin: 0; color: var(--am-muted); text-align: center; }
.am-panel-link {
  min-height: 42px;
  padding: 9px 14px;
  display: inline-flex;
  align-items: center;
  border: 1px solid #cfdbea;
  border-radius: 11px;
  color: #0759bd;
  background: #fff;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
}
.am-panel-link:hover { background: var(--am-primary-soft); }

.am-card__body { padding: clamp(22px, 4vw, 44px); }

.am-document {
  color: #25324a;
  font-size: 16px;
  overflow-wrap: anywhere;
}

.am-document h1,
.am-document h2,
.am-document h3 {
  color: #15284a;
  line-height: 1.3;
  scroll-margin-top: 96px;
}

.am-document h1 { font-size: 30px; }
.am-document h2 { margin-top: 32px; font-size: 23px; }
.am-document h3 { margin-top: 24px; font-size: 19px; }
.am-document p, .am-document li { color: #37445c; }
.am-document a { color: var(--am-primary); }
.am-document table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.am-document th, .am-document td { padding: 11px; border: 1px solid var(--am-border); text-align: left; }
.am-document blockquote { margin: 20px 0; padding: 14px 18px; border-left: 4px solid var(--am-primary); background: var(--am-primary-soft); }

.am-state {
  min-height: 260px;
  padding: 36px 24px;
  display: grid;
  place-items: center;
  text-align: center;
}

.am-state__content { max-width: 560px; }
.am-state__icon { width: 58px; height: 58px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 50%; background: var(--am-primary-soft); color: var(--am-primary); font-size: 25px; font-weight: 900; }
.am-state h2 { margin: 0 0 8px; font-size: 22px; }
.am-state p { margin: 0; color: var(--am-muted); }

.am-spinner {
  width: 38px;
  height: 38px;
  margin: 0 auto 16px;
  border: 4px solid #dce9fa;
  border-top-color: var(--am-primary);
  border-radius: 50%;
  animation: am-spin 0.8s linear infinite;
}

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

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

.am-btn {
  min-height: 46px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
}

.am-btn:not(:disabled):hover { transform: translateY(-1px); }
.am-btn:disabled { cursor: not-allowed; opacity: .48; }
.am-btn--primary { color: #fff; background: var(--am-primary); box-shadow: 0 8px 20px rgba(18, 103, 216, .22); }
.am-btn--secondary { color: #37445c; border-color: var(--am-border); background: #fff; }
.am-btn--danger { color: var(--am-danger); border-color: #efc7c7; background: #fff; }

.am-legal-list { display: grid; gap: 18px; }

.am-legal-item {
  border: 1px solid var(--am-border);
  border-radius: 14px;
  overflow: hidden;
}

.am-legal-item__head {
  padding: 18px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--am-border);
  background: #f9fbfe;
}

.am-legal-item__head h2 { margin: 0; font-size: 20px; }
.am-legal-item__head p { margin: 3px 0 0; color: var(--am-muted); font-size: 13px; }
.am-legal-item__content { max-height: 430px; padding: 22px; overflow: auto; }

.am-confirmations { margin: 22px 0 0; padding: 0; display: grid; gap: 12px; border: 0; }
.am-confirmations legend { margin-bottom: 10px; color: #15284a; font-size: 16px; font-weight: 800; }
.am-confirmation-list { display: grid; gap: 12px; }

.am-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--am-border);
  border-radius: 12px;
  background: #fbfcfe;
  cursor: pointer;
}

.am-check input { width: 19px; height: 19px; margin: 3px 0 0; accent-color: var(--am-primary); flex: 0 0 auto; }
.am-check span { color: #344057; font-weight: 650; }

.am-alert { margin-bottom: 18px; padding: 13px 15px; border: 1px solid #f0caca; border-radius: 11px; background: #fff1f1; color: #8f2424; }
.am-alert[hidden] { display: none; }

.am-consent-bar {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--am-border);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 -8px 26px rgba(28, 47, 74, .13);
  backdrop-filter: blur(10px);
}

.am-consent-bar__inner {
  width: min(1040px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px 24px;
}

.am-consent-bar__status { min-width: 0; display: grid; gap: 2px; }
.am-consent-bar__status strong { color: #15284a; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.am-consent-bar__status span { color: var(--am-primary); font-size: 13px; font-weight: 800; }
.am-consent-bar__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

.am-preview-tools { margin-bottom: 18px; padding: 18px; display: grid; grid-template-columns: minmax(180px, 1fr) auto; gap: 9px 12px; align-items: end; border: 1px solid var(--am-border); border-radius: 14px; background: #fff; box-shadow: var(--am-shadow); }
.am-select-label { grid-column: 1 / -1; color: #344057; font-size: 13px; font-weight: 800; }
.am-select { width: 100%; min-height: 46px; padding: 9px 12px; border: 1px solid #cdd8e8; border-radius: 10px; background: #fff; color: var(--am-text); }
.am-document-title { margin: 0 0 22px; color: #15284a; font-size: 24px; }

/* Gerenciamento visual de documentos legais no Painel Super Admin. */
#documentos-legais .am-legal-page-header { margin-bottom: 18px; }
#documentos-legais .am-legal-page-header .am-title { font-size: clamp(25px, 3vw, 32px); }
#documentos-legais .am-legal-page-header .am-subtitle { margin-top: 6px; }
#documentos-legais .am-legal-manager { padding: clamp(18px, 3vw, 28px); overflow: visible; }
#documentos-legais .am-legal-manager__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}
#documentos-legais .am-legal-manager__header h3,
#documentos-legais .am-legal-section-heading h3,
#documentos-legais .am-legal-detail h3 { margin: 0; color: #15284a; }
#documentos-legais .am-legal-manager__header h3 { font-size: 20px; }
#documentos-legais .am-legal-manager__header p,
#documentos-legais .am-legal-section-heading p { margin: 5px 0 0; color: var(--am-muted); font-size: 13px; }

#documentos-legais .am-legal-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
#documentos-legais .am-legal-summary__item {
  min-width: 0;
  padding: 13px 15px;
  border: 1px solid var(--am-border);
  border-radius: 12px;
  background: #f8fbff;
}
#documentos-legais .am-legal-summary__item span { display: block; color: var(--am-muted); font-size: 12px; font-weight: 700; }
#documentos-legais .am-legal-summary__item strong { display: block; margin-top: 3px; color: #15284a; font-size: 20px; }
#documentos-legais .am-preview-tools { box-shadow: none; background: #fbfcfe; }

#documentos-legais .am-legal-detail,
#documentos-legais .am-legal-versions,
#documentos-legais .am-legal-content {
  margin-top: 18px;
  padding: clamp(17px, 2.5vw, 24px);
  border: 1px solid var(--am-border);
  border-radius: 14px;
  background: #fff;
}
#documentos-legais .am-legal-detail__header,
#documentos-legais .am-legal-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
#documentos-legais .am-legal-kicker { color: var(--am-primary); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
#documentos-legais .am-legal-detail h3 { margin-top: 4px; font-size: 21px; }
#documentos-legais .am-legal-detail__badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
#documentos-legais .am-legal-properties {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  margin: 20px 0 0;
  border: 1px solid var(--am-border);
  border-radius: 12px;
  overflow: hidden;
}
#documentos-legais .am-legal-properties > div { min-width: 0; padding: 13px 15px; border-right: 1px solid var(--am-border); border-bottom: 1px solid var(--am-border); background: #fbfcfe; }
#documentos-legais .am-legal-properties > div:nth-child(3n) { border-right: 0; }
#documentos-legais .am-legal-properties > div:nth-child(n + 4):nth-child(-n + 6) { border-bottom: 0; }
#documentos-legais .am-legal-properties > .am-legal-property--wide { grid-column: 1 / -1; border-top: 1px solid var(--am-border); border-right: 0; border-bottom: 0; }
#documentos-legais .am-legal-properties dt { color: var(--am-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
#documentos-legais .am-legal-properties dd { min-height: 30px; margin: 6px 0 0; color: #243653; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
#documentos-legais .am-legal-properties dd .am-badge { min-height: 26px; padding: 2px 9px; font-size: 12px; }
#documentos-legais .am-legal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
#documentos-legais .botao-geral:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }

#documentos-legais .am-legal-table-wrap { margin-top: 16px; border: 1px solid var(--am-border); border-radius: 12px; overflow: hidden; }
#documentos-legais .am-legal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
#documentos-legais .am-legal-table th,
#documentos-legais .am-legal-table td { padding: 13px 15px; border-bottom: 1px solid var(--am-border); color: #344057; text-align: left; overflow-wrap: anywhere; }
#documentos-legais .am-legal-table th { background: #f5f8fc; color: #52627a; font-size: 11px; letter-spacing: .03em; text-transform: uppercase; }
#documentos-legais .am-legal-table tbody tr:last-child td { border-bottom: 0; }
#documentos-legais .am-legal-table__empty td { padding: 24px; color: var(--am-muted); text-align: center; }
#documentos-legais .am-legal-table .am-badge { min-height: 26px; padding: 2px 9px; font-size: 11px; }
#documentos-legais .am-legal-table-action { min-height: 36px; padding: 7px 11px; white-space: nowrap; }
#documentos-legais .am-legal-content .am-legal-section-heading { align-items: center; margin-bottom: 18px; }
#documentos-legais .am-legal-content-summary { margin: 0 0 14px; padding: 12px 14px; border-left: 3px solid var(--am-primary); border-radius: 8px; background: var(--am-primary-soft); color: #344057; font-size: 13px; }
#documentos-legais .am-legal-content .am-document { max-height: 520px; padding: clamp(17px, 3vw, 28px); border: 1px solid var(--am-border); border-radius: 12px; overflow-y: auto; background: #fbfcfe; }
#documentos-legais .am-badge--archived { border-color: #d8dee8; background: #f1f3f6; color: #5e6b7d; }

.am-legal-modal { width: min(820px, calc(100vw - 32px)); max-height: min(860px, calc(100dvh - 32px)); }
.am-legal-modal .modal-corpo { min-height: 0; overflow-y: auto; }
.am-legal-modal .modal-grid { align-items: start; }
.am-legal-modal .modal-campo textarea { resize: vertical; }
.am-legal-modal .am-legal-editor-field textarea { min-height: 260px; line-height: 1.55; }
.am-legal-modal-check { grid-column: 1 / -1; padding: 14px 16px; border: 1px solid var(--am-border); border-radius: 12px; background: #f8fbff; }
.am-legal-modal-check label { display: flex; align-items: center; gap: 10px; color: #273a57; font-size: 14px; font-weight: 800; }
.am-legal-modal-check input { width: 18px; height: 18px; accent-color: var(--am-primary); }
.am-legal-modal-check small { display: block; margin: 7px 0 0 28px; color: var(--am-muted); line-height: 1.45; }
.am-legal-modal :is(input, select, textarea):disabled { color: #5f6f86; background: #f5f7fa; cursor: not-allowed; opacity: 1; }
.am-legal-modal-actions { flex-wrap: wrap; }

.am-footer { padding: 0 16px 32px; color: var(--am-muted); text-align: center; font-size: 13px; }
.am-footer a { color: var(--am-primary); }
.am-footer__links { margin-bottom: 8px; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 18px; }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  body[data-pagina-aceite] { padding-bottom: calc(236px + env(safe-area-inset-bottom)); }
  .am-topbar__inner { width: min(100% - 22px, 1160px); min-height: 62px; }
  .am-brand { font-size: 20px; }
  .am-brand__mark, .am-brand__logo { width: 38px; height: 38px; }
  .am-topbar__link { padding: 8px 10px; font-size: 12px; }
  .am-shell { width: min(100% - 22px, 1040px); margin: 22px auto 36px; }
  .am-hero { padding: 21px 19px; }
  .am-card__body { padding: 20px 17px; }
  .am-legal-item__head { display: block; padding: 16px; }
  .am-legal-item__head .am-badge { margin-top: 9px; }
  .am-legal-item__content { max-height: 360px; padding: 17px; }
  .am-actions { display: grid; grid-template-columns: 1fr; }
  .am-btn { width: 100%; }
  .am-consent-bar { padding: 12px 11px calc(12px + env(safe-area-inset-bottom)); }
  .am-consent-bar__inner { grid-template-columns: 1fr; gap: 10px; }
  .am-consent-bar__status { text-align: center; }
  .am-consent-bar__actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .am-consent-bar__actions .am-btn--primary { order: -1; min-height: 50px; }
  .am-preview-tools { grid-template-columns: 1fr; }
  .am-admin-content { width: calc(100% - 22px); margin: 20px auto 32px; }
  .am-preview-admin .cabecalho-data { max-width: 50vw; }
  .am-panel-link { min-height: 40px; padding: 8px 10px; font-size: 12px; }
  #documentos-legais .am-legal-manager__header,
  #documentos-legais .am-legal-detail__header,
  #documentos-legais .am-legal-section-heading { display: grid; grid-template-columns: 1fr; }
  #documentos-legais .am-legal-manager__header .botao-geral { width: 100%; }
  #documentos-legais .am-legal-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #documentos-legais .am-legal-properties { grid-template-columns: 1fr; }
  #documentos-legais .am-legal-properties > div,
  #documentos-legais .am-legal-properties > div:nth-child(3n),
  #documentos-legais .am-legal-properties > div:nth-last-child(-n + 3) { border-right: 0; border-bottom: 1px solid var(--am-border); }
  #documentos-legais .am-legal-properties > div:last-child { border-bottom: 0; }
  #documentos-legais .am-legal-detail__badges { justify-content: flex-start; }
  #documentos-legais .am-legal-actions { display: grid; grid-template-columns: 1fr; }
  #documentos-legais .am-legal-table-wrap { border: 0; overflow: visible; }
  #documentos-legais .am-legal-table,
  #documentos-legais .am-legal-table tbody,
  #documentos-legais .am-legal-table tr,
  #documentos-legais .am-legal-table td { display: block; width: 100%; }
  #documentos-legais .am-legal-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
  #documentos-legais .am-legal-table tr { border: 1px solid var(--am-border); border-radius: 12px; overflow: hidden; background: #fff; }
  #documentos-legais .am-legal-table td { display: grid; grid-template-columns: minmax(110px, .8fr) minmax(0, 1fr); gap: 12px; border-bottom: 1px solid var(--am-border); }
  #documentos-legais .am-legal-table td::before { color: var(--am-muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
  #documentos-legais .am-legal-table td:nth-child(1)::before { content: "Versão"; }
  #documentos-legais .am-legal-table td:nth-child(2)::before { content: "Status"; }
  #documentos-legais .am-legal-table td:nth-child(3)::before { content: "Publicação"; }
  #documentos-legais .am-legal-table td:nth-child(4)::before { content: "Nova manifestação"; }
  #documentos-legais .am-legal-table td:nth-child(5)::before { content: "Ações"; }
  #documentos-legais .am-legal-table__empty td { display: block; padding: 22px; text-align: center; }
  #documentos-legais .am-legal-table__empty td::before { content: none; }
  .am-legal-modal { width: 100%; max-height: calc(100dvh - 20px); }
  .am-legal-modal .am-legal-editor-field textarea { min-height: 220px; }
  .am-legal-modal-check small { margin-left: 0; }
}

@media (max-width: 430px) {
  .am-secure-label { display: none; }
  .am-preview-admin .cabecalho-data { display: none; }
  .am-preview-admin .cabecalho-dia { font-size: 17px; }
  .am-panel-link { max-width: 92px; text-align: center; line-height: 1.2; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
