/* ════════════════════════════════════════════════════════════
   mwLink Bridge — Design System
   Based on mwConnect Connected Product Foundation (CPF)
   Matches the mwLink Cloud (Losant CPF) visual design exactly
   ════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  /* Brand / accent — matches CPF btn-custom #7896FF lavender-blue */
  --cpf-primary:      #7896FF;
  --cpf-secondary:    #404755;
  --cpf-success:      #029810;
  --cpf-danger:       #F87666;
  --cpf-warning:      #e58e00;
  --cpf-info:         #3db3b3;

  /* Text — matches CPF text hierarchy */
  --cpf-text-white:   #FFFFFF;
  --cpf-text-light:   #B0B2C9;
  --cpf-text-mid:     #56597B;
  --cpf-text-dark:    #13141E;

  /* Backgrounds — matches CPF bg_dark(body)/#f3f4f5, bg_mid/#fbfbfb, bg_light/white */
  --cpf-bg-light:     #FFFFFF;
  --cpf-bg-mid:       #FBFBFB;
  --cpf-bg-dark:      #F3F4F5;

  /* Borders — matches CPF E5E6F3 */
  --cpf-border:       #E5E6F3;
  --cpf-nav-width:    260px;
  --cpf-topnav-height: 56px;

  /* Fonts — matches CPF Open Sans + DM Sans (used for labels/telemetry) */
  --cpf-font:         'Open Sans', 'Helvetica Neue', 'Arial', sans-serif;
  --cpf-font-dm:      'DM Sans', 'Open Sans', sans-serif;
}

/* ── Base ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: var(--cpf-font);
  font-size: 15px;
  color: var(--cpf-text-dark);
  background-color: var(--cpf-bg-dark) !important;
  overflow-x: hidden;
}

/* CPF body: fixed-top navbar means body needs top padding */
body.cpf-body {
  padding-top: var(--cpf-topnav-height);
}

/* ── Top Navigation ────────────────────────────────────────── */
.navbar-top {
  height: var(--cpf-topnav-height);
  background-color: var(--cpf-bg-light);
  box-shadow: 0 0 12px 2px rgba(0, 0, 0, 0.06);
  z-index: 1040;
}

.brand-text {
  font-size: 20px;
  font-weight: 700;
  color: var(--cpf-text-dark);
  letter-spacing: -0.3px;
}
.brand-accent { color: var(--cpf-primary); }
.brand-small { font-size: 14px; font-weight: 700; }

/* Logo image in top nav */
.navbar-brand-img {
    height: 42px;
  object-fit: contain;
}

.user-icon {
  font-size: 28px;
  color: var(--cpf-text-mid);
  cursor: pointer;
}
.icon-sm { font-size: 16px; vertical-align: middle; }

/* ── Page Wrapper (matches CPF `main` flex container) ────── */
.page-wrapper {
  display: flex;
  flex-wrap: nowrap;
  height: calc(100vh - var(--cpf-topnav-height));
  overflow-x: auto;
  overflow-y: hidden;
}

/* ── Sidebar Navigation ────────────────────────────────────── */
.cpf-element-nav {
  width: var(--cpf-nav-width);
  min-width: var(--cpf-nav-width);
  min-height: calc(100vh - var(--cpf-topnav-height));
  background-color: var(--cpf-bg-light);
  box-shadow: 0 0 12px 2px rgba(0, 0, 0, 0.05);
  padding: 12px 0;
  position: sticky;
  top: var(--cpf-topnav-height);
  align-self: flex-start;
  height: calc(100vh - var(--cpf-topnav-height));
  overflow-y: auto;
  z-index: 1030;
}

.cpf-element-nav .nav-link {
  color: var(--cpf-text-dark);
  border-radius: 6px;
  margin: 2px 10px;
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s;
}

.cpf-element-nav .nav-link:hover {
  background-color: var(--cpf-bg-dark);
  color: var(--cpf-primary);
}

.cpf-element-nav .nav-link.active {
  background-color: var(--cpf-bg-dark);
  color: var(--cpf-text-dark);
  font-weight: 700;
  letter-spacing: -0.28px;
}

.cpf-text-dark { color: var(--cpf-text-dark); }

.cpf-element-nav-top { flex: 1; }

.cpf-icon-small {
  font-size: 18px;
  vertical-align: middle;
}

.cpf-element-nav-label {
  vertical-align: middle;
}

/* ── Main Content ──────────────────────────────────────────── */
.cpf-page {
  background-color: var(--cpf-bg-mid);
  padding: 10px 42px;
  width: 100%;
  height: calc(100vh - var(--cpf-topnav-height));
  box-sizing: border-box;
  position: relative;
  overflow-y: auto;
}

/* ── Block Components ──────────────────────────────────────── */
.cpf-block-small {
  background-color: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 20px;
  width: 100%;
}

.cpf-block {
  height: 322px;
  background-color: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  overflow: hidden;
}

.cpf-block-x-small {
  height: 166px;
  background-color: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
}

.cpf-block-large {
  height: 346px;
  background-color: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  overflow: hidden;
}

/* ── Typography ────────────────────────────────────────────── */
.h5-title {
  color: #13141E;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--cpf-text-dark);
  margin-bottom: 24px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn-primary,
.btn-custom {
  display: inline-flex;
  padding: 8px 28px;
  justify-content: center;
  align-items: center;
  gap: 10px;
  border-radius: 6px;
  background: var(--cpf-primary) !important;
  color: #FFF !important;
  font-size: 12px;
  font-weight: 600;
  border-color: var(--cpf-primary) !important;
}

.btn-primary:hover,
.btn-custom:hover {
  filter: brightness(0.9);
}

.btn-primary:disabled,
.btn-custom:disabled {
  filter: brightness(0.55) !important;
  background-color: var(--cpf-primary) !important;
}

.btn-outline-secondary {
  border-color: var(--cpf-border) !important;
  color: var(--cpf-text-mid) !important;
}
.btn-outline-secondary:hover {
  background-color: var(--cpf-bg-dark) !important;
  color: var(--cpf-text-dark) !important;
}

/* ── Status Badges ─────────────────────────────────────────── */
.badge-online  { background-color: var(--cpf-success) !important; }
.badge-offline { background-color: var(--cpf-danger)  !important; }
.badge-error   { background-color: #dc3545 !important; }
.badge-unknown { background-color: var(--cpf-text-mid)!important; }
.badge-degraded{ background-color: var(--cpf-warning) !important; color: #333 !important; }
.badge-pending_discovery { background-color: #6c757d !important; }

/* ── Telemetry Items ───────────────────────────────────────── */
.telemetry-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-left: 1em;
}

.telemetry-value {
  color: #525477;
  font-size: 24px;
  font-weight: 700;
}

.telemetry-description {
  color: #56597B;
  font-family: var(--cpf-font-dm);
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.32px;
}

/* ── Tables ────────────────────────────────────────────────── */
.table {
  font-size: 14px;
}

/* CPF table style — borderless rows, header/footer separated by single line */
.cpf-table tbody,
.cpf-table tfoot,
.cpf-table tr,
.cpf-table td,
.cpf-table th {
  border-style: none;
  border-width: 0;
}
.cpf-table thead > tr { font-weight: bold; }
.cpf-table td { padding-top: 12px; padding-bottom: 12px; }
.cpf-table { border-top: 1px solid var(--cpf-border); margin-bottom: 0 !important; }
.cpf-table > thead { border-bottom: 1px solid var(--cpf-border); }

.table thead th {
  font-weight: 700;
  font-size: 13px;
  color: var(--cpf-text-mid);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--cpf-border);
}

/* ── Range Slider (level control) ─────────────────────────── */
.level-slider {
  accent-color: var(--cpf-primary);
  width: 100%;
}

/* ── Spinner ───────────────────────────────────────────────── */
.spinner-brand {
  color: var(--cpf-primary);
}

/* ── Powered-by footer ─────────────────────────────────────── */
.powered-by-container {
  border-top: 1px solid var(--cpf-border);
  padding: 12px 16px 8px;
}

.powered-by-logo {
  max-width: 140px;
  height: auto;
  display: block;
}

.app-version {
  font-size: 11px;
  color: var(--cpf-text-light);
  margin-top: 4px;
}

/* ── Nav Admin section ─────────────────────────────────────────────── */
.cpf-nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cpf-text-light);
  padding: 6px 20px 2px;
  margin-top: 4px;
}

/* ── Dashboard filter bar ──────────────────────────────────────────── */
.cpf-filter-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--cpf-text-mid);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cpf-filter-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--cpf-text-dark);
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 6px;
  padding: 4px 14px;
}

/* ── Summary row (Total card) ──────────────────────────────────────── */
.cpf-summary-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cpf-summary-icon {
  font-size: 28px;
  color: var(--cpf-primary);
  flex-shrink: 0;
}
.cpf-summary-label {
  font-size: 12px;
  color: var(--cpf-text-mid);
}
.cpf-summary-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--cpf-text-dark);
  line-height: 1.1;
}

/* ── Overview row (Overview card) ─────────────────────────────────── */
.cpf-overview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--cpf-border);
}
.cpf-overview-row:last-child { border-bottom: none; }
.cpf-overview-icon {
  font-size: 20px;
  color: var(--cpf-primary);
  flex-shrink: 0;
}
.cpf-overview-label {
  font-size: 13px;
  color: var(--cpf-text-dark);
}

/* ── Zone card click-to-select (faults / energy / occupancy grids) ─── */
[data-zone]:not(.zone-card-solo) { cursor: pointer; }

/* ── Area card (dashboard + areas page) ────────────────────────────── */
.cpf-area-card {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 10px;
  padding: 16px;
  transition: box-shadow 0.15s, border-color 0.15s;
  height: 100%;
}
.cpf-area-card:hover {
  box-shadow: 0 4px 16px rgba(120, 150, 255, 0.15);
  border-color: var(--cpf-primary);
}
.cpf-area-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--cpf-text-dark);
}
.cpf-area-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--cpf-text-mid);
}

/* ── Zone badge (area card) ────────────────────────────────────────── */
.cpf-zone-badge {
  background: var(--cpf-bg-mid);
  color: var(--cpf-text-mid);
  border: 1px solid var(--cpf-border);
  font-weight: 500;
  font-size: 11px;
}

/* ── Zone card (area_detail) ───────────────────────────────────────── */
.cpf-zone-card {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 12px 14px;
  transition: box-shadow 0.15s, border-color 0.15s;
  color: var(--cpf-text-dark);
}
.cpf-zone-card:hover {
  box-shadow: 0 2px 8px rgba(120, 150, 255, 0.12);
  border-color: var(--cpf-primary);
}

/* ── Form controls — match CPF border/radius ───────────────── */
.form-control {
  padding: 8px 18px;
  border-radius: 6px;
  border: 1px solid var(--cpf-border);
  font-size: 14px;
}

.form-select {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--cpf-border);
  font-size: 14px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--cpf-primary);
  box-shadow: 0 0 0 0.2rem rgba(120, 150, 255, 0.25);
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-content {
  border-radius: var(--bs-border-radius, 8px);
  border: 1px solid var(--cpf-border);
}

.modal-header {
  border-bottom: 1px solid var(--cpf-border);
  font-weight: 700;
}

.modal-footer {
  border-top: 1px solid var(--cpf-border);
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  .cpf-element-nav {
    position: fixed;
    top: var(--cpf-topnav-height);
    left: 0;
    z-index: 1035;
    min-height: 100vh;
  }
  .cpf-page {
    padding: 20px 16px;
  }
}

/* ── Filter bar (Areas & Zones page) ──────────────────────────────── */
.cpf-filter-bar {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 12px 16px;
}
.cpf-select {
  font-size: 13px;
  color: var(--cpf-text-dark);
  border: 1px solid var(--cpf-border);
  border-radius: 6px;
  background: #fff;
}
.cpf-select:focus {
  border-color: var(--cpf-primary);
  box-shadow: 0 0 0 0.15rem rgba(25, 129, 232, 0.2);
}

/* ══════════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════════ */

.login-body {
  min-height: 100vh;
  background: #f0f1f3;
  display: flex;
  flex-direction: column;
  font-family: var(--cpf-font, 'Open Sans', sans-serif);
}

/* Wrapper fills remaining space above footer */
.login-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 16px;
}

.login-card {
  background: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  padding: 48px 44px 40px;
  width: 100%;
  max-width: 440px;
}

/* Logo */
.login-logo-wrap {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo {
  max-width: 200px;
  height: auto;
}

/* Field labels */
.login-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #2c2d3a;
  margin-bottom: 6px;
}

.login-device-id {
  background: #f5f7fc;
  border: 1px solid #d9dfef;
  border-radius: 8px;
  padding: 12px 14px;
}

.login-device-id-label {
  font-size: 12px;
  font-weight: 700;
  color: #58607a;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.login-device-id-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.login-device-id-value {
  flex: 1;
  display: block;
  margin: 0;
  padding: 8px 10px;
  background: #ffffff;
  border: 1px solid #cfd6e8;
  border-radius: 6px;
  color: #22304d;
  font-size: 13px;
  word-break: break-all;
}

.login-device-id-copy {
  border: 1px solid #c7d3f6;
  background: #ffffff;
  color: #2d62cf;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.login-device-id-copy:hover,
.login-device-id-copy:focus {
  background: #edf3ff;
  color: #234ea7;
}

.login-device-id-help {
  margin-top: 8px;
  font-size: 12px;
  color: #6e7691;
  line-height: 1.4;
}

/* Inputs — blue outline on focus */
.login-input {
  font-size: 14px;
  border: 1px solid #c8cbda;
  border-radius: 6px;
  padding: 9px 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-input:focus {
  border-color: #3d75e4;
  box-shadow: 0 0 0 0.2rem rgba(61, 117, 228, 0.2);
  outline: none;
}

/* Password wrapper with eye toggle */
.login-pwd-wrap {
  position: relative;
}

.login-pwd-wrap .login-input {
  padding-right: 44px;
  width: 100%;
}

.login-pwd-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 4px;
  color: #8b8ea8;
  cursor: pointer;
  line-height: 1;
}

.login-pwd-toggle:hover {
  color: #3d75e4;
}

/* Disclaimer text */
.login-terms {
  font-size: 12px;
  color: #8b8ea8;
  text-align: center;
  margin: 16px 0 18px;
  line-height: 1.5;
}

.login-link {
  color: #3d75e4;
  text-decoration: none;
}

.login-link:hover {
  text-decoration: underline;
}

/* Sign In button */
.btn-signin {
  background-color: #3d75e4;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  padding: 10px 0;
  transition: background-color 0.15s;
}

.btn-signin:hover,
.btn-signin:focus {
  background-color: #2d62cf;
  color: #ffffff;
}

/* Forgot Password link */
.login-forgot {
  font-size: 13px;
  color: #3d75e4;
  text-decoration: none;
}

.login-forgot:hover {
  text-decoration: underline;
}

/* Page footer */
.login-footer {
  text-align: center;
  padding: 14px 16px;
  font-size: 12px;
  color: #9496a8;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.login-env {
  background: #e5e6f3;
  color: #56597b;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  padding: 2px 8px;
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD — new cloud-matching elements
   ══════════════════════════════════════════════════════════════ */

/* Site selection input (read-only, matches cloud focused-style) */
.dashboard-site-input {
  max-width: 320px;
  background: var(--cpf-bg-light);
  border: 1.5px solid var(--cpf-primary);
  color: var(--cpf-text-dark);
  font-weight: 500;
  font-size: 14px;
  border-radius: 6px;
  padding: 5px 14px;
  cursor: default;
}

.dashboard-site-input:focus {
  border-color: var(--cpf-primary);
  box-shadow: 0 0 0 0.15rem rgba(120, 150, 255, 0.2);
}

/* Site address in Total card */
.dashboard-address {
  font-size: 14px;
  font-weight: 400;
  color: var(--cpf-text-mid);
  line-height: 1.4;
}

/* Device count link */
.dashboard-device-link {
  color: var(--cpf-text-dark);
}

.dashboard-device-link:hover {
  color: var(--cpf-primary);
}

.dashboard-device-icon {
  font-size: 26px;
  color: var(--cpf-text-mid);
}

.dashboard-device-count {
  font-size: 22px;
  font-weight: 700;
  color: var(--cpf-text-dark);
}

/* Map block */
.dashboard-map-block {
  height: 360px;
}

.dashboard-map-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.dashboard-map-placeholder {
  width: 100%;
  height: 100%;
  background: var(--cpf-bg-dark);
}

/* ══════════════════════════════════════════════════════════════
   STATUS & CONTROL PAGE
   ══════════════════════════════════════════════════════════════ */

/* Controls bar */
.sc-bar {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 20px 24px;
}

/* Vertical divider between area selector and override controls */
.sc-vdivider {
  width: 1px;
  background: var(--cpf-border);
  height: 100%;
  min-height: 40px;
}

/* Uppercase micro-label */
.sc-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--cpf-text-mid);
  white-space: nowrap;
}

/* Section heading inside bar */
.sc-section-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--cpf-text-dark);
}

/* Narrow number input for dim level */
.sc-dim-input {
  width: 90px !important;
  text-align: center;
}

/* Zone card */
.sc-zone-card {
  position: relative;
  height: 100%;
  min-height: 160px;
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 16px;
  transition: box-shadow 0.15s, border-color 0.15s;
}

/* Slow pulse for active HVAC/fan icons */
@keyframes hvac-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}
.tstat-active {
  animation: hvac-pulse 2.4s ease-in-out infinite;
}

/* Footer section — always rendered, keeps all cards the same height */
.zone-card-footer {
  border-top: 1px solid #eee;
  margin-top: 6px;
  padding-top: 4px;
  min-height: 30px;
}

/* HVAC status block — compact 2-row display */
.zone-hvac-status {
  font-size: 10px;
  line-height: 1.4;
  color: #666;
  flex: 1;
  min-width: 0;
}
.zone-hvac-placeholder {
  /* empty spacer for non-HVAC cards — keeps footer same height */
}

/* Gear / config button */
.zone-cfg-btn {
  background: none;
  border: none;
  padding: 2px 3px;
  cursor: pointer;
  color: #bbb;
  line-height: 1;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.zone-cfg-btn:hover {
  color: #555;
  background: #f0f0f0;
}

/* Pill flash while awaiting BACnet confirmation */
@keyframes pill-flash {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}
.zt-sending .badge {
  animation: pill-flash 1.4s ease-in-out infinite;
}

/* Lock controls while command is pending — prevent double-sends */
.zt-sending .zone-tog,
.zt-sending .zone-slider {
  pointer-events: none;
  opacity: 0.45;
}

/* Selected zone card */
.sc-zone-card.zt-selected {
  border-color: var(--cpf-primary);
  box-shadow: 0 0 0 2px rgba(13, 110, 253, 0.25), 0 2px 10px rgba(13, 110, 253, 0.1);
}

/* Selection checkbox */
.zone-select-cb {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--cpf-primary);
  margin-top: 1px;
}

.sc-zone-card:hover {
  box-shadow: 0 2px 10px rgba(120, 150, 255, 0.12);
  border-color: var(--cpf-primary);
}

.sc-zone-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--cpf-text-dark);
}

.sc-zone-area {
  font-size: 11px;
  color: var(--cpf-text-mid);
}

/* Level progress bar */
.sc-level-bar-wrap {
  height: 6px;
  background: var(--cpf-bg-dark);
  border-radius: 3px;
  overflow: hidden;
}

.sc-level-bar {
  height: 100%;
  background: var(--cpf-primary);
  border-radius: 3px;
  transition: width 0.35s ease;
  min-width: 0;
}

/* Level badge states — fixed width so digit count doesn't shift layout */
.sc-badge-on,
.sc-badge-off,
.sc-badge-unknown {
  min-width: 46px;
  text-align: center;
  display: inline-block;
}
.sc-badge-on {
  background: var(--cpf-primary) !important;
  color: #fff !important;
}
.sc-badge-off {
  background: var(--cpf-bg-dark) !important;
  color: var(--cpf-text-mid) !important;
}
.sc-badge-unknown {
  background: var(--cpf-border) !important;
  color: var(--cpf-text-mid) !important;
}

/* Occupancy chip pill */
.zone-occ-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  gap: 3px;
  white-space: nowrap;
  cursor: default;
}
.zone-occ-chip .material-symbols-outlined {
  font-size: 15px;
  line-height: 1;
}
.zone-occ-chip.occ-occupied {
  background: rgba(76,175,80,0.15);
  border-color: rgba(76,175,80,0.45);
  color: #2e7d32;
}
.zone-occ-chip.occ-hold {
  background: rgba(255,152,0,0.15);
  border-color: rgba(255,152,0,0.45);
  color: #e65100;
}
.zone-occ-chip.occ-unoccupied {
  background: var(--cpf-bg-dark);
  border-color: var(--cpf-border);
  color: var(--cpf-text-mid);
}

.zone-temp-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 20px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  gap: 3px;
  cursor: default;
}
.zone-temp-chip.temp-chip-cool {
  background: rgba(13,202,240,0.15);
  border-color: rgba(13,202,240,0.45);
  color: #0987a0;
}
.zone-temp-chip.temp-chip-heat {
  background: rgba(220,53,69,0.12);
  border-color: rgba(220,53,69,0.40);
  color: #b02a37;
}
.zone-temp-chip.temp-chip-neutral {
  background: var(--cpf-bg-dark);
  border-color: var(--cpf-border);
  color: var(--cpf-text-mid);
}

/* ── Fan chip pill (zone cards) ─────────────────────────────────────────── */
.zone-fan-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  border-radius: 20px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  gap: 2px;
  cursor: default;
}
.zone-fan-chip.fan-chip-on {
  background: rgba(32,201,151,0.15);
  border-color: rgba(32,201,151,0.45);
  color: #0f8060;
}
.zone-fan-chip.fan-chip-auto {
  background: var(--cpf-bg-dark);
  border-color: var(--cpf-border);
  color: var(--cpf-text-mid);
}

/* ── Humidity chip pill (zone cards) ────────────────────────────────────── */
.zone-hum-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 5px;
  border-radius: 20px;
  border: 1px solid rgba(13,110,253,0.25);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  gap: 2px;
  cursor: default;
  background: rgba(13,110,253,0.08);
  color: #3572c6;
}

/* ── Occupancy page cards ───────────────────────────────────────────────── */
.occ-card {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 14px 16px 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
  height: 100%;
}
.occ-card:hover {
  box-shadow: 0 2px 10px rgba(120, 150, 255, 0.12);
  border-color: var(--cpf-primary);
}
.occ-zone-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--cpf-text-dark);
}
.occ-zone-sub {
  font-size: 11px;
  color: var(--cpf-text-mid);
}
.occ-chip-unknown {
  font-size: 11px;
  color: var(--cpf-text-mid);
  flex-shrink: 0;
}
.occ-chart-canvas {
  border-radius: 4px;
  display: block;
  width: 100%;
}
.occ-axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--cpf-text-mid);
  margin-top: 3px;
  user-select: none;
}

/* ── Energy page cards ──────────────────────────────────────────────────── */
.nrg-card {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 8px;
  padding: 14px 16px 12px;
  transition: box-shadow 0.15s, border-color 0.15s;
  height: 100%;
}
.nrg-card:hover {
  box-shadow: 0 2px 10px rgba(120, 150, 255, 0.12);
  border-color: var(--cpf-primary);
}
.nrg-zone-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--cpf-text-dark);
}
.nrg-zone-sub {
  font-size: 11px;
  color: var(--cpf-text-mid);
}
.nrg-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  border: 1px solid rgba(33,150,243,0.45);
  background: rgba(33,150,243,0.12);
  color: #1565c0;
  font-size: 11px;
  font-weight: 600;
  gap: 3px;
  white-space: nowrap;
  cursor: default;
}
.nrg-chip .material-symbols-outlined {
  font-size: 15px;
  line-height: 1;
}
.nrg-chart-canvas {
  border-radius: 4px;
  display: block;
  width: 100%;
}
.nrg-axis-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--cpf-text-mid);
  margin-top: 3px;
  user-select: none;
}

/* Zone card toggle switch */
.zone-tog {
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--cpf-bg-dark);
  border: 1px solid var(--cpf-border);
  position: relative;
  flex-shrink: 0;
  padding: 0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.zone-tog .zt-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--cpf-text-mid);
  transition: transform 0.2s, background 0.2s;
}
.zone-tog.zt-on {
  background: var(--cpf-primary);
  border-color: var(--cpf-primary);
}
.zone-tog.zt-on .zt-thumb {
  transform: translateX(20px);
  background: #fff;
}
/* Pulse ring while command is in flight */
@keyframes zt-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(var(--cpf-primary-rgb, 13,110,253), 0.5); }
  70%  { box-shadow: 0 0 0 6px rgba(var(--cpf-primary-rgb, 13,110,253), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--cpf-primary-rgb, 13,110,253), 0); }
}
.zone-tog.zt-sending {
  animation: zt-pulse 0.8s ease-out infinite;
  pointer-events: none;
}

/* Dim level % readout */
.zone-dim-pct {
  font-size: 12px;
  color: var(--cpf-text-mid);
  min-width: 34px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── NetX Thermostat screen widget ─────────────────────────────────────── */
.ntp-screen-card {
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 12px;
  padding: 20px 16px 16px;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* The dark "glass" face */
.ntp-screen {
  width: 100%;
  max-width: 320px;
  background: #0d1117;
  border-radius: 20px;
  border: 2px solid rgba(255,255,255,0.08);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 4px 24px rgba(0,0,0,0.35);
  padding: 28px 20px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  transition: box-shadow 0.6s ease, border-color 0.6s ease;
  position: relative;
  overflow: hidden;
}
/* Subtle gloss line at top */
.ntp-screen::before {
  content: '';
  position: absolute;
  top: 0; left: 12%; right: 12%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.14), transparent);
  pointer-events: none;
}

/* Active state glow — cool (blue) */
.ntp-screen.ntp-active-cool {
  border-color: rgba(13,202,240,0.40);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 4px 24px rgba(0,0,0,0.35),
    0 0 22px rgba(13,202,240,0.28);
}
/* Active state glow — heat (red) */
.ntp-screen.ntp-active-heat {
  border-color: rgba(220,53,69,0.40);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.06),
    0 4px 24px rgba(0,0,0,0.35),
    0 0 22px rgba(220,53,69,0.28);
}

/* Gateway name label at top of screen */
.ntp-screen-name {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255,255,255,0.30);
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  margin-bottom: 8px;
}

/* Big temperature readout */
.ntp-screen-temp {
  font-size: 5.2rem;
  font-weight: 700;
  line-height: 1;
  color: #dde1f0;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  font-family: var(--cpf-font-dm, 'DM Sans', 'Open Sans', sans-serif);
  transition: color 0.4s ease;
}
.ntp-screen-temp.ntp-temp-cool { color: #67e8f9; }
.ntp-screen-temp.ntp-temp-heat { color: #fca5a5; }

/* Mode label row — icon + text */
.ntp-screen-mode {
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  margin-top: 2px;
}

/* Active SP line */
.ntp-screen-sp {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

/* Stat chips row inside the screen face */
.ntp-screen-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

/* Individual stat chip — dark-glass style */
.ntp-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 12px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.11);
  color: rgba(255,255,255,0.60);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
/* Occupied state — soft green tint */
.ntp-stat-chip.chip-occupied {
  background: rgba(74,222,128,0.14);
  border-color: rgba(74,222,128,0.30);
  color: #86efac;
}
/* Fan On state — teal tint */
.ntp-stat-chip.chip-fan-on {
  background: rgba(52,211,153,0.14);
  border-color: rgba(52,211,153,0.30);
  color: #6ee7b7;
}
/* CO2 high alert — amber tint */
.ntp-stat-chip.chip-co2-high {
  background: rgba(251,191,36,0.14);
  border-color: rgba(251,191,36,0.30);
  color: #fde68a;
}

/* Override badge row below the screen (warning) */
.ntp-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  width: 100%;
}

/* Range slider accent colour */
.zone-slider {
  accent-color: var(--cpf-text-mid);
}
/* webkit track: grey when off, blue gradient trail when on */
.zone-slider::-webkit-slider-runnable-track {
  background: rgba(108,117,125,0.25) !important;
}
.zone-tog.zt-on + .zone-slider::-webkit-slider-runnable-track {
  background: linear-gradient(
    to right,
    var(--cpf-primary) 0%,
    var(--cpf-primary) var(--fill, 0%),
    rgba(108,117,125,0.25) var(--fill, 0%),
    rgba(108,117,125,0.25) 100%
  ) !important;
  accent-color: var(--cpf-primary);
}
/* Firefox */
.zone-tog.zt-on + .zone-slider::-moz-range-progress {
  background-color: var(--cpf-primary);
}

/* ── Floor Plan view ─────────────────────────────────────────────── */

/* Container holds the image and SVG overlay */
.sc-fp-container {
  position: relative;
  margin: 0 auto;
  border-radius: 8px;
  border: 1px solid var(--cpf-border);
  background: #ffffff;
  overflow: hidden;
  line-height: 0; /* removes gap under inline img */
}

.sc-fp-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
  user-select: none;
  -webkit-user-drag: none;
}

/* SVG overlay sits exactly on top of the image */
.sc-fp-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* Zone marker circle and label in SVG */
.fp-marker circle {
  transition: r 0.15s, filter 0.15s;
  cursor: pointer;
}
.fp-marker:hover circle {
  filter: brightness(1.15);
}
.fp-marker.fp-edit circle {
  cursor: move;
}

/* Upload / empty placeholder */
.sc-fp-empty {
  border: 2px dashed var(--cpf-border);
  border-radius: 8px;
  padding: 56px 24px;
  text-align: center;
  background: var(--cpf-bg-dark);
}

/* Floating popup card — positioned via JS with position:fixed */
.sc-fp-popup {
  position: fixed;
  z-index: 1080;
  background: var(--cpf-bg-light);
  border: 1px solid var(--cpf-border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.13);
  padding: 14px 16px;
  min-width: 200px;
  max-width: 240px;
}

/* Edit-mode banner */
.sc-fp-edit-banner {
  background: #FFF7E0;
  border: 1px solid #E6CC7A;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  color: #7A5800;
}

/* ── Floor Plan Viewer / Editor (areas.html + area_detail.html) ─────────── */
.fp-viewport {
  width: 100%;
  max-width: 1556px;
  height: 610px;
  overflow: scroll;
  scrollbar-width: none;
  cursor: grab;
  border-radius: 8px;
  border: 1px solid var(--cpf-border);
  background: #ffffff;
}
.fp-viewport::-webkit-scrollbar { display: none; }

.fp-container {
  position: relative;
  display: block;
  width: 100%;
  margin: 0 auto;
  overflow: visible;
  user-select: none;
}

.fp-image {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
  draggable: false;
}

/* ── Zone marker ── */
.fp-zone-marker {
  position: absolute;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: default;
  user-select: none;
}

.fp-zone-marker.fp-unplaced {
  display: none !important;
}

.fp-marker-dot {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--cpf-primary);
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  transition: transform 0.1s, box-shadow 0.1s;
}

.fp-marker-label {
  margin-top: 3px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

/* Edit mode — markers become draggable */
.fp-edit-mode .fp-zone-marker {
  cursor: grab;
}
.fp-edit-mode .fp-zone-marker:hover .fp-marker-dot {
  box-shadow: 0 0 0 3px rgba(120,150,255,0.35), 0 2px 8px rgba(0,0,0,0.35);
}

.fp-zone-marker.fp-dragging {
  cursor: grabbing !important;
  z-index: 100;
}
.fp-zone-marker.fp-dragging .fp-marker-dot {
  transform: scale(1.15);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}

/* Remove button (×) on each marker in edit mode */
.fp-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--cpf-danger, #dc3545);
  border: none;
  color: #fff;
  font-size: 12px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 20;
}
.fp-remove-btn:hover { filter: brightness(0.85); }

/* Edit hint bar */
.fp-edit-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.58);
  color: #fff;
  font-size: 12px;
  padding: 5px 14px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: none;
  white-space: nowrap;
}

/* ── Empty state ── */
.fp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 52px 20px;
  text-align: center;
}

/* ── Unplaced zones panel ── */
.fp-unplaced-panel {
  background: var(--cpf-bg-dark);
  border: 1px dashed var(--cpf-border);
  border-radius: 8px;
  padding: 12px 14px;
}
.fp-unplaced-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--cpf-text-mid);
  display: flex;
  align-items: center;
  gap: 4px;
}
.fp-unplaced-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px dashed var(--cpf-primary);
  border-radius: 20px;
  font-size: 12px;
  color: var(--cpf-primary);
  background: var(--cpf-bg-light);
  cursor: grab;
  user-select: none;
}
.fp-unplaced-chip:hover {
  background: rgba(100, 130, 255, 0.08);
}
.fp-unplaced-chip:active {
  cursor: grabbing;
}

/* ── Toast notification ── */
.fp-toast {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 10px;
}
.fp-toast.fp-toast-success {
  background: rgba(25,135,84,0.12);
  border: 1px solid rgba(25,135,84,0.35);
  color: #157347;
}
.fp-toast.fp-toast-danger {
  background: rgba(220,53,69,0.10);
  border: 1px solid rgba(220,53,69,0.35);
  color: #b02a37;
}

