body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: transparent;
  color: #111;
  margin: 0;
  padding-inline: 20px; /*For Twinsights Styling Adaptation*/
}

.frame-container {
  display: none;
  width: 100%;
  height: calc(100vh - 80px);
}
.frame-container.active {
  display: block;
}
.frame-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

h1 {
  text-align: center;
  color: #2f3f59;
}

#devicesContainer {
  /* display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center; */
  display: flex;
  flex-wrap: nowrap;
  gap: 12px;
  overflow-x: auto;
  /* padding: 10px; */
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

#facilityContainer {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

:root {
  --accent: #2f3e5a;
  --accentdark: #1c2535;
  --accentlight: #3d5278;
  --accenttint: #f0f4fa;
  --bg: #eef1f6;
  --card: #ffffff;
  --card-inner: #f7f9fc;
  --text: #0f1923;
  --text-secondary: #4a5568;
  --muted: #8a96a8;
  --radius: 10px;
  --shadow: 0 2px 8px rgba(17, 24, 39, 0.06), 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-hover: 0 8px 24px rgba(17, 24, 39, 0.1), 0 2px 6px rgba(17, 24, 39, 0.06);
  --ok: #16a34a;
  --warn: #f59e0b;
  --crit: #ef4444;
  --border: #e2e7ef;
  --border-strong: #c8d0dc;
  --fill: 0%;
}
.realm-selector{
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 20px;
  gap: 20px;
}

/* ============================================================
   DEVICE CARD
   ============================================================ */
.panel-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--accent);
  text-transform: uppercase;
  text-align: center;
}

.device-card {
  /* background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex: 1;
  min-width: 260px;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition:
    box-shadow 0.2s,
    border-color 0.2s,
    transform 0.2s; */
  flex: 0 0 auto;
  width: 400px;

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.device-card:hover {
  box-shadow: var(--shadow-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}

/* Top accent line */
.device-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accentdark), var(--accentlight));
}

/* ---------- Title bar ---------- */
.device-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 13px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.device-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: var(--accent);
}

.device-id-badge {
  font-size: 12px;
  letter-spacing: 0.4px;
  color: var(--muted);
  font-family: 'Courier New', monospace;
  background: var(--accenttint);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
}
.device-category-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accenttint, #f0f4fa);
  color: var(--accent, #2f3e5a);
  border: 1px solid var(--border, #e2e7ef);
}
/* ---------- Metrics ---------- */
.metrics-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 7px;
  transition: background 0.15s;
}

.metric:hover {
  background: var(--accenttint);
}

.metric .left {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.6px;
  color: var(--muted);
  text-transform: uppercase;
  flex: 1;
}

.metric .right {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  font-family: 'Courier New', monospace;
  text-align: right;
}

/* unit text after value */
.metric .right span {
  color: var(--text);
}

.metric .right span + * {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

/* ---------- Toggle switch ---------- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  transition:
    background 0.2s,
    border-color 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  left: 2px;
  top: 2px;
  background: var(--muted);
  border-radius: 50%;
  transition:
    transform 0.2s,
    background 0.2s,
    box-shadow 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accentdark);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

/* ---------- Shed panel ---------- */
.shed-panel {
  margin: 0 12px 12px;
  border-radius: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.shed-active {
  background: rgba(245, 158, 11, 0.06);
  border-color: rgba(245, 158, 11, 0.25);
}

.shed-inactive {
  background: var(--card-inner);
  border-color: var(--border);
}

.shed-unconfigured {
  background: transparent;
  border-color: var(--border);
  border-style: dashed;
  opacity: 0.45;
}

.shed-unconfigured .shed-indicator {
  background: var(--muted);
}

.shed-unconfigured .shed-label {
  color: var(--muted);
  font-style: italic;
}

.shed-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.shed-indicator {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-strong);
  transition: background 0.3s;
  flex-shrink: 0;
}

.shed-active .shed-indicator {
  background: var(--warn);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.5);
}

.shed-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
  flex: 1;
}

.shed-active .shed-label {
  color: var(--warn);
}

.shed-toggle-wrap {
  margin-left: auto;
}

.shed-meta {
  display: flex;
  gap: 20px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(245, 158, 11, 0.15);
}

.shed-meta-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.shed-meta-label {
  font-size: 8px;
  letter-spacing: 0.8px;
  color: var(--muted);
  text-transform: uppercase;
}

.shed-meta-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--warn);
  font-family: 'Courier New', monospace;
}

/* END OF DEVICES CSS */

/* input[type="range"] {
  width: 140px;
} */

/* ALL IoT Panels use this */
.panel {
  display: flex ;
  flex-direction: column;
  /* max-width: 1080px; */
  /* margin: 20px auto; */
  margin-right: 10px;
  background: #ffffff;
  padding: 16px;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.06);
  border: 1px solid var(--bg);
  gap: 16px;
  min-height: 100%;
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 0;
  color: #1f2d4a;
  font-display: optional;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.form-row.small {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.form-row.small .inline {
  margin-left: 8px;
}

label {
  font-size: 13px;
  color: #334155;
}

input,
select {
  padding: 8px 10px;
  border-radius: 6px;
  border: 1px solid #d1e3f0;
  background: var(--accenttint);
  font-size: 14px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

button {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

button.secondary {
  background: #f3f4f6;
  color: #111;
}

.form-msg {
  margin-top: 8px;
  font-size: 13px;
  color: #0f5132;
}

@media (max-width: 640px) {
  .panel {
    padding: 12px;
  }

  .form-row.small {
    flex-direction: column;
  }
}

.device-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 22px;
}

.device-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.device-switch .slider {
  position: absolute;
  cursor: pointer;
  background-color: #c46767;
  border-radius: 22px;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  transition: 0.25s;
}

.device-switch .slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.25s;
}

.device-switch input:checked + .slider {
  background-color: #4caf50;
}

.device-switch input:checked + .slider::before {
  transform: translateX(20px);
}

.bool-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
}

.bool-status-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.bool-on {
  color: #3a9e6e;
  background: rgba(58, 158, 110, 0.1);
  border: 1px solid rgba(58, 158, 110, 0.25);
}

.bool-off {
  color: var(--muted);
  background: rgba(138, 150, 168, 0.08);
  border: 1px solid var(--border);
}

.agent-card {
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.agent-card-header {
  border-bottom: 1px solid #eef0f2;
  padding-bottom: 10px;
  margin-bottom: 12px;
}
.agent-card-header::-webkit-details-marker {
  display: none;
}
.agent-card-header::marker {
  content: none;
}
.agent-card-header::after {
  content: "->";
  float: right;
  transition: transform 0.2s;
}

details[open] .agent-card-header::after {
  transform: rotate(90deg);
}   
.agent-name {
  font-size: 16px;
  font-weight: 600;
  color: #1f2937;
}

.agent-id {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.agent-card-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px 24px;
}

/* Mobile fallback */
@media (max-width: 768px) {
  .agent-card-body {
    grid-template-columns: 1fr;
  }
}

.info-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.info-label {
  font-size: 13px;
  color: #6b7280;
}

.info-value {
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  text-align: right;
  word-break: break-word;
}

/* telemetry row card */
.telemetry-row {
  border: 1px solid #e6e8eb;
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

/* header with remove button */
.telemetry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.telemetry-header .telemetry-title {
  font-size: 14px;
  font-weight: 600;
}

.remove-telemetry {
  display: inline-flex;
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted, #718096);
  font-size: 16px;
  padding: 2px 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.remove-telemetry:hover {
  background: rgba(239,68,68,0.12);
  border-color: #f87171;
  color: #f87171;
}

/* Add button */
.add-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
}

.add-btn:hover {
  background: #095bb0;
}

/* pub-write section slight indent */
.pub-write-section {
  margin-left: 6px;
  border-left: 2px dashed #eef2f6;
  padding-left: 10px;
}

.tab-buttons {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  justify-content: center;
}

.tab-buttons button {
  padding: 8px 20px;
  cursor: pointer;
  /* border: 1px solid #ccc; */
  background: #c5c5c5;
  border-radius: var(--radius);
  color: var(--text);
}

.tab-buttons button:hover {
  background-color: #2f3f597c;
}

.tab-buttons button.active {
  background: var(--accent);
  font-weight: bold;
  color: white;
}

.tab-not-allowed {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  color: var(--text-muted, #888);
  font-size: 1rem;
}

.tab-not-allowed span {
  font-size: 2.5rem;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Category filter tabs (IoT Assets panel) */
.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  /* padding: 10px 0 14px; */
}

.category-tab-btn {
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: transparent;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.category-tab-btn:hover {
  background: #2f3f597c;
  border-color: var(--border-strong);
}

.category-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Setpoint controller */
.setpoint-control {
  display: flex;
  flex-direction: row;
  gap: 6px;
  width: 100%;
  align-items: center;
}

.setpoint-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent, #2f3e5a) var(--fill, 0%),
    var(--border) var(--fill, 0%)
  );
  outline: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

.setpoint-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: var(--shadow);
  cursor: grab;
  transition: transform 0.15s;
}

.setpoint-slider::-webkit-slider-thumb:active {
  cursor: grabbing;
  transform: scale(1.2);
}

.setpoint-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.setpoint-input {
  width: 64px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--card-inner);
  color: var(--text);
  font-family: 'Courier New', Courier, monospace;
  text-align: center;
}

.setpoint-input:focus {
  outline: none;
  border-color: var(--accent);
}

.setpoint-unit {
  font-size: 11px;
  color: var(--muted);
}

/* Inline editable inputs (non-readonly number / text) */
.inline-edit-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.inline-edit-input {
  width: 72px;
  padding: 4px 6px;
  font-size: 12px;
  font-family: inherit;
  color: var(--accent);
  background: var(--card-inner, #f5f7fb);
  border: 1px solid var(--border);
  border-radius: 5px;
  text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.inline-edit-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(47, 62, 90, 0.1);
}

.inline-edit-text {
  width: 110px;
  text-align: left;
}

.inline-edit-unit {
  font-size: 11px;
  color: var(--muted);
}

.device-title-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.device-indicator {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}

.indicator-ok,
.indicator-fail {
  opacity: 1;
}

.indicator-ok {
  color: var(--ok);
}

.indicator-fail {
  color: var(--crit);
}

.icon {
  font-size: 24px;
  color: var(--muted);
  vertical-align: middle;
  margin-right: 8px;
}

.icon-medium {
  font-size: 20px;
  vertical-align: middle;
  align-self: center  ;
}



.icon-mini {
  font-size: 16px;
  color: var(--muted);
  align-self: center;
}

.icon-nano {
  font-size: 16px;
  color: var(--muted);
  align-self: center;
  position: relative;
  opacity: 0.5;
  top: 1px;
}

.icon-green {
  color: var(--ok);
}

.icon-red {
  color: var(--crit);
}

.icon-yellow {
  color: var(--warn);
}

.icon-cold {
  color: var(--ACMV_COLOR);
}

.icon-water {
  color: var(--WATER_COLOR)
}

.icon-lightning {
 color: var(--ELECTRICAL_COLOR);
}

.icon-money {
  color: var(--COST_COLOR);
}

/* ============================================================
   Register Device — tab, table, modal, action button styles
   ============================================================ */

/* ── shared tab content visibility ──────────────────────── */
.tab-content { display: none; }
.tab-content.active { display: block; }
.hidden { display: none !important; }

/* ── edit-mode banner ────────────────────────────────────── */
.edit-mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  background: rgba(99,179,237,0.1);
  border: 1px solid var(--accent, #63b3ed);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--accent, #63b3ed);
}
.edit-mode-banner strong { font-weight: 600; }
.cancel-edit-btn {
  padding: 3px 12px;
  border: 1px solid var(--accent, #63b3ed);
  border-radius: 4px;
  background: transparent;
  color: var(--accent, #63b3ed);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}
.cancel-edit-btn:hover { background: rgba(99,179,237,0.18); }

/* ── assets table ────────────────────────────────────────── */
.assets-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}
.assets-table thead { border-bottom: 1px solid var(--border, #1e2d3d); }
.assets-table th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--muted, #718096);
  text-transform: uppercase;
}
.assets-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border, #1e2d3d);
  color: var(--text, #e2e8f0);
}
.assets-table tbody tr:hover { background: rgba(255,255,255,0.04); }

/* ── action buttons ──────────────────────────────────────── */
.action-buttons { display: flex; gap: 6px; }
.edit-btn, .delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.edit-btn {
  border: 1px solid var(--border, #1e2d3d);
  color: var(--muted, #718096);
}
.edit-btn:hover {
  background: rgba(99,179,237,0.12);
  border-color: var(--accent, #63b3ed);
  color: var(--accent, #63b3ed);
}
.delete-btn {
  border: 1px solid var(--border, #1e2d3d);
  color: var(--muted, #718096);
}
.delete-btn:hover {
  background: rgba(239,68,68,0.12);
  border-color: #f87171;
  color: #f87171;
}

/* ── search input ────────────────────────────────────────── */
.search-input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border, #1e2d3d);
  border-radius: 6px;
  background: transparent;
  color: var(--text, #e2e8f0);
  font-size: 0.875rem;
  width: 100%;
  max-width: 280px;
}
.search-input::placeholder { color: var(--muted, #718096); }
.search-input:focus { outline: none; border-color: var(--accent, #63b3ed); }

/* ── manage-assets tab header ────────────────────────────── */
.assets-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.no-assets-message { text-align: center; color: var(--muted, #718096); padding: 2rem; }

/* ── modal overlay backdrop ──────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}
.modal-overlay.active { display: flex; }

/* ── delete confirmation modal ───────────────────────────── */
.delete-modal-card {
  background: white;
  border-radius: 1rem;
  padding: 2.5rem 2rem 2rem;
  width: 380px;
  max-width: 92vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.delete-modal-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff1f0;
  color: #e53935;
  margin-bottom: 1.25rem;
}
.delete-modal-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #1a1a1a;
  margin: 0 0 0.5rem;
}
.delete-modal-message {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.5;
  margin: 0 0 1.5rem;
}
.delete-modal-response {
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  margin-bottom: 1.25rem;
}
.delete-modal-response.success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}
.delete-modal-response.error {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}
.delete-modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}
.delete-modal-cancel {
  flex: 1;
  padding: 0.75rem;
  border: 1px solid #ddd;
  background: #f5f5f5;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 500;
  color: #444;
  transition: background 0.15s, border-color 0.15s;
}
.delete-modal-cancel:hover:not(:disabled) {
  background: #e8e8e8;
  border-color: #bbb;
}
.delete-modal-cancel:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.delete-modal-confirm {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: #e53935;
  color: white;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.15s;
}
.delete-modal-confirm:hover:not(:disabled) { background: #c62828; }
.delete-modal-confirm:disabled {
  background: #ef9a9a;
  cursor: not-allowed;
}
.delete-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  font-size: 13px;
  color: var(--muted, #888);
  font-style: italic;
  width: 100%;
}

/* ── Optional-field infrastructure ───────────────────────────────────────── */

.add-optional-field-row { display: flex; gap: 8px; align-items: center; margin: 10px 0 4px; }
.add-optional-field-row select { flex: 1; }
.add-optional-btn { white-space: nowrap; }

.optional-field-card {
  border: 1px solid #d1e3f0;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #f8fbff;
}
.optional-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #334155;
}
.remove-optional-field {
  background: none;
  border: none;
  color: #e53935;
  font-size: 16px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.remove-optional-field:hover { color: #c62828; }

/* KV-map editor */
.kv-editor { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.kv-row { display: flex; gap: 6px; align-items: center; }
.kv-key, .kv-value { flex: 1; }
.kv-remove {
  background: none;
  border: none;
  color: #e53935;
  font-size: 14px;
  cursor: pointer;
  padding: 0 4px;
}
.add-kv-btn {
  font-size: 11px;
  padding: 4px 10px;
  background: #f3f4f6;
  border: 1px solid #d1e3f0;
  border-radius: 4px;
  cursor: pointer;
  color: #334155;
  align-self: flex-start;
}

/* Wildcard topic tags */
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; min-height: 24px; }
.tag-item {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #e0f0ff;
  color: #1e4976;
  border-radius: 12px;
  padding: 3px 10px;
  font-size: 12px;
}
.tag-remove {
  background: none;
  border: none;
  color: #1e4976;
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.add-tag-row { display: flex; gap: 6px; }
.add-tag-input { flex: 1; }
.add-tag-btn { font-size: 11px; padding: 4px 10px; }

/* ── Filter-array editor (valueFilters, messageMatchFilters, etc.) ─────────── */

.filter-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.filter-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-row select { width: 90px; }
.filter-row .filter-path { flex: 1; min-width: 120px; }
.filter-row .filter-check-group { display: flex; gap: 8px; align-items: center; font-size: 12px; color: #334155; white-space: nowrap; }
.filter-check-group label { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.filter-remove {
  display: inline-flex;
  align-items: center;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted, #718096);
  font-size: 14px;
  padding: 2px 5px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.filter-remove:hover {
  background: rgba(239,68,68,0.12);
  border-color: #f87171;
  color: #f87171;
}
.add-filter-btn { align-self: flex-start; margin-bottom: 8px; }

/* ── messageMatchPredicate ──────────────────────────────────────────────────── */

.predicate-type-row { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; font-size: 13px; }
.predicate-type-row label { color: #334155; white-space: nowrap; }
.predicate-sub-fields { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.predicate-sub-fields .form-row { margin-bottom: 0; flex: 1; min-width: 120px; }

/* ── Link-type section label ────────────────────────────────────────────────── */

.link-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  letter-spacing: 0.05em;
  margin: 8px 0 4px;
}

/* ── end optional-field styles ────────────────────────────────────────────── */

.page-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border, #e2e7ef);
  border-top-color: var(--accent, #2f3e5a);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

/* ── Custom checkbox styling (IoT form — excludes toggle-switch inputs) ─────── */
#asset-form input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border: 1.5px solid var(--border, #1e2d3d);
  border-radius: 3px;
  background: transparent;
  cursor: pointer;
  position: relative;
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  transition: background 0.15s, border-color 0.15s;
}
#asset-form input[type="checkbox"]:checked {
  background: var(--accent, #63b3ed);
  border-color: var(--accent, #63b3ed);
}
#asset-form input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}
#asset-form .toggle-switch input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  pointer-events: none;
}