/* UTU Engine — unified navy palette (LIGHT visual-only change).
 * Loaded LAST. The Home dashboard is the palette reference:
 * #090f17 page, #0d1722 cards, #223242 dividers.
 * Dark mode only; no geometry, visibility, behavior, data or status changes.
 * Semantic success/warning/error, provider logos and Home-specific colors stay intact.
 */
:root[data-theme="dark"] {
  --bg:#090f17;
  --bg-deep:#080f17;
  --surface:#0d1722;
  --surface-strong:#122334;
  --surface-soft:#101e2d;
  --ink:#edf5fb;
  --muted:#a7b4c6;
  --line:#223242;
  --line-strong:#30485b;
  --blue:#00bbd0;
  --blue-2:#008eac;
  --utu-deep:#090f17;
  --utu-field:#101e2d;
  --utu-panel:#0d1722;
  --utu-panel-soft:#122334;
  --utu-panel-hover:#1a3044;
  --utu-text:#edf5fb;
  --utu-subtext:#a7b4c6;
  --utu-dim:#8fa5b9;
  --utu-stroke:#223647;
  --utu-stroke-soft:#1e3041;
  --utu-highlight:#43d1dd;
  --utu-glow:rgba(0,184,205,.06);
  --utu-connection-canvas:#0a1724;
  --utu-connection-border:#294054;
  --utu-connection-copy:#d5e4f0;
}
html[data-theme="dark"] {color-scheme:dark;}
html[data-theme="dark"] body {background-color:#090f17;color:var(--utu-text);}

/* Shared cards on every workspace, including dynamically created content.
 * Do not target #home-view: its existing reference colors are unchanged. */
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view,#how-to-view
) :is(
  .card,.panel,.subpanel,.tool-card,.tool-row,.connection-card,.user-card,
  .settings-nav-card,.settings-content-card,.central-tool-group,
  .notification-settings-card,.notification-channel-card,.notification-rule-card,
  .trigger-settings-card,.trigger-source-card,.trigger-account-card,
  .analytics-chart-card,.analytics-kpi,.analytics-control-card,
  .topology-builder-card,.application-card,.investigation-summary,
  .timeline-card,.execution-timeline-shell
) {
  background-color:var(--utu-panel)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text);
}
/* Investigation Details is a transparent layout shell, NOT a card. The generic
   workspace .panel background above must not cover the patterned UTU canvas. */
:root[data-theme="dark"] #investigations-view #investigation-detail.panel{
  background-color:transparent!important;background-image:none!important;
  border-color:transparent!important;box-shadow:none!important;
}
/* Nested surface hierarchy is intentionally subtle, like Home tables and rows. */
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view,#how-to-view
) :is(
  .setup-step,.notification-content-section,.notification-check,
  .notification-rule-summary,.notification-rule-editor-grid,
  .trigger-editor-section,.trigger-endpoint-line,.trigger-rule-editor-grid section,
  .analytics-pricing-item,.analytics-settings-layout>.panel,
  .sensitive-policy-item,.sensitive-rule-row,.security-invariant-note,
  .cross-app-summary-card,.cross-app-manual-verification,
  .prom-target-card,.prom-binding-card,.prom-target-group,
  .es-log-field-discovery,.topology-node-editor,.topology-legend,
  .settings-nav-group,.central-tool-bind-summary
) {
  background-color:var(--utu-panel-soft)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text);
}
/* Modals are often portaled directly to body, outside their original page. */
:root[data-theme="dark"] :is(
  .modal-dialog,.tool-modal-dialog,.notification-editor,
  .trigger-source-editor,.trigger-account-editor,.trigger-credential-dialog,
  .user-editor-modal,.central-tool-bind-dialog,.utu-pricing-modal,
  .utu-operations-editor,.application-create-panel,
  .utu-connection-drawer.utu-v3-editor
) {
  background-color:var(--utu-panel)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text)!important;
}
:root[data-theme="dark"] :is(
  .modal-dialog,.tool-modal-dialog,.notification-editor,
  .trigger-source-editor,.trigger-account-editor,.trigger-credential-dialog,
  .user-editor-modal,.central-tool-bind-dialog,.utu-pricing-modal,
  .utu-operations-editor,.application-create-panel
) :is(
  .card,.subpanel,.utu-tool-substep,.utu-v3-card,.utu-user-v3-card,
  .utu-sensitive-table-row,.argocd-app,.argocd-resource-list,
  .notification-content-section,.notification-rule-editor-grid>section,
  .trigger-editor-section,.host-server-card,.prom-binding-card,.prom-target-card
) {
  background:var(--utu-panel-soft)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text)!important;
}
/* Specific wizard/editor surfaces with historical hardcoded brighter blues. */
:root[data-theme="dark"] #application-tool-modal :is(
  .utu-unified-tool-dialog,.utu-tool-substep,.tool-modal-dialog,
  .tool-modal-settings,.tool-modal-section
),
:root[data-theme="dark"] .utu-v3-editor :is(
  .utu-guided-step,.utu-guided-servers .host-server-card
) {
  background:var(--utu-panel-soft)!important;
  border-color:var(--utu-stroke)!important;
}
/* The User editor shares the dark Investigation palette rather than the
   generic soft blue editor surface. Keep this at the source of the override. */
:root[data-theme="dark"] #user-modal-backdrop :is(
  .utu-user-v3-card,#user-application-scope.utu-user-v3-card
){
  background:#0d1722!important;
  background-image:none!important;
  border-color:#263e50!important;
}
/* The connection drawer intentionally has transparent inner groups.
 * Only its top-level canvas changes — no new cards or wizard layout. */
:root[data-theme="dark"] body > #connection-editor.utu-v3-editor.utu-connection-drawer {
  background:var(--utu-connection-canvas)!important;
  border-color:var(--utu-stroke)!important;
}
:root[data-theme="dark"] #connection-editor.utu-v3-editor .utu-guided-content :is(
  .utu-guided-step,.utu-guided-servers .host-server-card
) {
  background:transparent!important;
  border-color:var(--utu-stroke)!important;
}
/* Fields: Create/Edit, wizards, search and filters, including native options. */
:root[data-theme="dark"] :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="hidden"]),
  textarea,select,[role="combobox"]
) {
  background-color:var(--utu-field)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text)!important;
}
:root[data-theme="dark"] :is(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]),
  textarea,select,[role="combobox"]
):focus {
  background-color:#16283a!important;
  border-color:var(--utu-highlight)!important;
}
:root[data-theme="dark"] :is(input,textarea)::placeholder {
  color:var(--utu-dim)!important;
  opacity:1;
}
:root[data-theme="dark"] :is(select,option,optgroup) {
  color-scheme:dark;
  background-color:var(--utu-field);
  color:var(--utu-text);
}
:root[data-theme="dark"] :is(input[type="checkbox"],input[type="radio"]) {
  accent-color:#00b6ce;
}
/* Custom role pickers, dropdowns and menus (native selects are covered above). */
:root[data-theme="dark"] :is(
  [role="listbox"],[role="menu"],.dropdown-menu,.dropdown-content,
  .utu-user-menu,.utu-user-v3-role-options,.utu-v3-dropdown,
  .custom-select-menu,.autocomplete-list
) {
  background-color:var(--utu-panel-soft)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text);
}
:root[data-theme="dark"] :is(
  [role="option"]:hover,[role="menuitem"]:hover,
  .dropdown-menu button:hover,.utu-user-menu button:hover
) {
  background-color:var(--utu-panel-hover)!important;
}
/* Data tables and pagination: keep semantic status pills unchanged. */
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) :is(
  thead th,.utu-operations-table thead th,.investigation-table thead th,
  .notification-delivery-table thead th,.trigger-history-table thead th
) {
  background:var(--utu-panel-soft)!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-subtext)!important;
}
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) :is(table,.utu-operations-table,.investigation-table) :is(td,th) {
  border-color:var(--utu-stroke-soft)!important;
}
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) :is(table,.utu-operations-table,.investigation-table) tbody tr:hover {
  background-color:var(--utu-panel-hover)!important;
}
/* Secondary button treatments only: primary / danger and success/error remain semantic. */
:root[data-theme="dark"] :is(
  .modal-actions,.actions,.central-tool-actions,.utu-operations-actions,
  .utu-operations-head-actions,.utu-operations-pager,.pagination
) button:not(.primary):not(.danger):not(.active):not([aria-current="page"]) {
  background-color:#172a3b!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text)!important;
}
:root[data-theme="dark"] :is(
  .modal-actions,.actions,.central-tool-actions,.utu-operations-actions,
  .utu-operations-head-actions,.utu-operations-pager,.pagination
) button:not(.primary):not(.danger):not(.active):hover {
  background-color:var(--utu-panel-hover)!important;
}
:root[data-theme="dark"] :is(
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view,#applications-view,
  #connections-view,#investigations-view,#topology-view
) :is(pre,.code-block,.json-preview,.lab-result-panel pre) {
  background-color:#0a1724!important;
  border-color:var(--utu-stroke)!important;
  color:var(--utu-text)!important;
}


/* Home-style table hierarchy.  Applies to real table rows, not just headers:
 * the old broad legacy rules also colored tbody cells on Notifications/Tools. */
:root[data-theme="dark"] {
  --utu-table-head:#152232;
  --utu-table-row:#0d1722;
}
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) :is(
  .utu-operations-table-wrap,.investigation-table-wrap,
  .notification-delivery-table-wrap,.trigger-history-table-wrap,
  .prom-tool-target-table-wrap,.cross-app-table-wrap
) {
  background-color:var(--utu-panel)!important;
  border-color:var(--utu-stroke)!important;
}
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) table thead th {
  background-color:var(--utu-table-head)!important;
  border-color:var(--utu-stroke)!important;
}
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) table tbody :is(tr,td) {
  background-color:var(--utu-table-row)!important;
}
:root[data-theme="dark"] :is(
  #applications-view,#connections-view,#investigations-view,#topology-view,
  #tools-view,#tool-lab-view,#triggers-view,#notifications-view,
  #analytics-view,#settings-view,#users-view
) table tbody tr:hover :is(td,th) {
  background-color:var(--utu-panel-hover)!important;
}
/* Tools is the reference regression: the outer group is both .panel and
 * .central-tool-group, previously forced to legacy #13283b. */
:root[data-theme="dark"] #tools-view .central-tool-group.panel {
  background:var(--utu-panel)!important;
  border-color:var(--utu-stroke)!important;
}
:root[data-theme="dark"] #tools-view .central-tool-kind,
:root[data-theme="dark"] #tools-view .central-tool-count {
  background:var(--utu-panel-hover)!important;
}
