:root {
  --bg: #edf3f8;
  --bg-soft: #f6f9fc;
  --surface: #ffffff;
  --surface-soft: #f8fbff;
  --surface-strong: #0d4d80;
  --surface-strong-2: #0b3c66;
  --text: #15324b;
  --text-soft: #5e748a;
  --line: #d7e2ec;
  --line-strong: #b9cbdc;
  --blue: #1863a2;
  --blue-2: #0c4f82;
  --blue-soft: #e7f2fd;
  --green: #1d9d58;
  --green-soft: #e8f7ee;
  --amber: #cc8a05;
  --amber-soft: #fff3de;
  --red: #d84d4d;
  --red-soft: #fdeaea;
  --shadow-sm: 0 8px 20px rgba(17, 49, 83, 0.05);
  --shadow-md: 0 18px 45px rgba(17, 49, 83, 0.09);
  --radius-card: 24px;
  --radius-pill: 999px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(24, 99, 162, 0.08), transparent 28%),
    linear-gradient(180deg, #f5f9fc 0%, var(--bg) 100%);
  color: var(--text);
}

body.auth-required {
  overflow: hidden;
}

button, input, select, textarea { font: inherit; }

[hidden] {
  display: none !important;
}

body.auth-shell-guest #refreshButton,
body.auth-shell-guest #logoutButton,
body.auth-shell-guest #liveBadge,
body.auth-shell-guest #tenantBadge,
body.auth-shell-guest #orgSwitch,
body.auth-shell-guest [data-view="matrix"],
body.auth-shell-guest [data-view="account"],
body.auth-shell-guest [data-view="app_android"],
body.auth-shell-guest [data-view="admin"],
body.auth-shell-guest [data-view="admin_accounts"] {
  display: none !important;
}

body.auth-shell-guest #headerAuthActions {
  display: inline-flex !important;
}

body.auth-shell-authenticated #headerAuthActions {
  display: none !important;
}

body[data-current-view="overview"] .workspace-hero,
body[data-current-view="overview"] .workspace-hint,
body[data-current-view="overview"] #globalContextHelp {
  display: none;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(7, 20, 34, 0.7);
  backdrop-filter: blur(4px);
}

.auth-overlay.visible {
  display: flex;
}

.auth-card {
  width: min(560px, 100%);
  max-height: min(92vh, 920px);
  overflow: auto;
  background: #ffffff;
  border-top: 6px solid var(--monitor-green, #5fad82);
  border-radius: 6px;
  box-shadow: 0 28px 70px rgba(7, 24, 40, 0.32);
  padding: 28px;
  display: grid;
  gap: 18px;
}

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  color: var(--surface-strong-2);
}

.auth-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.auth-switch-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.auth-mode-button {
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 10px 14px;
  background: var(--bg-soft);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.auth-mode-button.active {
  background: var(--monitor-green, #5fad82);
  color: #fff;
  border-color: var(--monitor-green, #5fad82);
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-form[hidden] {
  display: none !important;
}

.auth-link-button {
  width: fit-content;
  border: 0;
  background: transparent;
  color: var(--monitor-green-strong, #18884b);
  padding: 4px 0;
  font-weight: 800;
  cursor: pointer;
}

.auth-link-button:hover,
.auth-link-button:focus-visible {
  text-decoration: underline;
  outline: none;
}

.google-auth-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2937;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}

.google-auth-button:hover,
.google-auth-button:focus-visible {
  border-color: #3b82f6;
  color: #0f4c81;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 700;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.auth-download-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.auth-download-button {
  justify-content: center;
  min-height: 42px;
  text-align: center;
}

@media (max-width: 520px) {
  .auth-download-row {
    grid-template-columns: 1fr;
  }
}

.password-field {
  position: relative;
  display: flex;
  align-items: center;
}

.password-field input {
  width: 100%;
  padding-right: 86px;
}

.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  min-width: 58px;
  height: 34px;
  transform: translateY(-50%);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--blue-soft);
  color: var(--blue-2);
  font-size: .86rem;
  font-weight: 800;
  cursor: pointer;
}

.password-toggle:hover,
.password-toggle:focus-visible {
  border-color: var(--blue);
  background: #d8ebfb;
  outline: none;
}

.config-lazy-placeholder {
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--text-soft);
  padding: 14px;
  font-size: .9rem;
  font-weight: 700;
}

.config-section-picker {
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
  padding: 14px;
  display: grid;
  gap: 12px;
}

.config-section-picker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  color: #e2e8f0;
}

.config-section-picker-head span {
  color: rgba(226, 232, 240, 0.68);
  font-size: .86rem;
}

.config-section-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.config-section-choice {
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 10px;
  background: rgba(30, 41, 59, 0.82);
  color: #f8fafc;
  padding: 11px 12px;
  cursor: pointer;
}

.config-section-choice span {
  font-weight: 800;
}

.config-section-choice small {
  color: rgba(226, 232, 240, 0.65);
}

.config-section-choice:hover,
.config-section-choice:focus-visible {
  border-color: rgba(96, 165, 250, 0.7);
  background: rgba(30, 64, 110, 0.82);
  outline: none;
}

.config-section-choice.is-active {
  border-color: rgba(34, 197, 94, 0.7);
  background: rgba(20, 83, 45, 0.55);
}

.config-selected-section {
  display: grid;
  gap: 12px;
}

.config-subsection-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
}

.config-subsection-choice {
  display: grid;
  gap: 3px;
  text-align: left;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.74);
  color: #e2e8f0;
  padding: 9px 10px;
  cursor: pointer;
}

.config-subsection-choice span {
  font-weight: 800;
  font-size: .92rem;
}

.config-subsection-choice small {
  color: rgba(226, 232, 240, 0.62);
}

.config-subsection-choice:hover,
.config-subsection-choice:focus-visible {
  border-color: rgba(96, 165, 250, 0.62);
  background: rgba(30, 64, 110, 0.76);
  outline: none;
}

.config-subsection-choice.is-active {
  border-color: rgba(34, 197, 94, 0.68);
  background: rgba(20, 83, 45, 0.5);
}

.auth-status {
  min-height: 24px;
  color: var(--text-soft);
  font-weight: 600;
}

.auth-status.error {
  color: var(--red);
}

.auth-status.ok {
  color: var(--green);
}

.auth-note {
  margin: -4px 0 0;
  color: var(--text-soft);
  font-size: .9rem;
  line-height: 1.5;
}

.compact-form {
  display: grid;
  gap: 10px;
}

.compact-form label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: .86rem;
  font-weight: 700;
}

.compact-form input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.compact-button {
  width: 100%;
  justify-content: center;
}

.account-device-card {
  display: grid;
  gap: 12px;
}

.account-device-status {
  font-size: .86rem;
  font-weight: 700;
  color: var(--text-soft);
}

.account-device-status.ok {
  color: var(--green);
}

.account-device-status.error {
  color: var(--red);
}

.account-device-status.muted {
  color: var(--text-soft);
}

.account-device-list {
  display: grid;
  gap: 10px;
}

.account-device-list.empty {
  color: var(--text-soft);
  font-size: .9rem;
}

.account-device-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(24, 99, 162, .12);
  border-radius: 14px;
  background: #f8fbff;
}

.account-device-meta {
  grid-column: 1 / -1;
  color: var(--text-soft);
  font-size: .82rem;
}

.small-danger-button {
  border: 0;
  border-radius: 10px;
  padding: 7px 10px;
  background: #fee2e2;
  color: #991b1b;
  font-weight: 800;
  cursor: pointer;
}

.small-danger-button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.account-grid .panel-span-2 {
  grid-column: 1 / -1;
}

.account-profile-form,
.account-device-form-main {
  margin-top: 16px;
}

.account-owned-device-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.account-owned-device-grid.empty {
  display: block;
  color: var(--text-soft);
  font-weight: 700;
}

.account-owned-device-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(96, 165, 250, .18);
  border-radius: 18px;
  background: rgba(8, 20, 38, .78);
}

.account-owned-device-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-detail {
  font-size: .92rem;
}

.portal-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.portal-header {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(0, auto);
  grid-template-areas:
    "brand actions"
    "nav nav";
  gap: 24px;
  align-items: center;
  padding: 20px 28px;
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface-strong-2) 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 16px 40px rgba(7, 32, 56, 0.22);
}

.brand-cluster {
  grid-area: brand;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #4eb0ff, #c2ebff);
  color: var(--surface-strong-2);
  font-size: 1.2rem;
  font-weight: 800;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  white-space: nowrap;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.72);
  font-size: .92rem;
  max-width: 460px;
}

.brand-copy {
  min-width: 250px;
}

.top-nav {
  grid-area: nav;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
}

.nav-item {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 14px;
  padding: 11px 16px;
  background: rgba(255, 255, 255, 0.06);
  color: #f1f7fd;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.nav-item:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.12);
}

.nav-item.active {
  background: #ffffff;
  color: var(--blue-2);
  border-color: #ffffff;
}

.nav-quick {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: .92rem;
}

.header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.header-auth-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.user-switch,
.org-switch {
  min-width: 220px;
  display: grid;
  gap: 6px;
}

 .user-switch-readonly {
  min-width: 290px;
}

.user-switch-readonly select,
.user-switch select[hidden] {
  display: none !important;
}

.user-switch span,
.org-switch span {
  font-size: .78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
}

.user-switch select,
.org-switch select,
.form-stack input,
.form-stack select,
.form-stack textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 11px 14px;
}

.user-current-display {
  min-height: 47px;
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 11px 14px;
  font-weight: 700;
  line-height: 1.35;
}

.user-guest-actions {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
}

.user-guest-actions[hidden] {
  display: none !important;
}

.org-switch[hidden] {
  display: none;
}

.status-pill,
.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-pill);
  padding: 9px 14px;
  background: var(--blue-soft);
  color: var(--blue-2);
  font-weight: 700;
  white-space: nowrap;
}

.muted-pill {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.mini-badge.ok {
  background: rgba(34, 197, 94, 0.16);
  color: #22c55e;
}

.mini-badge.warn {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

.mini-badge.danger {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
}

.portal-body {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 24px;
  padding: 24px 28px 32px;
}

.portfolio-sidebar {
  display: grid;
  gap: 18px;
  align-content: start;
}

.sidebar-card,
.panel-card {
  background: var(--surface);
  border: 1px solid rgba(24, 99, 162, 0.08);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
}

.sidebar-card {
  padding: 18px;
}

.sidebar-title {
  margin-bottom: 14px;
  font-size: .84rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-soft);
  font-weight: 800;
}

.workspace {
  display: grid;
  gap: 20px;
  align-content: start;
}

.workspace-hero {
  background: linear-gradient(160deg, #ffffff, #f2f8fe);
  border: 1px solid rgba(24, 99, 162, 0.08);
  border-radius: 28px;
  box-shadow: var(--shadow-md);
  padding: 22px 24px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: center;
}

.workspace-hero h1 {
  margin: 0 0 6px;
  font-size: 2rem;
}

.workspace-hero p {
  margin: 0;
  color: var(--text-soft);
}

.workspace-hint {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(24, 99, 162, 0.12);
  border-radius: 18px;
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
}

.workspace-hint strong {
  color: var(--blue-2);
}

.workspace-hint span {
  color: var(--text-soft);
  line-height: 1.55;
}

.global-context-help {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(37, 99, 235, 0.18);
  background: linear-gradient(135deg, rgba(219, 234, 254, 0.92), rgba(239, 246, 255, 0.96));
  box-shadow: var(--shadow-sm);
  color: var(--text-main);
}

.global-context-help strong {
  color: var(--blue-2);
}

.global-context-help span {
  color: var(--text-soft);
  line-height: 1.55;
}

.hero-meta {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hero-meta-card {
  min-width: 160px;
  padding: 14px 16px;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.hero-meta-label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: .82rem;
  font-weight: 700;
}

.hero-meta-card strong {
  font-size: 1rem;
}

.metrics-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
}

.overview-hero-card {
  display: grid;
  gap: 18px;
  background:
    radial-gradient(circle at top right, rgba(78, 176, 255, 0.18), transparent 26%),
    linear-gradient(160deg, #ffffff, #f4f8fd);
  border: 1px solid rgba(24, 99, 162, 0.12);
  box-shadow: var(--shadow-md);
}

.overview-hero-head {
  margin-bottom: 0;
  align-items: start;
}

.overview-kicker {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 99, 162, 0.08);
  color: var(--blue-2);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.overview-hero-head h2 {
  margin: 8px 0 0;
  font-size: 1.45rem;
}

.overview-hero-side {
  display: grid;
  justify-items: end;
  gap: 10px;
}

.overview-state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 150px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 800;
  border: 1px solid transparent;
}

.overview-state-badge.state-ok,
.overview-state-badge.state-online {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(29, 157, 88, 0.18);
}

.overview-state-badge.state-warn {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(204, 138, 5, 0.18);
}

.overview-state-badge.state-error,
.overview-state-badge.state-offline {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(216, 77, 77, 0.18);
}

.overview-state-badge.state-idle {
  background: var(--blue-soft);
  color: var(--blue-2);
  border-color: rgba(24, 99, 162, 0.12);
}

.overview-updated {
  color: var(--text-soft);
  font-weight: 700;
}

.overview-hero-banner {
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(13, 77, 128, 0.94), rgba(24, 99, 162, 0.92));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.55;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.overview-hero-banner.is-ok {
  background: linear-gradient(135deg, #1b8d53, #25a661);
}

.overview-hero-banner.is-warn {
  background: linear-gradient(135deg, #bf7a04, #de9a1a);
}

.overview-hero-banner.is-error {
  background: linear-gradient(135deg, #b53f3f, #d84d4d);
}

.overview-hero-banner.is-idle {
  background: linear-gradient(135deg, rgba(13, 77, 128, 0.94), rgba(24, 99, 162, 0.92));
}

.overview-pill-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
}

.overview-pill-card {
  display: grid;
  gap: 6px;
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(24, 99, 162, 0.08);
  box-shadow: var(--shadow-sm);
}

.overview-pill-label {
  color: var(--text-soft);
  font-size: .8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.overview-pill-card strong {
  font-size: 1.08rem;
  color: var(--blue-2);
}

.overview-pill-card small {
  color: var(--text-soft);
  line-height: 1.4;
}

.overview-native-summary.empty {
  display: none;
}

.overview-native-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.overview-native-card {
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(24, 99, 162, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 251, 255, 0.98));
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 14px;
}

.overview-native-card h3 {
  margin: 0;
  font-size: 1.08rem;
  color: var(--blue-2);
}

.overview-native-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.5;
}

.overview-native-card--bess1x {
  border-color: rgba(245, 158, 11, 0.18);
}

.overview-native-card--bess0,
.overview-native-card--bess0-win10 {
  border-color: rgba(45, 212, 191, 0.18);
}

.overview-native-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.overview-native-kpi {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(14, 25, 43, 0.04);
  border: 1px solid rgba(24, 99, 162, 0.08);
}

.overview-native-kpi span {
  color: var(--text-soft);
  font-size: .8rem;
  font-weight: 700;
}

.overview-native-kpi strong {
  font-size: 1.02rem;
  color: var(--text);
}

.overview-native-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(24, 99, 162, 0.08);
  border: 1px solid rgba(24, 99, 162, 0.1);
  color: var(--text);
}

.overview-native-note strong {
  color: var(--blue-2);
}

.metric-tile {
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border: 1px solid rgba(24, 99, 162, 0.08);
  border-radius: 22px;
  box-shadow: var(--shadow-sm);
  padding: 18px 18px 16px;
  display: grid;
  gap: 8px;
}

.metric-label {
  color: var(--text-soft);
  font-size: .85rem;
  font-weight: 700;
}

.metric-tile strong {
  font-size: 1.5rem;
  letter-spacing: -0.02em;
  color: var(--blue-2);
}

.metric-tile small {
  color: var(--text-soft);
  line-height: 1.4;
}

.view {
  display: none;
  gap: 20px;
}

.view.active {
  display: grid;
}

.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, .85fr) minmax(0, .85fr);
  gap: 20px;
}

.panel-flow {
  grid-column: span 3;
}

.devices-grid,
.operation-grid,
.matrix-grid,
.events-grid,
.ai-grid,
.admin-grid,
.admin-account-grid,
.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.panel-span-2 {
  grid-column: span 2;
}

.panel-card {
  padding: 22px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.panel-head-copy {
  display: grid;
  gap: 6px;
}

.panel-note {
  margin: 14px 0 0;
  color: var(--text-soft);
  line-height: 1.5;
}

.panel-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-help-target {
  cursor: help;
  border-radius: 16px;
}

.panel-help-target:focus-visible {
  outline: 3px solid rgba(59, 130, 246, 0.45);
  outline-offset: 4px;
}

.panel-collapse-body {
  display: grid;
  gap: 16px;
}

.panel-collapse-body[hidden] {
  display: none !important;
}

.panel-card.is-collapsible {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.panel-card.is-collapsible:hover {
  border-color: rgba(37, 99, 235, 0.18);
}

.panel-card.is-collapsed .panel-head {
  margin-bottom: 0;
}

.panel-toggle-button {
  border: 1px solid rgba(37, 99, 235, 0.22);
  background: rgba(239, 246, 255, 0.95);
  color: var(--blue-2);
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.panel-toggle-button:hover,
.panel-toggle-button:focus-visible {
  background: #dbeafe;
  outline: none;
}

.admin-device-actions {
  margin-top: 10px;
}

.ai-config-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.ai-config-grid label {
  display: grid;
  gap: 6px;
}

.ai-config-grid span {
  color: var(--text-soft);
  font-size: 0.88rem;
}

.ai-config-grid input,
.ai-config-grid select {
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 9px 10px;
  font: inherit;
  background: #fff;
}

.ai-config-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.inline-flag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-main);
}

.ai-config-status {
  margin-top: 8px;
  font-size: 0.88rem;
  color: var(--text-soft);
}

.ai-help-chat-log {
  margin-top: 12px;
  min-height: 220px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
  padding: 12px;
  display: grid;
  gap: 10px;
}

.ai-help-chat-log.empty {
  color: var(--text-soft);
}

.ai-help-bubble {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.ai-help-bubble.user {
  background: rgba(39, 120, 201, 0.14);
}

.ai-help-bubble.ai {
  background: rgba(33, 147, 106, 0.14);
}

.ai-help-role {
  font-size: 0.78rem;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.ai-help-attach {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.ai-help-attach label {
  color: var(--text-soft);
  font-size: 0.9rem;
}

.ai-help-files-info {
  margin-top: 6px;
  color: var(--text-soft);
  font-size: 0.85rem;
}

.ai-help-composer {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.ai-help-composer textarea {
  min-height: 74px;
  resize: vertical;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 10px 12px;
  font: inherit;
  background: #fff;
}

@media (max-width: 860px) {
  .admin-user-actions {
    grid-template-columns: 1fr;
  }

  .ai-config-grid {
    grid-template-columns: 1fr;
  }

  .ai-help-composer {
    grid-template-columns: 1fr;
  }
}

.energy-flow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, #fbfdff, #f4f8fd),
    radial-gradient(circle at top left, rgba(78, 176, 255, 0.12), transparent 28%);
}

.flow-node {
  min-height: 170px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 14px 10px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid rgba(24, 99, 162, 0.10);
}

.flow-node.is-online {
  border-color: rgba(29, 157, 88, 0.22);
  box-shadow: inset 0 0 0 1px rgba(29, 157, 88, 0.08);
}

.flow-node.is-warn {
  border-color: rgba(204, 138, 5, 0.24);
  box-shadow: inset 0 0 0 1px rgba(204, 138, 5, 0.08);
}

.flow-node.is-offline,
.flow-node.is-error {
  border-color: rgba(216, 77, 77, 0.24);
  box-shadow: inset 0 0 0 1px rgba(216, 77, 77, 0.08);
}

.flow-node strong {
  font-size: 1rem;
}

.flow-node span {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--blue-2);
}

.flow-node small {
  color: var(--text-soft);
  line-height: 1.35;
}

.flow-icon {
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--blue-soft);
  color: var(--blue-2);
}

.flow-icon svg {
  width: 44px;
  height: 44px;
}

.flow-link {
  height: 4px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #a9d3fb, #1a72b6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.overview-primary-flow {
  margin-bottom: 20px;
  padding: 22px;
  border-radius: 16px;
  background: #32495f;
  border: 1px solid rgba(202, 220, 236, 0.22);
  box-shadow: 0 18px 40px rgba(17, 49, 83, 0.16);
}

.overview-primary-flow .panel-head {
  color: #fff;
  align-items: center;
  margin-bottom: 18px;
}

.overview-primary-flow .panel-head h2 {
  color: #fff;
  font-size: 1.25rem;
}

.overview-primary-flow .mini-badge {
  justify-self: center;
  background: #edf6ff;
  color: var(--blue-2);
  border-color: rgba(24, 99, 162, 0.22);
  font-weight: 900;
}

.overview-primary-flow .energy-flow {
  grid-template-columns: repeat(10, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(180px, auto));
  gap: 22px 18px;
  padding: 26px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f8fd 100%);
  border-color: rgba(185, 203, 220, 0.75);
}

.overview-primary-flow .flow-node {
  min-height: 165px;
  border-radius: 18px;
  border-width: 1px;
}

.overview-primary-flow .flow-node strong {
  color: #eef3f7;
  font-size: 1.05rem;
}

.overview-primary-flow .flow-node span {
  font-size: 1.12rem;
  color: var(--blue-2);
}

.overview-primary-flow .flow-icon {
  width: 76px;
  height: 76px;
  border-radius: 18px;
}

.overview-primary-flow .energy-flow > :nth-child(1) { grid-column: 1 / span 2; grid-row: 1; }
.overview-primary-flow .energy-flow > :nth-child(2) { grid-column: 3 / span 2; grid-row: 1; }
.overview-primary-flow .energy-flow > :nth-child(3) { grid-column: 5 / span 2; grid-row: 1; }
.overview-primary-flow .energy-flow > :nth-child(4) { grid-column: 7 / span 2; grid-row: 1; }
.overview-primary-flow .energy-flow > :nth-child(5) { grid-column: 9 / span 2; grid-row: 1; }
.overview-primary-flow .energy-flow > :nth-child(6) { grid-column: 1 / span 2; grid-row: 2; }
.overview-primary-flow .energy-flow > :nth-child(7) { grid-column: 3 / span 2; grid-row: 2; }
.overview-primary-flow .energy-flow > :nth-child(8) { grid-column: 5 / span 3; grid-row: 2; }
.overview-primary-flow .energy-flow > :nth-child(9) { grid-column: 8 / span 2; grid-row: 2; }

.overview-primary-flow .flow-link {
  align-self: center;
  width: 100%;
}

.device-card-actions {
  display: flex;
  justify-content: flex-end;
  margin: 10px 0 4px;
}

.native-manage-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(24, 99, 162, 0.18);
}

.native-manage-link:hover {
  background: var(--blue-2);
}

.device-portal-shell {
  display: grid;
  gap: 18px;
}

.device-portal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.device-portal-head h2 {
  margin: 4px 0 6px;
  font-size: 1.35rem;
  color: var(--text);
}

.device-portal-head p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
}

.device-portal-kicker {
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: 0;
  color: var(--blue-2);
  text-transform: uppercase;
}

.device-portal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: min(520px, 100%);
}

.device-portal-select {
  width: min(360px, 100%);
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  padding: 0 12px;
  font-weight: 800;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.device-portal-open-link {
  text-decoration: none;
  white-space: nowrap;
}

.device-portal-layout {
  display: grid;
  grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.device-portal-list {
  display: grid;
  gap: 12px;
}

.device-portal-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.device-portal-card.active {
  border-color: rgba(24, 99, 162, 0.42);
  box-shadow: 0 0 0 2px rgba(24, 99, 162, 0.08), var(--shadow-sm);
}

.device-portal-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.device-portal-card-head strong,
.device-portal-card-head span {
  display: block;
}

.device-portal-card-head strong {
  color: var(--text);
  font-size: 1rem;
}

.device-portal-card-head span {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: .85rem;
}

.device-portal-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: var(--radius-pill);
  font-style: normal;
  font-weight: 800;
  font-size: .78rem;
}

.device-portal-status.online {
  color: #0d6b3d;
  background: var(--green-soft);
}

.device-portal-status.offline {
  color: #9a2f2f;
  background: var(--red-soft);
}

.device-portal-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.device-portal-metrics div {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: 12px;
  background: var(--surface-soft);
  border: 1px solid rgba(185, 203, 220, 0.55);
}

.device-portal-metrics span {
  color: var(--text-soft);
  font-size: .76rem;
  font-weight: 800;
}

.device-portal-metrics strong {
  min-width: 0;
  color: var(--text);
  font-size: .88rem;
  overflow-wrap: anywhere;
}

.device-open-native {
  width: 100%;
}

.device-native-stage {
  min-height: 680px;
  border-radius: 16px;
  overflow: hidden;
  background: #0d1b2a;
  border: 1px solid rgba(24, 99, 162, 0.2);
  box-shadow: var(--shadow-md);
}

.device-native-empty {
  min-height: 680px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 24px;
  color: #dbeaff;
  text-align: center;
}

.device-native-empty strong {
  font-size: 1.2rem;
  color: #fff;
}

.device-native-empty span {
  max-width: 520px;
  line-height: 1.5;
  color: #b6c8d8;
}

.device-native-frame {
  display: block;
  width: 100%;
  height: min(82vh, 920px);
  min-height: 680px;
  border: 0;
  background: #2c3e50;
}

@media (max-width: 980px) {
  .overview-primary-flow {
    padding: 16px;
  }

  .overview-primary-flow .energy-flow {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    gap: 12px;
    padding: 16px;
  }

  .overview-primary-flow .energy-flow > * {
    grid-column: auto !important;
    grid-row: auto !important;
  }

  .overview-primary-flow .flow-link {
    width: 4px;
    height: 34px;
    justify-self: center;
  }

  .device-portal-layout {
    grid-template-columns: 1fr;
  }

  .device-portal-head,
  .device-portal-actions {
    align-items: stretch;
  }

  .device-portal-head {
    flex-direction: column;
  }

  .device-portal-actions,
  .device-portal-select,
  .device-portal-open-link {
    width: 100%;
  }

  .device-native-stage,
  .device-native-empty,
  .device-native-frame {
    min-height: 620px;
  }
}

.detail-list {
  display: grid;
  gap: 10px;
}

.detail-list > div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.detail-list span {
  color: var(--text-soft);
  font-weight: 600;
}

.detail-list strong {
  text-align: right;
}

.compact-detail > div {
  padding: 10px 12px;
}

.capability-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.capability-card {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.capability-card h3 {
  margin: 0;
  font-size: 1rem;
}

.capability-card p {
  margin: 0;
  color: var(--text-soft);
}

.capability-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.capability-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #b7e4c7;
  background: #e9f7ef;
  color: #146c43;
  font-size: .78rem;
  font-weight: 700;
}

.capability-chip.off {
  border-color: #d1d5db;
  background: #f3f4f6;
  color: #6b7280;
}

.device-list,
.events,
.analysis-list,
.bar-list {
  display: grid;
  gap: 12px;
}

.empty {
  color: var(--text-soft);
}

.device-card,
.event-card,
.command-card,
.analysis-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 14px 16px;
}

.device-card strong,
.event-card strong,
.command-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.device-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.device-card-copy {
  min-width: 0;
}

.device-card-copy small {
  display: block;
  color: var(--text-soft);
  font-size: .82rem;
  line-height: 1.4;
  margin-top: -2px;
}

.device-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .03em;
  border: 1px solid var(--line);
}

.device-chip.neutral {
  background: #f3f6fb;
  color: #4b5d73;
}

.device-chip.success {
  background: var(--green-soft);
  color: var(--green);
  border-color: rgba(29, 157, 88, 0.22);
}

.device-chip.warn {
  background: var(--amber-soft);
  color: var(--amber);
  border-color: rgba(204, 138, 5, 0.22);
}

.device-chip.error,
.device-chip.offline {
  background: var(--red-soft);
  color: var(--red);
  border-color: rgba(216, 77, 77, 0.22);
}

.device-meta,
.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  color: var(--text-soft);
  font-size: .92rem;
}

.admin-user-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr)) repeat(4, auto);
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.admin-user-actions label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: .84rem;
  font-weight: 800;
}

.admin-user-actions select,
.admin-user-actions input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 700;
}

.admin-user-actions .ghost-button {
  white-space: nowrap;
}

.admin-account-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(170px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.admin-account-toolbar label,
.admin-account-detail-grid label {
  display: grid;
  gap: 6px;
  color: var(--text-soft);
  font-size: .86rem;
  font-weight: 800;
}

.admin-account-toolbar input,
.admin-account-toolbar select,
.admin-account-detail-grid input,
.admin-account-detail-grid select {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  padding: 0 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 750;
}

.admin-account-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.admin-account-table-wrap.empty,
.admin-account-detail.empty {
  padding: 18px;
  color: var(--text-soft);
  font-weight: 800;
}

.admin-account-table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
}

.admin-account-table th,
.admin-account-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.admin-account-table th {
  color: var(--text-soft);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: #f6f9fd;
}

.admin-account-row.is-selected {
  background: var(--blue-soft);
}

.admin-account-cell {
  display: grid;
  gap: 4px;
}

.admin-account-cell small {
  color: var(--text-soft);
  font-weight: 700;
}

.admin-account-actions,
.admin-account-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-account-detail {
  display: grid;
  gap: 14px;
}

.admin-account-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.admin-account-detail-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.ghost-button.warn {
  border-color: rgba(204, 138, 5, 0.28);
  color: var(--amber);
  background: var(--amber-soft);
}

.ghost-button.success {
  border-color: rgba(29, 157, 88, 0.25);
  color: var(--green);
  background: var(--green-soft);
}

.device-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
  margin-top: 12px;
}

.device-detail-grid > div {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fbff;
  padding: 10px 12px;
}

.device-detail-grid span {
  display: block;
  color: var(--text-soft);
  font-size: .78rem;
  margin-bottom: 4px;
}

.device-detail-grid strong {
  display: block;
  margin: 0;
  font-size: .92rem;
}

.bar-item {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  padding: 14px 16px;
}

.bar-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.bar-title {
  font-weight: 800;
}

.bar-meta {
  color: var(--text-soft);
  font-size: .92rem;
}

.bar-track {
  height: 12px;
  border-radius: var(--radius-pill);
  background: #edf3f8;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, #59b97f, #1c9656);
}

.bar-fill.normal {
  background: linear-gradient(90deg, #69b8ff, #1b6db4);
}

.bar-fill.heavy {
  background: linear-gradient(90deg, #ffca59, #d88c00);
}

.bar-fill.offline {
  background: linear-gradient(90deg, #e8edf2, #cbd7e2);
}

.site-list-item {
  width: 100%;
  display: grid;
  gap: 8px;
  text-align: left;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.site-list-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.site-list-item.active {
  border-color: #8fc3f8;
  background: linear-gradient(180deg, #ffffff, #eef7ff);
}

.site-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot.online { background: var(--green); }
.dot.degraded { background: var(--amber); }
.dot.offline { background: var(--red); }

.form-stack {
  display: grid;
  gap: 16px;
}

.form-stack label {
  display: grid;
  gap: 8px;
}

.form-stack span {
  color: var(--text-soft);
  font-weight: 600;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.ghost-button {
  border-radius: 14px;
  padding: 11px 16px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  border: none;
  background: linear-gradient(180deg, #2075bf, #0f5c9d);
  color: #fff;
  box-shadow: 0 10px 18px rgba(23, 98, 162, 0.24);
}

.primary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
}

.ghost-button.danger {
  border-color: rgba(216, 77, 77, 0.25);
  color: var(--red);
}

.matrix-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #fbfdff, #f7fbff);
  padding: 14px;
}

.matrix-table {
  width: 100%;
  min-width: 760px;
  border-collapse: separate;
  border-spacing: 8px;
}

.matrix-table th {
  text-align: left;
  color: var(--text-soft);
  font-weight: 700;
  padding: 8px 10px;
}

.matrix-row-label {
  min-width: 220px;
  padding: 12px 10px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
}

.matrix-cell {
  min-width: 130px;
  padding: 12px 10px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: center;
  cursor: pointer;
}

.matrix-cell.closed {
  background: var(--green-soft);
  border-color: rgba(29, 157, 88, 0.22);
}

.matrix-cell.open {
  background: #fff;
}

.matrix-cell.waiting {
  background: var(--amber-soft);
  border-color: rgba(204, 138, 5, 0.22);
}

.matrix-cell.timeout {
  background: var(--red-soft);
  border-color: rgba(216, 77, 77, 0.22);
}

.matrix-cell.absent {
  background: #f2f5f8;
  color: var(--text-soft);
}

.matrix-title {
  display: block;
  font-weight: 800;
  margin-bottom: 4px;
}

.matrix-meta {
  color: var(--text-soft);
  font-size: .86rem;
}

.analysis-hero {
  padding: 18px 20px;
  border-radius: 20px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  font-weight: 800;
}

.analysis-hero.ok {
  background: var(--green-soft);
  color: var(--green);
}

.analysis-hero.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.analysis-hero.error {
  background: var(--red-soft);
  color: var(--red);
}

.analysis-list .analysis-item {
  border-left: 4px solid var(--blue);
}

.analysis-alert-item,
.analysis-report-item {
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.analysis-alert-head {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.analysis-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
}

.analysis-tag.warn {
  background: var(--amber-soft);
  color: var(--amber);
}

.analysis-tag.error {
  background: var(--red-soft);
  color: var(--red);
}

.analysis-tag.status.open {
  background: var(--blue-soft);
  color: var(--blue-2);
}

.analysis-tag.status.ack {
  background: #eef5ff;
  color: #214f84;
}

.analysis-tag.status.resolved {
  background: var(--green-soft);
  color: var(--green);
}

.analysis-actions-inline {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.analysis-actions-inline .ghost-button {
  padding: 7px 10px;
  border-radius: 10px;
}

.analysis-actions-inline .ghost-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.analysis-alert-item small,
.analysis-report-meta {
  display: block;
  margin-top: 5px;
  color: var(--text-soft);
  font-size: .85rem;
}

.timeline-chart {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  padding: 8px 10px 10px;
  overflow-x: auto;
}

.timeline-chart.empty {
  color: var(--text-soft);
  font-size: .92rem;
}

.timeline-chart svg {
  display: block;
  width: 100%;
  min-width: 680px;
  height: auto;
}

.timeline-grid-bg {
  fill: #f8fbff;
}

.timeline-grid-line {
  stroke: #d7e3f3;
  stroke-width: 1;
}

.timeline-grid-line.strong {
  stroke: #b7cbe8;
  stroke-width: 1.3;
}

.timeline-axis-label {
  fill: #5f7391;
  font-size: 11px;
  font-weight: 700;
}

.timeline-line {
  fill: none;
  stroke-width: 2;
}

.timeline-line.soc {
  stroke: #2f8cff;
}

.timeline-line.bess {
  stroke: #16a34a;
}

.timeline-line.grid {
  stroke: #f97316;
}

.timeline-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 6px;
  color: var(--text-soft);
  font-size: .86rem;
}

.timeline-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.soc {
  background: #2f8cff;
}

.legend-dot.bess {
  background: #16a34a;
}

.legend-dot.grid {
  background: #f97316;
}

.daily-rec-box {
  grid-column: 1 / -1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
}

.plain-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.65;
}

.compact-list {
  font-size: .95rem;
}

.info-stack {
  display: grid;
  gap: 10px;
}

.info-stack > div {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.info-stack span {
  color: var(--text-soft);
  font-size: .86rem;
  font-weight: 700;
}

.info-stack strong {
  font-size: .98rem;
}

.event-level {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
}

.event-level.info { color: var(--blue-2); }
.event-level.warn { color: var(--amber); }
.event-level.error { color: var(--red); }

.summary-grid {
  display: grid;
  gap: 10px;
}

.summary-card {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  border: 1px solid var(--line);
}

.summary-label {
  color: var(--text-soft);
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 800;
}

.summary-card strong {
  font-size: 1.35rem;
  line-height: 1.1;
}

.summary-card small {
  color: var(--text-soft);
  line-height: 1.45;
}

.identity-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.identity-card {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.identity-card span {
  color: var(--text-soft);
  font-size: .82rem;
  font-weight: 700;
}

.identity-card strong {
  font-size: .95rem;
  word-break: break-word;
}

.json-block {
  min-height: 220px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #0f2236;
  color: #dbeaff;
  overflow: auto;
}

.json-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "Cascadia Code", "Consolas", monospace;
  font-size: .83rem;
  line-height: 1.55;
}

.json-block.empty {
  background: var(--surface-soft);
  color: var(--text-soft);
}

.org-list {
  display: grid;
  gap: 10px;
}

.org-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
}

.org-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--text-soft);
  font-size: .86rem;
}

.org-meta span {
  padding: 6px 10px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--line);
}

.portfolio-panel {
  padding: 18px;
}

.overview-portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.hero-summary-card {
  min-height: 116px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

@media (max-width: 1500px) {
  .metrics-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview-native-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-pill-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .overview-portfolio-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1260px) {
  .portal-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions"
      "nav";
  }

  .top-nav {
    justify-content: flex-start;
  }

  .header-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .portal-body {
    grid-template-columns: 1fr;
  }

  .overview-grid,
  .devices-grid,
  .operation-grid,
  .matrix-grid,
  .events-grid,
  .ai-grid,
  .admin-grid,
  .admin-account-grid,
  .account-grid,
  .account-owned-device-grid {
    grid-template-columns: 1fr;
  }

  .overview-native-grid {
    grid-template-columns: 1fr;
  }

  .panel-span-2 {
    grid-column: auto;
  }

  .overview-portfolio-grid {
    grid-template-columns: 1fr;
  }

  .identity-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 980px) {
  .admin-account-toolbar,
  .admin-account-detail-grid {
    grid-template-columns: 1fr;
  }

  .workspace-hero {
    grid-template-columns: 1fr;
  }

  .hero-meta {
    justify-content: flex-start;
  }

  .metrics-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .overview-pill-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .energy-flow {
    grid-template-columns: 1fr;
  }

  .flow-link {
    width: 4px;
    height: 36px;
    margin: 0 auto;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .device-detail-grid {
    grid-template-columns: 1fr;
  }

  .overview-native-kpis {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .portal-header,
  .portal-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .metrics-strip {
    grid-template-columns: 1fr;
  }

  .overview-pill-row {
    grid-template-columns: 1fr;
  }

  .top-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.device-config-cloud {
  display: grid;
  gap: 14px;
}

.device-config-cloud--bess1x {
  background: linear-gradient(180deg, rgba(13, 27, 45, 0.96), rgba(22, 40, 66, 0.98));
  border-color: rgba(96, 165, 250, 0.18);
}

.device-config-cloud--bess0,
.device-config-cloud--bess0-win10 {
  background: linear-gradient(180deg, rgba(15, 29, 48, 0.96), rgba(24, 46, 74, 0.98));
  border-color: rgba(45, 212, 191, 0.18);
}

.config-native-shell-host {
  display: grid;
  gap: 14px;
}

.config-native-shell {
  display: grid;
  gap: 16px;
  padding: 20px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: linear-gradient(180deg, rgba(11, 21, 36, 0.98), rgba(15, 27, 44, 0.98));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 18px 40px rgba(6, 18, 33, 0.24);
}

.config-native-shell.empty {
  color: var(--text-soft);
  background: var(--surface-soft);
  border-style: dashed;
}

.config-native-shell--bess1x {
  border-color: rgba(96, 165, 250, 0.22);
}

.config-native-shell--bess0,
.config-native-shell--bess0-win10 {
  border-color: rgba(45, 212, 191, 0.18);
}

.config-native-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.config-native-brand {
  display: grid;
  gap: 8px;
}

.config-native-overline {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(191, 219, 254, 0.78);
}

.config-native-brand h3 {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 900;
  color: #f8fafc;
}

.config-native-brand p {
  margin: 0;
  color: rgba(226, 232, 240, 0.74);
  line-height: 1.55;
}

.config-native-identity {
  display: grid;
  gap: 10px;
  align-content: start;
  justify-items: end;
}

.config-native-identity div {
  display: grid;
  gap: 4px;
  min-width: 220px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.config-native-identity span,
.config-native-meta-card span {
  color: rgba(191, 219, 254, 0.68);
  font-size: 0.82rem;
}

.config-native-identity strong,
.config-native-meta-card strong {
  color: #f8fafc;
  font-weight: 800;
}

.config-native-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.config-native-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(30, 41, 59, 0.72);
  color: rgba(226, 232, 240, 0.82);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  cursor: pointer;
  transition: 0.2s ease;
}

.config-native-tab.active {
  color: #eff6ff;
  background: linear-gradient(180deg, rgba(59, 130, 246, 0.42), rgba(37, 99, 235, 0.46));
  border-color: rgba(96, 165, 250, 0.42);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.22);
}

.config-native-tab:hover,
.config-native-tab:focus {
  outline: none;
  color: #fff;
  border-color: rgba(125, 211, 252, 0.58);
  background: rgba(37, 99, 235, 0.34);
  transform: translateY(-1px);
}

.config-native-helpbar,
.config-context-help,
.config-import-status {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(10, 18, 31, 0.58);
  color: rgba(219, 234, 254, 0.9);
  font-weight: 700;
  line-height: 1.45;
}

.config-native-helpbar {
  border-color: rgba(250, 204, 21, 0.18);
  background: rgba(234, 179, 8, 0.08);
  color: #fde68a;
}

.config-context-help {
  margin-top: -4px;
}

.config-import-status.muted {
  color: rgba(191, 219, 254, 0.72);
  border-style: dashed;
}

.config-import-status.warn {
  color: #fde68a;
  border-color: rgba(245, 158, 11, 0.36);
  background: rgba(245, 158, 11, 0.1);
}

.config-import-status.ok {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(22, 163, 74, 0.12);
}

.config-transfer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  background: rgba(15, 23, 42, 0.48);
}

.config-transfer-tools strong,
.config-transfer-tools span {
  display: block;
}

.config-transfer-tools strong {
  color: #f8fafc;
  font-weight: 900;
}

.config-transfer-tools span {
  margin-top: 4px;
  color: rgba(191, 219, 254, 0.76);
  line-height: 1.45;
}

.config-transfer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(96, 165, 250, 0.32);
  background: rgba(37, 99, 235, 0.22);
  color: #dbeafe;
  font-weight: 800;
  cursor: pointer;
}

.file-action-button:hover {
  border-color: rgba(125, 211, 252, 0.58);
  color: #fff;
}

.config-native-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.config-native-meta-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(10, 18, 31, 0.48);
}

.device-config-cloud .panel-note {
  margin-top: -2px;
  color: rgba(226, 232, 240, 0.8);
}

.device-config-cloud .detail-list > div,
.device-config-cloud .audit-card,
.device-config-cloud .json-block,
.device-config-cloud .config-preview-card {
  border-color: rgba(148, 163, 184, 0.12);
  background: rgba(10, 18, 31, 0.66);
  box-shadow: none;
}

.device-config-cloud .detail-list span,
.device-config-cloud .audit-card-meta,
.device-config-cloud .config-subtitle {
  color: rgba(191, 219, 254, 0.76);
}

.device-config-cloud .detail-list strong,
.device-config-cloud .json-block,
.device-config-cloud .audit-card strong {
  color: #f8fafc;
}

.device-config-cloud .audit-list.empty,
.device-config-cloud .json-block.empty {
  background: rgba(17, 24, 39, 0.7);
  border-color: rgba(148, 163, 184, 0.12);
  color: rgba(191, 219, 254, 0.72);
}

.config-audit-banner {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(24, 99, 162, 0.12);
  background: linear-gradient(180deg, #f5faff, #eaf3fd);
  color: var(--blue-2);
  font-weight: 700;
  line-height: 1.45;
}

.config-audit-banner.muted {
  color: var(--text-soft);
  background: var(--surface-soft);
  border-style: dashed;
}

.config-form-grid {
  display: grid;
  gap: 18px;
}

.config-form-grid--bess1x .config-form-section {
  border-color: rgba(96, 165, 250, 0.34);
  background: linear-gradient(180deg, rgba(14, 26, 44, 0.98), rgba(19, 33, 53, 0.98));
  box-shadow: inset 0 1px 0 rgba(148, 163, 184, 0.08), 0 18px 40px rgba(6, 18, 33, 0.26);
}

.config-form-grid--bess0 .config-form-section,
.config-form-grid--bess0-win10 .config-form-section {
  border-color: rgba(45, 212, 191, 0.22);
  background: linear-gradient(180deg, rgba(18, 33, 53, 0.98), rgba(23, 41, 65, 0.98));
  box-shadow: inset 0 1px 0 rgba(125, 211, 252, 0.05), 0 18px 40px rgba(8, 20, 35, 0.24);
}

.config-form-section {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #fbfdff, #f5f9fe);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.config-form-section--skeleton {
  position: relative;
}

.config-form-section--skeleton::after {
  content: "Đang chờ config report";
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.78);
  color: rgba(191, 219, 254, 0.92);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.config-form-head {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.config-form-head[type="button"] {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  appearance: none;
}

.config-form-head:hover,
.config-form-head:focus {
  outline: none;
}

.config-form-head:hover h3,
.config-form-head:focus h3 {
  color: #fef9c3;
}

.config-form-section--force-open .config-form-head {
  cursor: default;
}

.config-form-head-copy {
  display: grid;
  gap: 6px;
  min-width: min(100%, 520px);
}

.config-section-body[hidden] {
  display: none !important;
}

.config-form-section:not(.is-open) {
  padding-bottom: 18px;
}

.config-form-head h3,
.config-subtitle {
  margin: 0 0 6px;
  font-size: 1rem;
}

.config-form-head p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.45;
  flex: 1 1 420px;
}

.config-form-section[data-config-collapsible="1"] > .config-form-head {
  position: relative;
  padding-right: 42px;
  cursor: pointer;
}

.config-form-section[data-config-collapsible="1"] > .config-form-head::after {
  content: "▸";
  content: "▸";
  position: absolute;
  right: 0;
  top: 4px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: #bfdbfe;
  font-size: 1rem;
  font-weight: 900;
  transition: transform 0.18s ease, background 0.18s ease;
}

.config-form-section.is-open[data-config-collapsible="1"] > .config-form-head::after {
  transform: rotate(90deg);
  background: rgba(34, 197, 94, 0.14);
  color: #bbf7d0;
}

.config-form-head:hover {
  opacity: 0.96;
}

.device-chip-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.config-section-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.config-form-head[role="button"]:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.75);
  outline-offset: 4px;
  border-radius: 14px;
}

.config-form-section[data-config-collapsible="1"] > .config-form-head {
  padding-right: 0;
}

.config-form-section[data-config-collapsible="1"] > .config-form-head::after {
  display: none;
}

.config-section-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 62px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.28);
  background: rgba(59, 130, 246, 0.12);
  color: #dbeafe;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.config-section-toggle:hover,
.config-section-toggle:focus-visible {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(147, 197, 253, 0.42);
  outline: none;
}

.config-section-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  background: rgba(15, 23, 42, 0.22);
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.config-form-section.is-open .config-section-state {
  color: #bbf7d0;
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(22, 163, 74, 0.12);
}

.config-form-section.is-open .config-section-toggle {
  border-color: rgba(34, 197, 94, 0.34);
  background: rgba(22, 163, 74, 0.14);
  color: #dcfce7;
}

.config-form-section:not(.is-open) .config-section-state {
  color: #bfdbfe;
}

.config-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: #1d4ed8;
  font-size: 0.8rem;
  font-weight: 800;
}

.config-form-section.is-open .config-section-count {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}

.config-form-grid--bess1x .config-form-head h3,
.config-form-grid--bess1x .config-form-head p,
.config-form-grid--bess1x .config-field-label,
.config-form-grid--bess1x .config-field-hint,
.config-form-grid--bess1x .config-field-key {
  color: #dbeafe;
}

.config-form-grid--bess1x .config-form-head {
  align-items: flex-start;
  padding: 2px 0 12px;
  border-bottom: 1px solid rgba(96, 165, 250, 0.16);
}

.config-form-grid--bess1x .config-form-head h3 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.config-form-grid--bess1x .config-form-head p {
  color: rgba(219, 234, 254, 0.72);
}

.config-form-grid--bess1x .config-section-count {
  background: rgba(59, 130, 246, 0.14);
  color: #bfdbfe;
  border: 1px solid rgba(96, 165, 250, 0.22);
}

.config-form-grid--bess1x .config-form-section.is-open .config-section-count {
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
}

.config-form-grid--bess1x .config-field-key {
  color: rgba(251, 191, 36, 0.9);
  font-family: Consolas, "Courier New", monospace;
}

.config-form-grid--bess1x .config-field-hint {
  color: rgba(191, 219, 254, 0.74);
}

.config-form-grid--bess1x .config-field input,
.config-form-grid--bess1x .config-field select,
.config-form-grid--bess1x .config-field textarea {
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
  border-color: rgba(96, 165, 250, 0.22);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.config-form-grid--bess1x .config-field input:focus,
.config-form-grid--bess1x .config-field select:focus,
.config-form-grid--bess1x .config-field textarea:focus {
  outline: none;
  border-color: rgba(96, 165, 250, 0.6);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.config-form-grid--bess0 .config-form-head,
.config-form-grid--bess0-win10 .config-form-head {
  align-items: flex-start;
  padding: 2px 0 12px;
  border-bottom: 1px solid rgba(45, 212, 191, 0.12);
}

.config-form-grid--bess0 .config-form-head h3,
.config-form-grid--bess0-win10 .config-form-head h3,
.config-form-grid--bess0 .config-field-label,
.config-form-grid--bess0-win10 .config-field-label {
  color: #e2f8f4;
}

.config-form-grid--bess0 .config-form-head p,
.config-form-grid--bess0-win10 .config-form-head p,
.config-form-grid--bess0 .config-field-hint,
.config-form-grid--bess0-win10 .config-field-hint,
.config-form-grid--bess0 .config-field-key,
.config-form-grid--bess0-win10 .config-field-key {
  color: rgba(222, 247, 244, 0.72);
}

.native-view-shell {
  margin-bottom: 18px;
}

.native-view-shell.empty {
  display: none;
}

.native-view-shell .config-native-shell {
  margin: 0;
}

.hardware-native-shell {
  padding: 0;
  border-radius: 0;
  border: 0;
  background: #2c3e50;
  box-shadow: none;
  color: #ecf0f1;
  font-family: Arial, Helvetica, sans-serif;
}

.hardware-native-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
}

.hardware-native-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.hardware-native-header h1 {
  margin: 0;
  color: #fff;
  font-size: 1.875rem;
  line-height: 2.25rem;
  font-weight: 700;
  letter-spacing: 0;
}

.hardware-native-header-right,
.hardware-native-timebox {
  display: flex;
  align-items: center;
  gap: 16px;
  color: #d1d5db;
  font-size: 0.875rem;
}

.hardware-native-timebox {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: #fff;
}

.hardware-native-timebox #system-time-display {
  font-family: Consolas, "Courier New", monospace;
  font-size: 1.25rem;
  line-height: 1.75rem;
}

.hardware-native-timebox #price-tier-indicator {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.hardware-native-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.hardware-native-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 12px;
  border-radius: 999px;
  background: #374151;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
}

.hardware-native-badge--danger {
  background: #dc2626;
}

.hardware-native-clock {
  color: #d1d5db;
  font-family: Consolas, "Courier New", monospace;
  white-space: nowrap;
}

.hardware-native-lang {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #9ca3af;
  font-size: 0.875rem;
  font-weight: 500;
}

.hardware-native-lang i {
  color: #4b5563;
  font-style: normal;
}

.hardware-native-device-lines {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
  color: #9ca3af;
  text-align: center;
  font-size: 0.875rem;
}

.hardware-native-device-lines code {
  padding: 2px 6px;
  border-radius: 4px;
  background: #1e293b;
  color: #fde047;
  font-family: Consolas, "Courier New", monospace;
  font-weight: 700;
}

.hardware-native-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
}

.hardware-native-tabs--bess1x {
  border-bottom: 1px solid #4b5563;
}

.hardware-native-tabs .config-native-tab {
  min-height: 42px;
  padding: 10px 20px;
  border: 0;
  border-radius: 6px 6px 0 0;
  background: #34495e;
  color: #ecf0f1;
  box-shadow: none;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.25rem;
  letter-spacing: 0;
  transition: background-color 0.3s ease;
  transform: none;
}

.hardware-native-tabs .config-native-tab.active,
.hardware-native-tabs .config-native-tab:hover,
.hardware-native-tabs .config-native-tab:focus {
  outline: none;
  background: #556c80;
  color: #fff;
  border-color: transparent;
  box-shadow: none;
  transform: none;
}

.hardware-native-status {
  margin-bottom: 24px;
  padding: 16px;
  border: 0;
  border-radius: 12px;
  text-align: center;
  font-weight: 700;
  line-height: 1.45;
}

.hardware-native-status--bess1x {
  position: sticky;
  top: 64px;
  z-index: 40;
  background: #374151;
  color: #facc15;
}

.hardware-native-status--bess0 {
  background: #3498db;
  color: #fff;
}

.hardware-native-helpline {
  margin-top: -12px;
  color: rgba(209, 213, 219, 0.82);
  font-size: 0.875rem;
  line-height: 1.4;
  text-align: center;
}

.hardware-native-strip {
  margin-bottom: 24px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #374151;
  background: rgba(31, 41, 55, 0.4);
}

.hardware-native-strip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: #fff;
  font-size: 0.875rem;
}

.hardware-native-strip-head span,
.hardware-native-strip-hint {
  color: #d1d5db;
  font-size: 0.75rem;
}

.hardware-native-emergency {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
  padding: 16px;
  border-radius: 12px;
  border: 2px solid #374151;
  background: #1f2937;
}

.hardware-native-emergency button {
  min-height: 40px;
  padding: 8px 16px;
  border: 0;
  border-radius: 8px;
  background: #ea580c;
  color: #fff;
  font: inherit;
  font-weight: 700;
}

.hardware-native-emergency button.danger {
  background: #dc2626;
}

body.hardware-device-mode {
  background: #2c3e50;
  color: #ecf0f1;
}

body.hardware-device-mode .portal-shell {
  display: block;
  min-height: 100vh;
  background: #2c3e50;
}

body.hardware-device-mode .portal-header,
body.hardware-device-mode .portfolio-sidebar,
body.hardware-device-mode .portfolio-panel,
body.hardware-device-mode .workspace-hero,
body.hardware-device-mode .workspace-hint,
body.hardware-device-mode #globalContextHelp {
  display: none !important;
}

body.hardware-device-mode .portal-body {
  display: block;
  padding: 0;
}

body.hardware-device-mode .workspace {
  display: block;
  max-width: none;
  margin: 0;
}

body.hardware-device-mode .view {
  display: none;
  padding: 0;
}

body.hardware-device-mode .view.active {
  display: block;
}

body.hardware-device-mode .native-view-shell,
body.hardware-device-mode .config-native-shell-host {
  margin: 0;
}

body.hardware-device-mode .panel-card,
body.hardware-device-mode .overview-native-summary,
body.hardware-device-mode .metric-tile,
body.hardware-device-mode .config-preview-card,
body.hardware-device-mode .config-form-section,
body.hardware-device-mode .config-native-block {
  max-width: 1280px;
  margin: 24px auto;
  border: 1px solid #4a627a;
  border-radius: 12px;
  background: #34495e;
  box-shadow: none;
  color: #ecf0f1;
}

body.hardware-device-mode .overview-grid,
body.hardware-device-mode .devices-grid,
body.hardware-device-mode .operation-grid,
body.hardware-device-mode .matrix-grid,
body.hardware-device-mode .events-grid,
body.hardware-device-mode .ai-grid {
  width: min(1280px, calc(100% - 48px));
  margin: 24px auto;
}

body.hardware-device-mode .overview-grid .panel-card,
body.hardware-device-mode .devices-grid .panel-card,
body.hardware-device-mode .operation-grid .panel-card,
body.hardware-device-mode .events-grid .panel-card,
body.hardware-device-mode .ai-grid .panel-card {
  max-width: none;
  margin: 0;
}

body.hardware-device-mode .metrics-strip,
body.hardware-device-mode .overview-pill-row,
body.hardware-device-mode .config-transfer-tools,
body.hardware-device-mode .config-preview-layout {
  width: min(1280px, calc(100% - 48px));
  margin: 24px auto;
}

body.hardware-device-mode .metric-tile {
  margin: 0;
  background: #1f2937;
}

body.hardware-device-mode .panel-head h2,
body.hardware-device-mode .panel-card h2,
body.hardware-device-mode .panel-card h3,
body.hardware-device-mode .metric-tile strong {
  color: #fff;
}

body.hardware-device-mode .panel-note,
body.hardware-device-mode .detail-list,
body.hardware-device-mode .metric-tile small {
  color: #d1d5db;
}

body.hardware-device-mode .detail-list > div,
body.hardware-device-mode .overview-pill-card,
body.hardware-device-mode .overview-native-card,
body.hardware-device-mode .device-card,
body.hardware-device-mode .event-card,
body.hardware-device-mode .command-card,
body.hardware-device-mode .analysis-item,
body.hardware-device-mode .capability-card {
  border-color: #4a627a;
  background: #1f2937;
  box-shadow: none;
  color: #ecf0f1;
}

body.hardware-device-mode .detail-list span,
body.hardware-device-mode .overview-pill-label,
body.hardware-device-mode .overview-pill-card small,
body.hardware-device-mode .device-card-copy small,
body.hardware-device-mode .capability-card p {
  color: #d1d5db;
}

body.hardware-device-mode .detail-list strong,
body.hardware-device-mode .overview-pill-card strong,
body.hardware-device-mode .device-card strong,
body.hardware-device-mode .event-card strong,
body.hardware-device-mode .command-card strong,
body.hardware-device-mode .analysis-item strong {
  color: #fff;
}

body.hardware-device-mode input,
body.hardware-device-mode select,
body.hardware-device-mode textarea {
  background-color: #34495e;
  color: #fff;
  border-color: #7f8c8d;
}

body.hardware-device-mode table th,
body.hardware-device-mode table td {
  border-color: #4a627a;
}

.config-form-grid--bess0 .config-section-count,
.config-form-grid--bess0-win10 .config-section-count {
  background: rgba(45, 212, 191, 0.12);
  color: #ccfbf1;
  border: 1px solid rgba(45, 212, 191, 0.18);
}

.config-form-grid--bess0 .config-form-section.is-open .config-section-count,
.config-form-grid--bess0-win10 .config-form-section.is-open .config-section-count {
  background: rgba(34, 197, 94, 0.12);
  color: #bbf7d0;
}

.config-form-grid--bess0 .config-field-key,
.config-form-grid--bess0-win10 .config-field-key {
  font-family: Consolas, "Courier New", monospace;
}

.config-form-grid--bess0 .config-field input,
.config-form-grid--bess0 .config-field select,
.config-form-grid--bess0 .config-field textarea,
.config-form-grid--bess0-win10 .config-field input,
.config-form-grid--bess0-win10 .config-field select,
.config-form-grid--bess0-win10 .config-field textarea {
  background: rgba(11, 19, 32, 0.72);
  color: #f8fafc;
  border-color: rgba(45, 212, 191, 0.16);
}

.config-form-grid--bess0 .config-field input:focus,
.config-form-grid--bess0 .config-field select:focus,
.config-form-grid--bess0 .config-field textarea:focus,
.config-form-grid--bess0-win10 .config-field input:focus,
.config-form-grid--bess0-win10 .config-field select:focus,
.config-form-grid--bess0-win10 .config-field textarea:focus {
  outline: none;
  border-color: rgba(45, 212, 191, 0.48);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.14);
}

.config-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.config-field {
  display: grid;
  gap: 6px;
}

.config-field--template {
  border: 1px dashed rgba(250, 204, 21, 0.34);
  border-radius: 16px;
  padding: 10px;
  background: rgba(250, 204, 21, 0.04);
}

.config-template-badge {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(250, 204, 21, 0.42);
  border-radius: 999px;
  padding: 3px 9px;
  color: #fde68a;
  background: rgba(180, 83, 9, 0.16);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.config-field-wide {
  grid-column: span 2;
}

.config-field-label {
  font-weight: 800;
  color: var(--text);
}

.config-field-key {
  color: var(--text-soft);
  font-size: 0.75rem;
  letter-spacing: 0.01em;
}

.config-field-hint {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.config-field input,
.config-field select,
.config-field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
}

.config-field textarea {
  min-height: 120px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

.config-field--bms-config {
  gap: 10px;
}

.config-pack-setup {
  display: grid;
  gap: 18px;
}

.config-pack-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.config-pack-overview-item {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(59, 130, 246, 0.18);
  background: linear-gradient(180deg, rgba(30, 41, 59, 0.9), rgba(15, 23, 42, 0.88));
}

.config-pack-overview-item span {
  color: rgba(148, 163, 184, 0.96);
  font-size: 0.86rem;
  letter-spacing: 0.01em;
}

.config-pack-overview-item strong {
  color: #f8fafc;
  font-size: 1.18rem;
  font-weight: 800;
}

.config-pack-intro,
.config-pack-extra {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(96, 165, 250, 0.16);
  background: rgba(15, 23, 42, 0.42);
  color: rgba(226, 232, 240, 0.9);
}

.config-pack-intro strong,
.config-pack-extra-title {
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 800;
}

.config-pack-intro span {
  line-height: 1.5;
}

.config-pack-capacity-grid,
.config-pack-summary-grid {
  display: grid;
  gap: 14px 18px;
}

.config-pack-capacity-grid {
  grid-template-columns: minmax(0, 1fr);
}

.config-pack-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.config-pack-slot-block {
  display: grid;
  gap: 12px;
}

.config-native-stack {
  display: grid;
  gap: 16px;
}

.config-native-block {
  display: grid;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(8, 18, 32, 0.54);
}

.config-native-block--compact {
  gap: 10px;
}

.config-native-block--muted {
  border-style: dashed;
  background: rgba(15, 23, 42, 0.36);
}

.config-native-block-head {
  display: grid;
  gap: 4px;
}

.config-native-block-head h4 {
  margin: 0;
  color: #f8fafc;
  font-size: 1.02rem;
  font-weight: 800;
}

.config-native-block-head p {
  margin: 0;
  color: rgba(226, 232, 240, 0.84);
  line-height: 1.55;
}

.config-native-block-body {
  display: grid;
  gap: 14px;
}

.config-fleet-shell {
  display: grid;
  gap: 16px;
}

.config-fleet-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px 18px;
}

.config-slot-list-cloud,
.config-cycle-list {
  display: grid;
  gap: 14px;
}

.config-slot-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.74);
}

.config-slot-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.config-slot-card-head strong {
  color: #f8fafc;
  font-size: 1rem;
}

.config-slot-card-head span {
  color: rgba(191, 219, 254, 0.9);
  font-size: 0.86rem;
}

.config-empty-note {
  color: rgba(226, 232, 240, 0.82);
}

.bms-config-editor {
  display: grid;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(96, 165, 250, 0.18);
  background: rgba(8, 18, 32, 0.52);
}

.bms-config-summary {
  color: rgba(226, 232, 240, 0.9);
  font-weight: 700;
  line-height: 1.45;
}

.bms-slot-list {
  display: grid;
  gap: 14px;
}

.bms-slot-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.74);
}

.bms-slot-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #f8fafc;
}

.bms-slot-card-head strong {
  font-size: 1.05rem;
}

.bms-slot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: rgba(248, 250, 252, 0.92);
  font-weight: 800;
}

.bms-slot-toggle input[type="checkbox"] {
  width: 28px;
  height: 28px;
  accent-color: #0ea5e9;
}

.bms-slot-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px 18px;
}

.bms-slot-field {
  display: grid;
  gap: 8px;
  color: rgba(248, 250, 252, 0.92);
  font-weight: 700;
}

.bms-slot-field--wide {
  grid-column: 1 / -1;
}

.bms-slot-field span {
  font-size: 0.9rem;
}

.bms-slot-field input,
.bms-slot-field select {
  width: 100%;
  border: 1px solid rgba(125, 211, 252, 0.24);
  border-radius: 12px;
  background: rgba(51, 65, 85, 0.86);
  color: #f8fafc;
  padding: 11px 12px;
  font-size: 0.98rem;
}

.bms-config-hidden {
  display: none !important;
}

.config-field.is-disabled input,
.config-field.is-disabled select,
.config-field.is-disabled textarea,
.config-form-grid.is-skeleton .config-field input,
.config-form-grid.is-skeleton .config-field select,
.config-form-grid.is-skeleton .config-field textarea {
  opacity: 0.8;
  cursor: not-allowed;
  background-image: linear-gradient(180deg, rgba(148, 163, 184, 0.06), rgba(15, 23, 42, 0.12));
}

.config-form-grid.is-skeleton .config-field-key {
  color: rgba(250, 204, 21, 0.82);
}

.config-form-grid.is-skeleton .config-field-hint {
  color: rgba(191, 219, 254, 0.68);
}

.config-input-error {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 3px rgba(216, 77, 77, 0.14);
}

.config-preview-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
}

.config-preview-card {
  min-width: 0;
}

.audit-list {
  display: grid;
  gap: 12px;
}

.audit-list.empty {
  padding: 16px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  color: var(--text-soft);
  background: var(--surface-soft);
}

.audit-card {
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-sm);
  display: grid;
  gap: 10px;
}

.audit-card-head,
.audit-card-meta,
.audit-chip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.audit-card-head {
  justify-content: space-between;
}

.audit-card-meta {
  color: var(--text-soft);
  font-size: 0.88rem;
}

.audit-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue-2);
  font-size: 0.82rem;
  font-weight: 700;
}

.audit-chip.muted {
  background: var(--bg-soft);
  color: var(--text-soft);
}

.json-block.compact pre {
  max-height: 180px;
}

@media (max-width: 980px) {
  .config-native-hero {
    grid-template-columns: 1fr;
  }

  .config-native-identity {
    justify-items: stretch;
  }

  .config-native-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .config-field-grid,
  .config-preview-layout {
    grid-template-columns: 1fr;
  }

  .config-field-wide {
    grid-column: auto;
  }

  .bms-slot-card-grid {
    grid-template-columns: 1fr;
  }

  .bms-slot-field--wide {
    grid-column: auto;
  }
}

@media (max-width: 640px) {
  .config-native-meta {
    grid-template-columns: 1fr;
  }

  .config-native-tab {
    width: 100%;
    justify-content: flex-start;
  }
}

.remote-native-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 20px 0 22px;
}

.remote-native-card {
  display: grid;
  gap: 12px;
  padding: 18px 18px 16px;
  border-radius: 22px;
  border: 1px solid rgba(124, 146, 176, 0.24);
  background:
    linear-gradient(180deg, rgba(22, 31, 49, 0.96), rgba(15, 23, 38, 0.96));
  box-shadow: 0 18px 32px rgba(5, 10, 18, 0.18);
}

.remote-native-card h3 {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 800;
  color: #f6fbff;
}

.remote-native-card p {
  margin: 0;
  color: var(--text-soft);
  line-height: 1.55;
}

.remote-native-card .detail-list {
  margin-top: 2px;
}

.remote-native-card .detail-list div {
  background: rgba(255, 255, 255, 0.02);
}

.remote-native-meta-line {
  color: var(--text-soft);
  font-size: .9rem;
  line-height: 1.6;
}

.remote-native-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.remote-native-lines {
  display: grid;
  gap: 8px;
}

.remote-native-lines.empty {
  color: var(--text-soft);
}

.remote-native-line {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(124, 146, 176, 0.18);
  background: rgba(255, 255, 255, 0.025);
}

.remote-native-line strong {
  color: #f6fbff;
  font-size: .96rem;
}

.remote-native-line small {
  color: var(--text-soft);
  line-height: 1.45;
}

/* Keep the customer overview inside the viewport even when site names or live values are long. */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

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

.portal-shell,
.portal-body,
.portfolio-sidebar,
.workspace,
.view,
.overview-grid,
.overview-native-summary,
.overview-native-card,
.overview-primary-flow,
.panel-card,
.metric-tile,
.overview-pill-card,
.device-card,
.event-card,
.analysis-item,
.bar-item,
.detail-list > div {
  min-width: 0;
}

.portal-body {
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  align-items: start;
}

.workspace {
  overflow: hidden;
}

#view-overview,
#view-devices,
#view-meters,
#view-events,
#view-operation,
#view-livecan,
#view-update,
#view-app_android,
#view-backup,
#view-ai,
#view-matrix {
  width: 100%;
  min-width: 0;
}

.android-app-panel {
  display: grid;
  gap: 16px;
}

.android-app-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.android-app-card {
  display: grid;
  gap: 6px;
  min-height: 120px;
  border: 1px solid #dbe5ee;
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
}

.android-app-card span {
  color: #64748b;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.android-app-card strong {
  color: #0f3154;
  font-size: 1.3rem;
}

.android-app-card small {
  color: #64748b;
  line-height: 1.45;
}

.android-app-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 860px) {
  .android-app-grid {
    grid-template-columns: 1fr;
  }
}

.metrics-strip {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.overview-pill-row {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.overview-native-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.overview-native-kpis {
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.overview-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .85fr);
  align-items: start;
}

.panel-flow,
.overview-primary-flow {
  grid-column: 1 / -1;
  width: 100%;
}

.overview-primary-flow .energy-flow {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-template-rows: auto;
}

.overview-primary-flow .energy-flow > * {
  grid-column: auto !important;
  grid-row: auto !important;
}

.flow-link {
  min-width: 44px;
}

.flow-node strong,
.flow-node span,
.flow-node small,
.detail-list span,
.detail-list strong,
.overview-native-kpi span,
.overview-native-kpi strong,
.overview-pill-card span,
.overview-pill-card strong,
.device-card-copy,
.event-card,
.analysis-item {
  overflow-wrap: anywhere;
}

.detail-list > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(108px, max-content);
  align-items: center;
}

.detail-list strong {
  min-width: 0;
  max-width: 100%;
}

@media (max-width: 1280px) {
  .portal-body {
    grid-template-columns: 1fr;
  }

  .workspace {
    order: 1;
  }

  .portfolio-sidebar {
    order: 2;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .portal-body {
    padding: 14px;
  }

  .overview-primary-flow .energy-flow,
  .energy-flow {
    grid-template-columns: 1fr;
  }

  .flow-link {
    width: 4px;
    height: 28px;
    justify-self: center;
  }

  .detail-list > div {
    grid-template-columns: 1fr;
  }
}

/* LuxPower-style cloud monitor: full system UI first, native device UI only after explicit selection. */
:root {
  --monitor-green: #5fad82;
  --monitor-green-dark: #3f9a68;
  --monitor-bg: #eef4f5;
  --monitor-line: #d7e1e6;
  --monitor-text: #203447;
  --monitor-muted: #7890a1;
}

body:not(.hardware-device-mode) {
  background: var(--monitor-bg);
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .portal-header {
  grid-template-columns: minmax(260px, 1fr) auto minmax(260px, 1fr);
  grid-template-areas: "brand nav actions";
  gap: 18px;
  align-items: stretch;
  padding: 0 22px;
  min-height: 78px;
  background: var(--monitor-green);
  border-bottom: 1px solid rgba(36, 123, 78, 0.22);
  box-shadow: none;
}

body:not(.hardware-device-mode) .brand-cluster,
body:not(.hardware-device-mode) .header-actions {
  align-self: center;
}

body:not(.hardware-device-mode) .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

body:not(.hardware-device-mode) .brand-title {
  color: #fff;
}

body:not(.hardware-device-mode) .brand-subtitle {
  display: none;
}

body:not(.hardware-device-mode) .top-nav {
  align-self: stretch;
  justify-content: center;
  gap: 0;
}

body:not(.hardware-device-mode) .nav-item {
  min-width: 104px;
  min-height: 64px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  box-shadow: none;
}

body:not(.hardware-device-mode) .nav-item:hover,
body:not(.hardware-device-mode) .nav-item.active {
  transform: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

body:not(.hardware-device-mode) .nav-quick {
  min-width: auto;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

body:not(.hardware-device-mode) .user-current-display,
body:not(.hardware-device-mode) .muted-pill {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.24);
}

body:not(.hardware-device-mode) .portal-body {
  grid-template-columns: minmax(270px, 330px) minmax(0, 1fr);
  gap: 18px;
  padding: 14px 18px 26px;
}

body:not(.hardware-device-mode) .sidebar-card,
body:not(.hardware-device-mode) .panel-card,
body:not(.hardware-device-mode) .metric-tile,
body:not(.hardware-device-mode) .overview-pill-card,
body:not(.hardware-device-mode) .hero-meta-card,
body:not(.hardware-device-mode) .account-owned-device-card {
  border-radius: 4px;
  border: 1px solid var(--monitor-line);
  background: #fff;
  box-shadow: none;
}

body:not(.hardware-device-mode) .sidebar-title,
body:not(.hardware-device-mode) .overview-kicker,
body:not(.hardware-device-mode) .metric-label,
body:not(.hardware-device-mode) .overview-pill-label {
  letter-spacing: 0;
  text-transform: none;
}

body:not(.hardware-device-mode) .sidebar-card {
  padding: 14px;
}

body:not(.hardware-device-mode) .site-list-item {
  border-radius: 4px;
  background: #fff;
}

body:not(.hardware-device-mode) .site-list-item.active {
  border-color: var(--monitor-green);
  box-shadow: inset 4px 0 0 var(--monitor-green);
}

body:not(.hardware-device-mode) #view-overview {
  gap: 12px;
}

body:not(.hardware-device-mode) #view-overview > .metrics-strip {
  order: 1;
}

body:not(.hardware-device-mode) #view-overview > .overview-primary-flow {
  order: 2;
}

body:not(.hardware-device-mode) #view-overview > .overview-hero-card {
  order: 3;
}

body:not(.hardware-device-mode) #view-overview > .overview-grid {
  order: 4;
}

body:not(.hardware-device-mode) #overviewNativeHeader,
body:not(.hardware-device-mode) .overview-native-summary.empty {
  display: none !important;
}

body:not(.hardware-device-mode) .metrics-strip {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

body:not(.hardware-device-mode) .metric-tile {
  position: relative;
  min-height: 128px;
  padding: 50px 16px 14px;
  overflow: hidden;
}

body:not(.hardware-device-mode) .metric-tile .metric-label {
  position: absolute;
  inset: 0 0 auto;
  min-height: 34px;
  padding: 8px 12px;
  color: #fff;
  font-weight: 800;
}

body:not(.hardware-device-mode) .metric-tile:nth-child(1) .metric-label { background: #5dbde0; }
body:not(.hardware-device-mode) .metric-tile:nth-child(2) .metric-label { background: #e97b9d; }
body:not(.hardware-device-mode) .metric-tile:nth-child(3) .metric-label { background: #f19a62; }
body:not(.hardware-device-mode) .metric-tile:nth-child(4) .metric-label { background: #51bf86; }
body:not(.hardware-device-mode) .metric-tile:nth-child(5) .metric-label { background: #6ba6df; }
body:not(.hardware-device-mode) .metric-tile:nth-child(6) .metric-label { background: #ef6b6b; }

body:not(.hardware-device-mode) .metric-tile strong {
  justify-self: end;
  color: var(--monitor-text);
  font-size: 1.35rem;
}

body:not(.hardware-device-mode) .metric-tile small {
  justify-self: end;
  color: var(--monitor-muted);
}

body:not(.hardware-device-mode) .overview-primary-flow {
  margin: 0;
  padding: 14px;
  border-radius: 4px;
  background: #fff;
  border-color: var(--monitor-line);
  box-shadow: none;
}

body:not(.hardware-device-mode) .overview-primary-flow .panel-head,
body:not(.hardware-device-mode) .overview-primary-flow .panel-head h2 {
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .overview-primary-flow .panel-head h2::before {
  content: "System Information / ";
  color: var(--monitor-muted);
  font-weight: 700;
}

body:not(.hardware-device-mode) .overview-primary-flow .mini-badge {
  background: #eef8f2;
  color: var(--monitor-green-dark);
  border-color: rgba(63, 154, 104, 0.24);
}

body:not(.hardware-device-mode) .overview-primary-flow .energy-flow {
  min-height: 360px;
  padding: 28px;
  border-radius: 4px;
  border-color: #e4ecef;
  background: #fff;
}

body:not(.hardware-device-mode) .flow-node {
  border-radius: 4px;
  border-color: #dbe8df;
  background: #fff;
}

body:not(.hardware-device-mode) .overview-primary-flow .flow-node strong,
body:not(.hardware-device-mode) .flow-node strong {
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .overview-primary-flow .flow-node span,
body:not(.hardware-device-mode) .flow-node span {
  color: #0d4d80;
}

body:not(.hardware-device-mode) .flow-icon {
  background: #edf7f1;
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .flow-link {
  height: 3px;
  background: linear-gradient(90deg, #b7dbca, var(--monitor-green));
  box-shadow: none;
}

body:not(.hardware-device-mode) .overview-hero-card {
  gap: 12px;
  background: #fff;
  border-radius: 4px;
  box-shadow: none;
}

body:not(.hardware-device-mode) .overview-kicker {
  padding: 0;
  background: transparent;
  color: var(--monitor-muted);
}

body:not(.hardware-device-mode) .overview-hero-banner {
  border-radius: 4px;
  background: #eef8f2;
  color: var(--monitor-green-dark);
  box-shadow: none;
}

body:not(.hardware-device-mode) .overview-hero-banner.is-warn {
  background: #fff6e7;
  color: #9a6506;
}

body:not(.hardware-device-mode) .overview-hero-banner.is-error {
  background: #fdecec;
  color: #a83232;
}

body:not(.hardware-device-mode) .overview-pill-row {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

body:not(.hardware-device-mode) .overview-pill-card {
  padding: 12px;
}

body:not(.hardware-device-mode) .overview-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .75fr);
  gap: 14px;
}

body:not(.hardware-device-mode) .panel-card {
  padding: 16px;
}

body:not(.hardware-device-mode) .panel-head h2 {
  font-size: 1.05rem;
}

body:not(.hardware-device-mode) .account-owned-device-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

body:not(.hardware-device-mode) .small-manage-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 4px;
  background: var(--monitor-green);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

body:not(.hardware-device-mode) .small-manage-link:hover,
body:not(.hardware-device-mode) .small-manage-link:focus-visible {
  background: var(--monitor-green-dark);
  outline: none;
}

body:not(.hardware-device-mode) .account-device-item {
  grid-template-columns: minmax(0, 1fr) auto auto;
  border-radius: 4px;
}

@media (max-width: 1320px) {
  body:not(.hardware-device-mode) .portal-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "nav"
      "actions";
    padding: 12px 18px;
  }

  body:not(.hardware-device-mode) .top-nav,
  body:not(.hardware-device-mode) .header-actions {
    justify-content: flex-start;
  }

  body:not(.hardware-device-mode) .nav-item {
    min-height: 42px;
  }
}

@media (max-width: 1280px) {
  body:not(.hardware-device-mode) .portal-body,
  body:not(.hardware-device-mode) .overview-grid {
    grid-template-columns: 1fr;
  }
}

body:not(.hardware-device-mode) .portal-header {
  grid-template-columns: minmax(210px, auto) minmax(0, 1fr);
  grid-template-areas:
    "brand actions"
    "nav nav";
  gap: 8px 14px;
  padding: 8px 20px 0;
  min-height: 0;
}

body:not(.hardware-device-mode) .top-nav {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  justify-content: center;
  scrollbar-width: thin;
}

body:not(.hardware-device-mode) .nav-item {
  flex: 0 0 auto;
  min-width: auto;
  min-height: 48px;
  padding: 0 16px;
  white-space: nowrap;
}

body:not(.hardware-device-mode) .nav-quick {
  min-height: 34px;
  padding: 7px 10px;
}

body:not(.hardware-device-mode) .header-actions {
  gap: 8px;
  align-self: start;
  padding-top: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

body:not(.hardware-device-mode) .header-actions > * {
  flex: 0 0 auto;
}

body:not(.hardware-device-mode) .user-switch > span,
body:not(.hardware-device-mode) .org-switch > span {
  display: none;
}

body:not(.hardware-device-mode) .user-switch-readonly {
  min-width: 210px;
  max-width: 260px;
}

body:not(.hardware-device-mode) .user-current-display {
  display: block;
  min-height: 34px;
  padding: 7px 10px;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body:not(.hardware-device-mode) .primary-button,
body:not(.hardware-device-mode) .ghost-button,
body:not(.hardware-device-mode) .status-pill {
  border-radius: 4px;
  padding: 8px 12px;
}

body:not(.hardware-device-mode) #view-overview > .portfolio-panel {
  order: 5;
}

@media (max-width: 760px) {
  body:not(.hardware-device-mode) .portal-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions"
      "nav";
    gap: 6px;
    padding: 8px;
  }

  body:not(.hardware-device-mode) .header-actions,
  body:not(.hardware-device-mode) .top-nav {
    justify-content: flex-start;
  }

  body:not(.hardware-device-mode) .user-switch-readonly {
    min-width: 190px;
    max-width: 220px;
  }

  body:not(.hardware-device-mode) .nav-item {
    min-height: 40px;
    padding: 0 12px;
  }

  body:not(.hardware-device-mode) .metrics-strip {
    grid-template-columns: 1fr;
  }
}

/* Lux-like outer monitor shell. Native BESS0/BESS1X pages keep their device UI. */
body:not(.hardware-device-mode) .top-nav .nav-item:not([data-view="overview"]):not([data-view="meters"]):not([data-view="devices"]):not([data-view="ai"]) {
  display: none;
}

body:not(.hardware-device-mode) .top-nav .nav-item[data-view="overview"] { order: 1; }
body:not(.hardware-device-mode) .top-nav .nav-item[data-view="meters"] { order: 2; }
body:not(.hardware-device-mode) .top-nav .nav-item[data-view="devices"] { order: 3; }
body:not(.hardware-device-mode) .top-nav .nav-item[data-view="ai"] { order: 4; }

body:not(.hardware-device-mode) .workspace-hero,
body:not(.hardware-device-mode) .workspace-hint,
body:not(.hardware-device-mode) .portfolio-sidebar,
body:not(.hardware-device-mode) #globalContextHelp {
  display: none !important;
}

body:not(.hardware-device-mode) .portal-body {
  grid-template-columns: minmax(0, 1fr);
  padding: 18px 22px 34px;
}

body:not(.hardware-device-mode) .workspace {
  min-width: 0;
}

body:not(.hardware-device-mode) #view-overview > .overview-hero-card,
body:not(.hardware-device-mode) #view-overview > .overview-pill-row,
body:not(.hardware-device-mode) #view-overview > .overview-grid,
body:not(.hardware-device-mode) #view-overview > .portfolio-panel {
  display: none !important;
}

body:not(.hardware-device-mode) .lux-filter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--monitor-line);
  border-radius: 4px;
  background: #fff;
}

body:not(.hardware-device-mode) .lux-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--monitor-muted);
  font-weight: 700;
  white-space: nowrap;
}

body:not(.hardware-device-mode) .lux-check input {
  accent-color: var(--monitor-green-dark);
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
}

body:not(.hardware-device-mode) .lux-filter-row select,
body:not(.hardware-device-mode) .lux-table-toolbar input {
  min-height: 36px;
  min-width: 190px;
  border: 1px solid #c7d6dd;
  border-radius: 4px;
  background: #fff;
  color: var(--monitor-text);
  font-weight: 700;
  padding: 7px 10px;
}

body:not(.hardware-device-mode) .lux-action-btn,
body:not(.hardware-device-mode) .lux-green-btn,
body:not(.hardware-device-mode) .lux-date-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--monitor-green-dark);
  border-radius: 4px;
  background: var(--monitor-green);
  color: #fff;
  font-weight: 800;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
}

body:not(.hardware-device-mode) .lux-date-btn {
  min-width: 36px;
  background: #fff;
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .lux-date-chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid #c7d6dd;
  border-radius: 4px;
  background: #f7fbfd;
  color: var(--monitor-text);
  font-weight: 800;
}

body:not(.hardware-device-mode) .lux-monitor-lower {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, .8fr);
  gap: 14px;
  order: 5;
}

body:not(.hardware-device-mode) .lux-chart-card,
body:not(.hardware-device-mode) .lux-main-panel,
body:not(.hardware-device-mode) .lux-left-menu {
  border: 1px solid var(--monitor-line);
  border-radius: 4px;
  background: #fff;
  box-shadow: none;
}

body:not(.hardware-device-mode) .lux-chart-card {
  padding: 14px;
}

body:not(.hardware-device-mode) .lux-chart-card h2,
body:not(.hardware-device-mode) .lux-chart-card h3 {
  margin: 0;
  color: var(--monitor-text);
  font-size: 1rem;
}

body:not(.hardware-device-mode) .lux-wide {
  min-width: 0;
}

body:not(.hardware-device-mode) .lux-full {
  grid-column: 1 / -1;
}

body:not(.hardware-device-mode) .lux-side-stack {
  display: grid;
  gap: 14px;
  min-width: 0;
}

body:not(.hardware-device-mode) .lux-panel-head,
body:not(.hardware-device-mode) .lux-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

body:not(.hardware-device-mode) .lux-panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

body:not(.hardware-device-mode) .lux-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 10px 0;
  color: var(--monitor-muted);
  font-size: .86rem;
  font-weight: 800;
}

body:not(.hardware-device-mode) .lux-legend span::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  border-radius: 999px;
  background: var(--legend-color, var(--monitor-green));
}

body:not(.hardware-device-mode) .lux-legend .solar { --legend-color: #f5b24d; }
body:not(.hardware-device-mode) .lux-legend .battery { --legend-color: #63b36d; }
body:not(.hardware-device-mode) .lux-legend .grid { --legend-color: #568fd8; }
body:not(.hardware-device-mode) .lux-legend .load { --legend-color: #db5f80; }
body:not(.hardware-device-mode) .lux-legend .soc { --legend-color: #8b6bd8; }

body:not(.hardware-device-mode) .lux-empty-chart {
  min-height: 240px;
  display: grid;
  place-items: center;
  border: 1px solid #e4edf1;
  border-radius: 4px;
  background:
    linear-gradient(#f3f7f9 1px, transparent 1px),
    linear-gradient(90deg, #f3f7f9 1px, transparent 1px),
    #fff;
  background-size: 100% 48px, 72px 100%, auto;
  color: var(--monitor-muted);
  font-weight: 700;
  text-align: center;
}

body:not(.hardware-device-mode) .lux-notification-list {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

body:not(.hardware-device-mode) .lux-notification-list article,
body:not(.hardware-device-mode) .lux-revenue-tile {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid #edf2f4;
  border-radius: 4px;
  background: #f9fbfc;
}

body:not(.hardware-device-mode) .lux-notification-list strong,
body:not(.hardware-device-mode) .lux-revenue-tile strong {
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .lux-notification-list span,
body:not(.hardware-device-mode) .lux-revenue-tile span {
  color: var(--monitor-muted);
  font-size: .9rem;
}

body:not(.hardware-device-mode) .lux-revenue-tile.revenue-main {
  border-color: #a7dfc2;
  background: #f4fff8;
}

body:not(.hardware-device-mode) .lux-revenue-tile.revenue-main strong {
  color: #168047;
  font-size: 1.08rem;
}

body:not(.hardware-device-mode) .lux-finance-grid {
  display: grid;
  gap: 10px;
}

body:not(.hardware-device-mode) .lux-revenue-tile.charge-cost {
  border-color: #f0c38a;
  background: #fff9ef;
}

body:not(.hardware-device-mode) .lux-revenue-tile.profit-main {
  border-color: #8cc7f2;
  background: #f1f8ff;
}

body:not(.hardware-device-mode) .lux-revenue-tile.charge-cost strong {
  color: #b96b00;
  font-size: 1.08rem;
}

body:not(.hardware-device-mode) .lux-revenue-tile.profit-main strong {
  color: #0a69a8;
  font-size: 1.08rem;
}

body:not(.hardware-device-mode) .lux-revenue-tile small {
  color: var(--monitor-muted);
  font-size: .78rem;
}

body:not(.hardware-device-mode) .lux-finance-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid #e8eef2;
  padding-top: 5px;
  color: var(--monitor-muted);
  font-size: .82rem;
}

body:not(.hardware-device-mode) .lux-finance-row em {
  font-style: normal;
}

body:not(.hardware-device-mode) .lux-finance-row b {
  color: var(--monitor-text);
  font-size: .82rem;
}

.language-switch {
  display: grid;
  gap: 4px;
  min-width: 118px;
}

.language-switch span {
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 800;
}

.language-switch select {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 6px 10px;
  font-weight: 800;
}

body:not(.hardware-device-mode) .lux-page {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

body:not(.hardware-device-mode) .lux-left-menu {
  align-self: start;
  overflow: hidden;
}

body:not(.hardware-device-mode) .lux-left-menu button {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #edf2f4;
  background: #fff;
  color: var(--monitor-text);
  font-weight: 800;
  text-align: left;
  cursor: pointer;
}

body:not(.hardware-device-mode) .lux-left-menu button.active,
body:not(.hardware-device-mode) .lux-left-menu button:hover {
  background: #eef8f2;
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .lux-main-panel {
  min-width: 0;
  padding: 14px;
}

body:not(.hardware-device-mode) .lux-data-grid {
  display: grid;
  grid-template-columns: minmax(170px, .72fr) minmax(0, 1fr) minmax(0, 1fr) minmax(170px, .72fr);
  gap: 14px;
  min-width: 0;
}

body:not(.hardware-device-mode) .lux-param-list {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid #e4edf1;
  border-radius: 4px;
  background: #fbfdfe;
}

body:not(.hardware-device-mode) .lux-param-list h3 {
  margin: 0 0 4px;
  font-size: .95rem;
}

body:not(.hardware-device-mode) .lux-param-list button {
  min-height: 32px;
  border: 1px solid #d8e4e9;
  border-radius: 4px;
  background: #fff;
  color: var(--monitor-text);
  font-weight: 700;
  text-align: left;
}

body:not(.hardware-device-mode) .lux-param-list button.active {
  border-color: var(--monitor-green);
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .lux-data-chart {
  min-height: 180px;
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 14px;
  border: 1px solid #e4edf1;
  border-radius: 4px;
  background:
    linear-gradient(#f3f7f9 1px, transparent 1px),
    #fff;
  background-size: 100% 42px, auto;
}

body:not(.hardware-device-mode) .lux-data-value {
  justify-self: end;
  align-self: end;
  color: #0d4d80;
  font-size: 1.4rem;
  font-weight: 900;
}

body:not(.hardware-device-mode) .lux-table-toolbar {
  margin: 0 0 12px;
}

body:not(.hardware-device-mode) .lux-table-toolbar strong {
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .lux-table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--monitor-line);
  border-radius: 4px;
}

body:not(.hardware-device-mode) .lux-overview-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: .92rem;
}

body:not(.hardware-device-mode) .lux-overview-table th,
body:not(.hardware-device-mode) .lux-overview-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #e6eef2;
  color: var(--monitor-text);
  text-align: left;
  white-space: nowrap;
}

body:not(.hardware-device-mode) .lux-overview-table th {
  background: #f4f8fa;
  color: #5f7688;
  font-weight: 900;
}

body:not(.hardware-device-mode) .lux-overview-table tr.alt td {
  background: #fbfdfe;
}

body:not(.hardware-device-mode) .lux-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #fff;
  font-size: .78rem;
  font-weight: 900;
}

body:not(.hardware-device-mode) .lux-status.online { background: #43a96f; }
body:not(.hardware-device-mode) .lux-status.notice { background: #e9a43d; }
body:not(.hardware-device-mode) .lux-status.offline { background: #9aa8b2; }

body:not(.hardware-device-mode) .lux-table-link {
  color: var(--monitor-green-dark);
  font-weight: 900;
  text-decoration: none;
}

body:not(.hardware-device-mode) .lux-table-link:hover {
  text-decoration: underline;
}

body:not(.hardware-device-mode) .lux-energy-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 12px;
}

body:not(.hardware-device-mode) .lux-energy-kpis article {
  min-height: 108px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--monitor-line);
  border-radius: 4px;
  background: #fff;
}

body:not(.hardware-device-mode) .lux-energy-kpis span {
  color: #fff;
  font-weight: 900;
}

body:not(.hardware-device-mode) .lux-energy-kpis strong {
  justify-self: end;
  color: var(--monitor-text);
  font-size: 1.28rem;
}

body:not(.hardware-device-mode) .lux-energy-kpis small {
  justify-self: end;
  color: var(--monitor-muted);
}

body:not(.hardware-device-mode) .lux-energy-kpis .yield { border-top: 34px solid #5dbde0; }
body:not(.hardware-device-mode) .lux-energy-kpis .battery { border-top: 34px solid #ec7d9e; }
body:not(.hardware-device-mode) .lux-energy-kpis .feed { border-top: 34px solid #f49b63; }
body:not(.hardware-device-mode) .lux-energy-kpis .load { border-top: 34px solid #56c38b; }

body:not(.hardware-device-mode) .lux-energy-kpis article > span {
  margin-top: -38px;
}

body:not(.hardware-device-mode) .lux-announcement {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 11px 14px;
  border: 1px solid #dfe8c4;
  border-radius: 4px;
  background: #fbfff0;
  color: #637229;
}

body:not(.hardware-device-mode) .lux-announcement strong {
  color: #4f8e34;
}

body:not(.hardware-device-mode) .lux-weather-card p {
  margin: 10px 0 12px;
  color: var(--monitor-muted);
  line-height: 1.45;
}

body:not(.hardware-device-mode) .lux-data-view[hidden] {
  display: none !important;
}

body:not(.hardware-device-mode) .lux-toolbar-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

body:not(.hardware-device-mode) .lux-toolbar-row input:not([type="checkbox"]),
body:not(.hardware-device-mode) .lux-toolbar-row select {
  min-height: 36px;
  min-width: 180px;
  border: 1px solid #c7d6dd;
  border-radius: 4px;
  background: #fff;
  color: var(--monitor-text);
  font-weight: 700;
  padding: 7px 10px;
}

body:not(.hardware-device-mode) .lux-subgrid {
  display: grid;
  gap: 14px;
}

body:not(.hardware-device-mode) .lux-subgrid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

body:not(.hardware-device-mode) .lux-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

body:not(.hardware-device-mode) .lux-summary-grid article {
  display: grid;
  gap: 5px;
  padding: 10px;
  border: 1px solid #e4edf1;
  border-radius: 4px;
  background: #fbfdfe;
}

body:not(.hardware-device-mode) .lux-summary-grid span {
  color: var(--monitor-muted);
  font-size: .84rem;
  font-weight: 800;
}

body:not(.hardware-device-mode) .lux-summary-grid strong {
  color: var(--monitor-text);
  font-weight: 900;
}

body:not(.hardware-device-mode) .lux-station-device-layout {
  display: grid;
  grid-template-columns: minmax(240px, .34fr) minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
}

body:not(.hardware-device-mode) .lux-station-selector,
body:not(.hardware-device-mode) .lux-station-detail {
  min-width: 0;
}

body:not(.hardware-device-mode) .lux-station-stack {
  display: grid;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
}

body:not(.hardware-device-mode) .lux-station-tile {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--monitor-line);
  border-radius: 4px;
  background: #fff;
}

body:not(.hardware-device-mode) .lux-station-tile.active {
  border-color: var(--monitor-green);
  box-shadow: inset 4px 0 0 var(--monitor-green);
}

body:not(.hardware-device-mode) .lux-station-tile h4 {
  margin: 0;
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .lux-station-tile div {
  color: #0d4d80;
  font-weight: 900;
}

body:not(.hardware-device-mode) .lux-station-tile small {
  color: var(--monitor-muted);
}

body:not(.hardware-device-mode) .lux-pager {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

body:not(.hardware-device-mode) .lux-pager select {
  min-height: 36px;
  border: 1px solid #c7d6dd;
  border-radius: 4px;
  background: #fff;
}

@media (max-width: 1180px) {
  body:not(.hardware-device-mode) .lux-monitor-lower,
  body:not(.hardware-device-mode) .lux-page,
  body:not(.hardware-device-mode) .lux-data-grid,
  body:not(.hardware-device-mode) .lux-station-device-layout,
  body:not(.hardware-device-mode) .lux-subgrid.two {
    grid-template-columns: 1fr;
  }

  body:not(.hardware-device-mode) .lux-energy-kpis {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

  body:not(.hardware-device-mode) .lux-left-menu {
    display: flex;
    overflow-x: auto;
  }

  body:not(.hardware-device-mode) .lux-left-menu button {
    flex: 0 0 auto;
    width: auto;
    border-right: 1px solid #edf2f4;
    border-bottom: 0;
  }

  body:not(.hardware-device-mode) .lux-full {
    grid-column: auto;
  }
}

@media (max-width: 760px) {
  body:not(.hardware-device-mode) .portal-body {
    padding: 10px;
  }

  body:not(.hardware-device-mode) .lux-filter-row select,
  body:not(.hardware-device-mode) .lux-filter-row .lux-action-btn,
  body:not(.hardware-device-mode) .lux-filter-row .lux-green-btn,
  body:not(.hardware-device-mode) .lux-filter-row .lux-date-btn,
  body:not(.hardware-device-mode) .lux-table-toolbar input {
    width: 100%;
    min-width: 0;
  }

  body:not(.hardware-device-mode) .lux-panel-head,
  body:not(.hardware-device-mode) .lux-panel-actions,
  body:not(.hardware-device-mode) .lux-table-toolbar,
  body:not(.hardware-device-mode) .lux-toolbar-row {
    align-items: stretch;
  }

  body:not(.hardware-device-mode) .lux-energy-kpis,
  body:not(.hardware-device-mode) .lux-summary-grid {
    grid-template-columns: 1fr;
  }

  body:not(.hardware-device-mode) .lux-toolbar-row input:not([type="checkbox"]),
  body:not(.hardware-device-mode) .lux-toolbar-row select,
  body:not(.hardware-device-mode) .lux-toolbar-row .lux-green-btn,
  body:not(.hardware-device-mode) .lux-toolbar-row .lux-date-btn {
    width: 100%;
    min-width: 0;
  }
}

/* Header compactness for admin sessions with many visible controls. */
body:not(.hardware-device-mode) .portal-header {
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  grid-template-areas:
    "brand actions"
    "nav nav";
  align-items: start;
  gap: 8px 12px;
  padding: 10px 18px 0;
  overflow: visible;
}

body:not(.hardware-device-mode) .brand-cluster {
  min-width: 0;
  width: 100%;
  gap: 10px;
  align-self: start;
}

body:not(.hardware-device-mode) .brand-copy {
  min-width: 0;
}

body:not(.hardware-device-mode) .brand-title {
  max-width: 205px;
  overflow: hidden;
  text-overflow: ellipsis;
}

body:not(.hardware-device-mode) .user-switch-readonly {
  display: none !important;
}

body:not(.hardware-device-mode) .header-actions {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  overflow: visible;
  min-width: 0;
  max-width: 100%;
}

body:not(.hardware-device-mode) .header-actions > * {
  flex: 0 1 auto;
}

body:not(.hardware-device-mode) .org-switch {
  min-width: 260px;
  max-width: 340px;
}

body:not(.hardware-device-mode) .org-switch select {
  min-height: 40px;
  border-radius: 4px;
  padding: 8px 12px;
}

body:not(.hardware-device-mode) .nav-quick,
body:not(.hardware-device-mode) #refreshButton,
body:not(.hardware-device-mode) #logoutButton,
body:not(.hardware-device-mode) #liveBadge {
  min-height: 40px;
  white-space: nowrap;
}

body:not(.hardware-device-mode) .top-nav {
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
}

@media (max-width: 1180px) {
  body:not(.hardware-device-mode) .portal-header {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions"
      "nav";
  }

  body:not(.hardware-device-mode) .header-actions {
    justify-content: flex-start;
  }
}

/* Cloud app home: user-facing plant detail from server data. */
body:not(.hardware-device-mode) #view-overview > .metrics-strip,
body:not(.hardware-device-mode) #view-overview > .overview-primary-flow,
body:not(.hardware-device-mode) #view-overview > .overview-hero-card,
body:not(.hardware-device-mode) #view-overview > .overview-grid,
body:not(.hardware-device-mode) #view-overview > .portfolio-panel {
  display: none !important;
}

body:not(.hardware-device-mode) .cloud-app-home {
  display: grid;
  gap: 16px;
}

body:not(.hardware-device-mode) .cloud-app-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 320px);
  gap: 16px;
  align-items: stretch;
  padding: 18px;
  border: 1px solid var(--monitor-line);
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.98), rgba(244,249,252,.98)),
    #fff;
}

body:not(.hardware-device-mode) .cloud-app-hero-main {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}

body:not(.hardware-device-mode) .cloud-app-kicker {
  color: var(--monitor-green-dark);
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  font-size: .78rem;
}

body:not(.hardware-device-mode) .cloud-app-hero h1,
body:not(.hardware-device-mode) .cloud-app-section-head h2,
body:not(.hardware-device-mode) .cloud-app-panel h2 {
  margin: 0;
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .cloud-app-hero h1 {
  font-size: clamp(1.35rem, 2.2vw, 2.1rem);
  line-height: 1.15;
}

body:not(.hardware-device-mode) .cloud-app-hero p,
body:not(.hardware-device-mode) .cloud-app-section-head p {
  margin: 0;
  color: var(--monitor-muted);
  line-height: 1.45;
}

body:not(.hardware-device-mode) .cloud-app-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 8px;
}

body:not(.hardware-device-mode) .cloud-app-toolbar label {
  display: grid;
  gap: 5px;
  min-width: min(280px, 100%);
  color: var(--monitor-muted);
  font-weight: 800;
  font-size: .84rem;
}

body:not(.hardware-device-mode) .cloud-app-toolbar select {
  min-height: 40px;
  border: 1px solid #c7d6dd;
  border-radius: 6px;
  background: #fff;
  color: var(--monitor-text);
  padding: 8px 10px;
  font-weight: 800;
}

body:not(.hardware-device-mode) .cloud-app-primary,
body:not(.hardware-device-mode) .cloud-app-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 900;
  text-decoration: none;
}

body:not(.hardware-device-mode) .cloud-app-primary {
  background: var(--monitor-green);
  color: #fff;
}

body:not(.hardware-device-mode) .cloud-app-secondary {
  border: 1px solid var(--monitor-green);
  background: #fff;
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .cloud-app-status-card {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 150px;
  padding: 18px;
  border-radius: 10px;
  border: 1px solid #dfe8ef;
  background: #f7fbfd;
}

body:not(.hardware-device-mode) .cloud-app-status-card span {
  width: fit-content;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eef3f6;
  color: var(--monitor-muted);
  font-size: .82rem;
  font-weight: 900;
}

body:not(.hardware-device-mode) .cloud-app-status-card strong {
  color: #0d4d80;
  font-size: 2rem;
  line-height: 1;
}

body:not(.hardware-device-mode) .cloud-app-status-card small {
  color: var(--monitor-muted);
  font-weight: 700;
}

body:not(.hardware-device-mode) .cloud-app-status-card.online {
  border-color: #a9ddbf;
  background: #f3fff7;
}

body:not(.hardware-device-mode) .cloud-app-status-card.online span {
  background: #dff5e8;
  color: #18884b;
}

body:not(.hardware-device-mode) .cloud-app-status-card.warn,
body:not(.hardware-device-mode) .cloud-app-status-card.notice {
  border-color: #f0d29f;
  background: #fff9ef;
}

body:not(.hardware-device-mode) .cloud-app-status-card.warn span,
body:not(.hardware-device-mode) .cloud-app-status-card.notice span {
  background: #fff0cf;
  color: #a36504;
}

body:not(.hardware-device-mode) .cloud-app-status-card.offline {
  border-color: #e7b7b7;
  background: #fff5f5;
}

body:not(.hardware-device-mode) .cloud-app-status-card.offline span {
  background: #ffe2e2;
  color: #a83232;
}

body:not(.hardware-device-mode) .cloud-app-energy,
body:not(.hardware-device-mode) .cloud-app-panel,
body:not(.hardware-device-mode) .cloud-app-kpi-grid article {
  border: 1px solid var(--monitor-line);
  border-radius: 10px;
  background: #fff;
}

body:not(.hardware-device-mode) .cloud-app-energy,
body:not(.hardware-device-mode) .cloud-app-panel {
  padding: 16px;
}

body:not(.hardware-device-mode) .cloud-app-section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

body:not(.hardware-device-mode) .cloud-app-section-head > span,
body:not(.hardware-device-mode) .cloud-app-section-head a {
  color: var(--monitor-green-dark);
  font-weight: 900;
  text-decoration: none;
}

body:not(.hardware-device-mode) .cloud-app-flow {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(90px, .4fr) minmax(160px, 1fr) minmax(90px, .4fr) minmax(160px, 1fr);
  grid-template-rows: auto auto;
  gap: 14px;
  align-items: center;
}

body:not(.hardware-device-mode) .cloud-app-node {
  min-height: 160px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 8px;
  padding: 16px;
  border: 1px solid #dce8ee;
  border-radius: 10px;
  background: #fbfdfe;
  text-align: center;
}

body:not(.hardware-device-mode) .cloud-app-node i {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  display: block;
  background: #e8f4ff;
  position: relative;
}

body:not(.hardware-device-mode) .cloud-app-node i::after {
  content: "";
  position: absolute;
  inset: 15px;
  border: 3px solid #0d4d80;
  border-radius: 6px;
}

body:not(.hardware-device-mode) .cloud-app-node.grid i { background: #eef8f2; }
body:not(.hardware-device-mode) .cloud-app-node.pcs i { background: #edf2ff; }
body:not(.hardware-device-mode) .cloud-app-node.battery i { background: #fff4df; }
body:not(.hardware-device-mode) .cloud-app-node.load i { background: #ffeef3; }

body:not(.hardware-device-mode) .cloud-app-node span {
  color: var(--monitor-muted);
  font-weight: 900;
}

body:not(.hardware-device-mode) .cloud-app-node strong {
  color: #0d4d80;
  font-size: 1.35rem;
}

body:not(.hardware-device-mode) .cloud-app-node small {
  color: var(--monitor-muted);
  line-height: 1.35;
}

body:not(.hardware-device-mode) .cloud-app-node.load {
  grid-column: 3 / span 1;
  grid-row: 2;
}

body:not(.hardware-device-mode) .cloud-app-line {
  min-height: 44px;
  display: grid;
  place-items: center;
  color: var(--monitor-muted);
  font-size: .78rem;
  font-weight: 900;
  position: relative;
}

body:not(.hardware-device-mode) .cloud-app-line::before {
  content: "";
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #9ed1b7, var(--monitor-green));
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

body:not(.hardware-device-mode) .cloud-app-line.to-left::before {
  background: linear-gradient(90deg, var(--monitor-green), #9ed1b7);
}

body:not(.hardware-device-mode) .cloud-app-line span {
  position: relative;
  padding: 3px 8px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #dce8ee;
}

body:not(.hardware-device-mode) .cloud-app-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

body:not(.hardware-device-mode) .cloud-app-kpi-grid article {
  display: grid;
  gap: 5px;
  padding: 14px;
}

body:not(.hardware-device-mode) .cloud-app-kpi-grid span,
body:not(.hardware-device-mode) .cloud-app-finance span {
  color: var(--monitor-muted);
  font-weight: 900;
}

body:not(.hardware-device-mode) .cloud-app-kpi-grid strong,
body:not(.hardware-device-mode) .cloud-app-finance strong {
  color: var(--monitor-text);
  font-size: 1.25rem;
}

body:not(.hardware-device-mode) .cloud-app-kpi-grid small,
body:not(.hardware-device-mode) .cloud-app-finance small {
  color: var(--monitor-muted);
}

body:not(.hardware-device-mode) .cloud-app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
  gap: 16px;
  align-items: start;
}

body:not(.hardware-device-mode) .cloud-app-panel.tech {
  grid-column: 1 / -1;
}

body:not(.hardware-device-mode) .cloud-app-finance {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

body:not(.hardware-device-mode) .cloud-app-finance div,
body:not(.hardware-device-mode) .cloud-app-event,
body:not(.hardware-device-mode) .cloud-app-tech-card {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid #e2ebf0;
  border-radius: 8px;
  background: #fbfdfe;
}

body:not(.hardware-device-mode) .cloud-app-finance div:nth-child(1) { background: #f3fff7; border-color: #bbe5ca; }
body:not(.hardware-device-mode) .cloud-app-finance div:nth-child(2) { background: #fff9ef; border-color: #f0d29f; }
body:not(.hardware-device-mode) .cloud-app-finance div:nth-child(3) { background: #f1f8ff; border-color: #b8d7f1; }

body:not(.hardware-device-mode) .cloud-app-events {
  display: grid;
  gap: 10px;
}

body:not(.hardware-device-mode) .cloud-app-event strong {
  color: var(--monitor-text);
}

body:not(.hardware-device-mode) .cloud-app-event span,
body:not(.hardware-device-mode) .cloud-app-event small {
  color: var(--monitor-muted);
  line-height: 1.35;
}

body:not(.hardware-device-mode) .cloud-app-event.error,
body:not(.hardware-device-mode) .cloud-app-event.fault {
  border-color: #efc1c1;
  background: #fff5f5;
}

body:not(.hardware-device-mode) .cloud-app-event.warn,
body:not(.hardware-device-mode) .cloud-app-event.warning {
  border-color: #f0d29f;
  background: #fff9ef;
}

body:not(.hardware-device-mode) .cloud-app-event.ok {
  border-color: #bbe5ca;
  background: #f3fff7;
}

body:not(.hardware-device-mode) .cloud-app-tech-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

body:not(.hardware-device-mode) .cloud-app-tech-card {
  color: var(--monitor-text);
  text-decoration: none;
}

body:not(.hardware-device-mode) .cloud-app-tech-card strong {
  color: var(--monitor-green-dark);
}

body:not(.hardware-device-mode) .cloud-app-tech-card span {
  color: var(--monitor-muted);
  line-height: 1.35;
}

body:not(.hardware-device-mode) .cloud-app-tech-card:hover,
body:not(.hardware-device-mode) .cloud-app-tech-card:focus-visible {
  border-color: var(--monitor-green);
  outline: none;
}

@media (max-width: 1180px) {
  body:not(.hardware-device-mode) .cloud-app-hero,
  body:not(.hardware-device-mode) .cloud-app-grid,
  body:not(.hardware-device-mode) .cloud-app-finance,
  body:not(.hardware-device-mode) .cloud-app-tech-grid {
    grid-template-columns: 1fr;
  }

  body:not(.hardware-device-mode) .cloud-app-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body:not(.hardware-device-mode) .cloud-app-flow {
    grid-template-columns: 1fr;
  }

  body:not(.hardware-device-mode) .cloud-app-node.load {
    grid-column: auto;
    grid-row: auto;
  }

  body:not(.hardware-device-mode) .cloud-app-line {
    min-height: 34px;
  }

  body:not(.hardware-device-mode) .cloud-app-line::before {
    width: 4px;
    height: 100%;
  }
}

@media (max-width: 680px) {
  body:not(.hardware-device-mode) .cloud-app-hero,
  body:not(.hardware-device-mode) .cloud-app-energy,
  body:not(.hardware-device-mode) .cloud-app-panel {
    padding: 12px;
  }

  body:not(.hardware-device-mode) .cloud-app-toolbar,
  body:not(.hardware-device-mode) .cloud-app-section-head {
    align-items: stretch;
  }

  body:not(.hardware-device-mode) .cloud-app-section-head {
    flex-direction: column;
  }

  body:not(.hardware-device-mode) .cloud-app-toolbar label,
  body:not(.hardware-device-mode) .cloud-app-primary,
  body:not(.hardware-device-mode) .cloud-app-secondary {
    width: 100%;
  }

  body:not(.hardware-device-mode) .cloud-app-kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* Phone app shell: compact top bar + bottom navigation. */
@media (max-width: 720px) {
  body:not(.hardware-device-mode) {
    background: #eef5f7;
    padding-bottom: calc(74px + env(safe-area-inset-bottom, 0px));
  }

  body:not(.hardware-device-mode) .portal-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions";
    align-items: center;
    min-height: 58px;
    padding: 8px 12px;
    background: var(--monitor-green);
    border-bottom: 0;
    box-shadow: 0 4px 14px rgba(25, 90, 60, .18);
  }

  body:not(.hardware-device-mode) .brand-cluster {
    grid-area: brand;
    align-self: center;
    width: auto;
    min-width: 0;
  }

  body:not(.hardware-device-mode) .brand-mark {
    width: 34px;
    height: 34px;
    font-size: .92rem;
  }

  body:not(.hardware-device-mode) .brand-title {
    max-width: none;
    font-size: 1rem;
    line-height: 1.1;
  }

  body:not(.hardware-device-mode) .brand-subtitle {
    display: none !important;
  }

  body:not(.hardware-device-mode) .header-actions {
    grid-area: actions;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    overflow: visible;
  }

  body:not(.hardware-device-mode) .header-actions > * {
    display: none !important;
  }

  body:not(.hardware-device-mode) #liveBadge:not([hidden]) {
    display: inline-flex !important;
    min-height: 30px;
    max-width: 118px;
    padding: 6px 9px;
    overflow: hidden;
    border-radius: 999px;
    background: rgba(255,255,255,.2);
    border-color: rgba(255,255,255,.25);
    color: #fff;
    font-size: .72rem;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  body.auth-shell-guest:not(.hardware-device-mode) #headerAuthActions {
    display: inline-flex !important;
    gap: 6px;
  }

  body.auth-shell-guest:not(.hardware-device-mode) #headerAuthActions .ghost-button,
  body.auth-shell-guest:not(.hardware-device-mode) #headerAuthActions .primary-button {
    min-height: 30px;
    padding: 6px 9px;
    border-radius: 999px;
    font-size: .76rem;
  }

  body:not(.hardware-device-mode) .top-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1100;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    min-height: calc(64px + env(safe-area-inset-bottom, 0px));
    padding: 5px 6px calc(5px + env(safe-area-inset-bottom, 0px));
    overflow: visible;
    background: #ffffff;
    border-top: 1px solid #dbe7ed;
    box-shadow: 0 -8px 22px rgba(30, 64, 90, .14);
  }

  body:not(.hardware-device-mode) .top-nav .nav-item {
    display: none !important;
  }

  body:not(.hardware-device-mode) .top-nav .nav-item[data-view="overview"],
  body:not(.hardware-device-mode) .top-nav .nav-item[data-view="meters"],
  body:not(.hardware-device-mode) .top-nav .nav-item[data-view="devices"],
  body:not(.hardware-device-mode) .top-nav .nav-item[data-view="ai"] {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 54px;
    padding: 6px 4px;
    border-radius: 12px;
    color: #6f8395;
    background: transparent;
    font-size: .74rem;
    font-weight: 900;
    line-height: 1.15;
    white-space: normal;
    text-align: center;
  }

  body:not(.hardware-device-mode) .top-nav .nav-item.active {
    background: #eaf7f0;
    color: var(--monitor-green-dark);
  }

  body:not(.hardware-device-mode) .portal-body {
    display: block;
    padding: 10px 10px 88px;
  }

  body:not(.hardware-device-mode) .workspace {
    display: block;
    min-width: 0;
  }

  body:not(.hardware-device-mode) .view.active {
    display: grid;
    gap: 10px;
  }

  body:not(.hardware-device-mode) .cloud-app-home {
    gap: 10px;
  }

  body:not(.hardware-device-mode) .cloud-app-hero {
    grid-template-columns: 1fr;
    gap: 10px;
    border-radius: 12px;
    padding: 12px;
  }

  body:not(.hardware-device-mode) .cloud-app-hero h1 {
    font-size: 1.25rem;
  }

  body:not(.hardware-device-mode) .cloud-app-hero p {
    font-size: .9rem;
  }

  body:not(.hardware-device-mode) .cloud-app-toolbar {
    margin-top: 4px;
    gap: 8px;
  }

  body:not(.hardware-device-mode) .cloud-app-toolbar label,
  body:not(.hardware-device-mode) .cloud-app-primary,
  body:not(.hardware-device-mode) .cloud-app-secondary {
    width: 100%;
  }

  body:not(.hardware-device-mode) .cloud-app-status-card {
    min-height: 116px;
    padding: 14px;
    border-radius: 12px;
  }

  body:not(.hardware-device-mode) .cloud-app-status-card strong {
    font-size: 1.72rem;
  }

  body:not(.hardware-device-mode) .cloud-app-energy,
  body:not(.hardware-device-mode) .cloud-app-panel,
  body:not(.hardware-device-mode) .cloud-app-kpi-grid article {
    border-radius: 12px;
  }

  body:not(.hardware-device-mode) .cloud-app-section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin-bottom: 10px;
  }

  body:not(.hardware-device-mode) .cloud-app-section-head h2 {
    font-size: 1.08rem;
  }

  body:not(.hardware-device-mode) .cloud-app-flow {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body:not(.hardware-device-mode) .cloud-app-node {
    min-height: 112px;
    grid-template-columns: 48px minmax(0, 1fr);
    justify-items: start;
    align-content: center;
    text-align: left;
    gap: 4px 12px;
    padding: 12px;
  }

  body:not(.hardware-device-mode) .cloud-app-node i {
    grid-row: span 3;
    width: 44px;
    height: 44px;
    border-radius: 13px;
  }

  body:not(.hardware-device-mode) .cloud-app-node i::after {
    inset: 13px;
    border-width: 2px;
  }

  body:not(.hardware-device-mode) .cloud-app-node strong {
    font-size: 1.14rem;
  }

  body:not(.hardware-device-mode) .cloud-app-node.load {
    grid-column: auto;
    grid-row: auto;
  }

  body:not(.hardware-device-mode) .cloud-app-line {
    min-height: 24px;
  }

  body:not(.hardware-device-mode) .cloud-app-line::before {
    width: 4px;
    height: 24px;
  }

  body:not(.hardware-device-mode) .cloud-app-line span {
    font-size: .72rem;
  }

  body:not(.hardware-device-mode) .cloud-app-kpi-grid,
  body:not(.hardware-device-mode) .cloud-app-grid,
  body:not(.hardware-device-mode) .cloud-app-finance,
  body:not(.hardware-device-mode) .cloud-app-tech-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body:not(.hardware-device-mode) .lux-page {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body:not(.hardware-device-mode) .lux-left-menu {
    position: sticky;
    top: 58px;
    z-index: 90;
    display: flex;
    overflow-x: auto;
    border-radius: 10px;
  }

  body:not(.hardware-device-mode) .lux-left-menu button {
    flex: 0 0 auto;
    width: auto;
    min-height: 40px;
    border-right: 1px solid #edf2f4;
    border-bottom: 0;
    white-space: nowrap;
  }

  body:not(.hardware-device-mode) .lux-main-panel,
  body:not(.hardware-device-mode) .lux-chart-card {
    border-radius: 10px;
    padding: 10px;
  }

  body:not(.hardware-device-mode) .lux-filter-row,
  body:not(.hardware-device-mode) .lux-toolbar-row,
  body:not(.hardware-device-mode) .lux-table-toolbar {
    align-items: stretch;
  }

  body:not(.hardware-device-mode) .lux-filter-row select,
  body:not(.hardware-device-mode) .lux-filter-row .lux-action-btn,
  body:not(.hardware-device-mode) .lux-filter-row .lux-green-btn,
  body:not(.hardware-device-mode) .lux-filter-row .lux-date-btn,
  body:not(.hardware-device-mode) .lux-toolbar-row input:not([type="checkbox"]),
  body:not(.hardware-device-mode) .lux-toolbar-row select,
  body:not(.hardware-device-mode) .lux-toolbar-row .lux-green-btn,
  body:not(.hardware-device-mode) .lux-toolbar-row .lux-date-btn,
  body:not(.hardware-device-mode) .lux-table-toolbar input {
    width: 100%;
    min-width: 0;
  }
}
