:root {
  color-scheme: dark;
  --bg: #020810;
  --surface-1: #06111c;
  --surface-2: #091b2a;
  --surface-hover: #0d2637;
  --border: #16384d;
  --border-bright: #245b73;
  --track: #183549;
  --text: #f4f9fc;
  --text-muted: #8ea9b8;
  --silver: #cbd8e2;
  --cyan: #21e6ee;
  --blue: #168bff;
  --cyan-soft: rgba(33, 230, 238, 0.12);
  --online: #36d399;
  --warning: #ffc857;
  --danger: #ff5d73;
  --focus: #8ffaff;
  --sidebar-width: 216px;
  --topbar-height: 76px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-width: 320px;
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(22, 56, 77, 0.13) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 56, 77, 0.13) 1px, transparent 1px);
  background-size: 40px 40px;
  font-size: 14px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

code {
  color: var(--silver);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--border-bright) transparent;
  scrollbar-width: thin;
  padding: 18px 14px;
  border-right: 1px solid var(--border);
  background: rgba(2, 8, 16, 0.97);
}

.brand {
  position: relative;
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 11px;
  padding: 3px 4px 15px;
  color: var(--text);
  text-decoration: none;
}

.brand::after {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--cyan), var(--blue), transparent);
  transform-origin: left;
  animation: trace-in 900ms ease-out both;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  background: var(--surface-1);
  box-shadow: 0 0 18px rgba(33, 230, 238, 0.16);
}

.brand-mark img {
  width: 48px;
  height: 48px;
  object-fit: cover;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.1;
}

.brand-copy strong {
  color: var(--text);
  font-size: 17px;
}

.brand-copy span {
  margin-top: 4px;
  color: var(--cyan);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.nav-list {
  display: grid;
  gap: 4px;
  margin-top: 22px;
}

.nav-item {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  background: transparent;
  text-align: left;
  transition: color 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.nav-item:hover {
  color: var(--text);
  background: var(--surface-1);
}

.nav-item.is-active {
  border-color: var(--border);
  color: var(--text);
  background: var(--cyan-soft);
  box-shadow: inset 2px 0 0 var(--cyan);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-count {
  min-width: 24px;
  margin-left: auto;
  color: var(--silver);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  text-align: right;
}

.sidebar-spacer {
  flex: 1;
}

.sidebar-status {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
}

.sidebar-status > span:last-child {
  display: grid;
  min-width: 0;
}

.sidebar-status strong,
.sidebar-status small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-status strong {
  color: var(--silver);
  font-size: 12px;
}

.sidebar-status small {
  margin-top: 2px;
  font-size: 10px;
}

.status-orbit {
  position: relative;
  width: 12px;
  height: 12px;
  flex: 0 0 12px;
  border: 1px solid var(--text-muted);
  border-radius: 50%;
}

.status-orbit::after {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  content: "";
  background: var(--text-muted);
}

.sidebar-status[data-phase="connected"] .status-orbit,
.sidebar-status[data-phase="demo"] .status-orbit {
  border-color: var(--online);
  box-shadow: 0 0 10px rgba(54, 211, 153, 0.32);
}

.sidebar-status[data-phase="connected"] .status-orbit::after,
.sidebar-status[data-phase="demo"] .status-orbit::after {
  background: var(--online);
}

.sidebar-status[data-phase="error"] .status-orbit,
.sidebar-status[data-phase="offline"] .status-orbit {
  border-color: var(--danger);
}

.sidebar-status[data-phase="error"] .status-orbit::after,
.sidebar-status[data-phase="offline"] .status-orbit::after {
  background: var(--danger);
}

.session-user {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  padding: 10px 6px 0;
  border-top: 1px solid var(--border);
}

.user-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  color: var(--cyan);
  background: var(--surface-1);
  font-size: 11px;
  font-weight: 800;
}

.session-user > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.session-user strong,
.session-user small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-user strong {
  color: var(--silver);
  font-size: 11px;
}

.session-user small {
  color: var(--text-muted);
  font-size: 9px;
}

.session-user form {
  margin: 0;
}

.session-user .icon-button {
  width: 34px;
  height: 34px;
}

.main-content {
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  padding: 0 30px 64px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(2, 8, 16, 0.94);
  backdrop-filter: blur(14px);
}

.topbar h1,
.section-heading h2,
.drawer-header h2,
.dialog-header h2 {
  margin: 0;
  color: var(--text);
  font-weight: 650;
}

.topbar h1 {
  font-size: 23px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sync-readout {
  display: grid;
  justify-items: end;
}

.sync-readout span {
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
}

.sync-readout strong {
  margin-top: 2px;
  color: var(--silver);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  font-weight: 500;
}

.connect-button,
.primary-button,
.secondary-button,
.text-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}

.connect-button,
.primary-button,
.secondary-button {
  min-height: 40px;
  gap: 8px;
  padding: 0 14px;
  font-weight: 650;
}

.connect-button,
.primary-button {
  border: 1px solid var(--cyan);
  color: #001018;
  background: var(--cyan);
  box-shadow: 0 0 18px rgba(33, 230, 238, 0.16);
}

.connect-button:hover,
.primary-button:hover {
  background: #7bf6fa;
}

.connect-button svg,
.primary-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
}

.secondary-button {
  border: 1px solid var(--border-bright);
  color: var(--silver);
  background: var(--surface-1);
}

.secondary-button:hover {
  border-color: var(--cyan);
  color: var(--text);
  background: var(--surface-hover);
}

.text-button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  color: var(--cyan);
  background: transparent;
  font-weight: 700;
}

.text-button:hover {
  color: var(--text);
}

.icon-button {
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--border);
  color: var(--silver);
  background: var(--surface-1);
}

.icon-button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
  background: var(--surface-hover);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.mobile-menu,
.mobile-nav {
  display: none;
}

.connection-banner {
  display: flex;
  min-height: 58px;
  align-items: center;
  gap: 13px;
  margin: 20px 0 0;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--warning);
  border-radius: 6px;
  background: rgba(6, 17, 28, 0.88);
}

.connection-banner > div {
  min-width: 0;
  flex: 1;
}

.connection-banner strong {
  display: block;
  color: var(--silver);
  font-size: 13px;
}

.connection-banner p {
  margin: 2px 0 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-banner[data-phase="connected"] {
  border-left-color: var(--online);
}

.connection-banner[data-phase="error"],
.connection-banner[data-phase="offline"] {
  border-left-color: var(--danger);
}

.connection-banner[data-phase="demo"] {
  border-left-color: var(--blue);
}

.connection-signal {
  position: relative;
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 50%;
  color: var(--warning);
}

.connection-signal span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.connection-banner[data-phase="connected"] .connection-signal {
  color: var(--online);
  box-shadow: 0 0 15px rgba(54, 211, 153, 0.2);
}

.connection-banner[data-phase="connected"] .connection-signal::after {
  position: absolute;
  inset: -1px;
  border: 1px solid currentColor;
  border-radius: 50%;
  content: "";
  animation: connection-pulse 2.4s ease-out infinite;
}

.connection-banner[data-phase="error"] .connection-signal,
.connection-banner[data-phase="offline"] .connection-signal {
  color: var(--danger);
}

.connection-banner[data-phase="demo"] .connection-signal {
  color: var(--blue);
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr)) minmax(220px, 1.5fr);
  margin: 26px 0 34px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.summary-stat {
  position: relative;
  display: grid;
  min-height: 110px;
  align-content: center;
  padding: 16px 18px;
  border-right: 1px solid var(--border);
}

.summary-stat:last-child {
  border-right: 0;
}

.summary-stat > span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-stat > strong {
  margin: 4px 0 2px;
  color: var(--text);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 31px;
  font-weight: 650;
  line-height: 1;
}

.summary-stat > small {
  color: var(--text-muted);
  font-size: 10px;
}

.summary-stat::before {
  position: absolute;
  top: -1px;
  left: 18px;
  width: 24px;
  height: 2px;
  content: "";
  background: var(--silver);
}

.summary-stat.is-online::before {
  background: var(--online);
}

.summary-stat.is-warning::before {
  background: var(--warning);
}

.summary-stat.is-offline::before {
  background: var(--danger);
}

.fleet-average {
  display: flex;
  min-height: 40px;
  align-items: baseline;
  gap: 5px;
}

.fleet-average strong {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 24px;
}

.fleet-average small {
  color: var(--text-muted);
  font-size: 10px;
}

.fleet-average > span {
  width: 1px;
  height: 24px;
  margin: 0 8px;
  align-self: center;
  background: var(--border);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  font-size: 19px;
}

.result-count {
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
}

.node-toolbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(240px, 1fr) auto auto;
  gap: 12px;
  margin: 16px 0 20px;
  padding: 10px 0;
  background: rgba(2, 8, 16, 0.94);
  backdrop-filter: blur(14px);
}

.search-field,
.select-field {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  background: var(--surface-1);
}

.search-field {
  max-width: 420px;
  padding: 0 12px;
}

.search-field:focus-within,
.select-field:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(33, 230, 238, 0.08);
}

.search-field svg,
.select-field svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.search-field input,
.select-field select {
  width: 100%;
  height: 38px;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search-field input::placeholder {
  color: #6f8795;
}

.select-field {
  min-width: 150px;
  padding: 0 10px;
}

.select-field select {
  appearance: none;
}

.segmented-control {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-1);
}

.segmented-control button {
  min-height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: 4px;
  color: var(--text-muted);
  background: transparent;
  font-size: 12px;
}

.segmented-control button:hover {
  color: var(--text);
}

.segmented-control button.is-selected {
  color: var(--text);
  background: var(--surface-hover);
  box-shadow: inset 0 -2px 0 var(--cyan);
}

.segmented-control.compact {
  min-height: 36px;
}

.segmented-control.compact button {
  min-height: 28px;
  padding: 0 8px;
  font-size: 10px;
}

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

.node-card {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(6, 17, 28, 0.94);
  transition: border-color 180ms ease, transform 180ms ease, background-color 180ms ease;
}

.node-card.is-entering {
  animation: card-enter 320ms ease-out both;
}

.node-card:hover {
  border-color: var(--border-bright);
  background: rgba(9, 27, 42, 0.97);
  transform: translateY(-2px);
}

.node-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 2px;
  content: "";
  background: var(--cyan);
  opacity: 0.78;
}

.node-card[data-status="stale"]::before {
  background: var(--warning);
}

.node-card[data-status="offline"]::before {
  background: var(--danger);
}

.node-card[data-status="fault"]::before {
  background: var(--danger);
}

.node-card-header {
  display: flex;
  min-height: 78px;
  align-items: flex-start;
  gap: 10px;
  padding: 18px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.node-identity {
  min-width: 0;
  flex: 1;
}

.node-title-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.node-title-row h3 {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rename-button,
.copy-button {
  display: inline-grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  color: var(--text-muted);
  background: transparent;
}

.rename-button:hover,
.copy-button:hover {
  color: var(--cyan);
  background: var(--cyan-soft);
}

.rename-button svg,
.copy-button svg {
  width: 14px;
  height: 14px;
}

.node-mac-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.node-mac {
  overflow: hidden;
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-status {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.node-status span {
  width: 7px;
  height: 7px;
  border: 1px solid currentColor;
  border-radius: 50%;
  background: currentColor;
}

.node-status[data-status="online"] {
  color: var(--online);
}

.node-status[data-status="stale"] {
  color: var(--warning);
}

.node-status[data-status="offline"] {
  color: var(--danger);
}

.node-status[data-status="fault"] {
  color: var(--danger);
}

.node-gauges {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  padding: 18px 10px 12px;
}

.gauge {
  display: grid;
  min-width: 0;
  justify-items: center;
}

.gauge-visual {
  position: relative;
  width: min(100%, 106px);
  aspect-ratio: 1 / 0.82;
}

.gauge svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.gauge circle {
  fill: none;
  stroke-width: 7;
  transform: rotate(135deg);
  transform-origin: 50px 50px;
}

.gauge .gauge-track {
  stroke: var(--track);
  stroke-dasharray: 75 25;
}

.gauge .gauge-value {
  stroke: var(--gauge-color, var(--cyan));
  stroke-linecap: round;
  stroke-dasharray: 0 100;
  transition: stroke-dasharray 420ms ease;
  filter: drop-shadow(0 0 4px rgba(33, 230, 238, 0.24));
}

.gauge[data-metric="humidity"] {
  --gauge-color: var(--blue);
}

.gauge[data-metric="water"] {
  --gauge-color: var(--silver);
}

.gauge.is-warning {
  --gauge-color: var(--warning);
}

.gauge.is-danger {
  --gauge-color: var(--danger);
}

.gauge-value-copy {
  position: absolute;
  inset: 37% 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: center;
  color: var(--text);
}

.gauge-value-copy strong {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 19px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.gauge-value-copy small {
  margin-left: 2px;
  color: var(--text-muted);
  font-size: 9px;
}

.gauge-label {
  margin-top: -9px;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
}

.gauge-unavailable {
  display: none;
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 17px;
}

.gauge.is-empty .gauge-value-copy strong,
.gauge.is-empty .gauge-value-copy small {
  display: none;
}

.gauge.is-empty .gauge-unavailable {
  display: inline;
}

.gauge.is-empty .gauge-value {
  stroke-dasharray: 0 100;
}

.node-card-footer {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  min-height: 46px;
  align-items: center;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.node-card-footer span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.node-card-footer svg {
  width: 13px;
  height: 13px;
}

.node-card[data-connection-status="online"] .node-card-footer {
  color: var(--online);
}

.details-button {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-top: 1px solid var(--border);
  color: var(--cyan);
  background: rgba(2, 8, 16, 0.24);
  font-size: 11px;
  font-weight: 700;
}

.details-button:hover {
  color: var(--text);
  background: var(--cyan-soft);
}

.alias-editor {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 5px;
}

.alias-editor input {
  min-width: 0;
  height: 30px;
  flex: 1;
  border: 1px solid var(--cyan);
  border-radius: 4px;
  outline: 0;
  color: var(--text);
  background: var(--bg);
  padding: 0 7px;
  font-weight: 650;
}

.alias-editor button {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--silver);
  background: var(--surface-2);
}

.alias-editor button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.alias-editor svg {
  width: 14px;
  height: 14px;
}

.empty-state {
  display: grid;
  min-height: 390px;
  place-items: center;
  align-content: center;
  padding: 40px 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.empty-state[hidden] {
  display: none;
}

.empty-circuit {
  position: relative;
  width: 108px;
  height: 64px;
  margin-bottom: 18px;
}

.empty-circuit::before,
.empty-circuit::after,
.empty-circuit span {
  position: absolute;
  height: 1px;
  content: "";
  background: var(--border-bright);
}

.empty-circuit::before {
  top: 15px;
  left: 5px;
  width: 78px;
}

.empty-circuit::after {
  right: 5px;
  bottom: 15px;
  width: 74px;
}

.empty-circuit span {
  width: 9px;
  height: 9px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  background: var(--bg);
  box-shadow: 0 0 12px rgba(33, 230, 238, 0.2);
}

.empty-circuit span:nth-child(1) {
  top: 11px;
  left: 0;
}

.empty-circuit span:nth-child(2) {
  top: 11px;
  right: 14px;
}

.empty-circuit span:nth-child(3) {
  right: 0;
  bottom: 11px;
}

.empty-state h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
}

.empty-state p {
  max-width: 580px;
  margin: 9px 0 0;
  color: var(--text-muted);
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  visibility: hidden;
  background: rgba(0, 5, 10, 0.72);
  opacity: 0;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.scrim.is-visible {
  visibility: visible;
  opacity: 1;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 80;
  width: min(480px, 100vw);
  overflow-y: auto;
  border-left: 1px solid var(--border-bright);
  background: #04101a;
  box-shadow: -18px 0 48px rgba(0, 0, 0, 0.42);
  transform: translateX(101%);
  transition: transform 240ms ease;
}

.detail-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  min-height: 98px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(4, 16, 26, 0.96);
  backdrop-filter: blur(14px);
}

.drawer-header h2 {
  font-size: 20px;
}

.drawer-header code {
  display: block;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.drawer-body {
  padding: 18px 22px 34px;
}

.drawer-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--text-muted);
  font-size: 11px;
}

.drawer-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 20px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.drawer-metric {
  min-width: 0;
  padding: 16px 10px;
  border-right: 1px solid var(--border);
}

.drawer-metric:last-child {
  border-right: 0;
}

.drawer-metric span {
  display: block;
  color: var(--text-muted);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.drawer-metric strong {
  display: inline-block;
  margin-top: 4px;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 20px;
}

.drawer-metric small {
  margin-left: 2px;
  color: var(--text-muted);
  font-size: 9px;
}

.trend-section,
.metadata-section {
  margin-top: 28px;
}

.trend-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.trend-header h3 {
  margin: 0;
  font-size: 15px;
}

.chart-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 2.33 / 1;
  margin-top: 14px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.chart-frame svg {
  display: block;
  width: 100%;
  height: 100%;
}

.chart-grid {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--cyan);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.5;
  filter: drop-shadow(0 0 5px rgba(33, 230, 238, 0.22));
}

.chart-point {
  fill: var(--bg);
  stroke: var(--cyan);
  stroke-width: 2;
}

.chart-empty {
  position: absolute;
  inset: 50% 0 auto;
  margin: 0;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  transform: translateY(-50%);
}

.trend-summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.trend-summary strong {
  margin-left: 3px;
  color: var(--silver);
  font-weight: 600;
}

.metadata-section dl {
  margin: 10px 0 0;
  border-top: 1px solid var(--border);
}

.metadata-section dl > div {
  display: grid;
  grid-template-columns: 125px 1fr;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.metadata-section dt {
  color: var(--text-muted);
  font-size: 11px;
}

.metadata-section dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--silver);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
  text-align: right;
}

[hidden] {
  display: none !important;
}

body[data-user-role="viewer"] [data-admin-only] {
  display: none !important;
}

.provision-section {
  padding: 28px 0 48px;
  animation: settings-enter 240ms ease-out both;
}

.provision-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.provision-heading h2 {
  margin-top: 5px;
  font-size: 24px;
}

.provision-heading > div:first-child p:last-child {
  max-width: 690px;
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.serial-state {
  display: flex;
  min-width: 210px;
  align-items: center;
  gap: 9px;
  justify-content: flex-end;
  color: var(--text-muted);
  font-size: 11px;
}

.serial-state > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #516473;
  box-shadow: 0 0 0 5px rgba(81, 100, 115, 0.08);
}

.serial-state[data-state="connecting"] > span {
  background: var(--warning);
  box-shadow: 0 0 10px rgba(255, 200, 87, 0.5);
  animation: serial-blink 1s ease-in-out infinite;
}

.serial-state[data-state="connected"] {
  color: var(--online);
}

.serial-state[data-state="connected"] > span {
  background: var(--online);
  box-shadow: 0 0 10px rgba(54, 211, 153, 0.6);
}

.serial-state[data-state="error"] {
  color: var(--danger);
}

.serial-state[data-state="error"] > span {
  background: var(--danger);
  box-shadow: 0 0 10px rgba(255, 93, 115, 0.55);
}

.provision-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: rgba(4, 16, 26, 0.72);
}

.provision-steps {
  padding: 24px 18px;
  border-right: 1px solid var(--border);
  background: rgba(2, 10, 17, 0.72);
}

.provision-step {
  position: relative;
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  min-height: 72px;
  color: #587082;
}

.provision-step:not(:last-child)::after {
  position: absolute;
  top: 30px;
  bottom: 0;
  left: 15px;
  width: 1px;
  content: "";
  background: var(--border);
}

.provision-step > span {
  display: grid;
  width: 31px;
  height: 31px;
  z-index: 1;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.provision-step div {
  display: grid;
  align-content: start;
  gap: 3px;
  padding-top: 3px;
}

.provision-step strong {
  color: inherit;
  font-size: 11px;
}

.provision-step small {
  font-size: 9px;
}

.provision-step.is-active {
  color: var(--cyan);
}

.provision-step.is-active > span {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(33, 230, 238, 0.16);
}

.provision-step.is-complete {
  color: var(--online);
}

.provision-step.is-complete > span {
  border-color: var(--online);
}

.provision-console {
  min-width: 0;
}

.serial-connect-panel {
  display: grid;
  min-height: 470px;
  place-items: center;
  align-content: center;
  padding: 40px;
  text-align: center;
}

.port-symbol {
  display: grid;
  width: 64px;
  height: 64px;
  margin-bottom: 24px;
  place-items: center;
  border: 1px solid rgba(33, 230, 238, 0.38);
  border-radius: 8px;
  color: var(--cyan);
  background: rgba(33, 230, 238, 0.06);
  box-shadow: 0 0 28px rgba(33, 230, 238, 0.08);
}

.port-symbol svg {
  width: 28px;
  height: 28px;
}

.serial-connect-panel h3 {
  margin-top: 7px;
  color: var(--silver);
  font-size: 20px;
}

.serial-connect-panel > p:not(.eyebrow) {
  max-width: 510px;
  margin: 10px 0 22px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.6;
}

.serial-connect-panel .serial-support {
  margin: 14px 0 0;
  color: #607889;
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.connected-device > section {
  padding: 24px 28px;
  border-bottom: 1px solid var(--border);
}

.connected-device > section:last-child {
  border-bottom: 0;
}

.direct-telegram-provisioning .inline-action {
  margin-top: 0;
}

.device-identity header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.device-identity h3,
.provision-section-title h3 {
  margin-top: 5px;
  color: var(--silver);
  font-size: 17px;
}

.identity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px 0 0;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.identity-grid > div {
  min-width: 0;
  padding: 13px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.identity-grid dt {
  color: var(--text-muted);
  font-size: 9px;
  text-transform: uppercase;
}

.identity-grid dd {
  margin: 5px 0 0;
  overflow: hidden;
  color: var(--silver);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provision-section-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.provision-section-title > svg {
  width: 20px;
  height: 20px;
  color: var(--cyan);
}

.inline-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.inline-action > span {
  color: var(--text-muted);
  font-size: 10px;
}

.registered-section {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.registered-list {
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.registered-list > p {
  margin: 0;
  padding: 26px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.registered-node {
  display: grid;
  grid-template-columns: 1.25fr 1fr 0.8fr 0.65fr 38px;
  gap: 18px;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid var(--border);
}

.registered-node > div {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.registered-node span {
  color: var(--text-muted);
  font-size: 9px;
  text-transform: uppercase;
}

.registered-node strong,
.registered-node code {
  overflow: hidden;
  color: var(--silver);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.registered-node .registered-actions {
  display: flex;
  justify-content: flex-end;
}

.registered-delete-button {
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  place-items: center;
  border: 1px solid rgba(255, 91, 115, 0.28);
  border-radius: 6px;
  color: var(--danger);
  background: rgba(255, 91, 115, 0.05);
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.registered-delete-button:hover {
  border-color: rgba(255, 91, 115, 0.7);
  background: rgba(255, 91, 115, 0.12);
  transform: translateY(-1px);
}

.registered-delete-button svg {
  width: 15px;
  height: 15px;
}

.confirm-node-dialog {
  width: min(470px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text);
  background: #04101a;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.72);
}

.confirm-node-dialog::backdrop {
  background: rgba(0, 5, 10, 0.8);
  backdrop-filter: blur(4px);
}

.confirm-node-content {
  padding: 28px;
}

.confirm-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  place-items: center;
  border: 1px solid rgba(54, 211, 153, 0.4);
  border-radius: 50%;
  color: var(--online);
  background: rgba(54, 211, 153, 0.06);
}

.confirm-icon.is-danger {
  border-color: rgba(255, 91, 115, 0.4);
  color: var(--danger);
  background: rgba(255, 91, 115, 0.07);
}

.confirm-node-content h2 {
  margin-top: 6px;
  font-size: 21px;
}

.confirm-node-content > p:not(.eyebrow) {
  margin: 9px 0 20px;
  color: var(--text-muted);
  font-size: 12px;
}

.confirm-node-content dl {
  margin: 0;
  border-top: 1px solid var(--border);
}

.confirm-node-content dl div {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.confirm-node-content dt {
  color: var(--text-muted);
  font-size: 10px;
}

.confirm-node-content dd {
  margin: 0;
  color: var(--silver);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
  text-align: right;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

.confirm-node-error {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  display: grid;
  width: min(920px, 100%);
  grid-template-columns: 1.1fr 0.9fr;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: rgba(3, 13, 22, 0.93);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.auth-brand {
  min-height: 560px;
  padding: 54px;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(145deg, rgba(33, 230, 238, 0.07), transparent 55%),
    rgba(2, 9, 16, 0.82);
}

.auth-brand img {
  width: 110px;
  height: 110px;
  margin-bottom: 56px;
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(33, 230, 238, 0.18);
}

.auth-brand h1 {
  margin-top: 7px;
  font-size: 36px;
}

.auth-brand > p:last-child {
  max-width: 360px;
  margin-top: 14px;
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.7;
}

.auth-panel {
  display: grid;
  align-content: center;
  padding: 48px;
}

.auth-back-link {
  width: max-content;
  margin-bottom: 28px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-decoration: none;
  text-transform: uppercase;
  transition: color 160ms ease;
}

.auth-back-link:hover {
  color: var(--accent);
}

.auth-back-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.auth-panel h2 {
  margin-top: 7px;
  font-size: 23px;
}

.auth-panel > p:not(.eyebrow) {
  margin: 8px 0 24px;
  color: var(--text-muted);
  font-size: 12px;
}

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

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-error {
  margin: 0;
  color: var(--danger);
  font-size: 11px;
}

.auth-local-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  color: #627989;
  font-size: 9px;
  text-transform: uppercase;
}

.auth-local-note span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 8px rgba(54, 211, 153, 0.7);
}

.settings-section {
  padding: 28px 0 48px;
  animation: settings-enter 240ms ease-out both;
}

.users-section {
  padding: 28px 0 48px;
  animation: settings-enter 240ms ease-out both;
}

.telegram-section {
  padding: 28px 0 48px;
  animation: settings-enter 240ms ease-out both;
}

.telegram-state {
  display: flex;
  min-width: 235px;
  align-items: center;
  gap: 11px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 22, 35, 0.62);
}

.telegram-state > span {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  border-radius: 50%;
  background: #596c79;
}

.telegram-state > div {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.telegram-state strong {
  color: var(--silver);
  font-size: 11px;
}

.telegram-state small {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-state[data-connected="true"] {
  border-color: rgba(54, 211, 153, 0.36);
}

.telegram-state[data-connected="true"] > span {
  background: var(--online);
  box-shadow: 0 0 10px rgba(54, 211, 153, 0.68);
}

.telegram-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.8fr) minmax(470px, 1.2fr);
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: rgba(4, 16, 26, 0.72);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.22);
}

.telegram-controls {
  border-right: 1px solid var(--border);
  background: rgba(3, 12, 20, 0.75);
}

.telegram-bot-panel,
.telegram-enrollment,
.telegram-qr-panel {
  padding: 26px;
  border-bottom: 1px solid var(--border);
}

.telegram-qr-panel {
  border-bottom: 0;
}

.telegram-bot-panel h3,
.telegram-enrollment h3,
.telegram-qr-panel h3,
.telegram-directory h3 {
  margin: 5px 0 0;
  color: var(--silver);
  font-size: 17px;
}

.telegram-bot-panel > p:not(.eyebrow, .form-error),
.telegram-enrollment > p {
  margin: 9px 0 18px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.65;
}

.telegram-relay-state {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(2, 10, 17, 0.62);
}

.telegram-relay-state > span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 10px color-mix(in srgb, var(--danger) 65%, transparent);
}

.telegram-relay-state[data-running="true"] {
  border-color: rgba(67, 226, 161, 0.32);
}

.telegram-relay-state[data-running="true"] > span {
  background: var(--online);
  box-shadow: 0 0 10px color-mix(in srgb, var(--online) 70%, transparent);
  animation: serial-blink 1.8s ease-in-out infinite;
}

.telegram-relay-state strong,
.telegram-relay-state small {
  display: block;
}

.telegram-relay-state strong {
  color: var(--silver);
  font-size: 11px;
}

.telegram-relay-state small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 8px;
  line-height: 1.45;
}

.telegram-bot-actions,
.telegram-link-row {
  display: flex;
  gap: 9px;
}

.telegram-bot-actions {
  justify-content: flex-end;
  margin-top: 3px;
}

.telegram-bot-actions .danger-action {
  margin-right: auto;
}

.telegram-link-row input {
  min-width: 0;
  min-height: 40px;
  flex: 1;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--silver);
  background: var(--bg);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.telegram-enrollment > .secondary-button {
  width: 100%;
  margin-top: 10px;
}

.telegram-qr-content {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
  margin-top: 18px;
}

.telegram-qr-code {
  width: 168px;
  height: 168px;
  overflow: hidden;
  border: 8px solid #fff;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(43, 220, 239, 0.32), 0 14px 34px rgba(0, 0, 0, 0.32);
}

.telegram-qr-code canvas,
.telegram-qr-code img {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.telegram-qr-code.is-empty {
  display: grid;
  place-items: center;
  border-color: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  background: rgba(3, 17, 29, 0.72);
  box-shadow: inset 0 0 0 1px var(--border);
}

.telegram-qr-code.is-empty svg {
  width: 48px;
  height: 48px;
  stroke-width: 1.2;
}

.telegram-qr-copy {
  min-width: 0;
}

.telegram-qr-kicker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--teal);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 8px;
  font-weight: 800;
}

.telegram-qr-kicker svg {
  width: 13px;
  height: 13px;
}

.telegram-qr-copy strong {
  display: block;
  overflow: hidden;
  margin-top: 8px;
  color: var(--silver);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-qr-copy p {
  margin: 7px 0 14px;
  color: var(--text-muted);
  font-size: 10px;
  line-height: 1.55;
}

.telegram-open-bot {
  width: 100%;
  text-decoration: none;
}

.telegram-directory {
  min-width: 0;
  padding: 28px;
}

.telegram-list > p {
  margin: 0;
  padding: 30px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.telegram-recipient {
  padding: 17px 0;
  border-bottom: 1px solid var(--border);
}

.telegram-recipient > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.telegram-recipient-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.telegram-recipient-identity > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.telegram-recipient-identity strong,
.telegram-recipient-identity small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.telegram-recipient-identity strong {
  color: var(--silver);
  font-size: 12px;
}

.telegram-recipient-identity small {
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
}

.telegram-recipient-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.telegram-recipient-actions .icon-button,
.telegram-recipient-actions .registered-delete-button {
  width: 34px;
  height: 34px;
}

.telegram-preferences {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 13px;
}

.telegram-preferences label {
  position: relative;
}

.telegram-preferences input {
  position: absolute;
  opacity: 0;
}

.telegram-preferences span {
  display: inline-flex;
  min-height: 29px;
  align-items: center;
  gap: 5px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--text-muted);
  background: rgba(2, 8, 16, 0.42);
  cursor: pointer;
  font-size: 9px;
}

.telegram-preferences svg {
  width: 13px;
  height: 13px;
}

.telegram-preferences input:checked + span {
  border-color: rgba(33, 230, 238, 0.38);
  color: var(--cyan);
  background: rgba(33, 230, 238, 0.07);
}

.telegram-preferences input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.user-management {
  display: grid;
  grid-template-columns: minmax(300px, 0.75fr) minmax(440px, 1.25fr);
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: rgba(4, 16, 26, 0.72);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.22);
}

.user-create-panel {
  padding: 30px;
  border-right: 1px solid var(--border);
  background: rgba(3, 12, 20, 0.75);
}

.user-create-panel h3,
.user-directory h3 {
  margin: 6px 0 0;
  color: var(--silver);
  font-size: 18px;
}

.user-create-panel > p:not(.eyebrow, .form-error) {
  margin: 10px 0 22px;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.user-form-fields {
  display: grid;
  gap: 13px;
}

.user-create-panel > .primary-button {
  width: 100%;
  margin-top: 4px;
}

.user-directory {
  min-width: 0;
  padding: 30px;
}

.user-directory-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.user-directory-heading > span {
  color: var(--text-muted);
  font-size: 9px;
  text-transform: uppercase;
}

.user-list > p {
  margin: 0;
  padding: 28px 0;
  color: var(--text-muted);
  font-size: 12px;
}

.user-row {
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
}

.user-account {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 11px;
}

.user-account > span:last-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.user-account strong {
  overflow: hidden;
  color: var(--silver);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-account small {
  color: var(--text-muted);
  font-size: 9px;
}

.user-row-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-role-select {
  min-height: 34px;
  padding: 0 30px 0 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--silver);
  background: var(--bg);
  font-size: 10px;
}

.current-user-badge {
  padding: 4px 7px;
  border: 1px solid rgba(33, 230, 238, 0.28);
  border-radius: 4px;
  color: var(--cyan);
  background: rgba(33, 230, 238, 0.06);
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

.settings-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.settings-heading h2 {
  margin-top: 5px;
  font-size: 24px;
}

.settings-heading > div:first-child > p:last-child {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.settings-state {
  display: flex;
  min-width: 285px;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(7, 22, 35, 0.62);
}

.settings-state > span:last-child {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.settings-state strong {
  color: var(--silver);
  font-size: 12px;
}

.settings-state small {
  overflow: hidden;
  color: var(--text-muted);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-state[data-phase="connected"] {
  border-color: rgba(54, 211, 153, 0.35);
}

.settings-state[data-phase="connected"] .connection-signal {
  border-color: rgba(54, 211, 153, 0.7);
  box-shadow: 0 0 16px rgba(54, 211, 153, 0.13);
}

.settings-state[data-phase="connected"] .connection-signal span {
  background: var(--online);
  box-shadow: 0 0 8px rgba(54, 211, 153, 0.8);
}

.settings-form {
  display: grid;
  grid-template-columns: minmax(230px, 0.7fr) minmax(420px, 1.3fr);
  margin-top: 24px;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  background: rgba(4, 16, 26, 0.72);
  box-shadow: 0 18px 54px rgba(0, 0, 0, 0.22);
}

.settings-intro {
  padding: 30px;
  border-right: 1px solid var(--border);
  background:
    linear-gradient(145deg, rgba(33, 230, 238, 0.055), transparent 55%),
    rgba(3, 12, 20, 0.75);
}

.settings-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 28px;
  place-items: center;
  border: 1px solid rgba(33, 230, 238, 0.38);
  border-radius: 6px;
  color: var(--cyan);
  background: rgba(33, 230, 238, 0.06);
  box-shadow: inset 0 0 18px rgba(33, 230, 238, 0.04);
}

.settings-icon svg {
  width: 22px;
  height: 22px;
}

.settings-intro h3 {
  margin-top: 7px;
  color: var(--silver);
  font-size: 18px;
}

.settings-intro > p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.settings-intro .security-note {
  margin-top: 28px;
}

.settings-fields {
  padding: 30px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.settings-actions .danger-action {
  margin-right: auto;
}

.form-field > span:first-child small {
  margin-left: 6px;
  color: #617383;
  font-size: 9px;
  font-weight: 500;
}

.broker-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text);
  background: #04101a;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.68), 0 0 28px rgba(33, 230, 238, 0.1);
}

.broker-dialog::backdrop {
  background: rgba(0, 5, 10, 0.76);
  backdrop-filter: blur(4px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-bottom: 1px solid var(--border);
}

.dialog-header h2 {
  font-size: 20px;
}

.dialog-header p:not(.eyebrow) {
  max-width: 470px;
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.dialog-body {
  padding: 20px 22px;
}

.protocol-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.protocol-control > span {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field > span:first-child {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 650;
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 5px;
  outline: 0;
  color: var(--text);
  background: var(--bg);
}

.form-field input:focus,
.form-field select:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(33, 230, 238, 0.08);
}

.field-wide {
  grid-column: 1 / -1;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 48px;
}

.password-field .icon-button {
  position: absolute;
  top: 2px;
  right: 2px;
  border: 0;
  background: transparent;
}

.security-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 16px;
  padding: 11px 12px;
  border-left: 2px solid var(--online);
  color: var(--text-muted);
  background: rgba(54, 211, 153, 0.06);
  font-size: 11px;
}

.security-note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--online);
}

.form-error {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--danger);
  font-size: 11px;
}

.dialog-footer {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 10px;
  padding: 15px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-1);
}

.danger-action {
  color: var(--danger);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 120;
  display: grid;
  width: min(360px, calc(100vw - 40px));
  gap: 8px;
}

.toast {
  display: flex;
  min-height: 46px;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--cyan);
  border-radius: 6px;
  color: var(--silver);
  background: #06111c;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42);
  animation: toast-in 180ms ease-out both;
}

.toast.is-error {
  border-left-color: var(--danger);
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  color: var(--cyan);
}

.toast.is-error svg {
  color: var(--danger);
}

.portal-section {
  padding: 28px 0 48px;
  animation: settings-enter 240ms ease-out both;
}

.portal-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  min-height: clamp(560px, 66vh, 700px);
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--border-bright);
  border-radius: 10px;
  background: #03101d;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(143, 250, 255, 0.03);
}

.portal-hero::before,
.portal-hero::after {
  position: absolute;
  z-index: 3;
  content: "";
  pointer-events: none;
}

.portal-hero::before {
  inset: 16px;
  border: 1px solid rgba(143, 250, 255, 0.08);
  border-radius: 6px;
}

.portal-hero::after {
  right: 34px;
  bottom: 34px;
  width: 82px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan));
  box-shadow: 0 0 12px rgba(33, 230, 238, 0.55);
}

.portal-hero-image,
.portal-hero-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.portal-hero-image {
  z-index: -2;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.94) contrast(1.04);
}

.portal-hero-scrim {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(2, 8, 16, 0.98) 0%, rgba(2, 8, 16, 0.9) 32%, rgba(2, 8, 16, 0.58) 54%, rgba(2, 8, 16, 0.12) 84%),
    linear-gradient(0deg, rgba(2, 8, 16, 0.52), transparent 48%);
}

.portal-hero-content {
  z-index: 2;
  width: min(650px, 61%);
  padding: clamp(44px, 6vw, 84px);
}

.portal-live-chip {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  gap: 8px;
  margin-bottom: 26px;
  padding: 0 11px;
  border: 1px solid rgba(54, 211, 153, 0.34);
  border-radius: 999px;
  color: #adf6d7;
  background: rgba(4, 30, 32, 0.76);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portal-live-chip > span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--online);
  box-shadow: 0 0 10px rgba(54, 211, 153, 0.8);
}

.portal-hero-content > .eyebrow {
  margin-bottom: 12px;
}

.portal-hero h2 {
  max-width: 660px;
  margin: 0;
  color: var(--text);
  font-size: clamp(44px, 4.7vw, 68px);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 0.98;
  text-wrap: balance;
}

.portal-hero-copy {
  max-width: 560px;
  margin: 24px 0 0;
  color: #a9c0ce;
  font-size: 15px;
  line-height: 1.75;
}

.portal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.portal-actions .primary-button,
.portal-actions .secondary-button {
  min-height: 46px;
  padding-inline: 17px;
}

.portal-signal-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 42px;
  padding-top: 18px;
  border-top: 1px solid rgba(142, 169, 184, 0.22);
}

.portal-signal-list > span {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  column-gap: 8px;
  min-width: 0;
}

.portal-signal-list svg {
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  color: var(--cyan);
}

.portal-signal-list strong,
.portal-signal-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-signal-list strong {
  color: var(--silver);
  font-size: 11px;
}

.portal-signal-list small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 9px;
}

.portal-hero-readout {
  position: absolute;
  right: 36px;
  bottom: 49px;
  z-index: 4;
  display: grid;
  justify-items: end;
  color: rgba(203, 216, 226, 0.72);
  font-family: "Cascadia Code", Consolas, monospace;
  line-height: 1;
}

.portal-hero-readout span {
  font-size: 8px;
  letter-spacing: 0.12em;
}

.portal-hero-readout strong {
  margin-top: 5px;
  color: var(--text);
  font-size: 20px;
  font-weight: 500;
}

.portal-capabilities {
  padding: 56px 0 0;
}

.portal-section-heading,
.portal-panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.portal-section-heading {
  padding-bottom: 22px;
}

.portal-section-heading h2,
.portal-panel-heading h2 {
  margin: 0;
  color: var(--text);
  font-weight: 650;
}

.portal-section-heading h2 {
  font-size: clamp(24px, 2.6vw, 34px);
  letter-spacing: -0.025em;
}

.portal-section-heading > p {
  max-width: 420px;
  margin: 0 0 2px;
  color: var(--text-muted);
  text-align: right;
}

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

.portal-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(145deg, rgba(9, 27, 42, 0.9), rgba(4, 15, 25, 0.98));
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.portal-card:hover {
  border-color: var(--border-bright);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  transform: translateY(-3px);
}

.portal-card-media,
.portal-alert-visual {
  position: relative;
  height: 238px;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.portal-card-media::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(180deg, transparent 48%, rgba(2, 8, 16, 0.82));
  pointer-events: none;
}

.portal-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 500ms ease;
}

.portal-card:hover .portal-card-media img {
  transform: scale(1.025);
}

.portal-card-tag {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid rgba(143, 250, 255, 0.25);
  border-radius: 999px;
  color: #d8fafd;
  background: rgba(2, 8, 16, 0.74);
  backdrop-filter: blur(8px);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.portal-card-tag svg {
  width: 12px;
  height: 12px;
  color: var(--cyan);
}

.portal-card-body {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  min-height: 154px;
  padding: 22px;
}

.portal-card-number {
  padding-top: 3px;
  color: var(--cyan);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 10px;
}

.portal-card-body h3 {
  margin: 0;
  color: var(--text);
  font-size: 18px;
  font-weight: 650;
}

.portal-card-body p {
  margin: 9px 0 0;
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.65;
}

.portal-alert-visual {
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 48%, rgba(33, 230, 238, 0.16), transparent 28%),
    linear-gradient(rgba(22, 56, 77, 0.2) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 56, 77, 0.2) 1px, transparent 1px),
    #04101a;
  background-size: auto, 28px 28px, 28px 28px, auto;
}

.portal-alert-ring,
.portal-alert-core,
.portal-alert-node {
  position: absolute;
  border-radius: 50%;
}

.portal-alert-ring {
  border: 1px solid rgba(33, 230, 238, 0.32);
  animation: portal-ping 3.2s ease-out infinite;
}

.portal-alert-ring-one {
  width: 108px;
  height: 108px;
}

.portal-alert-ring-two {
  width: 178px;
  height: 178px;
  animation-delay: 1.1s;
}

.portal-alert-core {
  z-index: 2;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 1px solid rgba(143, 250, 255, 0.42);
  background: linear-gradient(145deg, rgba(33, 230, 238, 0.2), rgba(22, 139, 255, 0.2));
  box-shadow: 0 0 34px rgba(33, 230, 238, 0.18);
}

.portal-alert-core svg {
  width: 25px;
  height: 25px;
  color: var(--cyan);
}

.portal-alert-node {
  width: 8px;
  height: 8px;
  border: 2px solid #06111c;
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(33, 230, 238, 0.9);
}

.portal-alert-node.node-one { margin: -118px 0 0 150px; }
.portal-alert-node.node-two { margin: 96px 0 0 174px; }
.portal-alert-node.node-three { margin: 58px 0 0 -168px; }

.portal-operations {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.8fr);
  gap: 14px;
  margin-top: 14px;
}

.portal-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(6, 17, 28, 0.86);
}

.portal-panel-heading {
  min-height: 88px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--border);
}

.portal-panel-heading h2 {
  font-size: 18px;
}

.portal-panel-heading > span {
  color: var(--online);
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.portal-panel-heading > span::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px rgba(54, 211, 153, 0.7);
  content: "";
}

.portal-flow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: 34px 24px 38px;
  list-style: none;
}

.portal-flow li {
  position: relative;
  display: grid;
  justify-items: center;
  min-width: 0;
  text-align: center;
}

.portal-flow li:not(:last-child)::after {
  position: absolute;
  top: 22px;
  left: calc(50% + 30px);
  width: calc(100% - 60px);
  height: 1px;
  content: "";
  background: linear-gradient(90deg, var(--border-bright), var(--cyan), var(--border-bright));
  opacity: 0.72;
}

.portal-flow li > span {
  position: relative;
  z-index: 2;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid var(--border-bright);
  border-radius: 50%;
  color: var(--cyan);
  background: #061522;
  box-shadow: 0 0 22px rgba(33, 230, 238, 0.08);
}

.portal-flow svg {
  width: 19px;
  height: 19px;
}

.portal-flow strong {
  margin-top: 13px;
  color: var(--silver);
  font-size: 11px;
}

.portal-flow small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 9px;
}

.portal-launch-list {
  display: grid;
  gap: 1px;
  background: var(--border);
}

.portal-launch-list button {
  display: grid;
  min-height: 67px;
  grid-template-columns: 36px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 11px;
  padding: 11px 16px;
  border: 0;
  color: var(--text-muted);
  background: #06111c;
  text-align: left;
  transition: color 160ms ease, background-color 160ms ease;
}

.portal-launch-list button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.portal-launch-list button > span:first-child {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--cyan);
  background: rgba(33, 230, 238, 0.06);
}

.portal-launch-list button > span:nth-child(2) {
  display: grid;
  min-width: 0;
}

.portal-launch-list button strong,
.portal-launch-list button small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-launch-list button strong {
  color: var(--silver);
  font-size: 11px;
}

.portal-launch-list button small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 9px;
}

.portal-launch-list button svg {
  width: 16px;
  height: 16px;
}

.portal-launch-list button > svg:last-child {
  transition: color 160ms ease, transform 160ms ease;
}

.portal-launch-list button:hover > svg:last-child {
  color: var(--cyan);
  transform: translate(2px, -2px);
}

@keyframes portal-ping {
  0% { opacity: 0.16; transform: scale(0.72); }
  42% { opacity: 0.65; }
  100% { opacity: 0; transform: scale(1.16); }
}

@keyframes trace-in {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

@keyframes connection-pulse {
  0% { opacity: 0.62; transform: scale(0.72); }
  80%, 100% { opacity: 0; transform: scale(1.65); }
}

@keyframes settings-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes serial-blink {
  50% { opacity: 0.42; }
}

@keyframes card-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 1240px) {
  .node-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-band {
    grid-template-columns: repeat(4, 1fr);
  }

  .wide-stat {
    grid-column: 1 / -1;
    border-top: 1px solid var(--border);
  }

  .portal-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-card-alerts {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  }

  .portal-card-alerts .portal-alert-visual {
    height: auto;
    min-height: 240px;
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }

  .portal-card-alerts .portal-card-body {
    align-content: center;
  }

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

@media (max-width: 1040px) {
  :root {
    --sidebar-width: 76px;
  }

  .sidebar {
    align-items: center;
    padding-inline: 10px;
  }

  .brand {
    width: 100%;
    justify-content: center;
  }

  .brand-copy,
  .nav-item > span:not(.nav-count),
  .sidebar-status > span:last-child,
  .session-user > span:nth-child(2) {
    display: none;
  }

  .nav-list,
  .nav-item {
    width: 100%;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .nav-count {
    position: absolute;
    margin: 0 0 24px 27px;
    min-width: 16px;
    padding: 1px 3px;
    border-radius: 4px;
    color: var(--bg);
    background: var(--cyan);
    font-size: 8px;
    text-align: center;
  }

  .sidebar-status {
    justify-content: center;
  }

  .session-user {
    grid-template-columns: 34px;
    justify-content: center;
  }

  .session-user form {
    display: none;
  }
}

@media (max-width: 820px) {
  body {
    padding-bottom: 68px;
  }

  .sidebar {
    visibility: hidden;
    width: 230px;
    transform: translateX(-101%);
    transition: transform 200ms ease, visibility 200ms ease;
  }

  .sidebar.is-open {
    visibility: visible;
    align-items: stretch;
    transform: translateX(0);
  }

  .sidebar.is-open .brand-copy,
  .sidebar.is-open .nav-item > span:not(.nav-count),
  .sidebar.is-open .sidebar-status > span:last-child,
  .sidebar.is-open .session-user > span:nth-child(2) {
    display: grid;
  }

  .sidebar.is-open .nav-item {
    justify-content: flex-start;
    padding: 0 11px;
  }

  .sidebar.is-open .nav-count {
    position: static;
    min-width: 24px;
    margin: 0 0 0 auto;
    color: var(--silver);
    background: transparent;
    font-size: 12px;
  }

  .sidebar.is-open .session-user {
    grid-template-columns: 32px minmax(0, 1fr) 34px;
    justify-content: stretch;
  }

  .sidebar.is-open .session-user form {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: 0 18px 36px;
  }

  .mobile-menu {
    display: inline-flex;
    flex: 0 0 38px;
  }

  .topbar {
    gap: 12px;
  }

  .portal-hero {
    min-height: 650px;
    align-items: flex-end;
  }

  .portal-hero-image {
    object-position: 67% center;
  }

  .portal-hero-scrim {
    background:
      linear-gradient(0deg, rgba(2, 8, 16, 0.98) 0%, rgba(2, 8, 16, 0.86) 46%, rgba(2, 8, 16, 0.18) 100%),
      linear-gradient(90deg, rgba(2, 8, 16, 0.74), transparent 72%);
  }

  .portal-hero-content {
    width: 100%;
    padding: 42px;
  }

  .portal-hero h2 {
    max-width: 590px;
  }

  .portal-hero-copy {
    max-width: 600px;
  }

  .portal-hero-readout {
    top: 34px;
    right: 34px;
    bottom: auto;
  }

  .topbar > div:nth-child(2) {
    min-width: 0;
    flex: 1;
  }

  .topbar h1 {
    font-size: 19px;
  }

  .sync-readout {
    display: none;
  }

  .connect-button span {
    display: none;
  }

  .connect-button {
    width: 40px;
    padding: 0;
  }

  .mobile-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
    min-height: 62px;
    padding-bottom: env(safe-area-inset-bottom);
    border-top: 1px solid var(--border);
    background: rgba(2, 8, 16, 0.97);
  }

  .mobile-nav button {
    display: grid;
    min-height: 58px;
    place-items: center;
    align-content: center;
    gap: 3px;
    border: 0;
    color: var(--text-muted);
    background: transparent;
    font-size: 9px;
  }

  .mobile-nav button.is-active {
    color: var(--cyan);
    box-shadow: inset 0 2px 0 var(--cyan);
  }

  .mobile-nav svg {
    width: 18px;
    height: 18px;
  }

  .settings-form {
    grid-template-columns: 1fr;
  }

  .user-management {
    grid-template-columns: 1fr;
  }

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

  .telegram-controls {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .user-create-panel {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

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

  .provision-steps {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    padding: 16px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .provision-step {
    grid-template-columns: 1fr;
    min-height: 52px;
    place-items: center;
    text-align: center;
  }

  .provision-step:not(:last-child)::after {
    top: 15px;
    right: 0;
    bottom: auto;
    left: 50%;
    width: 100%;
    height: 1px;
  }

  .provision-step div {
    padding-top: 0;
  }

  .provision-step small {
    display: none;
  }

  .registered-node {
    grid-template-columns: 1fr 1fr;
  }

  .settings-intro {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .node-toolbar {
    grid-template-columns: 1fr auto;
  }

  .node-toolbar .search-field {
    max-width: none;
  }

  .node-toolbar .segmented-control {
    grid-column: 1 / -1;
    grid-row: 2;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

  .node-toolbar .select-field {
    min-width: 138px;
  }
}

@media (max-width: 680px) {
  .main-content {
    padding-inline: 14px;
  }

  .portal-section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .portal-section-heading > p {
    max-width: 560px;
    text-align: left;
  }

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

  .portal-card-alerts {
    display: block;
    grid-column: auto;
  }

  .portal-card-alerts .portal-alert-visual {
    height: 238px;
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .portal-flow {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    row-gap: 30px;
  }

  .portal-flow li:nth-child(2)::after {
    display: none;
  }

  .connection-banner p {
    white-space: normal;
  }

  .settings-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .user-directory-heading,
  .user-row,
  .telegram-recipient > header {
    align-items: stretch;
    flex-direction: column;
  }

  .user-row-controls {
    justify-content: space-between;
  }

  .user-role-select {
    flex: 1;
  }

  .telegram-recipient-actions {
    justify-content: space-between;
  }

  .provision-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .serial-state {
    min-width: 0;
    justify-content: flex-start;
  }

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

  .connected-device > section {
    padding: 22px;
  }

  .inline-action {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-action button {
    width: 100%;
  }

  .auth-page {
    padding: 14px;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    min-height: 0;
    padding: 30px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .auth-brand img {
    width: 64px;
    height: 64px;
    margin-bottom: 24px;
  }

  .auth-brand h1 {
    font-size: 27px;
  }

  .auth-brand > p:last-child {
    display: none;
  }

  .auth-panel {
    padding: 30px;
  }

  .settings-state {
    min-width: 0;
  }

  .settings-intro,
  .settings-fields {
    padding: 22px;
  }

  .summary-band {
    grid-template-columns: 1fr 1fr;
  }

  .summary-stat,
  .summary-stat:nth-child(2n) {
    min-height: 96px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
  }

  .summary-stat:nth-child(2n) {
    border-right: 0;
  }

  .wide-stat {
    grid-column: 1 / -1;
    border-bottom: 0;
  }

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

  .node-toolbar {
    top: var(--topbar-height);
  }

  .node-toolbar .select-field {
    width: 44px;
    min-width: 44px;
    padding: 0 12px;
    overflow: hidden;
  }

  .node-toolbar .select-field select {
    position: absolute;
    width: 1px;
    opacity: 0;
  }

  .detail-drawer {
    width: 100vw;
    border-left: 0;
  }

  .dialog-footer {
    grid-template-columns: 1fr 1fr;
  }

  .dialog-footer > span {
    display: none;
  }

  .dialog-footer .danger-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .portal-hero {
    min-height: 720px;
  }

  .portal-hero::before {
    inset: 10px;
  }

  .portal-hero-content {
    padding: 30px 24px;
  }

  .portal-live-chip {
    margin-bottom: 20px;
  }

  .portal-hero h2 {
    font-size: 38px;
  }

  .portal-hero-copy {
    margin-top: 19px;
    font-size: 13px;
  }

  .portal-actions {
    display: grid;
    grid-template-columns: 1fr;
    margin-top: 24px;
  }

  .portal-actions .primary-button,
  .portal-actions .secondary-button {
    width: 100%;
  }

  .portal-signal-list {
    gap: 6px;
    margin-top: 30px;
  }

  .portal-signal-list > span {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

  .portal-signal-list svg {
    grid-row: auto;
    margin-bottom: 6px;
  }

  .portal-signal-list small {
    display: none;
  }

  .portal-hero-readout {
    display: none;
  }

  .portal-capabilities {
    padding-top: 42px;
  }

  .portal-card-media,
  .portal-alert-visual,
  .portal-card-alerts .portal-alert-visual {
    height: 210px;
  }

  .portal-panel-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

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

  .portal-flow li:not(:last-child)::after,
  .portal-flow li:nth-child(2)::after {
    top: 54px;
    left: 50%;
    display: block;
    width: 1px;
    height: 22px;
  }

  .telegram-qr-content {
    grid-template-columns: 1fr;
  }

  .telegram-qr-code {
    justify-self: center;
  }

  .telegram-qr-copy {
    text-align: center;
  }

  .telegram-qr-kicker {
    justify-content: center;
  }

  .topbar .eyebrow {
    display: none;
  }

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

  .settings-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .settings-actions button {
    width: 100%;
  }

  .identity-grid,
  .registered-node {
    grid-template-columns: 1fr;
  }

  .device-identity header {
    align-items: stretch;
    flex-direction: column;
  }

  .serial-connect-panel {
    min-height: 420px;
    padding: 28px 20px;
  }

  .confirm-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .broker-dialog {
    width: calc(100vw - 18px);
    max-height: calc(100vh - 18px);
  }

  .dialog-header,
  .dialog-body,
  .dialog-footer {
    padding-inline: 16px;
  }

  .drawer-body,
  .drawer-header {
    padding-inline: 16px;
  }

  .trend-header {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
