/* Tema noturno global. Apenas cores: a estrutura das páginas permanece intacta. */
html[data-theme="dark"] body:is([data-app-shell="internal"], :has(.home-shell)) {
  color-scheme: dark;
  --is-layer-canvas: #101214;
  --is-layer-structure: #171a1d;
  --is-layer-base: #1c2024;
  --is-layer-raised: #252a2f;
  --is-layer-metal: #2a3035;
  --is-bg: #101214;
  --is-page-bg: #101214;
  --is-section-bg: #1c2024;
  --is-section-subtle: #252a2f;
  --is-surface: #1c2024;
  --is-surface-soft: #252a2f;
  --is-surface-strong: #1c2024;
  --is-control-bg: #252a2f;
  --is-control-hover: #30363b;
  --is-control-active: #363e44;
  --is-text: #f5f6f7;
  --is-text-muted: #b7bec4;
  --is-muted: #b7bec4;
  --is-border: #343a40;
  --is-border-strong: #485057;
  --is-divider: #343a40;
  --is-primary: #268bb8;
  --is-primary-strong: #176e98;
  --is-primary-soft: #203847;
  --is-shadow: none;
  --is-ink: #f5f6f7;
  --is-metal-a: #252a2f;
  --is-metal-b: #171a1d;
  --is-galaxy: #101214;
  --bg: #101214;
  --panel: #1c2024;
  --panel-solid: #1c2024;
  --cell: #252a2f;
  --surface: #1c2024;
  --surface-muted: #252a2f;
  --surface-strong: #171a1d;
  --text: #f5f6f7;
  --muted: #b7bec4;
  --line: #343a40;
  --line-strong: #485057;
  --field-bg: #252a2f;
  --field-text: #f5f6f7;
  --field-placeholder: #a9b1b8;
  --field-border: #485057;
  --cad-field-bg: #252a2f;
  --cad-subtle-bg: #1c2024;
  --cad-table-bg: #1c2024;
  background: #101214 !important;
  color: #f5f6f7;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.app-shell-main, .reports-page, .demands-page, .registry-page) {
  background: #101214 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .conference-page {
  --conference-canvas: #101214;
  --conference-structure: #171a1d;
  --conference-panel: #1c2024;
  --conference-panel-raised: #252a2f;
  --conference-panel-muted: #252a2f;
  --conference-subtle: #252a2f;
  --conference-line: #343a40;
  --conference-line-soft: #343a40;
  --conference-text: #f5f6f7;
  --conference-muted: #b7bec4;
  --conference-metal-shadow: none;
  --conference-metal-highlight: none;
  --is-technical-bg: #252a2f;
  --is-control-bg: #252a2f;
  --is-control-hover: #30363b;
  --is-border: #343a40;
  --is-divider: #343a40;
  background: #101214;
}

html[data-theme="dark"] body[data-app-shell="internal"] .conference-page :is(.conference-band, .conference-workspace-switch, .conference-control-dashboard .conference-control-heading, .conference-control-stage-head, .conference-control-map, .conference-control-map-layout, .conference-control-surface) {
  background: #1c2024 !important;
  border-color: #343a40 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .conference-page :is(.conference-workspace-actions .secondary-button, .conference-context-toggle, .conference-workspace-button.is-active) {
  background: #252a2f !important;
  border-color: #485057 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .app-shell-nav {
  border-color: #343a40 !important;
  background: #171a1d !important;
  box-shadow: none !important;
  backdrop-filter: none;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.app-shell-brand .is-brand-lockup__service, .app-shell-more-icon) {
  color: #d4d9dd !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.app-shell-link, .app-shell-more-toggle, .app-shell-account-toggle, .app-shell-route-icon) {
  color: #d4d9dd !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.app-shell-link.is-active, .app-shell-mobile-link.is-active) {
  color: #f5f6f7;
  background: #252a2f;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.app-shell-clock-time, .app-shell-account-avatar, .app-shell-site, .app-shell-site select) {
  color: #f5f6f7;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.is-panel, .is-card, .is-section, .is-page-header, .is-toolbar, .is-modal, .is-drawer) {
  border-color: #343a40;
  background: #1c2024;
  box-shadow: none;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea, .is-input, .is-select, .is-textarea) {
  border-color: #485057 !important;
  background: #252a2f !important;
  color: #f5f6f7 !important;
  color-scheme: dark;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(input, textarea)::placeholder {
  color: #a9b1b8 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(input, select, textarea, button, a):focus-visible {
  outline-color: #54acd3;
}

/* Abas, filtros e tabelas seguem a mesma escala de superfícies. */
html[data-theme="dark"] body[data-app-shell="internal"] :is(.registry-command, .registry-filter-panel, .tool-panel, .registry-controls-panel, .registry-drawer, .report-context-bar, .entry-records-filters, .entry-records-list-panel, .demands-context-bar, .demands-toolbar, .demands-titlebar, .demands-workspace) {
  border-color: #343a40 !important;
  background: #1c2024 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.entry-records-columns, .conference-table thead, .conference-table th, .queue-group h2) {
  border-color: #343a40 !important;
  background: #252a2f !important;
  color: #b7bec4 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.conference-table td, .entry-cycle-row, .demand-row, .entry-records-footer) {
  border-color: #343a40 !important;
  background: #1c2024 !important;
  color: #f5f6f7;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.conference-table tbody tr:nth-child(even) td, .entry-cycle-row:nth-child(even), .demand-row:nth-child(even)) {
  background: #20252a !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.conference-table tbody tr:hover td, .entry-cycle-row:hover, .demand-row:hover) {
  background: #2a3035 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.filter-button, .row-action, .demands-secondary) {
  border-color: #485057 !important;
  background: #252a2f !important;
  color: #f5f6f7 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.filter-button, .row-action, .demands-secondary):hover {
  border-color: #626d75 !important;
  background: #30363b !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.primary-button, .is-button-primary, .demands-primary) {
  border-color: #268bb8 !important;
  background: #268bb8 !important;
  color: #fff !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.registry-command-kicker, .entry-section-kicker, .entry-context-crumb span, .demands-titlebar > div > span, .demands-context-crumb span) {
  color: #b7bec4 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.tag-badge.registry-equipment-tag, .entry-record-identity strong) {
  border-color: #485057 !important;
  background: #252a2f !important;
  color: #f5f6f7 !important;
}

/* Cadastros tinha uma paleta azul própria; a operação selecionada continua visível. */
html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] {
  --registry-night-canvas: #101214;
  --registry-night-surface: #1c2024;
  --registry-night-raised: #252a2f;
  --registry-night-hover: #30363b;
  --registry-night-line: #343a40;
  --registry-night-text: #f5f6f7;
  --registry-night-muted: #b7bec4;
  background: #101214 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] .registry-site-switch {
  border-color: #485057;
  background: #171a1d;
}

html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] .registry-site-switch button.active {
  border-color: #485057;
  background: #30363b;
  color: #f5f6f7;
  box-shadow: none;
}

html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] .registry-toolbar > .tab-buttons .filter-button.active {
  border-color: #268bb8 !important;
  background: #203847 !important;
  color: #f5f6f7 !important;
  box-shadow: inset 0 -2px 0 #268bb8 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] .registry-tab-count {
  background: #30363b;
  color: #d4d9dd;
}

html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] :is(.registry-site-chip, .registry-command-kicker, .registry-section-kicker) {
  border-color: #485057 !important;
  background: #252a2f !important;
  color: #d4d9dd !important;
}

html[data-theme="dark"] body[data-app-shell="internal"][data-cadastros-ui="galaxy"] :is(.registry-tab .section-title, .conference-table td, .registry-controls-panel, .registry-drawer) {
  border-color: #343a40;
  background: #1c2024;
}

/* Registros e Demandas deixam de impor um fundo azul ao restante do aplicativo. */
html[data-theme="dark"] body[data-app-shell="internal"] .app-shell-main:has(.reports-page) {
  background: #101214 !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .reports-page > .report-context-bar {
  border-color: #343a40;
  background: #1c2024;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.entry-records-pagination .filter-button, .reports-page > .report-context-bar .filter-button, .reports-page .report-head-actions .filter-button) {
  border-color: #485057;
  background: #252a2f;
  color: #f5f6f7;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.reports-page .report-workspace-head.report-command-bar, .queue-group h2, .demand-detail, .detail-actions) {
  border-color: #343a40;
  background: #1c2024;
}

html[data-theme="dark"] body[data-app-shell="internal"] :is(.demands-context-crumb span, .detail-number, .next-action-block label) {
  color: #d4d9dd !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .next-action-block {
  border-color: #343a40 !important;
  background: #252a2f !important;
}

/* Status mantém cores somente nos indicadores de situação e alertas. */
html[data-theme="dark"] body[data-app-shell="internal"] .status-page :is(.status-control-deck, .status-board-panel, .status-lane, .status-category-group, .status-type-lane, .status-type-status, .status-contract-coverage, .status-contract-item) {
  border-color: #343a40 !important;
  background: #1c2024 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .status-page :is(.status-lane-head, .status-category-head, .status-type-head, .status-type-status-head) {
  border-color: #343a40 !important;
  background: #252a2f !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .status-page :is(.status-unit, .status-control-deck__areas .filter-button, .status-control-deck__customize) {
  border-color: #485057 !important;
  background: #252a2f !important;
  box-shadow: none !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .status-page .status-unit:hover {
  background: #30363b !important;
}

html[data-theme="dark"] body[data-app-shell="internal"] .status-page :is(.status-type-head, .status-category-head) :is(h3, h4, strong) {
  color: #f5f6f7 !important;
}

/* Início usa variáveis próprias; todas passam para a mesma paleta. */
html[data-theme="dark"] body:has(.home-shell) .home-shell {
  --home-canvas: #101214;
  --home-structure: #171a1d;
  --home-topbar-bg: #1c2024;
  --home-topbar-border: #343a40;
  --home-tabs-bg: #1c2024;
  --home-tabs-soft: #252a2f;
  --home-tabs-line: #343a40;
  --home-clock-bg: #1c2024;
  --home-clock-soft: #252a2f;
  --home-clock-line: #343a40;
  --home-clock-accent: #f5f6f7;
  --home-assistant-bg: #1c2024;
  --home-assistant-soft: #252a2f;
  --home-assistant-line: #343a40;
  --home-assistant-accent: #f5f6f7;
  --home-agenda-bg: #1c2024;
  --home-agenda-soft: #252a2f;
  --home-agenda-line: #343a40;
  --home-agenda-accent: #f5f6f7;
  --home-events-bg: #1c2024;
  --home-events-soft: #252a2f;
  --home-events-line: #343a40;
  --home-events-accent: #f5f6f7;
  --home-personalizer-bg: #1c2024;
  --home-personalizer-soft: #252a2f;
  --home-personalizer-line: #343a40;
  --home-on-light: #f5f6f7;
  --home-on-light-muted: #b7bec4;
  --home-metal-shadow: none;
  --home-metal-highlight: none;
}
