:root {
  color-scheme: light;
  --tw-surface: #fff;
  --tw-surface-alt: #f4f6f7;
  --tw-text: #2c3e50;
  --tw-muted: #607d8b;
  --tw-heading: #00424e;
  --sensor-bg: #00424e;
  --sensor-edge: #00333d;
  --sensor-muted: #8fb6bd;
  --sensor-text: #fff;
}

:root[data-card-color="blue"] { --sensor-bg: #123d72; --sensor-edge: #0c2b52; --sensor-muted: #a4bdd9; }
:root[data-card-color="indigo"] { --sensor-bg: #303f77; --sensor-edge: #222c54; --sensor-muted: #b6bedc; }
:root[data-card-color="purple"] { --sensor-bg: #57386f; --sensor-edge: #3c264e; --sensor-muted: #cbb6da; }
:root[data-card-color="emerald"] { --sensor-bg: #125a48; --sensor-edge: #0b3e31; --sensor-muted: #9dc8b9; }
:root[data-card-color="slate"] { --sensor-bg: #344455; --sensor-edge: #23303d; --sensor-muted: #b3c2d0; }
:root[data-card-color="cyan"] { --sensor-bg: #07576b; --sensor-edge: #043c4b; --sensor-muted: #acd0da; }
:root[data-card-color="navy"] { --sensor-bg: #162c4b; --sensor-edge: #0c1c32; --sensor-muted: #adbed4; }
:root[data-card-color="orange"] { --sensor-bg: #874006; --sensor-edge: #5e2c04; --sensor-muted: #e8c8a9; }
:root[data-card-color="rose"] { --sensor-bg: #78374b; --sensor-edge: #542635; --sensor-muted: #dfb9c5; }
:root[data-card-color="white"] { --sensor-bg: #fff; --sensor-edge: #d6e1e4; --sensor-muted: #526e7a; --sensor-text: #23404a; --sensor-border: #dce7e7; }

:root[data-card-color="multicolor"] .sensor-card[data-color-index="0"] { --sensor-bg: #205d32; --sensor-end: #32743a; --sensor-edge: #174324; --sensor-muted: #d2e8d6; }
:root[data-card-color="multicolor"] .sensor-card[data-color-index="1"] { --sensor-bg: #123d72; --sensor-end: #1a5b88; --sensor-edge: #0c2b52; --sensor-muted: #c9dfee; }
:root[data-card-color="multicolor"] .sensor-card[data-color-index="2"] { --sensor-bg: #743547; --sensor-end: #884153; --sensor-edge: #502330; --sensor-muted: #ecd0d8; }
:root[data-card-color="multicolor"] .sensor-card[data-color-index="3"] { --sensor-bg: #125a48; --sensor-end: #17664f; --sensor-edge: #0b3e31; --sensor-muted: #c5e1d7; }
:root[data-card-color="multicolor"] .sensor-card[data-color-index="4"] { --sensor-bg: #874006; --sensor-end: #965419; --sensor-edge: #5e2c04; --sensor-muted: #f1dcc7; }
:root[data-card-color="multicolor"] .sensor-card[data-color-index="5"] { --sensor-bg: #57386f; --sensor-end: #6d4785; --sensor-edge: #3c264e; --sensor-muted: #e1d0ed; }
:root[data-card-color="multicolor"] .sensor-card {
  background-image:
    linear-gradient(110deg, var(--sensor-bg) 30%, transparent 100%),
    radial-gradient(circle, #ffffff24 1.5px, transparent 1.8px),
    linear-gradient(135deg, var(--sensor-bg), var(--sensor-end));
  background-size: 100% 100%, 16px 16px, 100% 100%;
}
:root[data-card-color="white"] .sensor-card {
  background-image: linear-gradient(110deg, #fff 40%, transparent 100%), radial-gradient(circle, #00424e12 1.5px, transparent 1.8px);
  background-size: 100% 100%, 16px 16px;
}
:root[data-card-color="white"] .sensor-card .sensor-footer { border-top-color: #dce7e7; }
:root[data-card-color="white"] .sensor-card .sensor-param-icon { background: #e8f3f1; border-color: #cddfdd; color: #376c67; }
:root[data-card-color="white"] .sensor-card .corrected-badge { background: #e8f5f1; color: #376c67; }

:root[data-theme="dark"] {
  color-scheme: dark;
  --tw-bg: #101c24;
  --tw-surface: #1b2b35;
  --tw-surface-alt: #243943;
  --tw-text: #e0ebef;
  --tw-muted: #afc2cb;
  --tw-heading: #c1eee5;
  --tw-card-border: #3c535f;
  --tw-accent-dark: #51d6bd;
  --tw-danger: #f0786b;
}

body { color: var(--tw-text); }
.meta { color: var(--tw-muted); }
.appearance-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--tw-warning);
  border-radius: 8px;
  background: var(--tw-surface);
  color: var(--tw-text);
}
.appearance-panel { max-width: 520px; }
.profile-page .profile-panel { max-width: 760px; }
.appearance-fields { border: 0; padding: 0; margin: 0; min-width: 0; }
.appearance-fields label { display: block; margin: 14px 0 6px; font-size: 13px; }
.appearance-fields select { width: 100%; padding: 10px 12px; border: 1px solid var(--tw-card-border); border-radius: 8px; font: inherit; }
.appearance-hint { color: var(--tw-muted); font-size: 13px; line-height: 1.6; }
.appearance-preview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 14px; margin: 18px 0; }
.appearance-preview { min-height: 190px; display: flex; flex-direction: column; }
.appearance-actions { display: flex; flex-wrap: wrap; gap: 10px; }

html[data-theme="dark"] :is(.panel, .summary-card, .device-list-panel, .device-card,
  .empty-state, .modal-dialog, .multiselect-panel, .settings-tabs, .pagination button,
  .multiselect-toggle, .icon-btn, .tv-fullscreen-overlay, table tr) {
  background: var(--tw-surface);
  color: var(--tw-text);
}
html[data-theme="dark"] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea) {
  background: var(--tw-surface-alt);
  color: var(--tw-text);
  border-color: var(--tw-card-border);
}
html[data-theme="dark"] :is(.meta, .detail-meta, .summary-card .label, .device-type,
  .item-sub, .profile-email, .modal-subtitle, .field-group label, .field-hint,
  .settings-subtitle, .settings-description, .settings-panel .field-group label,
  .settings-tabs [role="tab"], .instructions-list, .rule-emails, .form-step-label,
  .me-tab, .chosen-filename, .password-strength-label, .empty-note, .branding-row .meta,
  .schedule-table .sub, .me-overwrite-option small, .qr-panel p) {
  color: var(--tw-muted);
}
html[data-theme="dark"] :is(.profile-name, .client-name, .settings-panel h2,
  .settings-list-title, .modal-dialog h2, .me-tab.active, .me-sample-box i, .form-result,
  .me-export-title, #tvDeviceName) {
  color: var(--tw-heading);
}
html[data-theme="dark"] :is(.credentials-box, .api-example-box, .settings-panel > form,
  .multiselect-option:hover, .device-list-item:hover, .pagination button:hover:not(:disabled),
  .icon-btn:hover, .tv-exit-btn, #apiDeviceOptions) {
  background: var(--tw-surface-alt);
  color: var(--tw-text);
}
html[data-theme="dark"] :is(.device-list-item.active, .pagination button.active,
  .settings-tabs [aria-selected="true"]) {
  background: #167561;
  color: #fff;
}
html[data-theme="dark"] .device-list-item.active .item-sub { color: #d7eee8; }
html[data-theme="dark"] :is(.connection-status, .connection-status[data-state="degraded"],
  .control-warning, .control-badge, .demo-controller .control-badge, .form-note,
  .me-overwrite-option, .badge.warning) {
  background: #483c20;
  color: #f7d99a;
}
html[data-theme="dark"] :is(.dashboard-notice, .dashboard-alarm-panel,
  .connection-status[data-state="offline"], .badge.critical) {
  background: #482b30;
  color: #ffb7af;
  border-color: #965653;
}
html[data-theme="dark"] :is(.connection-status[data-state="live"], .badge.accent) { background: #193e35; color: #8ce2cb; }
html[data-theme="dark"] .badge.info { background: #213e56; color: #a3d8fb; }
html[data-theme="dark"] :is(.badge.neutral, .badge.disabled-badge) { background: #30434e; color: #c1d1d9; }
html[data-theme="dark"] :is(.button.accent, .button.accent:hover) { background: #167561; color: #fff; }
html[data-theme="dark"] :is(.button.secondary, .button.secondary:hover) { background: #4a606c; color: #fff; }
html[data-theme="dark"] :is(.button.danger, .button.danger:hover) { background: #b13d34; color: #fff; }
html[data-theme="dark"] .demo-controller { border-color: #d4ae59; }
html[data-theme="dark"] #controlMessage { color: var(--tw-heading); }
html[data-theme="dark"] #controlMessage[data-error="true"] { color: #ffb7af; }
html[data-theme="dark"] .control-history-entry { border-color: var(--tw-card-border); }
html[data-theme="dark"] :is(#tvDeviceMeta, .demo-controller .meta, .control-form .meta, .control-visual .meta) { color: var(--tw-muted); }
html[data-theme="dark"] .settings-tabs [role="tab"]:hover { background: #167561; color: #fff; }
html[data-theme="dark"] table td { border-bottom-color: var(--tw-card-border); }
html[data-theme="dark"] table td::before { color: var(--tw-muted); }
