#right-panel table { color:#606975; font-size:12px !important; }
body :is(label, input, select, textarea, option) {
  font-size:12px !important;
}
body select {
  box-sizing:border-box;
  min-height:28px;
  padding-top:0 !important;
  padding-bottom:0 !important;
  line-height:normal !important;
  vertical-align:middle;
}
body :is(input, textarea)::placeholder {
  font-size:12px !important;
}
.node-management-layout { row-gap:0 !important; }
.node-management-layout:has(#device-config-tab-buttons button.active-tab[data-tab="general" i]) > .node-management-list {
  align-self:stretch !important;
  display:flex;
  flex-direction:column;
}
.node-management-layout:has(#device-config-tab-buttons button.active-tab[data-tab="general" i]) > .node-management-list > .node-list-pane {
  flex:1;
}
.node-management-layout > #node-list-tabs { margin-bottom:0; align-self:stretch; }
.node-selected-heading {
  display:flex;
  align-items:center;
  padding:0 0 0 8px;
  min-width:0;
  overflow-wrap:anywhere;
  color:#303946;
  font-size:14px;
  font-weight:600;
}
html[data-theme="dark"] .node-selected-heading { color:var(--theme-text); }
.node-management-layout:has(#device-details:empty) > .node-selected-heading { visibility:hidden; }
#right-panel #device-details,
#right-panel #tcp-dev-details,
#right-panel #device-config,
#right-panel #tcp-dev-config {
  border:1px solid var(--pane-border, #d0d7de) !important;
}
#right-panel #device-details > h4,
#right-panel #tcp-dev-details > h4,
#right-panel #device-config-tabs > h4,
#right-panel #tcp-dev-config-tabs > h4 {
  display:block !important;
  border-left:0 !important;
  margin:-14px -14px 12px !important;
  padding:8px 14px !important;
  background:#eee !important;
  color:#303946 !important;
}
html[data-theme="dark"] #right-panel #device-details > h4,
html[data-theme="dark"] #right-panel #tcp-dev-details > h4,
html[data-theme="dark"] #right-panel #device-config-tabs > h4,
html[data-theme="dark"] #right-panel #tcp-dev-config-tabs > h4 {
  background:var(--theme-raised) !important;
  color:var(--theme-text) !important;
}
#device-config-tabs,
#tcp-dev-config-tabs { width:100%; box-sizing:border-box; }
#device-config-tabs > h4,
#tcp-dev-config-tabs > h4 { align-self:stretch; }
#device-config-tabs > h4 > span,
#tcp-dev-config-tabs > h4 > span { display:none !important; }
#device-config-tab-buttons,
#tcp-dev-config-tab-buttons {
  width:100%;
  box-sizing:border-box;
  box-shadow:inset 0 -1px var(--pane-border, #d0d7de);
}
.node-info-actions {
  display:flex;
  justify-content:flex-end;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  margin-top:12px;
}
.node-info-body {
  display:grid;
  grid-template-columns:100px minmax(0, 1fr);
  gap:36px;
  align-items:start;
}
.node-info-fields {
  display:grid;
  grid-template-columns:repeat(3, minmax(0, 1fr));
  gap:12px 6px;
}
.node-info-fields > div { min-width:0; overflow-wrap:anywhere; }
.node-info-body > div > img {
  display:block;
  width:100%;
  max-width:100% !important;
  height:100px;
  object-fit:contain;
}
.node-info-fields > div:has(input) {
  display:flex;
  align-items:center;
  flex-wrap:nowrap !important;
  gap:6px !important;
}
.node-info-fields > div > b { flex-shrink:0; }
.node-info-fields input {
  min-width:0 !important;
  width:140px !important;
  max-width:100%;
  flex:0 1 140px;
  box-sizing:border-box;
}
.node-info-fields input[type="number"] { width:80px !important; flex-basis:80px; }
#right-panel {
  --pane-border:#d0d7de;
  --pane-shadow:0 2px 6px rgba(31,41,55,0.08);
}
html[data-theme="dark"] #right-panel {
  --pane-border:var(--theme-border);
  --pane-shadow:0 2px 8px rgba(0,0,0,0.2);
}
#right-panel :is(
  .card .card:not(.tabbar), .node-list-pane,
  .connected-tab-panel:not(#device-category-content):not(#alarm-threshold-content),
  .ems-settings-group, .ems-controlled-load-allocation,
  .ems-meter-list, .ems-zone-device-details, .ems-circuit-datasource-box,
  .global-threshold-list-panel, .global-threshold-detail-panel,
  .history-chart-card, .power-analysis-section, .api-doc-toc,
  .tbw-toolbox, #ems-lc01-preview
) {
  border-color:var(--pane-border) !important;
  box-shadow:var(--pane-shadow);
}
body button:not(:where(
  #main-nav button, .nav-account button,
  .tbw-node button, .tbw-tapoff-item button, .rack-card button,
  .connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  .tabbar button, .modal-close-x, .modal-refresh-icon,
  .ems-source-token button, .ems-item-delete, .ems-circuit-main-toggle,
  .ems-circuit-phase-option, .tbw-tapoff-delete, .tbw-more-btn,
  .ems-meter-device, .ems-topology-item:not(.ems-topology-add-item), .ems-data-type,
  .global-threshold-list-item, .tbw-device-picker-option
)) {
  box-sizing:border-box;
  height:auto !important;
  min-height:28px !important;
  padding-top:3px !important;
  padding-bottom:3px !important;
  line-height:20px;
}
#main-layout > #right-panel { padding-left:12px; }
#right-panel table :is(th, td) { font-size:12px !important; }
#right-panel table > :is(thead, tbody, tfoot) > tr { height:auto; }
#right-panel table > :is(thead, tbody, tfoot) > tr > :is(th, td) {
  padding-top:8px;
  padding-bottom:8px;
  line-height:15px;
  vertical-align:middle;
}
#right-panel > .card {
  margin-top:0 !important;
  margin-bottom:0 !important;
  border:0 !important;
  box-sizing:border-box;
  min-height:100%;
  flex-shrink:0;
}
.card > .connected-tab-panel {
  margin-left:-14px;
  margin-right:-14px;
  width:calc(100% + 28px);
  box-sizing:border-box;
  border-left:0;
  border-right:0;
}
.card > .ems-site-detail.ems-topology-detail {
  margin-bottom:-14px;
  border-bottom:0;
}
#right-panel > #energy-management:not(.hidden):has(.ems-topology-detail) {
  display:flex;
  flex-direction:column;
  padding-bottom:0;
}
#energy-management:has(.ems-topology-detail) > .ems-management-shell {
  flex:1;
  grid-template-rows:auto minmax(auto, 1fr);
}
#energy-management .ems-management-shell > .card:has(> .ems-topology-detail) {
  display:flex;
  flex-direction:column;
}
#energy-management .ems-management-shell > .card:has(> .ems-topology-detail) > .ems-section-header {
  margin-bottom:0;
  flex-shrink:0;
}
#energy-management .ems-management-shell > .card:has(> .ems-topology-detail) > .ems-site-tabs {
  flex-shrink:0;
}
#energy-management .ems-topology-detail {
  display:flex;
  flex-direction:column;
  flex:1;
}
#energy-management .ems-topology-detail > .ems-topology {
  flex:1;
  align-items:stretch;
}
#energy-management .ems-topology-detail .ems-topology-pane {
  display:flex;
  flex-direction:column;
}
#energy-management .ems-topology-detail .ems-topology-pane > .connected-tabs {
  flex-shrink:0;
}
#energy-management .ems-topology-detail .ems-topology-pane > :is(.ems-topology-list, .ems-data-source) {
  flex:1;
  height:auto;
  min-height:420px;
}
#energy-management .ems-topology-detail .ems-topology-pane > .ems-sld-panel {
  min-height:480px;
}
#energy-management .ems-topology-detail .ems-topology.meters-workspace .ems-topology-pane:nth-child(2) > .ems-topology-list {
  display:flex;
  flex-direction:column;
  min-height:0;
}
#energy-management .ems-topology.meters-workspace .ems-topology-pane:nth-child(2) > .ems-topology-list > .ems-zone-device-config {
  display:flex;
  flex:0 0 auto;
  flex-direction:column;
  min-height:min-content;
}
#energy-management .ems-topology.meters-workspace .ems-topology-pane:nth-child(2) .ems-meter-association {
  flex:0 0 auto;
  align-items:stretch;
}
#energy-management .ems-topology.meters-workspace .ems-meter-list-label {
  grid-template-rows:auto auto;
  align-content:start;
  align-self:start;
}
#energy-management .ems-topology.meters-workspace .ems-meter-list {
  height:auto;
  max-height:min(420px, 50vh);
}
#energy-management .ems-zone-panel-heading {
  margin:-8px -10px 12px;
}
#energy-management .ems-topology .ems-source-heading {
  color:#303946;
  font-family:inherit;
  font-size:13px !important;
  font-weight:600;
}
#energy-management .ems-data-source > .ems-source-heading {
  margin:-8px -8px 12px;
}
#energy-management .ems-circuit-datasource-box {
  background:transparent !important;
  font-size:12px;
}
#energy-management .ems-circuit-datasource-box :is(
  .tbw-cm-pairing-title, .tbw-cm-pairing-label, .ems-circuit-cm-summary,
  input, select, textarea, option, button:not(.tbw-circuit-refresh-btn)
) {
  font-size:12px !important;
}
#right-panel .ems-summary-source-chain {
  margin-top:10px;
  gap:8px;
}
#right-panel .ems-summary-source-chain > .ems-source-token {
  background:#fff8d6;
  border:2px solid #f5c133;
  color:#303946;
  border-radius:6px;
  width:85%;
  align-self:center;
  overflow-wrap:anywhere;
}
#right-panel .ems-summary-source-chain > .ems-source-token .ems-source-remove {
  color:#303946;
}
#right-panel .ems-summary-source-chain > :is(.ems-source-equals, .ems-source-operator) {
  align-self:center;
  display:flex;
  align-items:center;
  justify-content:center;
  width:28px;
  min-height:20px !important;
  margin:0;
  padding:0 !important;
  border:0;
  background:transparent !important;
  box-shadow:none;
  color:var(--theme-text, #333) !important;
  font-size:18px;
  font-weight:600;
  line-height:20px !important;
}
#right-panel .ems-summary-source-chain > .ems-source-operator:disabled {
  opacity:1;
}
.connected-tabs + .connected-tab-panel,
.ems-selector-tabs + .connected-tab-panel {
  margin-top:0;
}
#device-category-content {
  margin-left:0;
  margin-right:0;
  width:100%;
  border:0 !important;
  background:#fff !important;
}
.node-list-pane {
  box-sizing:border-box;
  width:100%;
  padding:10px;
  border:1px solid #d0d7de;
  background:#fff;
}
.cfg-grid-networking {
  grid-template-columns:repeat(2, minmax(0, 1fr)) !important;
  gap:12px !important;
  margin-left:0 !important;
}
.cfg-grid-networking > .cfg-item {
  min-width:0;
  margin-left:0;
}
.cfg-grid-networking .cfg-network-group {
  grid-column:1 / -1;
  min-width:0;
  margin:4px 0 0;
  padding:10px 12px 12px;
  border:1px solid #d0d7de;
  border-radius:0;
  background:transparent;
}
.cfg-grid-networking .cfg-network-group > .cfg-parent-header {
  display:inline-flex;
  align-items:center;
  gap:6px;
  margin:0;
  padding:0 6px;
  color:#303946;
  font-size:12px;
  font-weight:600;
}
.cfg-network-group-marker {
  display:inline-block;
  flex:0 0 10px;
  width:10px;
  height:10px;
  background:#ffd000;
}
.cfg-grid-networking .cfg-parent-children-grid {
  grid-template-columns:repeat(2, minmax(0, 1fr));
  gap:12px;
  margin-left:0 !important;
}
.cfg-grid-networking .cfg-parent-children-grid > .cfg-item {
  min-width:0;
  margin-left:0;
}
.cfg-grid-networking .cfg-item > div:has(> input[id$="Part3"]) {
  display:flex;
  align-items:center;
  gap:3px !important;
  min-width:0;
}
.cfg-grid-networking .cfg-item > div:has(> input[id$="Part3"]) > input {
  box-sizing:border-box !important;
  flex:1 1 0;
  min-width:0;
  width:0 !important;
  padding:2px 3px !important;
  text-align:center;
}
html[data-theme="dark"] .cfg-grid-networking .cfg-network-group {
  background:var(--theme-surface) !important;
  border-color:var(--theme-border) !important;
}
html[data-theme="dark"] .cfg-grid-networking .cfg-network-group > .cfg-parent-header {
  color:var(--theme-text);
}
.node-selection-text-action {
  min-height:0 !important;
  padding:0 !important;
  border:0 !important;
  background:transparent !important;
  color:inherit;
  font:inherit;
  font-size:12px !important;
  line-height:normal !important;
  cursor:pointer;
}
.node-selection-text-action:hover:not(:disabled) { text-decoration:underline; }
.node-selection-text-action:disabled { opacity:.5; cursor:default; }
html[data-theme="dark"] .node-list-pane {
  border-color:var(--theme-border);
  background:var(--theme-surface);
}
html[data-theme="dark"] #device-category-content {
  background:var(--theme-surface) !important;
}
#device-config > #device-config-content,
#tcp-dev-config > #tcp-dev-config-content {
  margin-left:-14px;
  margin-right:-14px;
  padding-left:14px;
  padding-right:14px;
  box-sizing:border-box;
}
#right-panel table :is(thead, th),
#right-panel table > thead > tr > td { background:#eee !important; }
html[data-theme="dark"] #right-panel table :is(thead, th),
html[data-theme="dark"] #right-panel table > thead > tr > td { background:var(--theme-raised) !important; }
#right-panel {
  background:#f5f3f3 !important;
  scrollbar-color:#c5cbd3 #f5f3f3;
  --table-row-base:#fff;
  --table-row-alternate:#f3f4f6;
  --table-column-border:#e1e4e8;
}
html[data-theme="dark"] #right-panel {
  scrollbar-color:#718096 var(--theme-surface);
  --table-row-base:var(--theme-surface);
  --table-row-alternate:var(--theme-raised);
  --table-column-border:var(--theme-border);
}
#right-panel table > :is(thead, tbody, tfoot) > tr > :is(th, td) {
  border:0 !important;
}
#right-panel table > :is(thead, tbody, tfoot) > tr > :is(th, td):not(:last-child) {
  border-right:1px solid var(--table-column-border) !important;
}
#right-panel table > tbody > tr:nth-child(odd) {
  background-color:var(--table-row-base);
}
#right-panel table > tbody > tr:nth-child(even) {
  background-color:var(--table-row-alternate);
}
#right-panel table th,
#right-panel .ems-circuit-list-header { font-weight:400; color:#303946; }
table thead th[data-sortable="true"] { cursor:pointer; user-select:none; }
table thead th[data-sortable="true"]:focus-visible { outline:2px solid var(--theme-accent,#ffd000); outline-offset:-2px; }
table thead th[data-sortable="true"] .table-sort-arrows {
  display:inline-flex;
  flex-direction:column;
  justify-content:center;
  gap:1px;
  margin-left:6px;
  line-height:0;
  vertical-align:middle;
}
table thead th[data-sortable="true"] .table-sort-arrow {
  width:0;
  height:0;
  border-left:4px solid transparent;
  border-right:4px solid transparent;
  opacity:.35;
}
table thead th[data-sortable="true"] .table-sort-arrow-up { border-bottom:5px solid currentColor; }
table thead th[data-sortable="true"] .table-sort-arrow-down { border-top:5px solid currentColor; }
table thead th[data-sortable="true"][aria-sort="ascending"] .table-sort-arrow-up {
  border-bottom-color:#1683d8;
  opacity:1;
}
table thead th[data-sortable="true"][aria-sort="descending"] .table-sort-arrow-down {
  border-top-color:#1683d8;
  opacity:1;
}
#right-panel > .card > h3 { color:#303946 !important; }
html[data-theme="dark"] #right-panel > .card > h3 { color:var(--theme-text) !important; }
#right-panel h4,
#right-panel .card h3:not(#right-panel > .card > h3) {
  font-family:inherit !important;
  font-size:13px !important;
  font-weight:600 !important;
  color:#303946 !important;
  margin:0 0 12px !important;
}
html[data-theme="dark"] #right-panel h4,
html[data-theme="dark"] #right-panel .card h3:not(#right-panel > .card > h3) {
  color:var(--theme-text) !important;
}
#right-panel h4[style*="background-color:#666"] { background:#d8dce2 !important; color:#303946 !important; margin:0 !important; }
html[data-theme="dark"] #right-panel h4[style*="background-color:#666"] { background:#354151 !important; color:var(--theme-text) !important; }
#right-panel .ems-section-header > h4 { margin:0 !important; align-self:flex-start; }
#right-panel :is(.ems-topology-item-name, .ems-data-type, .ems-meter-device, .global-threshold-list-item, .TCPDevices-item) { color:#606975; }
#right-panel .TCPDevices-item { font-size:12px; font-weight:400; }
.node-table-scroll { width:100%; overflow-x:auto; }
.node-list-table { min-width:580px; font-size:12px; table-layout:auto; }
.node-list-table th { position:sticky; top:0; background:#edf0f3; z-index:1; white-space:nowrap; }
html[data-theme="dark"] #right-panel .node-list-table th { color:var(--theme-text); }
.node-list-table td { vertical-align:middle; overflow-wrap:anywhere; }
.node-list-table :is(th, td).node-selection-column { width:1%; padding-left:5px; padding-right:5px; text-align:center; white-space:nowrap; }
.node-list-table .node-link-address-cell { text-align:center; }
.node-list-table .TCPDevices-item { cursor:pointer; }
.node-list-table input[type="checkbox"] { margin:0; }
.pagination-bar {
  display:inline-flex;
  align-items:stretch;
  gap:0;
  border:0;
  margin:4px 0;
  vertical-align:middle;
}
.pagination-bar .pagination-item {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  box-sizing:border-box;
  min-width:32px;
  height:30px;
  margin:0;
  padding:0 9px;
  border:0 !important;
  border-radius:0 !important;
  background:#fff;
  color:#606975;
  font:400 13px 'IBM Plex Sans', sans-serif;
}
.pagination-bar .pagination-item { box-shadow:none; }
.pagination-bar button:hover:not(:disabled) { background:#edf0f3; color:#303946; }
.pagination-bar button:disabled { opacity:0.4; cursor:default; }
.pagination-bar button:focus-visible { outline:2px solid #b38f00; outline-offset:-2px; }
.pagination-bar .pagination-ellipsis { cursor:default; }
html[data-theme="dark"] .pagination-bar .pagination-item { background:var(--theme-surface); color:var(--theme-muted); }
html[data-theme="dark"] .pagination-bar button:hover:not(:disabled) { background:var(--theme-hover); color:var(--theme-text); }
.pagination-bar .pagination-item.is-current,
html[data-theme="dark"] .pagination-bar .pagination-item.is-current { background:#ffd000; color:#303946; font-weight:600; }
html[data-theme="dark"] #right-panel table,
html[data-theme="dark"] #right-panel :is(.ems-topology-item-name, .ems-data-type, .ems-meter-device, .global-threshold-list-item, .TCPDevices-item) { color:#bac3cf; }

.theme-toggle {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:7px 12px;
  margin:0;
  border:1px solid #d0d7de;
  border-radius:4px;
  background:#fff;
  color:#333;
  font:500 12px 'IBM Plex Sans', sans-serif;
  cursor:pointer;
}
.login-theme-toolbar { position:absolute; top:20px; right:24px; z-index:1; }
.theme-toggle:focus-visible { outline:2px solid #b38f00; outline-offset:3px; }

html[data-theme="dark"] {
  color-scheme:dark;
  --theme-page:#11151c;
  --theme-surface:#1a202a;
  --theme-raised:#232c38;
  --theme-hover:#2c3745;
  --theme-border:#3b4757;
  --theme-text:#e2e8f0;
  --theme-muted:#a8b4c4;
  --theme-accent:#ffd000;
  --theme-grid:#354253;
}
html[data-theme="dark"] body,
html[data-theme="dark"] #right-panel { background:var(--theme-surface) !important; color:var(--theme-text); }
html[data-theme="dark"] :where(.card, .top-titlebar, .top-titlebar-main, .app-footer,
  dialog, fieldset, .connected-tab-panel, .ems-data-source, .ems-topology-list,
  .ems-settings-group, .ems-controlled-load-allocation,
  .global-threshold-list-panel, .global-threshold-detail-panel,
  .alarm-threshold-drawer-panel, .history-chart-card, .history-metric-picker,
  [class$="-tooltip"], .api-doc-toc) {
  background-color:var(--theme-surface) !important;
  color:var(--theme-text);
  border-color:var(--theme-border) !important;
}
html[data-theme="dark"] :where(h1,h2,h3,h4,h5,h6,label,legend,
  .ems-form-grid label, .ems-settings-group legend, .ems-phase-colour-settings label,
  .ems-demand-controls label, .ems-dynamic-management-toggle > label,
  .history-chart-summary strong, .tbw-cm-pairing-title) { color:var(--theme-text); }
html[data-theme="dark"] :where(.muted, small, .history-chart-summary, .history-chart-legend,
  .global-threshold-range-hint, .global-threshold-required-legend,
  .alarm-threshold-required-legend, .api-doc-lead, .pwd-toggle) { color:var(--theme-muted); }
html[data-theme="dark"] :where(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]), select, textarea) {
  background-color:var(--theme-page) !important;
  color:var(--theme-text) !important;
  border-color:var(--theme-border) !important;
}
html[data-theme="dark"] :where(input,select,textarea):focus-visible {
  outline:2px solid var(--theme-accent);
  outline-offset:1px;
}
html[data-theme="dark"] :where(input,select,textarea):disabled,
html[data-theme="dark"] input[readonly] { background-color:var(--theme-raised) !important; color:var(--theme-muted) !important; }
html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder { color:var(--theme-muted); opacity:1; }
html[data-theme="dark"] :where(button, .mng-btn, .theme-toggle, .global-threshold-list-item,
  .ems-data-type, .ems-topology-item, .ems-source-token) {
  background-color:var(--theme-raised);
  color:var(--theme-text);
  border-color:var(--theme-border);
}
html[data-theme="dark"] :where(button, .mng-btn, .theme-toggle, .ems-data-type, .ems-topology-item):hover {
  background-color:var(--theme-hover);
  color:var(--theme-text);
}
html[data-theme="dark"] :where(button:disabled) { color:var(--theme-muted); }
html[data-theme="dark"] :where(.add-btn, .main-nav button.active-tab,
  .alarm-threshold-parameter-button.active, .global-threshold-list-item.active-dev) {
  background-color:var(--theme-accent);
  color:#171b22;
  border-color:#c5a200;
}
html[data-theme="dark"] .delete-btn { background:#44252b; color:#ffb4bc; border-color:#92515a; }
html[data-theme="dark"] .delete-btn:hover { background:#60303a; }
html[data-theme="dark"] .card.tabbar.main-nav,
html[data-theme="dark"] .top-titlebar-menu-fill { background-color:#151b24 !important; }
html[data-theme="dark"] .main-nav button:not(.active-tab) { background:transparent; color:var(--theme-muted); }
html[data-theme="dark"] .main-nav button:not(.active-tab):hover { background:var(--theme-hover); color:var(--theme-text); }
html[data-theme="dark"] :where(.connected-tab, .device-type-tab,
  #device-config-tabs button, #tcp-dev-config-tabs button, #tbw-cm-config-tabs button, #rack-cm-config-tabs button) {
  background-color:var(--theme-raised) !important;
  border-color:var(--theme-border) !important;
  color:var(--theme-muted) !important;
}
html[data-theme="dark"] :where(.connected-tab, .device-type-tab,
  #device-config-tabs button, #tcp-dev-config-tabs button, #tbw-cm-config-tabs button, #rack-cm-config-tabs button):is(.active,.active-tab) {
  background-color:var(--theme-surface) !important;
  color:var(--theme-accent) !important;
  border-top-color:var(--theme-accent) !important;
}
html[data-theme="dark"] :where(table, th, td, hr) { border-color:var(--theme-border) !important; }
html[data-theme="dark"] :where(thead, th, .ems-sites-table thead, .tbw-realtime-table th) {
  background-color:var(--theme-raised) !important;
  color:var(--theme-text);
}
html[data-theme="dark"] tbody tr:hover { background-color:var(--theme-hover); }
html[data-theme="dark"] :where(tr.is-selected, .ems-data-type.active, .ems-topology-item.active) {
  background-color:#36331f;
  color:var(--theme-text);
}
html[data-theme="dark"] :where(.tbw-canvas-wrap,.tbw-canvas,.rack-canvas,.ems-sld-canvas,
  .alarm-threshold-canvas-shell) { background-color:var(--theme-page); border-color:var(--theme-border); }
html[data-theme="dark"] .ems-status-message-warning { background:#3c2b19 !important; border-color:#99651f !important; color:#ffd19a !important; }
html[data-theme="dark"] .ems-status-message-unconfigured { background:#28313d !important; border-color:#526073 !important; color:#c5ceda !important; }
html[data-theme="dark"] .api-doc-callout { background:#183344; color:#b9e5ff; }
html[data-theme="dark"] .api-doc-callout.warning { background:#3c2b19; color:#ffd19a; }
html[data-theme="dark"] a { color:#91c9ff; }
html[data-theme="dark"] .ok { color:#7ee0aa; }
html[data-theme="dark"] .danger { color:#ff9da7; }
html[data-theme="dark"] :where(.history-chart-tooltip,.bdw-alert-tooltip) { background:var(--theme-raised) !important; color:var(--theme-text); }
html[data-theme="dark"] :where(.bulk-operation-overlay,.history-loading,
  .global-threshold-saving,.alarm-threshold-drawer-saving,.tbw-realtime-loading-overlay) {
  background:rgba(17,21,28,.88); color:var(--theme-text);
}
html[data-theme="dark"] dialog::backdrop { background:rgba(0,0,0,.65); }
html[data-theme="dark"] .login-pane { background:rgba(17,21,28,.92); }
html[data-theme="dark"] .login-pane .card { box-shadow:0 16px 48px rgba(0,0,0,.25); }
html[data-theme="dark"] .login-pane label { color:var(--theme-muted); }
html[data-theme="dark"] .login-pane .card button:first-child { background:var(--theme-accent); color:#171b22; border-color:#c5a200; }
html[data-theme="dark"] .login-pane .theme-toggle { background:var(--theme-raised); color:var(--theme-text); border-color:var(--theme-border); }

/* Legacy renderers use inline neutral colors; keep their semantic colors intact. */
html[data-theme="dark"] [style*="background"] { border-color:var(--theme-border); }
html[data-theme="dark"] :is([style*="background:#fff;"],[style*="background: #fff;"],
  [style*="background:#ffffff"],[style*="background: #ffffff"],
  [style*="background-color:#fff"],[style*="background-color: #fff"],
  [style*="background:#f5f5f5"],[style*="background: #f5f5f5"],
  [style*="background:#f7f7f7"],[style*="background: #f7f7f7"]) {
  background-color:var(--theme-surface) !important;
}
html[data-theme="dark"] :is([style*="color:#333"],[style*="color: #333"],
  [style*="color:#444"],[style*="color: #444"],[style*="color:#222"],[style*="color: #222"],
  [style*="color:#555"],[style*="color: #555"],[style*="color:#666"],[style*="color: #666"]) {
  color:var(--theme-text) !important;
}
html[data-theme="dark"] svg text { fill:var(--theme-text); }
html[data-theme="dark"] svg :is([fill="#fff"],[fill="#ffffff"],[fill="#f5f5f5"],[fill="white"]) { fill:var(--theme-surface); }
html[data-theme="dark"] svg :is([stroke="#ddd"],[stroke="#ccc"],[stroke="#333"],[stroke="#666"]) { stroke:var(--theme-muted); }
html[data-theme="dark"] :where(.ems-meter-list,.ems-meter-device,.ems-zone-device-details,
  .dashboard-sld-panel,#ems-lc01-preview,.ems-sld-legend,.ems-zone-toolbar,
  .ems-circuit-datasource-box,.ems-circuit-phase-menu,.ems-source-heading,
  #device-category-content,#alarm-threshold-content,.alarm-threshold-strip-panel,
  .inline-help-tip,.bulk-operation-overlay-content,.cfg-parent-row,
  .tbw-toolbox,.tbw-tool-item,.tbw-node,.tbw-tapoff-item,
  .tbw-device-picker-list,.tbw-cm-pairing-box,.tbw-outlet-config-card,
  .tbw-rename-panel,.tbw-confirm-panel,.tbw-cm-config-panel,.tbw-cm-config-body,
  .tbw-realtime-panel,.tbw-realtime-body,.realtime-alarm-details-panel,
  .realtime-alarm-details-section-title,.realtime-alarm-details-section .tbw-table,
  .rack-equipment-info-panel,.rack-equipment-edit-panel,.history-metric-option) {
  background-color:var(--theme-surface) !important;
  color:var(--theme-text);
  border-color:var(--theme-border) !important;
}
html[data-theme="dark"] :where(.ems-controller-device-status,.ems-zone-device-picker-label,
  .ems-meter-list-label,.ems-meter-list-heading label,.ems-zone-device-details dt,
  .ems-zone-device-details dd,.ems-tariff-controls label,.ems-calculation-countdown,
  .ems-setpoint-zone-value,.ems-zone-legend,.ems-circuit-list-header,.ems-topology-empty,
  .api-doc,.alarm-threshold-strip-panel-title,.cfg-item label,.tbw-page-note,
  .tbw-area-inline,.tbw-busway-name-field,.tbw-node-sub,.tbw-node-meta,
  .tbw-outlets-label,.tbw-outlet-config-sub,.tbw-form-field,.tbw-hint,.tbw-count,
  .tbw-modal-title,.tbw-confirm-msg,.tbw-cm-config-title,.tbw-realtime-title,
  .tbw-realtime-subtitle,.realtime-alarm-details-header h3,.dsh-detail-realtime-header,
  .realtime-alarm-filter,.tbw-char-counter,.bdw-empty,.rack-dashboard-meta,
  .power-analysis-section h4) { color:var(--theme-text); }
html[data-theme="dark"] :where(.ems-circuit-phase-button,.ems-circuit-phase-option,
  .ems-item-delete,.tbw-device-picker-button,.tbw-device-picker-option,
  .tbw-outlet-config-btn,.tbw-tapoff-delete,.tbw-more-btn,.tbw-back-btn,
  .tbw-canvas-zoom-controls button,.dsh-detail-tab,.modal-close-x,.modal-refresh-icon) {
  background-color:var(--theme-raised);
  color:var(--theme-text);
  border-color:var(--theme-border);
}
html[data-theme="dark"] :where(.ems-meter-device.is-selected,.tbw-device-picker-option:hover,
  .tbw-device-picker-option.is-selected,.dsh-detail-tab.active) { background-color:var(--theme-hover); color:var(--theme-text); }
html[data-theme="dark"] .ems-sld-line:not(.ems-sld-live) { stroke:var(--theme-muted); }
html[data-theme="dark"] .ems-sld-source { fill:var(--theme-surface); stroke:var(--theme-text); }
html[data-theme="dark"] :where(.ems-sld-bus,.ems-sld-zone-bus,.ems-sld-arrow:not(.ems-sld-live)) { fill:var(--theme-muted); }
html[data-theme="dark"] .ems-sld-zone-label-bg { fill:var(--theme-surface); }
html[data-theme="dark"] .ems-sld-zone-name { fill:var(--theme-accent); }
html[data-theme="dark"] .ems-sld-power-label { fill:#7ee0aa; }
html[data-theme="dark"] .ems-sld-zone-badge-text { fill:#fff; }
html[data-theme="dark"] :where(.ems-sld-circuit-sub,.ems-sld-empty-label) { fill:var(--theme-muted); }
html[data-theme="dark"] :where(.rack-equipment-info-psu-item,.rack-inlet-row,
  .rack-dashboard-metrics,.rack-dashboard-visual,.power-analysis-stat,.power-analysis-section,
  .bdw-board,.bdw-run) {
  background:var(--theme-surface);
  color:var(--theme-text);
  border-color:var(--theme-border);
}
html[data-theme="dark"] :where(.rack-dashboard-inlet,.rack-dashboard-inlet-name,
  .rack-dashboard-rack-header,.rack-dashboard-rack-meta,.power-analysis-stat strong,
  .bdw-run-busway-name) { color:var(--theme-text); }
html[data-theme="dark"] :where(.rack-dashboard-rack-header,.rack-dashboard-rack-meta) { background:var(--theme-raised); }
html[data-theme="dark"] .rack-dashboard-visual::after {
  background:repeating-linear-gradient(to bottom, var(--theme-surface) 0, var(--theme-surface) 5px, var(--theme-border) 6px, var(--theme-surface) 7px);
}
html[data-theme="dark"] :where(.power-analysis-status.normal,.power-analysis-status.redundant) { color:#7ee0aa; }
html[data-theme="dark"] :where(.power-analysis-status.warning,.power-analysis-status.partial) { color:#ffd19a; }
html[data-theme="dark"] :where(.power-analysis-status.critical,.power-analysis-status.at_risk,.power-analysis-status.incomplete) { color:#ff9da7; }
html[data-theme="dark"] :where(.power-analysis-status.unknown,.power-analysis-status.unsupported,
  .power-analysis-status.unavailable,.power-analysis-status.stale) { color:var(--theme-muted); }
html[data-theme="dark"] .ems-circuit-controlled-load-select[data-controlled-load="SmartLoad"],
html[data-theme="dark"] .ems-circuit-controlled-load-select option[value="SmartLoad"] { background-color:#cceee8 !important; color:#000 !important; }
html[data-theme="dark"] .ems-circuit-controlled-load-select[data-controlled-load="DemandResponse"],
html[data-theme="dark"] .ems-circuit-controlled-load-select option[value="DemandResponse"] { background-color:#ffdbcc !important; color:#000 !important; }
html[data-theme="dark"] .ems-circuit-controlled-load-select option[value="No"] { background-color:var(--theme-page); color:var(--theme-text); }
html[data-theme="dark"] .ems-controlled-load-allocation-row small { color:#000; }
html[data-theme="dark"] .theme-toggle:hover { background:var(--theme-hover); color:var(--theme-text); }

#right-panel :is(tr.is-selected, .ems-data-type.active, .ems-meter-device.is-selected,
  .global-threshold-list-item.active-dev, .TCPDevices-item.active-dev, .TCPDevices-item.active-disabled-dev),
#right-panel :is(.ems-topology-item, .ems-data-type).active .ems-topology-item-name,
#right-panel .ems-meter-device.is-selected .ems-meter-device-name {
  color:#252d38;
  font-weight:600;
}
#right-panel .global-threshold-list-item.active-dev strong { font-weight:600; }
html[data-theme="dark"] #right-panel :is(tr.is-selected, .ems-data-type.active, .ems-meter-device.is-selected),
html[data-theme="dark"] #right-panel :is(.ems-topology-item, .ems-data-type).active .ems-topology-item-name,
html[data-theme="dark"] #right-panel .ems-meter-device.is-selected .ems-meter-device-name {
  color:#f1f5f9;
  font-weight:600;
}
html[data-theme="dark"] #right-panel :is(.global-threshold-list-item.active-dev, .TCPDevices-item.active-dev) {
  color:#171b22;
  font-weight:600;
}
html[data-theme="dark"] #right-panel .TCPDevices-item.active-disabled-dev { color:#f1f5f9; font-weight:600; }

#right-panel table > tbody > tr:is(.is-selected, .active-dev, .active-disabled-dev) {
  color:#252d38;
  font-weight:600;
}
html[data-theme="dark"] #right-panel table > tbody > tr:is(.is-selected, .active-dev, .active-disabled-dev) {
  color:#f1f5f9;
}
#right-panel .ems-sites-table > tbody > tr > td:first-child,
#right-panel .node-list-table > tbody > tr > .node-name-cell,
#right-panel table:not(.node-list-table) > tbody > tr:is(.is-selected, .active-dev, .active-disabled-dev) > td:first-child {
  position:relative;
  padding-left:18px;
}
#right-panel table:not(.node-list-table) > tbody > tr:is(.is-selected, .active-dev, .active-disabled-dev) > td:first-child::before,
#right-panel .node-list-table > tbody > tr:is(.is-selected, .active-dev, .active-disabled-dev) > .node-name-cell::before {
  content:"";
  position:absolute;
  left:5px;
  top:7px;
  bottom:7px;
  width:5px;
  background:#f5c133;
}

body input[type="checkbox"] {
  appearance:none;
  box-sizing:border-box !important;
  width:16px !important;
  height:16px !important;
  min-width:16px !important;
  min-height:16px !important;
  max-width:16px !important;
  max-height:16px !important;
  flex:0 0 16px !important;
  padding:0 !important;
  border:1px solid #c5cbd3 !important;
  border-radius:0 !important;
  background:#fff;
  display:inline-grid;
  place-content:center;
  vertical-align:middle;
  cursor:pointer;
}
body input[type="checkbox"]::after {
  content:"\2713";
  color:#303946;
  font-size:13px;
  font-weight:800;
  line-height:1;
  transform:scale(0);
}
body input[type="checkbox"]:checked { background:#ffd000; border-color:#d6b73d !important; }
body input[type="checkbox"]:checked::after { transform:scale(1); }
body input[type="checkbox"]:indeterminate { background:#ffd000; border-color:#d6b73d !important; }
body input[type="checkbox"]:indeterminate::after {
  content:"";
  width:8px;
  height:2px;
  background:#303946;
  transform:scale(1);
}
html[data-theme="dark"] body input[type="checkbox"]:not(:checked):not(:indeterminate) {
  background:var(--theme-page);
  border-color:#718096 !important;
}
body input[type="checkbox"]:focus-visible { outline:2px solid #b38f00; outline-offset:2px; }
body input[type="checkbox"]:disabled { cursor:not-allowed; opacity:0.55; }

body {
  --tab-text:#606975;
  --tab-selected-text:#303946;
  --tab-hover:rgba(96,105,117,0.08);
}
html[data-theme="dark"] body {
  --tab-text:var(--theme-muted);
  --tab-selected-text:var(--theme-text);
  --tab-hover:rgba(168,180,196,0.08);
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button) {
  position:relative;
  border:0 !important;
  border-radius:0 !important;
  box-shadow:none !important;
  background:transparent !important;
  color:var(--tab-text) !important;
  font-size:12px !important;
  font-weight:400 !important;
  padding:10px 16px;
  margin-bottom:0;
  transition:color 0.18s ease, background-color 0.18s ease;
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button)::after {
  content:"";
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  height:4px;
  background:#ffd000;
  transform-origin:center;
  transform:scaleX(0);
  transition:transform 0.18s ease;
  pointer-events:none;
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button):is(.active, .active-tab, [aria-selected="true"]) {
  color:var(--tab-selected-text) !important;
  font-weight:600 !important;
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button):is(.active, .active-tab, [aria-selected="true"])::after {
  transform:scaleX(1);
  animation:tab-indicator-expand 0.18s ease both;
}
@keyframes tab-indicator-expand {
  from { transform:scaleX(0); }
  to { transform:scaleX(1); }
}
body #energy-management .connected-tab.tab-indicator-static::after { animation:none !important; }
body #energy-management .connected-tab.tab-indicator-static { transition:none !important; }
body :is(.add-btn, .tbw-tapoff-move, .alarm-threshold-parameter-button.active, .ems-source-add-circle):hover:not(:disabled) {
  background-color:#6a35c5 !important;
  border-color:#5b2bb0 !important;
  color:#fff !important;
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button):hover:not(:disabled) {
  background:var(--tab-hover) !important;
  color:var(--tab-selected-text) !important;
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button):focus-visible {
  outline:2px solid #b38f00;
  outline-offset:-2px;
}
body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
  #device-config-tabs button, #tcp-dev-config-tabs button,
  #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button):disabled {
  opacity:0.45;
}
@media (prefers-reduced-motion:reduce) {
  body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
    #device-config-tabs button, #tcp-dev-config-tabs button,
    #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button),
  body :is(.connected-tab, .device-type-tab, .dsh-detail-tab, .tbw-outlet-tab-btn,
    #device-config-tabs button, #tcp-dev-config-tabs button,
    #tbw-cm-config-tabs button, #rack-cm-config-tabs button):not(#main-nav button)::after {
    transition:none;
    animation:none;
  }
}
#right-panel .ems-topology :is(.card, fieldset, .ems-topology-list, .ems-data-source,
  .ems-topology-item, .ems-data-type, .ems-meter-device, .ems-zone-device-details),
#right-panel .ems-topology :is(.ems-topology-item, .ems-data-type).active::before {
  border-radius:0;
}
#right-panel .ems-topology .ems-topology-list > .ems-topology-item,
#right-panel .ems-topology .ems-zone-items > .ems-topology-item,
#right-panel .ems-topology .ems-data-types > .ems-data-type {
  margin:0;
  background:#e8e8e8 !important;
  color:#303946 !important;
  box-shadow:0 1px 3px rgba(31, 41, 55, 0.16);
}
#right-panel .ems-topology .ems-topology-list > .ems-topology-item + .ems-topology-item,
#right-panel .ems-topology .ems-zone-items > .ems-topology-item + .ems-topology-item,
#right-panel .ems-topology .ems-data-types > .ems-data-type + .ems-data-type {
  border-top:1px solid #b8b8b8;
}
#right-panel .ems-topology .ems-zone-items > .ems-topology-item,
#right-panel .ems-topology .ems-data-types.ems-circuit-list .ems-circuit-items-scroll > .ems-data-type {
  margin:0;
  background:#e8e8e8 !important;
  color:#303946 !important;
  box-shadow:0 1px 3px rgba(31, 41, 55, 0.16);
}
#right-panel .ems-topology .ems-zone-items > .ems-topology-item + .ems-topology-item,
#right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type + .ems-data-type {
  border-top:1px solid #b8b8b8;
}
#right-panel .ems-topology .ems-topology-list > .ems-topology-item.active + .ems-topology-item,
#right-panel .ems-topology .ems-zone-items > .ems-topology-item.active + .ems-topology-item,
#right-panel .ems-topology .ems-data-types > .ems-data-type.active + .ems-data-type,
#right-panel .ems-topology .ems-topology-list > .ems-topology-item + .ems-topology-item.active,
#right-panel .ems-topology .ems-zone-items > .ems-topology-item + .ems-topology-item.active,
#right-panel .ems-topology .ems-data-types > .ems-data-type + .ems-data-type.active {
  border-top-color:transparent;
}
#right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type.active + .ems-data-type,
#right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type + .ems-data-type.active {
  border-top-color:transparent;
}
#right-panel .ems-topology .ems-data-types:not(.ems-circuit-list) > .ems-data-type {
  border:0 !important;
}
#right-panel .ems-topology .ems-data-types:not(.ems-circuit-list) > .ems-data-type:not(.active) + .ems-data-type:not(.active) {
  border-top:1px solid #b8b8b8 !important;
}
#right-panel .ems-topology .ems-data-types {
  gap:0;
}
#right-panel .ems-topology .ems-zone-items > .ems-topology-item:hover,
#right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type:hover,
#right-panel .ems-topology .ems-data-types > .ems-data-type:hover {
  position:relative;
  z-index:1;
  box-shadow:0 2px 6px rgba(31, 41, 55, 0.2);
}
#right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type:not(.active) :is(
  select, option, .ems-circuit-phase-button
) {
  color:#606975 !important;
}
html[data-theme="dark"] #right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type:not(.active) :is(
  select, option, .ems-circuit-phase-button
) {
  color:#bac3cf !important;
}
#right-panel .ems-topology .ems-data-types:not(.ems-circuit-list) > .ems-data-type:not(.active) {
  color:#606975 !important;
}
html[data-theme="dark"] #right-panel .ems-topology .ems-data-types:not(.ems-circuit-list) > .ems-data-type:not(.active) {
  color:#bac3cf !important;
}
#right-panel .ems-topology .ems-topology-list > .ems-topology-item.active,
#right-panel .ems-topology .ems-zone-items > .ems-topology-item.active,
#right-panel .ems-topology .ems-circuit-items-scroll > .ems-data-type.active,
#right-panel .ems-topology .ems-data-types.ems-circuit-list .ems-circuit-items-scroll > .ems-data-type.active,
#right-panel .ems-topology .ems-data-types > .ems-data-type.active {
  background:#fff !important;
  color:#303946 !important;
}
#energy-management .ems-topology-detail .ems-topology-pane > .ems-topology-list:is(.ems-zones-panel, .ems-circuits-panel) {
  display:flex;
  flex-direction:column;
  min-height:0;
  overflow:hidden;
}
#energy-management .ems-zones-panel > .ems-zone-toolbar {
  flex:0 0 auto;
  position:static;
}
#energy-management .ems-zones-panel > .ems-zone-items {
  flex:1 1 auto;
  min-height:0;
  height:auto;
  overflow-y:auto;
  padding:0;
}
#energy-management .ems-zones-panel > .ems-zone-items > .ems-zone-add-footer {
  display:block;
  width:100%;
  margin:20px 0 0;
  border-radius:0;
}
#energy-management .ems-circuits-panel > .ems-circuit-list {
  display:flex;
  flex:1 1 auto;
  flex-direction:column;
  min-width:0;
  min-height:0;
  gap:0;
  overflow:hidden;
}
#energy-management .ems-circuits-panel .ems-circuit-items-scroll {
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  overflow:auto;
}
#energy-management .ems-circuit-list-header {
  position:sticky;
  top:0;
  z-index:1;
  min-height:24px;
  background:#fff;
}
#energy-management .ems-circuit-items-scroll > .ems-topology-add-item {
  display:block;
  width:100%;
  margin:20px 0 0;
  border-radius:0;
}
