:root {
  --portal-motion-instant: 80ms;
  --portal-motion-fast: 110ms;
  --portal-motion-standard: 180ms;
  --portal-motion-slow: 240ms;
  --portal-motion-ease-out: cubic-bezier(.2, .8, .2, 1);
  --portal-motion-ease-in-out: cubic-bezier(.4, 0, .2, 1);
  --portal-feedback-info: #176da1;
  --portal-feedback-success: #19745e;
  --portal-feedback-warning: #95660f;
  --portal-feedback-error: #aa3542;
  --portal-feedback-destructive: #9f2f3b;
  --portal-feedback-focus: #1684c5;
  --portal-feedback-disabled: #8293a1;
  --portal-feedback-ring: 0 0 0 3px rgba(22, 132, 197, .24);
  --portal-feedback-shadow: 0 12px 26px rgba(17, 64, 98, .14);
}

@view-transition {
  navigation: auto;
}

::view-transition-old(root) {
  animation: portal-view-out var(--portal-motion-fast) var(--portal-motion-ease-in-out) both;
}

::view-transition-new(root) {
  animation: portal-view-in var(--portal-motion-standard) var(--portal-motion-ease-out) both;
}

@keyframes portal-view-out {
  to { opacity: .94; transform: translateY(-2px); }
}

@keyframes portal-view-in {
  from { opacity: .94; transform: translateY(3px); }
}

html[data-portal-interactions="v1"] :where(button, a[href], input, select, textarea, summary, [role="button"]):focus-visible {
  outline: 3px solid var(--portal-feedback-focus) !important;
  outline-offset: 3px !important;
  box-shadow: var(--portal-feedback-ring);
}

html[data-portal-interactions="v1"] :where(button, input, select, textarea, [role="button"]):disabled,
html[data-portal-interactions="v1"] :where(button, a, input, select, textarea, [role="button"])[aria-disabled="true"] {
  cursor: not-allowed !important;
  filter: saturate(.55);
  opacity: .58;
  box-shadow: none !important;
  transform: none !important;
}

html[data-portal-interactions="v1"] .portal-interaction-target {
  transform-origin: center;
  transition:
    transform var(--portal-motion-fast) var(--portal-motion-ease-out),
    box-shadow var(--portal-motion-standard) var(--portal-motion-ease-out),
    border-color var(--portal-motion-standard) var(--portal-motion-ease-out),
    background-color var(--portal-motion-standard) var(--portal-motion-ease-out),
    color var(--portal-motion-standard) var(--portal-motion-ease-out) !important;
}

html[data-portal-interactions="v1"] .portal-interaction-pressing:not(:disabled) {
  transform: translateY(1px) scale(.982) !important;
  box-shadow: 0 3px 9px rgba(14, 51, 78, .14) !important;
}

html[data-portal-interactions="v1"] :where(
  .hub-card,
  .protocol-card,
  .reception-list button,
  .usage-doctor,
  .manifestation-item,
  .notification,
  .telemedicine-row,
  .public-type
) {
  transition:
    transform var(--portal-motion-standard) var(--portal-motion-ease-out),
    box-shadow var(--portal-motion-standard) var(--portal-motion-ease-out),
    border-color var(--portal-motion-standard) var(--portal-motion-ease-out),
    background-color var(--portal-motion-standard) var(--portal-motion-ease-out);
}

@media (hover: hover) and (pointer: fine) {
  html[data-portal-interactions="v1"] :where(
    .hub-card,
    .protocol-card,
    .reception-list button,
    .usage-doctor,
    .manifestation-item,
    .notification,
    .telemedicine-row,
    .public-type
  ):hover {
    transform: translateY(-2px);
    border-color: color-mix(in srgb, var(--portal-feedback-info) 34%, #cddce7);
    box-shadow: var(--portal-feedback-shadow);
  }
}

html[data-portal-interactions="v1"] :where(
  .hub-card,
  .protocol-card,
  .reception-list button,
  .usage-doctor,
  .manifestation-item,
  .notification,
  .telemedicine-row,
  .public-type
):focus-within {
  border-color: var(--portal-feedback-focus);
  box-shadow: var(--portal-feedback-ring), var(--portal-feedback-shadow);
}

html[data-portal-interactions="v1"] .portal-content-updating {
  animation: portal-content-update var(--portal-motion-standard) var(--portal-motion-ease-out) both;
  will-change: opacity, transform;
}

@keyframes portal-content-update {
  from { opacity: .72; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

html[data-portal-interactions="v1"] .portal-feedback-pending {
  position: relative;
  cursor: progress !important;
  padding-right: max(2.65em, 36px) !important;
}

html[data-portal-interactions="v1"] .portal-feedback-pending::after {
  content: "";
  position: absolute;
  top: 50%;
  right: .9em;
  width: 15px;
  height: 15px;
  margin-top: -8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: .74;
  animation: portal-progress-spin .72s linear infinite;
  pointer-events: none;
}

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

html[data-portal-interactions="v1"] .portal-feedback-success,
html[data-portal-interactions="v1"] .portal-feedback-context-success {
  animation: portal-result-success .58s var(--portal-motion-ease-out) both;
}

html[data-portal-interactions="v1"] .portal-feedback-error,
html[data-portal-interactions="v1"] .portal-feedback-context-error {
  animation: portal-result-error .44s var(--portal-motion-ease-out) both;
}

html[data-portal-interactions="v1"] .portal-feedback-warning {
  animation: portal-result-warning .5s var(--portal-motion-ease-out) both;
}

html[data-portal-interactions="v1"] .portal-feedback-selection {
  animation: portal-result-selection .42s var(--portal-motion-ease-out) both;
}

html[data-portal-interactions="v1"] .portal-feedback-notification {
  animation: portal-result-notification .55s var(--portal-motion-ease-out) both;
}

@keyframes portal-result-success {
  35% { border-color: color-mix(in srgb, var(--portal-feedback-success) 62%, transparent); box-shadow: 0 0 0 4px rgba(25, 116, 94, .12); }
}

@keyframes portal-result-error {
  30% { border-color: var(--portal-feedback-error); box-shadow: 0 0 0 4px rgba(170, 53, 66, .13); transform: translateX(-2px); }
  55% { transform: translateX(2px); }
}

@keyframes portal-result-warning {
  38% { border-color: var(--portal-feedback-warning); box-shadow: 0 0 0 4px rgba(149, 102, 15, .12); }
}

@keyframes portal-result-selection {
  45% { border-color: var(--portal-feedback-focus); box-shadow: 0 0 0 3px rgba(22, 132, 197, .12); }
}

@keyframes portal-result-notification {
  40% { box-shadow: 0 0 0 5px rgba(23, 109, 161, .13); }
}

html[data-portal-interactions="v1"] :where(.account-status,.login-status,[role="status"],[role="alert"]).portal-feedback-error {
  border-left: 4px solid var(--portal-feedback-error) !important;
}

html[data-portal-interactions="v1"] :where(.account-status,.login-status,[role="status"],[role="alert"]).portal-feedback-success {
  border-left: 4px solid var(--portal-feedback-success) !important;
}

html[data-portal-interactions="v1"] :where(.account-status,.login-status,[role="status"],[role="alert"]).portal-feedback-warning {
  border-left: 4px solid var(--portal-feedback-warning) !important;
}

html[data-portal-interactions="v1"] :where(.account-status,.login-status).info {
  border: 1px solid color-mix(in srgb, var(--portal-feedback-info) 24%, #dce8ef);
  background: #eef7fb;
  color: #245b78;
}

html[data-portal-interactions="v1"] :where(.account-status,.login-status).warning {
  border: 1px solid #ead7a8;
  background: #fff8e8;
  color: #725416;
}

/* Mantém os backdrops montados para permitir entrada e saída sem atrasar a ação. */
html[data-portal-interactions="v1"] .modal-backdrop,
html[data-portal-interactions="v1"] .citizen-modal,
html[data-portal-interactions="v1"] .council-delete-dialog-backdrop,
html[data-portal-interactions="v1"] .portal-auxiliary-dialog {
  display: flex !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity var(--portal-motion-standard) var(--portal-motion-ease-in-out),
    visibility 0s linear var(--portal-motion-standard);
}

html[data-portal-interactions="v1"] .modal-backdrop.open,
html[data-portal-interactions="v1"] .citizen-modal.open,
html[data-portal-interactions="v1"] .council-delete-dialog-backdrop.open,
html[data-portal-interactions="v1"] .portal-auxiliary-dialog.open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

html[data-portal-interactions="v1"] .modal-backdrop > .portal-modal,
html[data-portal-interactions="v1"] .citizen-modal > .citizen-modal-panel,
html[data-portal-interactions="v1"] .portal-auxiliary-dialog > .praise-dialog {
  opacity: .96;
  transform: translateY(8px) scale(.985);
  transition:
    opacity var(--portal-motion-standard) var(--portal-motion-ease-out),
    transform var(--portal-motion-standard) var(--portal-motion-ease-out);
}

html[data-portal-interactions="v1"] .modal-backdrop.open > .portal-modal,
html[data-portal-interactions="v1"] .citizen-modal.open > .citizen-modal-panel,
html[data-portal-interactions="v1"] .portal-auxiliary-dialog.open > .praise-dialog {
  opacity: 1;
  transform: none;
}

html[data-portal-interactions="v1"] .portal-chat .portal-chat-launcher,
html[data-portal-interactions="v1"] .portal-chat .portal-chat-panel {
  transition:
    opacity var(--portal-motion-standard) var(--portal-motion-ease-out),
    transform var(--portal-motion-standard) var(--portal-motion-ease-out),
    visibility 0s linear var(--portal-motion-standard);
}

html[data-portal-interactions="v1"] .portal-chat .portal-chat-launcher {
  display: flex !important;
  opacity: 1;
  visibility: visible;
}

html[data-portal-interactions="v1"] .portal-chat-launcher::before {
  content: none !important;
}

html[data-portal-interactions="v1"] .portal-chat-launcher-icon,
html[data-portal-interactions="v1"] .portal-chat-notification-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}

html[data-portal-interactions="v1"] .portal-chat-launcher-icon svg,
html[data-portal-interactions="v1"] .portal-chat-notification-icon svg,
html[data-portal-interactions="v1"] .portal-chat-icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

html[data-portal-interactions="v1"] .portal-chat-notification-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #176da1;
  background: #e2f0f8;
}

html[data-portal-interactions="v1"] .portal-chat .portal-chat-panel {
  position: absolute !important;
  right: 0;
  bottom: 0;
  display: grid !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.985);
}

html[data-portal-interactions="v1"] .portal-chat.open .portal-chat-launcher {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(5px) scale(.985);
}

html[data-portal-interactions="v1"] .portal-chat.open .portal-chat-panel {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition-delay: 0s;
}

html[data-portal-interactions="v1"] .ai-chat {
  transition:
    opacity var(--portal-motion-standard) var(--portal-motion-ease-out),
    transform var(--portal-motion-standard) var(--portal-motion-ease-out),
    visibility 0s linear var(--portal-motion-standard);
}

html[data-portal-interactions="v1"] .ai-chat[hidden] {
  display: grid !important;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px) scale(.985);
}

html[data-portal-interactions="v1"] .ai-chat:not([hidden]) {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  transition-delay: 0s;
}

@keyframes portal-layer-open {
  from { opacity: .88; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}

.portal-interaction-announcer {
  position: fixed !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.portal-sound-quick-toggle {
  position: fixed;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 11950;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(126, 158, 181, .54);
  border-radius: 13px;
  color: #174d70;
  background: rgba(248, 252, 255, .94);
  box-shadow: 0 8px 24px rgba(13, 49, 87, .16);
  backdrop-filter: blur(8px);
  cursor: pointer;
  transition:
    transform var(--portal-motion-fast) var(--portal-motion-ease-out),
    color var(--portal-motion-standard) ease,
    background-color var(--portal-motion-standard) ease;
}

.portal-sound-quick-toggle[hidden] {
  display: none !important;
}

.portal-sound-quick-toggle:hover {
  transform: translateY(-1px);
}

.portal-sound-quick-toggle:active {
  transform: translateY(1px) scale(.97);
}

.portal-sound-quick-toggle.is-muted {
  color: #8b4450;
  background: rgba(255, 246, 247, .96);
  border-color: rgba(176, 104, 115, .48);
}

.portal-sound-quick-toggle svg,
.interface-sound-mute svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.interface-sound-settings {
  display: grid;
  gap: 18px;
  max-width: 720px;
}

.interface-sound-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border: 1px solid #d6e3ec;
  border-radius: 15px;
  background: #f7fbfd;
}

.interface-sound-toggle strong,
.interface-sound-volume strong {
  display: block;
  color: #183b57;
}

.interface-sound-toggle small,
.interface-sound-volume small {
  display: block;
  margin-top: 4px;
  color: #687f90;
  line-height: 1.45;
}

.interface-switch {
  position: relative;
  flex: 0 0 auto;
  width: 50px;
  height: 29px;
}

.interface-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.interface-switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #a9b8c3;
  transition: background-color var(--portal-motion-standard) ease;
}

.interface-switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(15, 45, 67, .22);
  transition: transform var(--portal-motion-standard) var(--portal-motion-ease-out);
}

.interface-switch input:checked + span {
  background: #147d79;
}

.interface-switch input:checked + span::after {
  transform: translateX(21px);
}

.interface-switch input:focus-visible + span {
  outline: 3px solid var(--portal-feedback-focus);
  outline-offset: 3px;
}

.interface-sound-volume {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 18px;
  align-items: center;
}

.interface-sound-volume label {
  min-width: 0;
}

.interface-sound-volume output {
  min-width: 48px;
  color: #174d70;
  font-weight: 800;
  text-align: right;
}

.interface-sound-volume input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 34px;
  accent-color: #147d79;
}

.interface-sound-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.interface-sound-mute {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

@media (max-width: 600px) {
  .portal-sound-quick-toggle {
    width: 46px;
    height: 46px;
  }

  .interface-sound-toggle {
    align-items: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --portal-motion-instant: 1ms;
    --portal-motion-fast: 1ms;
    --portal-motion-standard: 1ms;
    --portal-motion-slow: 1ms;
  }

  ::view-transition-old(root),
  ::view-transition-new(root),
  html[data-portal-interactions="v1"] .portal-content-updating,
  html[data-portal-interactions="v1"] .portal-feedback-success,
  html[data-portal-interactions="v1"] .portal-feedback-context-success,
  html[data-portal-interactions="v1"] .portal-feedback-error,
  html[data-portal-interactions="v1"] .portal-feedback-context-error,
  html[data-portal-interactions="v1"] .portal-feedback-warning,
  html[data-portal-interactions="v1"] .portal-feedback-selection,
  html[data-portal-interactions="v1"] .portal-feedback-notification,
  html[data-portal-interactions="v1"] .portal-chat.open .portal-chat-panel,
  html[data-portal-interactions="v1"] .ai-chat:not([hidden]) {
    animation: none !important;
  }

  html[data-portal-interactions="v1"] :where(*, *::before, *::after) {
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
    transition-delay: 0s !important;
  }

  html[data-portal-interactions="v1"] .portal-interaction-pressing,
  html[data-portal-interactions="v1"] :where(.hub-card,.protocol-card,.reception-list button,.usage-doctor,.manifestation-item,.notification,.telemedicine-row,.public-type):hover {
    transform: none !important;
  }
}

@media (forced-colors: active) {
  .portal-sound-quick-toggle,
  .interface-sound-toggle {
    border: 1px solid CanvasText;
  }

  .interface-switch span {
    border: 1px solid CanvasText;
  }
}


/* Aparência global: escolha claro/escuro em Configurações. */
.interface-theme-settings {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 760px;
  margin-top: 16px;
}
.interface-theme-option {
  position: relative;
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr) 24px;
  align-items: center;
  gap: 14px;
  min-height: 104px;
  padding: 14px;
  border: 1px solid #d4e1ea;
  border-radius: 16px;
  background: #f8fbfd;
  cursor: pointer;
  transition:
    border-color var(--portal-motion-standard) ease,
    background-color var(--portal-motion-standard) ease,
    box-shadow var(--portal-motion-standard) ease,
    transform var(--portal-motion-fast) ease;
}
.interface-theme-option:hover {
  border-color: #9fc5dd;
  transform: translateY(-1px);
}
.interface-theme-option input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.interface-theme-option:has(input:checked) {
  border-color: #2482bd;
  box-shadow: 0 0 0 3px rgba(36, 130, 189, .12);
  background: #f2f9fd;
}
.interface-theme-option:has(input:focus-visible) {
  outline: 3px solid var(--portal-feedback-focus);
  outline-offset: 3px;
}
.interface-theme-preview {
  width: 86px;
  height: 64px;
  display: grid;
  grid-template-columns: 24px 1fr;
  grid-template-rows: 16px 1fr;
  gap: 5px;
  padding: 7px;
  border-radius: 11px;
  border: 1px solid rgba(74, 112, 139, .28);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
}
.interface-theme-preview i {
  display: block;
  border-radius: 4px;
}
.interface-theme-preview i:first-child { grid-column: 1 / -1; }
.interface-theme-preview i:nth-child(2) { grid-row: 2; }
.interface-theme-preview i:nth-child(3) { grid-row: 2; }
.interface-theme-preview.is-light { background: #eef5fa; }
.interface-theme-preview.is-light i:first-child { background: #1769ac; }
.interface-theme-preview.is-light i:nth-child(2) { background: #d7e5ef; }
.interface-theme-preview.is-light i:nth-child(3) { background: #fff; }
.interface-theme-preview.is-dark { background: #091722; border-color: #355166; }
.interface-theme-preview.is-dark i:first-child { background: #1769ac; }
.interface-theme-preview.is-dark i:nth-child(2) { background: #183247; }
.interface-theme-preview.is-dark i:nth-child(3) { background: #102535; }
.interface-theme-copy strong {
  display: block;
  color: #183b57;
  font-size: .94rem;
}
.interface-theme-copy small {
  display: block;
  margin-top: 5px;
  color: #687f90;
  line-height: 1.45;
}
.interface-theme-check {
  width: 20px;
  height: 20px;
  border: 2px solid #a9bdcb;
  border-radius: 50%;
}
.interface-theme-option:has(input:checked) .interface-theme-check {
  border: 6px solid #1675ad;
}

@media (max-width: 650px) {
  .interface-theme-settings { grid-template-columns: 1fr; }
  .interface-theme-option { grid-template-columns: 78px minmax(0, 1fr) 22px; }
  .interface-theme-preview { width: 78px; }
}

@media screen {
  html[data-portal-theme="dark"] {
    color-scheme: dark;
    --portal-navy: #d7ebfa;
    --portal-blue: #58a9ff;
    --portal-cyan: #27c5d4;
    --portal-green: #39c995;
    --portal-bg: #07131e;
    --portal-border: #294456;
    --portal-text: #e5eef5;
    --portal-muted: #9fb2c1;
    --portal-shadow: 0 18px 44px rgba(0, 0, 0, .34);
    --portal-theme-bg: #07131e;
    --portal-theme-bg-soft: #0b1a27;
    --portal-theme-surface: #102332;
    --portal-theme-surface-2: #142a3a;
    --portal-theme-surface-3: #193246;
    --portal-theme-border: #2a465a;
    --portal-theme-text: #e5eef5;
    --portal-theme-muted: #9fb2c1;
    --portal-theme-accent: #68b7ff;
    --portal-theme-input: #0c1e2c;
    --portal-theme-hover: #173247;
    --portal-theme-selected: #183e59;
  }

  html[data-portal-theme="dark"] body {
    background: var(--portal-theme-bg) !important;
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] body.portal-page {
    background:
      radial-gradient(circle at 12% -10%, rgba(28, 112, 171, .18), transparent 32%),
      linear-gradient(180deg, #07131e 0, #0a1824 45%, #07131e 100%) !important;
  }

  html[data-portal-theme="dark"] :where(h1,h2,h3,h4,h5,h6,strong,b,label,legend,summary) {
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] :where(p,small,.portal-muted,.field-help,.section-intro,.user-meta,.result-count) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] a:not(.portal-button):not(.button):not(.social-button) {
    color: #82c4ff;
  }

  html[data-portal-theme="dark"] .portal-topbar {
    background: linear-gradient(115deg, #061d34, #0a3e72 64%, #07547d) !important;
    border-bottom-color: #1594a4 !important;
    box-shadow: 0 8px 28px rgba(0,0,0,.34) !important;
  }

  html[data-portal-theme="dark"] .portal-topbar :where(h1,p,strong,span,a),
  html[data-portal-theme="dark"] .site-header :where(h1,p,strong,span,a),
  html[data-portal-theme="dark"] .login-visual :where(h1,p,strong,span,a) {
    color: #f4f9fc !important;
  }

  html[data-portal-theme="dark"] :where(
    .portal-hero,
    .portal-section,
    .hub-card,
    .login-card,
    .account-card,
    .account-section-hero,
    .account-section-summary,
    .social-card,
    .social-dialog,
    .social-global-user-search-results,
    .documents-browser,
    .documents-viewer,
    .documents-advanced-search-dialog,
    .documents-editor-panel,
    .agenda-hero,
    .agenda-stat,
    .agenda-card,
    .agenda-help,
    .agenda-sync-bridge .portal-section,
    .telemedicine-hero,
    .telemedicine-stat,
    .telemedicine-row,
    .telemedicine-current,
    .telemedicine-event,
    .telemedicine-preview,
    .telemedicine-modal,
    .portal-modal,
    .reception-sidebar,
    .reception-detail,
    .reception-group,
    .reception-item,
    .reception-summary,
    .overview-card,
    .clinical-section,
    .general-intro-card,
    .model-box,
    .protocol-card,
    .detail-panel,
    .sidebar,
    .panel,
    .status-card,
    .flow-box,
    .content-block,
    .citizen-action,
    .citizen-card,
    .manifestation-item,
    .notification,
    .citizen-modal-panel,
    .manifestation-type-card,
    .privacy-option,
    .selected-file,
    .attachment-link,
    .council-metric,
    .council-box,
    .usage-stat,
    .usage-doctors-panel,
    .usage-detail-panel,
    .usage-doctor,
    .achievement-card,
    .readiness-card,
    .user-row
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,.22);
  }

  html[data-portal-theme="dark"] :where(
    .hub-card,
    .social-card,
    .portal-section,
    .documents-browser,
    .documents-viewer,
    .account-card
  ) {
    background-image: none !important;
  }

  html[data-portal-theme="dark"] :where(
    .portal-section-heading,
    .social-section-heading,
    .social-post-header,
    .citizen-card-head,
    .citizen-modal-head,
    .documents-browser-toolbar,
    .documents-list-heading,
    .documents-viewer-head,
    .documents-advanced-search-head,
    .documents-editor-banner,
    .documents-editor-toolbar,
    .agenda-toolbar,
    .usage-panel-heading,
    .usage-history-toolbar,
    .portal-modal-header,
    .manifestation-form-footer,
    .form-section,
    .council-toolbar
  ) {
    background: var(--portal-theme-surface-2) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    select,
    textarea,
    .portal-search,
    .social-input,
    .social-select,
    .social-textarea,
    .reception-status,
    .council-toolbar input,
    .council-toolbar select,
    .documents-viewer-rename input
  ) {
    background: var(--portal-theme-input) !important;
    color: var(--portal-theme-text) !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] :where(
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
    textarea,
    .portal-search,
    .social-input,
    .social-textarea
  )::placeholder {
    color: #7890a2 !important;
    opacity: 1;
  }

  html[data-portal-theme="dark"] :where(
    .portal-button.secondary,
    .button.secondary,
    .social-button.secondary,
    .documents-search-title-only,
    .documents-advanced-search-trigger,
    .documents-order-trigger,
    .documents-order-reset,
    .documents-crumb,
    .documents-close-viewer,
    .portal-modal-close,
    .citizen-modal-close,
    .social-icon-button,
    .social-page-button,
    .usage-period-tabs button,
    .agenda-stat
  ) {
    background: #142b3b !important;
    color: #dcebf5 !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] :where(
    .portal-button.secondary,
    .button.secondary,
    .social-button.secondary,
    .documents-advanced-search-trigger,
    .documents-order-trigger,
    .documents-order-reset:not(:disabled),
    .documents-crumb,
    .social-page-button,
    .usage-period-tabs button
  ):hover {
    background: #1b3a50 !important;
    border-color: #4d7691 !important;
  }

  html[data-portal-theme="dark"] .portal-button.danger {
    background: #3b1b22 !important;
    color: #ffb8c1 !important;
    border-color: #65303b !important;
  }

  html[data-portal-theme="dark"] :where(
    .portal-hero h2,
    .portal-section-heading h2,
    .portal-section-heading h3,
    .hub-card h3,
    .account-section-hero h1,
    .account-card h2,
    .social-card h1,
    .social-card h2,
    .social-card h3,
    .citizen-card-head h2,
    .citizen-modal-head h2,
    .form-section-head h3,
    .detail-title,
    .detail-section-title,
    .council-metric strong,
    .council-box h3,
    .reception-title,
    .reception-group h3,
    .medical-hero h1,
    .detail-title,
    .site-header h1
  ) {
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] :where(
    .hub-card p,
    .portal-hero p,
    .account-section-hero p,
    .account-card > p,
    .account-section-summary span,
    .settings-section-note,
    .social-handle,
    .social-post-meta,
    .social-comment,
    .social-empty,
    .citizen-action > span,
    .manifestation-item small,
    .notification small,
    .form-section-head p,
    .field-footer,
    .privacy-option small,
    .manifestation-type-card small,
    .council-metric span,
    .council-table small,
    .usage-panel-heading p,
    .usage-history-note,
    .agenda-meta,
    .agenda-help-body,
    .telemedicine-filter-summary,
    .overview-label,
    .field-help
  ) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] :where(
    .social-person-row,
    .social-notification,
    .social-comment-bubble,
    .social-post,
    .documents-item-row,
    .documents-item,
    .agenda-list,
    .telemedicine-list,
    .council-table th,
    .council-table td,
    .usage-history-table th,
    .usage-history-table td,
    .user-row
  ) {
    border-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] :where(
    .documents-item,
    .manifestation-item,
    .notification,
    .social-person-row,
    .social-notification,
    .usage-doctor,
    .council-table tbody tr
  ):hover {
    background: var(--portal-theme-hover) !important;
  }

  html[data-portal-theme="dark"] :where(
    .documents-item.selected,
    .usage-doctor.active,
    .social-tab.active,
    .social-page-button.active,
    .agenda-stat.is-active
  ) {
    background: var(--portal-theme-selected) !important;
    border-color: #4d88ad !important;
  }

  html[data-portal-theme="dark"] .documents-item-row {
    background: var(--portal-theme-surface) !important;
    border-bottom-color: #203a4d !important;
  }
  html[data-portal-theme="dark"] .documents-item-row.pdf:has(.documents-item.selected),
  html[data-portal-theme="dark"] .documents-item-row.folder:has(.documents-item.selected) {
    background: #132f43 !important;
  }
  html[data-portal-theme="dark"] .documents-item-copy strong {
    color: #dcebf5 !important;
  }
  html[data-portal-theme="dark"] .documents-item-copy span {
    color: #91a8b8 !important;
  }
  html[data-portal-theme="dark"] .documents-item-icon {
    background: #1b3547 !important;
    border-color: #36556b !important;
  }
  html[data-portal-theme="dark"] .documents-pdf-thumbnails,
  html[data-portal-theme="dark"] .documents-pdf-toolbar,
  html[data-portal-theme="dark"] .documents-editor-side-rail,
  html[data-portal-theme="dark"] .documents-pdf-scroll,
  html[data-portal-theme="dark"] .documents-custom-viewer {
    background: #081722 !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] .portal-pdf-thumb-wrap,
  html[data-portal-theme="dark"] .portal-pdf-thumb-actions,
  html[data-portal-theme="dark"] .documents-sync-option,
  html[data-portal-theme="dark"] .documents-editor-field {
    background: #102637 !important;
    border-color: #2e4b60 !important;
    color: var(--portal-theme-text) !important;
  }
  html[data-portal-theme="dark"] .portal-pdf-page {
    background: #fff !important;
    color-scheme: light;
  }

  html[data-portal-theme="dark"] :where(
    .social-global-nav,
    .social-mobile-nav,
    .social-side-links,
    .social-global-user-search-box,
    .social-global-user-search-results,
    .portal-chat-panel,
    .portal-chat-header,
    .portal-chat-composer
  ) {
    background: #0f2231 !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] .social-nav-link,
  html[data-portal-theme="dark"] .social-mobile-nav-link {
    color: #b7cad7 !important;
  }
  html[data-portal-theme="dark"] .social-nav-link.active,
  html[data-portal-theme="dark"] .social-mobile-nav-link.active {
    color: #7fc5ff !important;
    background: #15364d !important;
  }
  html[data-portal-theme="dark"] .social-mini-cover,
  html[data-portal-theme="dark"] .social-profile-cover {
    filter: saturate(.82) brightness(.78);
  }

  html[data-portal-theme="dark"] :where(
    .telemedicine-toolbar,
    .telemedicine-current-grid,
    .telemedicine-date-block,
    .telemedicine-specialty-block,
    .telemedicine-form-grid,
    .telemedicine-followup-fields,
    .reception-controls,
    .reception-items,
    .clinical-overview,
    .content-grid
  ) {
    background: transparent !important;
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] :where(
    .telemedicine-row,
    .agenda-card,
    .reception-item,
    .protocol-card,
    .manifestation-type-card,
    .privacy-option
  ):hover {
    background: #173247 !important;
  }

  html[data-portal-theme="dark"] .agenda-card.is-read {
    border-color: #356a60 !important;
  }
  html[data-portal-theme="dark"] .agenda-card.is-unread {
    background: #102d40 !important;
    border-color: #3181ae !important;
  }
  html[data-portal-theme="dark"] .agenda-card.is-inactive {
    opacity: .72;
  }

  html[data-portal-theme="dark"] :where(
    .portal-note.info,
    .account-status.info,
    .login-status.info,
    .privacy-summary,
    .documents-presence-notice
  ) {
    background: #112f43 !important;
    color: #b9dff6 !important;
    border-color: #285978 !important;
  }
  html[data-portal-theme="dark"] :where(
    .portal-note.warning,
    .account-status.warning,
    .form-alert,
    .internal-note,
    .reception-scope-note
  ) {
    background: #362b12 !important;
    color: #f2d58a !important;
    border-color: #65501f !important;
  }
  html[data-portal-theme="dark"] :where(
    .portal-note.success,
    .account-status.success,
    .status-chip.concluida
  ) {
    background: #123329 !important;
    color: #9be0c4 !important;
    border-color: #285c4b !important;
  }
  html[data-portal-theme="dark"] :where(
    .account-status.error,
    .login-status.error,
    .portal-note.error
  ) {
    background: #3a1c24 !important;
    color: #ffb7c0 !important;
    border-color: #6e3542 !important;
  }

  html[data-portal-theme="dark"] .interface-theme-option {
    background: #102332;
    border-color: #2a465a;
  }
  html[data-portal-theme="dark"] .interface-theme-option:hover,
  html[data-portal-theme="dark"] .interface-theme-option:has(input:checked) {
    background: #163247;
    border-color: #4f85a7;
  }
  html[data-portal-theme="dark"] .interface-theme-copy strong,
  html[data-portal-theme="dark"] .interface-sound-toggle strong,
  html[data-portal-theme="dark"] .interface-sound-volume strong {
    color: var(--portal-theme-text);
  }
  html[data-portal-theme="dark"] .interface-theme-copy small,
  html[data-portal-theme="dark"] .interface-sound-toggle small,
  html[data-portal-theme="dark"] .interface-sound-volume small {
    color: var(--portal-theme-muted);
  }
  html[data-portal-theme="dark"] .interface-sound-toggle {
    background: #102332;
    border-color: #2a465a;
  }
  html[data-portal-theme="dark"] .interface-sound-volume output {
    color: #8ecbff;
  }
  html[data-portal-theme="dark"] .portal-sound-quick-toggle {
    color: #c8e5f7;
    background: rgba(13, 32, 46, .96);
    border-color: #355469;
    box-shadow: 0 8px 24px rgba(0,0,0,.32);
  }
  html[data-portal-theme="dark"] .portal-sound-quick-toggle.is-muted {
    color: #ffbac2;
    background: rgba(55, 27, 34, .96);
    border-color: #6a3944;
  }

  html[data-portal-theme="dark"] .login-panel {
    background: #07131e !important;
  }
  html[data-portal-theme="dark"] .login-card {
    background: #102332 !important;
  }

  html[data-portal-theme="dark"] .site-header {
    background: #0b1e2c !important;
    border-color: #294456 !important;
  }
  html[data-portal-theme="dark"] :where(.top-nav,.sidebar-heading,.detail-header,.action-bar,.status-strip) {
    border-color: #294456 !important;
  }
  html[data-portal-theme="dark"] :where(.protocol-card.active,.protocol-card[aria-current="true"]) {
    background: #183e59 !important;
    border-color: #4d88ad !important;
  }

  html[data-portal-theme="dark"] :where(
    .council-table,
    .usage-history-table
  ) {
    color: var(--portal-theme-text) !important;
  }
  html[data-portal-theme="dark"] :where(
    .council-table tbody tr:hover,
    .usage-history-table tbody tr:hover
  ) {
    background: #173247 !important;
  }

  html[data-portal-theme="dark"] ::selection {
    background: #2b78a8;
    color: #fff;
  }

  html[data-portal-theme="dark"] :where(
    hr,
    .timeline,
    .portal-section-heading,
    .social-card,
    .account-card
  ) {
    border-color: var(--portal-theme-border) !important;
  }
}

@media print {
  html[data-portal-theme="dark"] {
    color-scheme: light;
  }
}


/* Cobertura complementar dos módulos legados no modo escuro. */
@media screen {
  html[data-portal-theme="dark"] :where(
    .public-council,
    .public-type,
    .readiness-item,
    .general-rule,
    .notice,
    .alert,
    .clinical-alert,
    .check-item,
    .metadata-item,
    .sources,
    .model-text,
    .social-post,
    .social-comment-bubble,
    .social-person-row,
    .social-notification,
    .file-drop,
    .selected-file,
    .thread-message,
    .documents-advanced-search-note,
    .documents-sync-panel,
    .documents-editor-panel,
    .usage-history-table-wrap,
    .site-footer
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] :where(
    .public-council,
    .citizen-modal-content,
    .documents-list,
    .usage-main,
    .agenda-main,
    .telemedicine-main,
    .reception-layout,
    .clinical-overview
  ) {
    background-color: var(--portal-theme-bg) !important;
  }

  html[data-portal-theme="dark"] .public-council {
    background-image:
      radial-gradient(circle at 15% 0, rgba(27, 111, 169, .18), transparent 32%),
      linear-gradient(180deg, #07131e, #0a1824 60%, #07131e) !important;
  }

  html[data-portal-theme="dark"] :where(
    .readiness-secret,
    .status-chip,
    .privacy-chip,
    .reception-badge,
    .telemedicine-status,
    .telemedicine-capacity-chip,
    .agenda-status-chip,
    .agenda-capacity-chip,
    .social-professional-badge,
    .user-badge
  ) {
    border-color: #385469 !important;
  }

  html[data-portal-theme="dark"] .readiness-secret {
    background: #183044 !important;
    color: #b9d8ee !important;
  }
  html[data-portal-theme="dark"] .readiness-summary.ready {
    background: #123329 !important;
    border-color: #285c4b !important;
    color: #9be0c4 !important;
  }
  html[data-portal-theme="dark"] .readiness-summary.pending {
    background: #362b12 !important;
    border-color: #65501f !important;
    color: #f2d58a !important;
  }

  html[data-portal-theme="dark"] .form-alert--neutral {
    background: #132837 !important;
    border-color: #2b485b !important;
    color: #b2c5d3 !important;
  }
  html[data-portal-theme="dark"] .privacy-summary {
    background: #112f43 !important;
  }
  html[data-portal-theme="dark"] .thread-message {
    background: #162b3a !important;
  }
  html[data-portal-theme="dark"] .thread-message.council {
    background: #173a53 !important;
  }

  html[data-portal-theme="dark"] .reception-status[data-state="ok"] {
    background: #123329 !important;
    color: #9be0c4 !important;
    border-color: #285c4b !important;
  }
  html[data-portal-theme="dark"] .reception-status[data-state="missing"] {
    background: #3a1c24 !important;
    color: #ffb7c0 !important;
    border-color: #6e3542 !important;
  }

  html[data-portal-theme="dark"] :where(
    .telemedicine-status.solicitar,
    .telemedicine-status.em-aguardo,
    .telemedicine-status.sem-programacao,
    .telemedicine-status.solicitado,
    .status-chip.recebida,
    .status-chip.em_analise,
    .status-chip.encaminhada,
    .status-chip.aguardando_retorno,
    .status-chip.aguardando_cidadao
  ) {
    background: #26331b !important;
    color: #e6d68a !important;
  }
  html[data-portal-theme="dark"] :where(
    .telemedicine-status.concluido,
    .status-chip.concluida,
    .privacy-chip.identified
  ) {
    background: #123329 !important;
    color: #9be0c4 !important;
  }
  html[data-portal-theme="dark"] :where(
    .telemedicine-status.atrasado,
    .agenda-capacity-chip.is-critical
  ) {
    background: #3a1c24 !important;
    color: #ffb7c0 !important;
  }

  html[data-portal-theme="dark"] .documents-advanced-search-note {
    background: #0d2231 !important;
    color: #9fb5c5 !important;
    border-color: #29485e !important;
  }
  html[data-portal-theme="dark"] :where(.documents-loading,.documents-empty,.agenda-empty,.telemedicine-empty,.reception-empty,.usage-empty-state) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] :where(
    .portal-modal,
    .citizen-modal-panel,
    .social-dialog,
    .documents-advanced-search-dialog
  ) {
    color-scheme: dark;
  }

  html[data-portal-theme="dark"] .site-footer {
    border-top-color: #294456 !important;
  }
}

/* Modo escuro — cobertura geral após homologação visual de 23/09/2026.
   Mantém o modo claro como baseline e corrige somente superfícies legadas que
   ainda traziam fundos claros em Perfil, Conquistas, Recepção, Telemedicina e
   Guia Médico/assistente. Regras restritas a screen para preservar impressão. */
@media screen {
  /* Perfil social e editor de módulos. */
  html[data-portal-theme="dark"] :where(
    .social-profile-module,
    .social-module-order label
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] .social-profile-module p,
  html[data-portal-theme="dark"] .social-module-order-row {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] .social-chip {
    background: #183247 !important;
    color: #c4dfef !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] .social-profile-actions .social-button.secondary,
  html[data-portal-theme="dark"] .social-module-order-row .social-button.secondary {
    background: #142b3b !important;
    color: #dcebf5 !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] .social-profile-actions .social-button.secondary:hover,
  html[data-portal-theme="dark"] .social-module-order-row .social-button.secondary:hover {
    background: #1b3a50 !important;
    border-color: #4d7691 !important;
  }

  /* Conquistas e evolução Bronze/Prata/Ouro. */
  html[data-portal-theme="dark"] .account-level-panel {
    background: linear-gradient(135deg, #102332 0%, #0b1a27 100%) !important;
    border-color: var(--portal-theme-border) !important;
    color: var(--portal-theme-text) !important;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .28) !important;
  }

  html[data-portal-theme="dark"] :where(
    .account-level-head,
    .account-level-track,
    .account-level-next,
    .account-level-unlocks,
    .account-achievement
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] .account-level-track {
    background: #0d1f2d !important;
  }

  html[data-portal-theme="dark"] .account-level-track::before {
    background: #3a5366 !important;
  }

  html[data-portal-theme="dark"] .account-level-medal {
    background: #183044 !important;
    border-color: #4f6e83 !important;
    color: #e7f1f7 !important;
    box-shadow: 0 0 0 5px #0d1f2d !important;
  }

  html[data-portal-theme="dark"] :where(
    .account-level-head p,
    .account-level-step span,
    .account-level-next p,
    .account-level-unlocks p,
    .account-level-unlock,
    .account-achievement span,
    .account-level-footnote
  ) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] :where(
    .account-level-step strong,
    .account-level-next h3,
    .account-level-unlocks h3,
    .account-achievement strong
  ) {
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] .account-level-current {
    background: #182a38 !important;
    border-color: #3c5668 !important;
    color: #dbe9f2 !important;
  }
  html[data-portal-theme="dark"] .account-level-current.bronze {
    background: #34261d !important;
    border-color: #6f5038 !important;
    color: #f0c49d !important;
  }
  html[data-portal-theme="dark"] .account-level-current.prata {
    background: #222d36 !important;
    border-color: #506272 !important;
    color: #d5e0e8 !important;
  }
  html[data-portal-theme="dark"] .account-level-current.ouro {
    background: #342f16 !important;
    border-color: #6b5f28 !important;
    color: #f0dd83 !important;
  }

  html[data-portal-theme="dark"] .account-level-step.locked {
    opacity: .74;
  }

  /* Recepção: lista lateral de especialidades/exames. */
  html[data-portal-theme="dark"] .reception-list button {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: none !important;
  }

  html[data-portal-theme="dark"] .reception-list button:hover,
  html[data-portal-theme="dark"] .reception-list button.active,
  html[data-portal-theme="dark"] .reception-list button:focus-visible {
    background: var(--portal-theme-selected) !important;
    border-color: #4d88ad !important;
  }

  html[data-portal-theme="dark"] .reception-list span {
    color: var(--portal-theme-muted) !important;
  }

  /* Guia Médico: hero, etapas, protocolo, aplicação prática e conferência final. */
  html[data-portal-theme="dark"] :where(
    .hero,
    .medical-hero,
    .hero-step,
    .overview-card,
    .clinical-section,
    .check-item,
    .metadata-item,
    .general-intro-card,
    .official-protocol-heading,
    .practical-ai-card,
    .final-clinical-check,
    .learning-note
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .20) !important;
  }

  html[data-portal-theme="dark"] .hero,
  html[data-portal-theme="dark"] .medical-hero {
    background:
      radial-gradient(circle at 100% 0%, rgba(39, 197, 212, .09), transparent 24rem),
      linear-gradient(135deg, #102332 0%, #0b1a27 100%) !important;
    border-left-color: #27c5d4 !important;
  }

  html[data-portal-theme="dark"] .hero::after {
    border-color: rgba(104, 183, 255, .10) !important;
    box-shadow:
      0 0 0 35px rgba(39, 197, 212, .025),
      0 0 0 70px rgba(104, 183, 255, .018) !important;
  }

  html[data-portal-theme="dark"] :where(
    .hero-step,
    .check-item,
    .metadata-item,
    .general-intro-card
  ) {
    background: #142a3a !important;
    box-shadow: none !important;
  }

  html[data-portal-theme="dark"] :where(
    .hero-step,
    .overview-value,
    .metadata-value,
    .general-intro-card strong,
    .official-protocol-title h3,
    .practical-ai-copy strong
  ) {
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] :where(
    .field-help,
    .section-intro,
    .metadata-label,
    .general-intro-card span,
    .official-protocol-heading > p,
    .practical-ai-copy p,
    .learning-note
  ) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] .official-protocol-heading {
    background: linear-gradient(135deg, #13293a, #0f2231) !important;
    border-left-color: #68b7ff !important;
  }

  html[data-portal-theme="dark"] .official-protocol-title small,
  html[data-portal-theme="dark"] .practical-ai-copy small {
    color: #75c9d2 !important;
  }

  html[data-portal-theme="dark"] .official-protocol-nav a,
  html[data-portal-theme="dark"] .practical-ai-actions button {
    background: #142b3b !important;
    color: #cfe6f5 !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] .official-protocol-nav a:hover,
  html[data-portal-theme="dark"] .practical-ai-actions button:hover {
    background: #1b3a50 !important;
    border-color: #4d7691 !important;
  }

  html[data-portal-theme="dark"] .practical-ai-card {
    background: linear-gradient(115deg, #18233a, #122b3b 55%, #12312e) !important;
    border-color: #3f506f !important;
  }

  html[data-portal-theme="dark"] .final-clinical-check {
    background: #0f2231 !important;
  }

  html[data-portal-theme="dark"] .final-clinical-check::before {
    background: #1a3142 !important;
    color: #b7c9d6 !important;
  }

  html[data-portal-theme="dark"] .clinical-alert {
    background: #352816 !important;
    color: #f2d58a !important;
    border-color: #65501f !important;
    border-left-color: #a97d25 !important;
  }

  html[data-portal-theme="dark"] .clinical-alert :where(h3, li) {
    color: #f2d58a !important;
  }

  /* Assistente de pré-regulação/Gemini: tema escuro real sem perder identidade. */
  html[data-portal-theme="dark"] .ai-launcher {
    background: rgba(16, 35, 50, .98) !important;
    color: #e5eef5 !important;
    border-color: #355469 !important;
    box-shadow: 0 16px 38px rgba(0, 0, 0, .34) !important;
  }

  html[data-portal-theme="dark"] .ai-launcher:hover {
    background: #173247 !important;
    color: #fff !important;
  }

  html[data-portal-theme="dark"] .ai-gemini-launcher-logo {
    background: #102332 !important;
  }

  html[data-portal-theme="dark"] .ai-chat {
    background: #0b1a27 !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: 0 26px 70px rgba(0, 0, 0, .44) !important;
  }

  html[data-portal-theme="dark"] .ai-chat-header {
    background:
      radial-gradient(circle at 12% 15%, rgba(249, 171, 0, .09), transparent 31%),
      radial-gradient(circle at 90% 12%, rgba(155, 114, 203, .14), transparent 34%),
      linear-gradient(135deg, #13293a 0%, #18243a 56%, #211d38 100%) !important;
    color: var(--portal-theme-text) !important;
    border-bottom-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] .ai-chat-title h2 {
    color: #edf5fa !important;
  }

  html[data-portal-theme="dark"] :where(
    .ai-chat-title p,
    .ai-provider-status,
    .ai-provider-label,
    .ai-suggestions-label,
    .ai-form-footer,
    .ai-input-label
  ) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] .ai-close {
    background: #193246 !important;
    color: #dcebf5 !important;
  }

  html[data-portal-theme="dark"] .ai-close:hover {
    background: #21445e !important;
  }

  html[data-portal-theme="dark"] .ai-privacy-note {
    background: #352816 !important;
    color: #f2d58a !important;
    border-bottom-color: #65501f !important;
  }

  html[data-portal-theme="dark"] .ai-mode,
  html[data-portal-theme="dark"] .ai-mode.ai-protocol-seal {
    background: #173247 !important;
    color: #b9dff6 !important;
    border-color: #285978 !important;
    box-shadow: none !important;
  }

  html[data-portal-theme="dark"] .ai-messages {
    background:
      radial-gradient(circle at 100% 0, rgba(155, 114, 203, .05), transparent 34%),
      linear-gradient(180deg, #081722, #0b1a27) !important;
  }

  html[data-portal-theme="dark"] .ai-message.assistant {
    background: #142a3a !important;
    color: var(--portal-theme-text) !important;
    border-color: #29485e !important;
    border-left-color: #5f93bf !important;
    box-shadow: 0 7px 18px rgba(0, 0, 0, .18) !important;
  }

  html[data-portal-theme="dark"] .ai-message.loading {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] .ai-suggestion {
    background: #112a3e !important;
    color: #c9e6fa !important;
    border-color: #315b78 !important;
  }

  html[data-portal-theme="dark"] .ai-suggestion:hover {
    background: #173b55 !important;
  }

  html[data-portal-theme="dark"] .ai-form {
    background: #0f2231 !important;
    border-top-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] .ai-input {
    background: var(--portal-theme-input) !important;
    color: var(--portal-theme-text) !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] .ai-input::placeholder {
    color: #7890a2 !important;
  }

  html[data-portal-theme="dark"] .ai-message-rich h3,
  html[data-portal-theme="dark"] .ai-message-rich strong {
    color: #c9e6fa !important;
  }

  /* Telemedicina: regras com especificidade maior que os estilos legados V12/V16. */
  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-today {
    background: linear-gradient(145deg, #12313a 0%, #102a36 100%) !important;
    color: var(--portal-theme-text) !important;
    border-color: #396270 !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .22) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-today :where(span,strong,small) {
    color: inherit !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-stat {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .18) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-stat.urgent {
    background: linear-gradient(145deg, #342b16, #282313) !important;
    border-color: #65501f !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-stat.danger {
    background: linear-gradient(145deg, #351c24, #2a1820) !important;
    border-color: #6e3542 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-stat.waiting {
    background: linear-gradient(145deg, #12312e, #102725) !important;
    border-color: #285c4b !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-stat.review {
    background: linear-gradient(145deg, #182735, #13212e) !important;
    border-color: #3a5366 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-stat :where(span,strong,small) {
    color: inherit !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-workspace {
    background: linear-gradient(180deg, #0d1f2d 0%, #091822 100%) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: 0 12px 32px rgba(0, 0, 0, .24) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-toolbar {
    background: #102332 !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: none !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page :where(
    .telemedicine-search-wrap .portal-search,
    .telemedicine-toolbar-actions select
  ) {
    background: var(--portal-theme-input) !important;
    color: var(--portal-theme-text) !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-search-wrap label {
    color: #c7d8e4 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-view-switch {
    background: #0d2231 !important;
    border-color: #315069 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-view-switch button {
    background: transparent !important;
    color: #b8cbd8 !important;
    border-color: transparent !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-view-switch button:hover {
    background: #142f42 !important;
    color: #e5eef5 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-view-switch button[aria-pressed="true"] {
    background: var(--portal-theme-selected) !important;
    color: #eef7fc !important;
    border-color: #4d88ad !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .20) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-filter-summary {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-list {
    background: transparent !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-row {
    background: linear-gradient(180deg, #102332, #0d1f2d) !important;
    color: var(--portal-theme-text) !important;
    box-shadow: 0 7px 20px rgba(0, 0, 0, .20) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-row > :where(
    .telemedicine-patient,
    .telemedicine-specialty-block,
    .telemedicine-date-block,
    .telemedicine-actions
  ) {
    background: #142a3a !important;
    color: var(--portal-theme-text) !important;
    border-color: #315069 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page :where(
    .telemedicine-patient > button[data-action="patient"],
    .telemedicine-specialty-block strong,
    .telemedicine-date-block strong
  ) {
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page :where(
    .telemedicine-patient small,
    .telemedicine-specialty-block small,
    .telemedicine-date-block small
  ) {
    color: var(--portal-theme-muted) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-actions .portal-button.secondary {
    background: #142b3b !important;
    color: #dcebf5 !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-actions .portal-button.secondary:hover {
    background: #1b3a50 !important;
    border-color: #4d7691 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-empty {
    background: #102332 !important;
    color: var(--portal-theme-muted) !important;
    border-color: #355469 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page :where(
    .telemedicine-modal,
    .telemedicine-form-grid,
    .telemedicine-followup-fields,
    .telemedicine-current,
    .telemedicine-timeline
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .portal-modal-header {
    background: #142a3a !important;
    color: var(--portal-theme-text) !important;
    border-bottom-color: var(--portal-theme-border) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-current-grid div:not(.tm-history-current-card):not(.tm-history-current-card-top) {
    background: #0f2231 !important;
    color: var(--portal-theme-text) !important;
    border-color: #315069 !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-form-grid :where(input,select,textarea) {
    background: var(--portal-theme-input) !important;
    color: var(--portal-theme-text) !important;
    border-color: #355469 !important;
  }
}

/* Auditoria transversal: complementos do chrome, somente em tela escura.
   Tokens locais vencem a cascata legada sem modificar regras de layout. */
@media screen {
  html[data-portal-theme="dark"] body {
    --social-ink: #e5eef5;
    --social-muted: #9fb2c1;
    --social-line: #2a465a;
    --social-card: #102332;
  }

  html[data-portal-theme="dark"] .social-notification-panel,
  html[data-portal-theme="dark"] .social-notification-panel-footer a,
  html[data-portal-theme="dark"] .social-report-target,
  html[data-portal-theme="dark"] .citizen-card-body,
  html[data-portal-theme="dark"] .council-delete-toolbar {
    background: var(--portal-theme-surface);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .22);
  }
  html[data-portal-theme="dark"] .social-notification-panel-heading,
  html[data-portal-theme="dark"] .social-notification-panel-footer {
    background: var(--portal-theme-surface-2);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .social-notification-panel-read,
  html[data-portal-theme="dark"] .social-notification-trigger[aria-expanded="true"],
  html[data-portal-theme="dark"] .social-global-user-search-result:hover,
  html[data-portal-theme="dark"] .agenda-card-actions :is(a, button),
  html[data-portal-theme="dark"] .agenda-stat-icon,
  html[data-portal-theme="dark"] .agenda-sync-state,
  html[data-portal-theme="dark"] .agenda-status-chip {
    background: var(--portal-theme-surface-2);
    color: #c9e6fa;
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .social-notification-panel-read:hover,
  html[data-portal-theme="dark"] .social-notification-panel-footer a:hover,
  html[data-portal-theme="dark"] .agenda-card-actions :is(a, button):hover {
    background: var(--portal-theme-hover);
    border-color: #4d7691;
  }
  html[data-portal-theme="dark"] .social-skeleton {
    background: var(--portal-theme-surface-2);
  }
  html[data-portal-theme="dark"] .social-skeleton::after {
    background: linear-gradient(90deg, transparent, rgba(159, 178, 193, .12), transparent);
  }
  html[data-portal-theme="dark"] :is(.social-status.info, .agenda-status) {
    background: #112f43;
    color: #b9dff6;
    border-color: #285978;
  }
  html[data-portal-theme="dark"] :is(.social-status.success, .social-notification-panel-status.success, .agenda-status.success) {
    background: #123329;
    color: #9be0c4;
    border-color: #285c4b;
  }
  html[data-portal-theme="dark"] :is(.social-status.error, .social-notification-panel-status.error, .agenda-status.error, .social-button.danger, .agenda-capacity-alert) {
    background: #3a1c24;
    color: #ffb7c0;
    border-color: #6e3542;
  }
  html[data-portal-theme="dark"] .agenda-capacity-chip.is-full {
    background: #362b12;
    color: #f2d58a;
    border-color: #65501f;
  }
  html[data-portal-theme="dark"] .agenda-card mark {
    background: #5b461a;
    color: #ffe6a2;
  }
  html[data-portal-theme="dark"] .privacy-chip.confidential {
    background: #2c2442;
    color: #d8c6ff;
    border-color: #5c497c;
  }

  /* Estes estilos são inseridos por JS após a folha global. A especificidade
     inclui o escopo original; !important só enfrenta declarações já importantes. */
  html[data-portal-theme="dark"] body.mobile-login-mode .login-panel {
    background: var(--portal-theme-bg) !important;
  }
  html[data-portal-theme="dark"] body.mobile-login-mode .login-status.error {
    background: #3a1c24 !important;
    color: #ffb7c0 !important;
    border-color: #6e3542 !important;
    box-shadow: 0 7px 18px rgba(0, 0, 0, .2) !important;
  }
  html[data-portal-theme="dark"] body.mobile-login-mode .login-status.info {
    background: #112f43 !important;
    color: #b9dff6 !important;
    border-color: #285978 !important;
  }
  html[data-portal-theme="dark"] body.first-access-mode {
    background: var(--portal-theme-bg) !important;
  }
  html[data-portal-theme="dark"] body.first-access-mode .first-access-input-shell input {
    background: var(--portal-theme-input) !important;
    color: var(--portal-theme-text);
    border-color: #355469 !important;
  }
  html[data-portal-theme="dark"] body.first-access-mode :is(.first-access-password-card, .first-access-password-toggle, .first-access-password-check) {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] body.first-access-mode #firstAccessNotice {
    background: #112f43;
    color: #b9dff6;
    border-color: #285978;
  }
  html[data-portal-theme="dark"] #praiseRecipientDialog :is(.praise-dialog, .cancel, .praise-suggestion) {
    background: var(--portal-theme-surface);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }

  /* V19 define tokens no próprio card; redefini-los aqui alcança lista, grade,
     estados e seus subblocos, inclusive regras antigas com !important. */
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] .telemedicine-row:not(.is-discharge-achievement) {
    --tm-card-zone: #142a3a;
    --tm-card-zone-strong: #193246;
    --tm-card-border: #355469;
    --tm-card-title: #e5eef5;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] .telemedicine-filter-summary {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-muted) !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-card-hierarchy="v37"] .telemedicine-row:not(.is-discharge-achievement) :is(.telemedicine-zone-label, .telemedicine-reminders-label, .telemedicine-patient > small, .telemedicine-specialty-block small) {
    color: var(--portal-theme-muted) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-card-hierarchy="v37"] .telemedicine-row:not(.is-discharge-achievement) .telemedicine-date-block > strong {
    background: var(--portal-theme-surface);
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border);
  }

  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-row:not(.is-discharge-achievement) .telemedicine-specialty-block strong {
    color: var(--portal-theme-text) !important;
  }

  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] :is(.telemedicine-reminder-chip, .telemedicine-reminder-empty) {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] .telemedicine-row[data-status="solicitar"]:not(.is-discharge-achievement) .telemedicine-reminder-number {
    color: #0a0a05;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] .telemedicine-status.solicitar {
    background: #362b12 !important;
    color: #f2d58a !important;
    border-color: #65501f !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] :is(.telemedicine-status.atrasado, .telemedicine-alert-marker) {
    background: #3a1c24 !important;
    color: #ffb7c0 !important;
    border-color: #6e3542 !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] :is(.telemedicine-status.em-aguardo, .telemedicine-status.concluido):not(.is-achievement-status) {
    background: #123329 !important;
    color: #9be0c4 !important;
    border-color: #285c4b !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page[data-followup-cards="v19"] :is(.telemedicine-status.solicitado, .telemedicine-status.sem-programacao) {
    background: #112f43 !important;
    color: #b9dff6 !important;
    border-color: #285978 !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page .portal-modal-close {
    background-color: var(--portal-theme-surface-2) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page .portal-modal-close:is(:hover, :focus-visible) {
    background-color: var(--portal-theme-hover) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page #telemedicineSearch {
    background: var(--portal-theme-input) !important;
    color: var(--portal-theme-text) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 :is(
    .tm-inline-panel, .tm-inline-consultation, .tm-inline-form, .tm-inline-preview,
    .tm-inline-panel-head, .tm-inline-close, [data-tm-scheduled-field], [data-tm-active-field],
    .tm-inline-current, .tm-inline-event
  ) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
    box-shadow: none !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-choice {
    background: linear-gradient(145deg, var(--portal-theme-surface), var(--portal-theme-surface-2));
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-choice:has(input:checked) {
    background: var(--portal-theme-selected);
    border-color: #68b7ff;
    box-shadow: 0 0 0 2px rgba(104, 183, 255, .2);
  }
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 :is(
    .telemedicine-choice strong, .tm-inline-panel-head strong, .tm-inline-form > label
  ) {
    color: var(--portal-theme-text) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 :is(
    .telemedicine-choice small, .tm-inline-panel-head span, .tm-inline-form label small
  ) {
    color: var(--portal-theme-muted) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page :is(#consultScheduledFields, .telemedicine-notes-field) {
    background: var(--portal-theme-surface-2) !important;
    border-color: var(--portal-theme-border);
  }

  html[data-portal-theme="dark"] :is(.public-card, .public-type-icon, .hub-card-icon, .hub-status, .achievement-icon, .achievement-state, .user-badge, .social-professional-badge, .documents-access-chip) {
    background: var(--portal-theme-surface-2);
    color: #c9e6fa;
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] :is(.public-warning, .user-badge.bootstrap, .level-mini-badge.ouro) {
    background: #362b12;
    color: #f2d58a;
    border-color: #65501f;
  }
  html[data-portal-theme="dark"] .level-mini-badge.bronze {
    background: #34291d;
    color: #ecc29c;
    border-color: #715535;
  }
  html[data-portal-theme="dark"] .level-mini-badge.prata {
    background: #243340;
    color: #c9dbe8;
    border-color: #546d80;
  }
  html[data-portal-theme="dark"] .privacy-chip {
    background: #2c2442;
    color: #d8c6ff;
    border-color: #5c497c;
  }
  html[data-portal-theme="dark"] .user-badge.inactive {
    background: #3a1c24;
    color: #ffb7c0;
    border-color: #6e3542;
  }
  html[data-portal-theme="dark"] .achievement-card.unlocked :is(.achievement-icon, .achievement-state) {
    background: #123329;
    color: #9be0c4;
  }
  html[data-portal-theme="dark"] .achievement-card.planned :is(.achievement-icon, .achievement-state) {
    background: #243340;
    color: #b6c7d5;
  }
  html[data-portal-theme="dark"] .achievement-card.current :is(.achievement-icon, .achievement-state) {
    background: #112f43;
    color: #b9dff6;
  }
  html[data-portal-theme="dark"] body :is(.social-nav-link, .social-mobile-nav-link)[aria-current="page"],
  html[data-portal-theme="dark"] .nav-button.active {
    background: var(--portal-theme-selected);
    color: #c9e6fa;
  }
  html[data-portal-theme="dark"] .badge {
    background: #243340;
    color: #b6c7d5;
    border-color: #546d80;
  }
  html[data-portal-theme="dark"] .badge.age {
    background: #112f43;
    color: #b9dff6;
    border-color: #285978;
  }
  html[data-portal-theme="dark"] .badge.telehealth {
    background: #123d3a;
    color: #a7e5db;
    border-color: #2b6a63;
  }
  html[data-portal-theme="dark"] .badge.async {
    background: #2c2442;
    color: #d8c6ff;
    border-color: #5c497c;
  }
  html[data-portal-theme="dark"] .agenda-capacity-patients li {
    background: #30232d;
    color: #ffced3;
    border-color: #6e3542;
  }
  html[data-portal-theme="dark"] :is(input[type="checkbox"], input[type="radio"]) {
    background-color: var(--portal-theme-input);
    accent-color: #68b7ff;
  }
  html[data-portal-theme="dark"] body.mobile-admin-users-mode :is(.portal-hero, .portal-section-heading, .user-row, .user-meta) {
    background: var(--portal-theme-surface) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] :is(#manifestationsCard, #notificationsCard) .citizen-card-body {
    background: var(--portal-theme-surface);
  }
  html[data-portal-theme="dark"] :is(.form-step, .privacy-choice, .privacy-option-icon, .privacy-help-button, .privacy-help-icon, .form-confirm) {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .privacy-help-button:is([aria-expanded="true"], :hover) {
    background: var(--portal-theme-selected);
    color: #c9e6fa;
    border-color: #4d88ad;
  }
  html[data-portal-theme="dark"] .privacy-help-button[data-help] .privacy-help-icon {
    background: var(--portal-theme-hover);
    color: inherit;
  }
  html[data-portal-theme="dark"] :is(.portal-chat-notification-icon, .profile-photo-camera, .profile-photo-dialog-preview) {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .social-notification.judicial .social-avatar {
    background: #44351c;
    color: #ffdfa0;
  }
  html[data-portal-theme="dark"][data-portal-interactions="v1"] .social-action.portal-feedback-selection {
    background: var(--portal-theme-selected);
    color: #c9e6fa;
  }
  html[data-portal-theme="dark"] .interface-switch span {
    background: #364f62;
  }
  html[data-portal-theme="dark"] .interface-switch input:checked + span {
    background: #256d9c;
  }
  html[data-portal-theme="dark"] body.mobile-admin-users-mode .portal-section:nth-of-type(n) .portal-section-heading {
    background: var(--portal-theme-surface) !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] .readiness-mark {
    background: #263b4d;
    color: #cedde8;
  }
  html[data-portal-theme="dark"] .readiness-item.ok .readiness-mark {
    background: #173d32;
    color: #a8ead4;
  }
  html[data-portal-theme="dark"] .readiness-item.blocker .readiness-mark {
    background: #44351c;
    color: #ffdfa0;
  }
  html[data-portal-theme="dark"] #accountLevelBadge.level-mini-badge {
    background: #413226;
    color: #f5d4ab;
    border-color: #795c40;
  }
  html[data-portal-theme="dark"] #accountLevelBadge.level-mini-badge.prata {
    background: #293c4a;
    color: #d2e4ef;
    border-color: #5a7689;
  }
  html[data-portal-theme="dark"] #accountLevelBadge.level-mini-badge.ouro {
    background: #44351c;
    color: #ffdfa0;
    border-color: #86672e;
  }
  html[data-portal-theme="dark"] :is(.usage-individual-stats article, .usage-period-tabs, .usage-history-table th, .usage-history-note) {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] :is(.usage-individual-stats strong, .usage-history-table td) {
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .usage-individual-stats span {
    color: var(--portal-theme-muted);
  }
  html[data-portal-theme="dark"] .usage-presence-large.online {
    background: #173d32;
    color: #a8ead4;
    border-color: #2b6456;
  }
  html[data-portal-theme="dark"] .usage-presence-large.offline {
    background: #263b4d;
    color: #cedde8;
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .official-protocol-section details {
    background: var(--portal-theme-surface-2);
    border-color: var(--portal-theme-border);
    color: var(--portal-theme-text);
  }
  html[data-portal-theme="dark"] body.telemedicine-page .tm-inline-consult-form [data-tm-conditional-field] {
    background: #362b12 !important;
    border-color: #65501f !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page .tm-inline-consult-form [data-tm-absence-field] {
    background: #321c25 !important;
    border-color: #754452 !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page #tmInlineConsultation .telemedicine-outcome-picker legend,
  html[data-portal-theme="dark"] body.telemedicine-page .tm-condition-ready-title {
    color: var(--portal-theme-text) !important;
  }
  html[data-portal-theme="dark"] :is(#consultationModal, #outcomeEditModal) :is(#consultScheduledFields, #outcomeEditScheduled, .tm-outcome-edit-note),
  html[data-portal-theme="dark"] body.telemedicine-page .tm-condition-ready-toggle {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] body.telemedicine-page .telemedicine-mode-panel.conditional {
    background: #352d1e;
    color: #ffdfa0;
    border-color: #725b2e;
  }
  html[data-portal-theme="dark"] body.telemedicine-page :is(.telemedicine-mode-panel.absence, .tm-delete-note) {
    background: #351f2a;
    color: #ffced3;
    border-color: #6e3542;
  }
  /* Desktop dashboard selectors contain IDs and :has(), so match that
     component scope instead of adding !important to its whole subtree. */
  html[data-portal-theme="dark"] body:not(.mobile-citizen-mode) #newManifestationModal :is(.form-step, .privacy-choice, .privacy-option-icon, .form-confirm),
  html[data-portal-theme="dark"] body:not(.mobile-citizen-mode) #newManifestationForm > .form-section:nth-of-type(n) .form-step {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] #newManifestationModal .manifestation-type-card {
    --manifestation-icon-bg: #17384a;
    --manifestation-icon-fg: #b9dff6;
  }
  html[data-portal-theme="dark"] #newManifestationModal .manifestation-type-card:has(input[value="reclamacao"]) {
    --manifestation-icon-bg: #44351c;
    --manifestation-icon-fg: #ffdfa0;
  }
  html[data-portal-theme="dark"] #newManifestationModal .manifestation-type-card:has(input[value="elogio"]) {
    --manifestation-icon-bg: #173d32;
    --manifestation-icon-fg: #a8ead4;
  }
  html[data-portal-theme="dark"] #newManifestationModal .manifestation-type-card:has(input[value="denuncia"]) {
    --manifestation-icon-bg: #3a1c24;
    --manifestation-icon-fg: #ffb7c0;
  }
  html[data-portal-theme="dark"] body:not(.mobile-citizen-mode) #newManifestationModal .manifestation-type-card:has(input[value]) .type-icon {
    background: var(--manifestation-icon-bg);
    color: var(--manifestation-icon-fg);
  }
  html[data-portal-theme="dark"] .social-list-pagination {
    background: var(--portal-theme-surface-2);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] body.mobile-home-mode #toolsFallback :is(.hub-card, .hub-card-arrow) {
    background: var(--portal-theme-surface-2) !important;
    color: var(--portal-theme-text) !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] body:not(.mobile-citizen-mode) #newManifestationModal .privacy-choice-head span,
  html[data-portal-theme="dark"] :is(.manifestation-form-footer span, .file-drop > div > span, #attachmentList > span, #internalNotes > div) {
    color: var(--portal-theme-muted);
  }
  html[data-portal-theme="dark"] :is(.portal-eyebrow, .modal-kicker),
  html[data-portal-theme="dark"] body:not(.mobile-citizen-mode) #newManifestationModal .modal-kicker {
    color: #a1d4ed;
  }
  html[data-portal-theme="dark"] #praiseRecipientDialog #praiseRecipientForm .praise-kicker {
    color: #ffdfa0;
  }
  html[data-portal-theme="dark"] .council-table th {
    color: #c3d4e2;
  }
  html[data-portal-theme="dark"] :is(.reception-group > header, .reception-badge) {
    background: var(--portal-theme-surface-2);
    color: var(--portal-theme-text);
    border-color: var(--portal-theme-border);
  }
  html[data-portal-theme="dark"] .fast-check-mark {
    background: var(--portal-theme-input);
  }
  html[data-portal-theme="dark"] .fast-check input:checked + .fast-check-mark {
    background: #07866f;
    border-color: #29b59d;
  }
  html[data-portal-theme="dark"] .reception-checklist-legend [data-kind="mandatory"] {
    background: #3a1c24;
    color: #ffb7c0;
    border-color: #6e3542;
  }
  html[data-portal-theme="dark"] .reception-checklist-legend [data-kind="conditional"],
  html[data-portal-theme="dark"] .reception-group[data-group="conditional"] > header h3::before {
    background: #44351c;
    color: #ffdfa0;
    border-color: #86672e;
  }
  html[data-portal-theme="dark"] .reception-checklist-legend [data-kind="available"] {
    background: #17384a;
    color: #b9dff6;
    border-color: #36617b;
  }
  html[data-portal-theme="dark"] .reception-item-text {
    color: var(--portal-theme-text);
  }
  html[data-portal-theme="dark"] #receptionSummaryText {
    color: var(--portal-theme-muted);
  }
  html[data-portal-theme="dark"] .reception-kicker {
    color: #9edbdc;
  }
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 .telemedicine-row.tm-inline-open:not(.is-discharge-achievement) {
    background: var(--portal-theme-surface) !important;
    border-color: var(--portal-theme-border) !important;
  }
  /* V29 requires the discharge card to stay gold, including its open mobile
     state; V9's pale generic expansion gradient must not replace that identity. */
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 .telemedicine-row.is-discharge-achievement.tm-inline-open {
    background: var(--tm-card-surface) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 .tm-inline-loading {
    background: var(--portal-theme-surface-2) !important;
    color: var(--portal-theme-muted) !important;
    border-color: var(--portal-theme-border) !important;
  }
  html[data-portal-theme="dark"] body.telemedicine-page.tm-inline-mobile-v9 .tm-inline-status.error {
    background: #351f2a !important;
    color: #ffced3 !important;
    border-color: #6e3542 !important;
  }
}

