/* ================================================================
   Cockpit Control — Design System v3
   Terracotta / sand palette · Inter + JetBrains Mono
   ================================================================ */

:root {
  /* === NEUTRALS ============================================== */
  --ink-1:        #1a1813;
  --ink-2:        #2e2a22;
  --ink-3:        #58534a;
  --ink-4:        #8a8478;
  --ink-5:        #b8b3a4;

  --bg-app:       #f6f4ef;
  --bg-surface:   #fbfaf6;
  --bg-sunk:      #efece4;
  --bg-hover:     #f0ede4;
  --bg-mono:      #16140f;
  --bg-mono-2:    #1f1c15;

  --line:         #e2ddd0;
  --line-strong:  #d2ccba;
  --line-mono:    #2a2620;

  /* === ACCENT (terracotta) ==================================== */
  --accent:       #c46a47;
  --accent-ink:   #16140f;
  --accent-soft:  #f4ddd0;

  /* === STATUS ================================================= */
  --ok:           #2f7a4d;
  --ok-soft:      #e3efe5;
  --ok-ink:       #164227;

  --warn:         #a86a14;
  --warn-soft:    #f6e9c8;
  --warn-ink:     #5a3508;

  --err:          #b73c2c;
  --err-soft:     #f6dcd5;
  --err-ink:      #5a1612;

  --info:         #2c5db8;
  --info-soft:    #dde6f5;
  --info-ink:     #122252;

  --muted:        #8a8478;
  --muted-soft:   #ece8dd;

  /* Pin/function category colors */
  --cat-digital:  #2c5db8;
  --cat-pwm:      #8E4FD4;
  --cat-analog:   #2f7a4d;
  --cat-led:      #a86a14;
  --cat-i2c:      #00857C;

  /* === TYPE =================================================== */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --t-body:    14px;
  --t-small:   13px;
  --t-micro:   11px;
  --t-mono:    13px;
  --t-mono-sm: 12px;

  --lh-normal: 1.5;
  --lh-snug:   1.3;

  /* === SPACING ================================================ */
  --s-1:  4px;  --s-2:  8px;  --s-3:  12px;
  --s-4:  16px; --s-5:  20px; --s-6:  24px;

  /* === RADII ================================================== */
  --r-cell:  2px;
  --r-badge: 4px;
  --r-card:  6px;
  --r-input: 6px;
  --r-pill:  999px;

  /* === ELEVATION ============================================== */
  --elev-1: 0 1px 2px rgba(26,24,19,0.06);
  --elev-2: 0 4px 12px rgba(26,24,19,0.08), 0 1px 2px rgba(26,24,19,0.06);
  --elev-3: 0 12px 32px rgba(26,24,19,0.16), 0 2px 6px rgba(26,24,19,0.08);

  /* === MOTION ================================================= */
  --ease:     cubic-bezier(0.2, 0.0, 0.0, 1.0);
  --dur-fast: 120ms;
  --dur-base: 200ms;

  /* === HEIGHTS ================================================ */
  --ctrl-h:    32px;
  --ctrl-h-sm: 26px;

  /* === LEGACY COMPAT (mapped to new tokens) ================== */
  --page-bg:         var(--bg-app);
  --panel-bg:        var(--bg-surface);
  --panel-bg-strong: var(--bg-sunk);
  --border:          var(--line-strong);
  --text-main:       var(--ink-1);
  --text-muted:      var(--ink-3);
  --selected-row:    var(--accent-soft);
  --update-flash:    var(--warn-soft);
  --line-soft:       var(--line);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  color: var(--ink-1);
  background: var(--bg-app);
  font-family: var(--font-mono);
  font-size: var(--t-small);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, h4 { margin: 0; }
p { margin: 0; }

.mono-tag, code {
  font-family: var(--font-mono);
  font-size: var(--t-mono-sm);
  color: var(--ink-2);
}

.mono { font-family: var(--font-mono); }

.is-hidden { display: none !important; }

/* ============================================================
   APP SHELL
   ============================================================ */

.app-shell {
  display: flex;
  height: 100%;
  overflow: hidden;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */

.sidebar {
  width: 220px;
  background: var(--bg-mono);
  color: var(--ink-5);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line-mono);
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 17px 16px 15px;
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #2a2620;
}

.sidebar-brand-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  filter: drop-shadow(0 7px 16px rgba(0, 0, 0, 0.28));
}

.sidebar-brand-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.sidebar-brand-name {
  display: grid;
  gap: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  color: #f6f4ef;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.sidebar-brand-name span:last-child {
  color: #d9d3c3;
  font-weight: 650;
  letter-spacing: 0.075em;
}

.sidebar-brand-version {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  line-height: 1.1;
}

.sidebar-section {
  padding: 14px 14px 6px;
  border-bottom: 1px solid #2a2620;
}

.sidebar-section-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  padding: 0 2px 6px;
  display: block;
}

.sidebar-broker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 3px;
  background: var(--bg-mono-2);
  border: 1px solid #2c2820;
  color: #f6f4ef;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
}

.sidebar-broker-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
  background: var(--ink-4);
}

.sidebar-broker-dot.is-online {
  background: var(--ok);
  box-shadow: 0 0 4px rgba(47,122,77,0.7);
}

.sidebar-broker-select {
  background: transparent;
  border: none;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex: 1;
  min-width: 0;
  outline: none;
  padding: 0;
}

.sidebar-broker-select option {
  background: var(--bg-mono-2);
  color: #fff;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: var(--r-badge);
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  color: var(--ink-5);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.sidebar-nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #f6f4ef;
}

.sidebar-nav-item.is-active {
  background: #2a2519;
  border-left-color: var(--accent);
  color: #f6f4ef;
  font-weight: 600;
}

.sidebar-nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav-item.is-active svg { opacity: 1; }

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid #2a2620;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-avatar {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--accent);
  color: #16140f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-email {
  font-size: 11px;
  color: #f6f4ef;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.sidebar-user-role {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-4);
  display: block;
}

.sidebar-sign-out {
  background: transparent;
  border: 0;
  color: var(--ink-5);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  text-decoration: none;
  line-height: 1;
  transition: color var(--dur-fast);
}

.sidebar-sign-out:hover { color: var(--err); }

/* ============================================================
   TOP BAR → dark annunciator strip
   ============================================================ */

.top-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--line);
  padding: 0;
  margin-bottom: 0;
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 44px;
}

.app-header-block { display: none; }
.top-bar-title, .top-bar-subtitle { display: none; }

.top-bar-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  align-items: stretch;
  flex: 1;
  overflow: visible;
}

.top-bar-summary > span {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 6px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-width: 0;
  flex: 1 1 116px;
}

.top-bar-summary strong {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 600;
  display: block;
  white-space: nowrap;
}

.top-bar-summary > span > span,
.top-bar-summary > span > .pill,
.top-bar-summary > span > .compact-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-1);
  white-space: nowrap;
}

.top-bar-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-surface);
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.top-bar-actions .broker-switcher { display: none; }

/* ============================================================
   PILLS
   ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--r-pill);
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border: 1px solid transparent;
}

.pill::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: currentColor;
  flex-shrink: 0;
}

.compact-pill { padding: 2px 7px; }

.pill-ok  { background: var(--ok-soft);   color: var(--ok-ink);   border-color: rgba(31,138,76,0.25); }
.pill-warn{ background: var(--warn-soft); color: var(--warn-ink); border-color: rgba(217,139,20,0.25); }
.pill-bad { background: var(--err-soft);  color: var(--err-ink);  border-color: rgba(196,51,43,0.25); }
.pill-idle{ background: var(--muted-soft);color: var(--ink-3);    border-color: var(--line); }

/* Top-bar pills use standard light-surface pill styling (no overrides needed) */

/* ============================================================
   FLASH MESSAGES
   ============================================================ */

.notice, .alert { padding: 9px 16px; font-size: var(--t-small); margin: 0; }
.notice { background: var(--info-soft); color: var(--info-ink); border-bottom: 1px solid rgba(47,111,224,0.2); }
.alert  { background: var(--err-soft);  color: var(--err-ink);  border-bottom: 1px solid rgba(196,51,43,0.2); }

/* ============================================================
   DASHBOARD PAGE LAYOUT
   ============================================================ */

.dashboard-page {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(320px, var(--dashboard-top-height, 46vh)) 8px minmax(0, 1fr);
  gap: 0;
  overflow: hidden;
  background: var(--bg-app);
}

.dashboard-overview {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(600px, 0.95fr) minmax(760px, 1.35fr);
  gap: 0;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
}

.dashboard-overview > * { min-width: 0; }

.dashboard-section {
  background: var(--bg-surface);
  border: none;
  border-right: 1px solid var(--line);
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.dashboard-section:last-child { border-right: none; }

.dashboard-status-stack {
  background: transparent;
  border-right: 1px solid var(--line);
  padding: 0;
}

.dashboard-workbench {
  background: var(--bg-sunk);
  border-right: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.dashboard-splitter {
  position: relative;
  min-height: 8px;
  background: var(--bg-sunk);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  cursor: row-resize;
  z-index: 2;
}

.dashboard-splitter::before {
  content: "";
  position: absolute;
  inset: 3px 48%;
  border-top: 1px solid var(--ink-4);
  border-bottom: 1px solid var(--ink-4);
  opacity: 0.55;
}

.dashboard-splitter:hover,
.dashboard-splitter:focus-visible {
  background: var(--accent-soft);
  outline: none;
}

body.is-resizing-dashboard {
  cursor: row-resize;
  user-select: none;
}

.dashboard-nodes {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.dashboard-nodes > turbo-frame {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.dashboard-status-stack > turbo-frame {
  min-height: 0;
  display: block;
  height: 100%;
  overflow: hidden;
}

.dashboard-tab-panel > turbo-frame {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.dashboard-tab-radio { position: absolute; opacity: 0; pointer-events: none; }

.dashboard-tab-bar {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(340px, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.dashboard-tab {
  min-width: 0;
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 9px 14px;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  color: var(--ink-3);
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}

.dashboard-tab:hover { background: var(--bg-hover); color: var(--ink-1); }

.dashboard-tab-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: currentColor;
}

.dashboard-tab-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

.dashboard-tab-meta strong { color: var(--ink-1); }
.dashboard-log-tab-meta span { white-space: nowrap; }

#dashboard-tab-signals:checked ~ .dashboard-tab-bar .dashboard-tab-signals,
#dashboard-tab-logs:checked ~ .dashboard-tab-bar .dashboard-tab-logs {
  background: var(--bg-app);
  border-bottom-color: var(--accent);
  color: var(--ink-1);
}

.dashboard-tab-panel {
  min-height: 0;
  display: none;
  overflow: hidden;
}

#dashboard-tab-signals:checked ~ .dashboard-tab-panel-signals,
#dashboard-tab-logs:checked ~ .dashboard-tab-panel-logs {
  display: grid;
}

.section-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ============================================================
   PANEL HEADERS
   ============================================================ */

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.panel-tools { display: flex; gap: 6px; align-items: center; }

.panel-tools input[type="search"] {
  height: var(--ctrl-h-sm);
  min-width: 220px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  padding: 0 10px;
  font-size: var(--t-mono-sm);
  font-family: var(--font-mono);
  background: var(--bg-surface);
  color: var(--ink-1);
  outline: none;
  transition: border-color var(--dur-fast);
}

.panel-tools input[type="search"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
}

/* ============================================================
   STATUS CARDS
   ============================================================ */

.status-grid { display: grid; gap: 0; padding: 10px 14px; background: var(--bg-app); border-bottom: 1px solid var(--line); }
.compact-grid { grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.dashboard-status-stack .status-grid {
  height: 100%;
  overflow: auto;
  border-bottom: none;
  padding: 10px;
}
.dashboard-status-stack .compact-grid { grid-template-columns: 1fr; gap: 8px; }
.dashboard-status-stack .status-card h2 { padding: 6px 10px 5px; }
.dashboard-status-stack .kv-list { padding: 3px 10px 6px; }
.dashboard-status-stack .compact-kv { grid-template-columns: 76px minmax(0, 1fr); }
.dashboard-status-stack .kv-list dt,
.dashboard-status-stack .kv-list dd { padding-top: 3px; padding-bottom: 3px; }

.status-loading-banner {
  grid-column: 1 / -1; padding: 7px 10px;
  border: 1px dashed var(--line); border-radius: var(--r-card);
  background: var(--bg-surface); color: var(--ink-3); font-size: var(--t-small);
}
.status-loading-banner.is-hidden { display: none; }

.status-card { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); overflow: hidden; box-shadow: var(--elev-1); }

.status-card h2 {
  margin: 0; font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
  padding: 7px 12px 6px; border-bottom: 1px solid var(--line); background: var(--bg-sunk);
}

.kv-list { margin: 0; display: grid; padding: 4px 12px 8px; }

.compact-kv { grid-template-columns: 80px minmax(0, 1fr); }

.kv-list dt {
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 600;
  padding: 4px 0; border-bottom: 1px dashed var(--line); display: flex; align-items: center;
}
.kv-list dd {
  margin: 0; font-family: var(--font-mono); font-size: var(--t-mono-sm); color: var(--ink-1);
  padding: 4px 0 4px 10px; border-bottom: 1px dashed var(--line); display: flex; align-items: center; min-width: 0;
}
.kv-list dt:last-of-type, .kv-list dd:last-child { border-bottom: none; }

/* ============================================================
   SYSTEM OVERVIEW
   ============================================================ */

.system-overview-card {
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--bg-surface);
}

.system-overview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 45px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.system-overview-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.system-overview-title strong {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-1);
  white-space: nowrap;
}

.system-status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunk);
}

.system-status-tile {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 4px;
  min-height: 54px;
  padding: 8px 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.system-status-tile:nth-child(3n) { border-right: none; }

.system-status-tile > span {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-4);
  font-weight: 600;
}

.system-status-tile > strong {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.system-detail-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  overflow: auto;
  padding: 10px;
  background: var(--bg-app);
}

.system-detail-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--bg-surface);
  overflow: hidden;
  box-shadow: var(--elev-1);
}

.system-detail-card h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 7px 10px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunk);
}

.system-detail-card .kv-list {
  padding: 4px 10px 7px;
}

.system-detail-card .compact-kv {
  grid-template-columns: 70px minmax(0, 1fr);
}

.system-detail-card .kv-list dd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ============================================================
   BUTTONS & CHIPS
   ============================================================ */

.tool-chip,
.node-modal-actions button,
.hover-close {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: var(--ctrl-h-sm);
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  background: var(--bg-surface);
  color: var(--ink-2);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  white-space: nowrap;
}

.tool-chip:hover { background: var(--bg-hover); }

.top-bar-actions .tool-chip,
.top-bar-actions a.tool-chip {
  background: var(--bg-surface);
  border-color: var(--line-strong);
  color: var(--ink-2);
}
.top-bar-actions .tool-chip:hover,
.top-bar-actions a.tool-chip:hover { background: var(--bg-hover); color: var(--ink-1); }

.tool-chip-danger { background: var(--err-soft); color: var(--err-ink); border-color: rgba(196,51,43,0.3); }
.tool-chip-danger:hover { background: color-mix(in srgb, var(--err) 12%, white); }
.tool-chip.is-disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

.user-chip {
  display: inline-flex; align-items: center; height: var(--ctrl-h-sm); padding: 0 10px;
  border: 1px solid var(--line-mono); border-radius: var(--r-input);
  background: var(--bg-mono-2); color: var(--ink-5);
  font-family: var(--font-mono); font-size: 11px; white-space: nowrap;
}

.broker-select {
  border: 1px solid var(--line-strong); border-radius: var(--r-input);
  height: var(--ctrl-h-sm); min-width: 150px; background: var(--bg-surface);
  color: var(--ink-1); font-family: var(--font-mono); font-size: 12px; padding: 0 8px; outline: none;
}

.tool-select {
  height: var(--ctrl-h-sm); border: 1px solid var(--line-strong); border-radius: var(--r-input);
  background: var(--bg-surface); color: var(--ink-1);
  font-family: var(--font-mono); font-size: 12px; padding: 0 8px; outline: none;
}

.tool-toggle { display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; cursor: pointer; }
.tool-toggle input[type="checkbox"] { margin: 0; accent-color: var(--accent); }

/* ============================================================
   TABLES
   ============================================================ */

.data-table { width: 100%; border-collapse: collapse; font-size: var(--t-small); }

.data-table th, .data-table td {
  border-bottom: 1px solid var(--line); padding: 6px 10px;
  white-space: nowrap; text-align: left; vertical-align: middle;
}

.data-table thead th {
  position: sticky; top: 0; z-index: 1;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3);
  background: var(--bg-sunk); border-bottom: 1px solid var(--line);
}

.dense-table tbody tr:hover { background: var(--bg-hover); }
.interactive-row { cursor: pointer; }
.interactive-row:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.interactive-row.is-selected td { background: var(--accent-soft); }
.table-wrap { min-height: 0; overflow: auto; }
.dense-wrap, .log-wrap { min-height: 0; }
.dashboard-signals .dense-wrap { overflow: auto; }
.dashboard-nodes .dense-wrap { overflow-y: auto; overflow-x: hidden; }
.log-wrap { overflow: auto; }

/* ============================================================
   LOG PANEL
   ============================================================ */

.log-summary-row {
  display: flex; flex-wrap: wrap; gap: 16px; padding: 7px 14px;
  border-bottom: 1px solid var(--line); background: var(--bg-sunk);
  font-family: var(--font-mono); font-size: 11px; color: var(--ink-3);
}
.log-summary-row strong { color: var(--ink-1); font-weight: 600; }

.log-panel-status {
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunk);
}

.logs-header-row {
  padding: 9px 14px; background: var(--bg-sunk);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.logs-header-row .section-title { color: var(--ink-2); }
.log-awaiting-status { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }

/* ============================================================
   SIGNALS TABLE
   ============================================================ */

.dashboard-signals .signals-table { width: 100%; min-width: 0; table-layout: fixed; }
.dashboard-signals .signals-table th:nth-child(1), .dashboard-signals .signals-table td:nth-child(1) { width: 16%; }
.dashboard-signals .signals-table th:nth-child(2), .dashboard-signals .signals-table td:nth-child(2) { width: 23%; }
.dashboard-signals .signals-table th:nth-child(3), .dashboard-signals .signals-table td:nth-child(3) { width: 18%; }
.dashboard-signals .signals-table th:nth-child(4), .dashboard-signals .signals-table td:nth-child(4) { width: 7%; }
.dashboard-signals .signals-table th:nth-child(5), .dashboard-signals .signals-table td:nth-child(5) { width: 11%; }
.dashboard-signals .signals-table th:nth-child(6), .dashboard-signals .signals-table td:nth-child(6) { width: 13%; }
.dashboard-signals .signals-table th:nth-child(7), .dashboard-signals .signals-table td:nth-child(7) { width: 5%; }
.dashboard-signals .signals-table th:nth-child(8), .dashboard-signals .signals-table td:nth-child(8) { width: 7%; }
.dashboard-signals .signals-table td { max-width: 0; overflow: hidden; text-overflow: ellipsis; }

.signal-value-cell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(64px, 86px); align-items: center; gap: 8px; min-width: 0; }
.signal-value-cell [data-cell="signal-current-value"] { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.inline-signal-command-form { margin: 0; min-width: 0; display: inline-grid; grid-template-columns: minmax(0, 1fr) 9px; align-items: center; gap: 4px; }
.inline-signal-command-input { width: 100%; min-width: 0; height: 22px; border: 1px solid var(--line-strong); border-radius: var(--r-cell); padding: 0 6px; font-family: var(--font-mono); font-size: 11px; background: var(--bg-surface); color: var(--ink-1); }
.inline-command-status { width: 9px; height: 9px; border-radius: 999px; background: transparent; flex: 0 0 auto; display: inline-block; }
.inline-command-status.is-ok    { background: var(--ok); }
.inline-command-status.is-error { background: var(--err); }
.inline-command-status.is-sending { background: var(--warn); animation: inline-status-pulse 0.8s ease-in-out infinite; }

@keyframes inline-status-pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.signals-header-meta { display: grid; gap: 2px; min-width: 0; }
.signals-counts { display: flex; flex-wrap: wrap; gap: 8px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.signals-counts strong { color: var(--ink-1); }
.dashboard-signals .panel-header-row { flex-wrap: wrap; align-items: flex-start; }
.dashboard-signals .panel-tools { margin-left: auto; flex: 1 1 360px; min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
.dashboard-signals .panel-tools input[type="search"] { flex: 1 1 260px; min-width: 180px; max-width: 420px; }
.signal-filter-form { row-gap: 4px; }
.signals-pagination { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 5px 14px; border-top: 1px solid var(--line); }
.pagination-status { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }

/* ============================================================
   NODES TABLE
   ============================================================ */

.dashboard-nodes .nodes-table { table-layout: fixed; min-width: 0; }
.dashboard-nodes .nodes-table th:nth-child(1), .dashboard-nodes .nodes-table td:nth-child(1) { width: 23%; }
.dashboard-nodes .nodes-table th:nth-child(2), .dashboard-nodes .nodes-table td:nth-child(2) { width: 16%; }
.dashboard-nodes .nodes-table th:nth-child(3), .dashboard-nodes .nodes-table td:nth-child(3) { width: 13%; }
.dashboard-nodes .nodes-table th:nth-child(4), .dashboard-nodes .nodes-table td:nth-child(4) { width: 8%; }
.dashboard-nodes .nodes-table th:nth-child(5), .dashboard-nodes .nodes-table td:nth-child(5) { width: 14%; }
.dashboard-nodes .nodes-table th:nth-child(6), .dashboard-nodes .nodes-table td:nth-child(6) { width: 26%; }
.dashboard-nodes .known-nodes-table { table-layout: fixed; min-width: 0; }
.dashboard-nodes .known-nodes-table th:nth-child(1), .dashboard-nodes .known-nodes-table td:nth-child(1) { width: 25%; }
.dashboard-nodes .known-nodes-table th:nth-child(2), .dashboard-nodes .known-nodes-table td:nth-child(2) { width: 19%; }
.dashboard-nodes .known-nodes-table th:nth-child(3), .dashboard-nodes .known-nodes-table td:nth-child(3) { width: 18%; }
.dashboard-nodes .known-nodes-table th:nth-child(4), .dashboard-nodes .known-nodes-table td:nth-child(4) { width: 22%; }
.dashboard-nodes .known-nodes-table th:nth-child(5), .dashboard-nodes .known-nodes-table td:nth-child(5) { width: 16%; }
.dashboard-nodes td[data-cell="node-endpoint"], .dashboard-nodes td[data-cell="node-name"], .dashboard-nodes td[data-cell="node-version"] { max-width: 0; overflow: hidden; text-overflow: ellipsis; }
.dashboard-nodes td[data-cell^="known-node-"] { max-width: 0; vertical-align: top; }
.dashboard-nodes td[data-cell="known-node-id"] code { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.known-node-primary, .known-node-secondary, .known-node-detail { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.known-node-secondary { margin-top: 2px; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.known-node-detail + .known-node-detail { margin-top: 3px; }
.known-node-detail strong { color: var(--ink-1); font-weight: 600; margin-right: 4px; }
.known-node-actions,
.node-action-group { display: flex; flex-wrap: nowrap; gap: 4px; align-items: center; white-space: nowrap; }
.inline-tool-form { display: inline-block; margin: 0; }

.nodes-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.nodes-tab-radio {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nodes-tab-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunk);
}

.nodes-tab {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 36px;
  padding: 7px 12px;
  border-right: 1px solid var(--line);
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nodes-tab:last-child { border-right: none; }
.nodes-tab:hover { background: var(--bg-hover); color: var(--ink-1); }
.nodes-tab strong { color: var(--ink-1); font-size: 11px; }

#nodes-tab-connected:checked ~ .nodes-tab-bar .nodes-tab-connected,
#nodes-tab-known:checked ~ .nodes-tab-bar .nodes-tab-known {
  background: var(--bg-surface);
  border-bottom-color: var(--accent);
  color: var(--ink-1);
}

.nodes-tab-panel {
  min-height: 0;
  display: none;
  overflow: hidden;
}

#nodes-tab-connected:checked ~ .nodes-tab-panel-connected,
#nodes-tab-known:checked ~ .nodes-tab-panel-known {
  display: grid;
}

.nodes-tab-panel-connected {
  grid-template-rows: minmax(0, 1fr);
}

.nodes-tab-panel-known {
  grid-template-rows: auto minmax(0, 1fr);
}

.nodes-tab-panel-known .node-config-subtitle {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.dashboard-nodes .data-table th,
.dashboard-nodes .data-table td {
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.25;
}

.dashboard-nodes .tool-chip {
  height: 22px;
  padding: 0 8px;
  font-size: 11px;
}

/* ============================================================
   ADMIN LIST PAGES
   ============================================================ */

.admin-list-page {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.admin-list-section {
  border-right: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.admin-list-section > .panel-header-row {
  flex: 0 0 auto;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.admin-list-section > .table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.admin-add-toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.admin-add-button {
  cursor: pointer;
}

.admin-add-panel {
  display: none;
  border-bottom: 1px solid var(--line);
  background: var(--bg-app);
}

.admin-add-toggle:checked ~ .admin-add-panel {
  display: block;
}

.brokers-page .data-table,
.firmware-page .data-table {
  table-layout: fixed;
}

.brokers-page .data-table td,
.firmware-page .data-table td {
  overflow: hidden;
  text-overflow: ellipsis;
}

.brokers-page .data-table td:last-child,
.firmware-page .data-table td:last-child {
  overflow: visible;
}

.brokers-page .tool-chip,
.firmware-page .tool-chip {
  height: 24px;
  padding: 0 9px;
  font-size: 11px;
}

.brokers-page .inline-tool-form,
.firmware-page .inline-tool-form {
  display: inline-block;
  margin: 0;
}

/* ============================================================
   BROKER FORM PAGE
   ============================================================ */

.broker-form-page {
  height: 100%;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
}

.broker-form-shell {
  border-right: none;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.broker-form-shell > .panel-header-row {
  flex: 0 0 auto;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.broker-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}

.broker-form-grid {
  display: grid;
  grid-template-columns: minmax(420px, 680px) minmax(300px, 420px);
  gap: 14px;
  align-items: start;
  max-width: 1120px;
}

.broker-form-card {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--bg-surface);
  box-shadow: var(--elev-1);
  overflow: hidden;
}

.broker-form-card h2 {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-sunk);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.broker-field-grid {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 10px 14px;
  align-items: start;
  padding: 12px;
}

.broker-field-grid label,
.broker-field-label {
  padding-top: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.broker-field-grid input[type="text"],
.broker-field-grid input[type="number"],
.broker-field-grid select,
.broker-field-grid textarea {
  width: 100%;
  min-height: var(--ctrl-h-sm);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  background: var(--bg-surface);
  color: var(--ink-1);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 4px 8px;
}

.broker-field-grid input:focus,
.broker-field-grid select:focus,
.broker-field-grid textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
  outline: none;
}

.broker-json-field {
  min-height: 190px;
  resize: vertical;
}

.broker-checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--ctrl-h-sm);
  color: var(--ink-3);
  font-size: 12px;
}

.broker-checkbox-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--accent);
}

.broker-field-hint {
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 11px;
}

.broker-readonly-value {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctrl-h-sm);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
}

.broker-token-card {
  max-width: 420px;
}

.broker-token-notice,
.broker-form-alert {
  max-width: 1120px;
  margin-bottom: 12px;
}

.broker-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1120px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.broker-form-actions .tool-chip {
  height: 28px;
}

/* ============================================================
   FIRMWARE BUILDS PAGE
   ============================================================ */

.firmware-page {
  grid-template-rows: minmax(0, 1fr);
}

.firmware-hero-section {
  border-right: none;
  border-bottom: 1px solid var(--line);
  background: var(--bg-surface);
}

.firmware-page-header {
  align-items: flex-start;
}

.firmware-title-group {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.firmware-upload-form {
  padding: 14px;
}

.firmware-upload-grid {
  display: grid;
  grid-template-columns: minmax(150px, 0.8fr) minmax(160px, 0.9fr) minmax(130px, 0.65fr) minmax(220px, 1.1fr) minmax(260px, 1.2fr) auto;
  gap: 10px;
  align-items: end;
}

.firmware-upload-grid label {
  min-width: 0;
  display: grid;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.firmware-upload-grid input[type="text"],
.firmware-upload-grid input[type="number"],
.firmware-upload-grid input[type="file"],
.firmware-upload-grid textarea {
  width: 100%;
  min-width: 0;
  min-height: var(--ctrl-h-sm);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-input);
  padding: 4px 8px;
  background: var(--bg-surface);
  color: var(--ink-1);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.firmware-upload-grid textarea {
  min-height: 42px;
  resize: vertical;
}

.firmware-upload-grid input:focus,
.firmware-upload-grid textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent);
  outline: none;
}

.firmware-notes-field {
  min-width: 220px;
}

.checkbox-label {
  display: flex !important;
  grid-auto-flow: unset;
  grid-template-columns: none;
  align-items: center;
  gap: 8px !important;
  white-space: nowrap;
}

.checkbox-label input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}

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

.firmware-list-section {
  display: flex;
  flex-direction: column;
}

.firmware-list-section .data-table th:nth-child(1),
.firmware-list-section .data-table td:nth-child(1) { width: 13%; }
.firmware-list-section .data-table th:nth-child(2),
.firmware-list-section .data-table td:nth-child(2) { width: 12%; }
.firmware-list-section .data-table th:nth-child(3),
.firmware-list-section .data-table td:nth-child(3) { width: 7%; }
.firmware-list-section .data-table th:nth-child(4),
.firmware-list-section .data-table td:nth-child(4) { width: 9%; }
.firmware-list-section .data-table th:nth-child(5),
.firmware-list-section .data-table td:nth-child(5) { width: 20%; }
.firmware-list-section .data-table th:nth-child(6),
.firmware-list-section .data-table td:nth-child(6) { width: 10%; }
.firmware-list-section .data-table th:nth-child(7),
.firmware-list-section .data-table td:nth-child(7) { width: 15%; }
.firmware-list-section .data-table th:nth-child(8),
.firmware-list-section .data-table td:nth-child(8) { width: 14%; }

.brokers-page .data-table th:nth-child(1),
.brokers-page .data-table td:nth-child(1) { width: 14%; }
.brokers-page .data-table th:nth-child(2),
.brokers-page .data-table td:nth-child(2) { width: 18%; }
.brokers-page .data-table th:nth-child(3),
.brokers-page .data-table td:nth-child(3) { width: 14%; }
.brokers-page .data-table th:nth-child(4),
.brokers-page .data-table td:nth-child(4) { width: 11%; }
.brokers-page .data-table th:nth-child(5),
.brokers-page .data-table td:nth-child(5) { width: 9%; }
.brokers-page .data-table th:nth-child(6),
.brokers-page .data-table td:nth-child(6) { width: 14%; }
.brokers-page .data-table th:nth-child(7),
.brokers-page .data-table td:nth-child(7) { width: 20%; }

/* ============================================================
   HOVER CARD & MODAL
   ============================================================ */

.signal-hover-card { position: fixed; z-index: 40; width: 340px; max-width: calc(100vw - 16px); border: 1px solid var(--line-strong); border-radius: var(--r-card); background: var(--bg-surface); box-shadow: var(--elev-3); padding: 12px; }
.signal-hover-card.is-hidden, .node-modal.is-hidden { display: none; }
.hover-card-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; }
.hover-card-actions { display: flex; align-items: center; gap: 5px; }
.hover-pin-state { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.hover-close { padding: 0 8px; height: var(--ctrl-h-sm); }
.hover-grid, .node-modal-grid { margin: 0; display: grid; grid-template-columns: 95px minmax(0, 1fr); gap: 2px 8px; font-size: var(--t-small); }
.hover-grid dt, .node-modal-grid dt { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.hover-grid dd, .node-modal-grid dd { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-family: var(--font-mono); font-size: var(--t-mono-sm); }
.signal-command-form { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); display: grid; gap: 6px; }
.signal-command-label { font-family: var(--font-mono); font-size: 9px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.signal-command-row { display: flex; gap: 6px; align-items: center; }
.signal-command-input { flex: 1 1 auto; min-width: 0; height: var(--ctrl-h-sm); border: 1px solid var(--line-strong); border-radius: var(--r-input); padding: 0 8px; font-family: var(--font-mono); font-size: 12px; background: var(--bg-surface); color: var(--ink-1); outline: none; }
.signal-command-input:focus { border-color: var(--accent); }
.node-modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(11,14,19,0.5); padding: 12px; }
.node-modal-card { width: min(860px, 96vw); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); padding: 16px; box-shadow: var(--elev-3); }
.node-modal-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.node-modal-header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.node-modal-actions { margin-top: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.node-diagnostics-panel { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.node-diagnostics-empty { grid-column: 1 / -1; padding: 10px; border: 1px dashed var(--line); border-radius: var(--r-card); color: var(--ink-3); font-family: var(--font-mono); font-size: var(--t-mono-sm); }
.diagnostic-card { border: 1px solid var(--line); border-radius: var(--r-card); background: color-mix(in srgb, var(--bg-surface) 92%, var(--bg-hover)); padding: 10px; min-width: 0; }
.diagnostic-card header { display: flex; align-items: center; gap: 7px; margin-bottom: 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.diagnostic-card header strong { font-weight: 700; }
.diagnostic-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 16%, transparent); flex: 0 0 auto; }
.diagnostic-card-warn .diagnostic-dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 18%, transparent); }
.diagnostic-card-bad .diagnostic-dot { background: var(--err); box-shadow: 0 0 0 3px color-mix(in srgb, var(--err) 16%, transparent); }
.diagnostic-card-body { display: grid; gap: 7px; }
.diagnostic-line { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; min-width: 0; font-family: var(--font-mono); font-size: var(--t-mono-sm); }
.diagnostic-line span { color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diagnostic-line strong { color: var(--ink-1); font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.diagnostic-stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
.diagnostic-stat { display: grid; gap: 2px; padding: 6px 7px; border: 1px solid var(--line); border-radius: var(--r-input); background: var(--bg-surface); min-width: 0; }
.diagnostic-stat span { font-family: var(--font-mono); font-size: 9px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.04em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diagnostic-stat strong { font-family: var(--font-mono); font-size: 12px; color: var(--ink-1); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diagnostic-bar-row { display: grid; gap: 4px; }
.diagnostic-bar { height: 7px; border-radius: 999px; background: var(--bg-hover); overflow: hidden; border: 1px solid var(--line); }
.diagnostic-bar span { display: block; height: 100%; border-radius: inherit; background: var(--ok); min-width: 2px; transition: width var(--dur-fast); }
.diagnostic-bar-warn .diagnostic-bar span { background: var(--warn); }
.diagnostic-bar-bad .diagnostic-bar span { background: var(--err); }

@media (max-width: 860px) {
  .node-diagnostics-panel { grid-template-columns: 1fr; }
}

/* ============================================================
   FLASH ANIMATION
   ============================================================ */

.just-updated { animation: brokerUpdateFlash 0.7s ease-out; }
.pill-ok.just-updated { animation: none; }
@keyframes brokerUpdateFlash { 0% { background-color: var(--warn-soft); } 100% { background-color: inherit; } }

/* ============================================================
   NODE CONFIG PAGE
   ============================================================ */

.node-config-page { grid-template-rows: auto minmax(0, 1fr); }
.node-config-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--bg-surface); }
.node-config-subtitle { margin: 3px 0 0; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.node-config-apply-error { margin: 0; padding: 8px 12px; border: 1px solid rgba(196,51,43,0.3); border-radius: var(--r-card); background: var(--err-soft); color: var(--err-ink); font-weight: 600; font-size: var(--t-small); }
.node-config-apply-warning { margin: 0; padding: 8px 12px; border: 1px solid rgba(217,139,20,0.3); border-radius: var(--r-card); background: var(--warn-soft); color: var(--warn-ink); font-weight: 600; font-size: var(--t-small); }
.node-config-body { display: flex; flex-direction: column; gap: 0; min-height: 0; overflow: auto; padding: 14px; }
.capability-tabs-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.capability-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.capability-tab { border: 1px solid var(--line-strong); border-radius: var(--r-input); padding: 5px 11px; color: var(--ink-3); background: var(--bg-surface); text-decoration: none; font-family: var(--font-mono); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast); }
.capability-tab:hover { background: var(--bg-hover); color: var(--ink-1); }
.capability-tab.is-active { color: var(--ink-1); border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.capability-tab.has-mutations { border-color: var(--err); }
.capability-tab-badge { min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px; background: var(--err); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; }
.capability-tab-badge.is-hidden { display: none; }
.node-config-form { min-height: 0; display: flex; flex-direction: column; gap: 6px; overflow: auto; padding-right: 2px; }
.node-config-form .table-wrap { overflow: auto; }
.restore-snapshot-panel { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.restore-snapshot-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.subsection-title { margin: 0; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.restore-snapshot-table-wrap { max-height: 260px; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.restore-snapshot-table { table-layout: fixed; }
.restore-snapshot-table th, .restore-snapshot-table td { overflow: hidden; text-overflow: ellipsis; }
.restore-snapshot-table th:nth-last-child(1), .restore-snapshot-table td:nth-last-child(1) { width: 86px; text-align: right; }
.restore-snapshot-muted { display: block; color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.i2c-inventory-strip { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-sunk); }
.i2c-inventory-title { display: flex; align-items: baseline; gap: 6px; color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; }
.i2c-inventory-title strong { color: var(--ink-1); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.i2c-inventory-chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.i2c-inventory-chip { display: inline-flex; align-items: center; gap: 4px; }
.i2c-inventory-meta { color: var(--ink-3); font-family: var(--font-mono); font-size: 11px; }
.i2c-inventory-empty { margin: 0; }

/* ============================================================
   CAPABILITY GRID (GPIO / MCP / PCA / WS2812)
   ============================================================ */

.capability-grid { table-layout: fixed; }
.gpio-card-grid { display: grid; gap: 5px; }
.gpio-card { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); padding: 8px 12px; display: grid; grid-template-columns: minmax(250px, 340px) minmax(340px, 1fr); grid-template-areas: "header controls" "summary controls" "details details"; align-items: start; gap: 3px 12px; transition: border-color var(--dur-fast); }
.gpio-card:hover { border-color: var(--line-strong); }
.gpio-card-header { grid-area: header; display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.gpio-card-title-group { min-width: 0; display: grid; gap: 2px; align-content: start; }
.gpio-card-title-group[title] { cursor: help; }
.gpio-card-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.gpio-card-title { margin: 0; font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink-1); line-height: 1.2; }
.gpio-card-meta { display: flex; flex-wrap: wrap; gap: 2px 8px; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }
.gpio-card-summary, .gpio-card-details { display: grid; gap: 3px; }
.gpio-card-summary { grid-area: summary; }
.gpio-card-details { grid-area: details; }
.gpio-card-controls { grid-area: controls; display: grid; grid-template-columns: 58px minmax(260px, auto) minmax(150px, auto); gap: 4px 10px; align-items: start; justify-self: start; width: min(100%, 620px); }
.gpio-control-field, .gpio-field { display: grid; gap: 2px; align-content: start; }
.gpio-control-field label, .gpio-field label { font-family: var(--font-mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.gpio-control-field-checkbox { align-self: start; }
.gpio-control-field-button { min-width: 92px; }
.gpio-control-field-actions { min-width: 150px; }
.gpio-row-actions { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.gpio-control-field-modes { min-width: 0; }
.gpio-mode-rail { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.gpio-mode-chip { border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--bg-surface); color: var(--ink-3); padding: 1px 8px; font-family: var(--font-mono); font-size: 10px; line-height: 1.3; white-space: nowrap; cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast); }
.gpio-mode-chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--ink-1); font-weight: 700; }
.gpio-row-actions .tool-chip, .ws2812-row-actions .tool-chip, .capability-grid td > .tool-chip { white-space: nowrap; padding: 0 8px; height: 22px; font-size: 11px; }
.encoder-button-cell .stack-tight { display: grid; gap: 4px; min-width: 96px; }
.encoder-button-cell .inline-checkbox { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.encoder-layout-pin { display: block; white-space: nowrap; }
.gpio-boolean-field .grid-checkbox-cell, .gpio-control-field-checkbox .grid-checkbox-cell { text-align: left; padding-top: 2px; }
.gpio-control-field-checkbox .grid-checkbox { margin-left: 2px; }
.gpio-config-block { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); padding: 8px; display: grid; gap: 5px; }
.gpio-config-block h4 { margin: 0; font-family: var(--font-mono); font-size: 9px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); }
.gpio-field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 5px 8px; }
.gpio-placeholder { display: grid; gap: 3px; color: var(--ink-3); font-size: var(--t-small); }
.gpio-placeholder p { margin: 0; }
.gpio-row-note { font-family: var(--font-mono); font-size: 10px; line-height: 1.3; }
.gpio-row-note-warning { color: var(--err-ink); }
.grid-input, .grid-select { width: 100%; min-width: 0; height: 22px; border: 1px solid var(--line-strong); border-radius: var(--r-input); padding: 0 6px; font-family: var(--font-mono); font-size: 11px; background: var(--bg-surface); color: var(--ink-1); outline: none; transition: border-color var(--dur-fast); }
.grid-input:focus, .grid-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 20%, transparent); }
.grid-input-number { text-align: right; }
.command-picker-field { cursor: pointer; }

/* ============================================================
   COMMAND PICKER
   ============================================================ */

.command-picker-modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(11,14,19,0.5); padding: 12px; }
.command-picker-card { width: min(980px, 96vw); max-height: min(86vh, 900px); border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); padding: 16px; box-shadow: var(--elev-3); display: grid; grid-template-rows: auto auto minmax(0, 1fr); gap: 10px; }
.command-picker-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.command-picker-header h3 { margin: 0; font-family: var(--font-mono); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-2); }
.command-picker-tools { display: grid; grid-template-columns: minmax(260px, 1fr) 140px 180px auto; gap: 8px; align-items: center; }
.command-picker-count { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); text-align: right; }
.command-picker-results-wrap { min-height: 0; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-sunk); padding: 8px; }
.command-picker-results { display: grid; gap: 8px; }
.command-picker-group { display: grid; gap: 4px; }
.command-picker-group-toggle { width: 100%; border: 1px solid var(--line); border-radius: var(--r-badge); background: var(--bg-surface); color: var(--ink-1); display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; text-align: left; padding: 5px 10px; font-family: var(--font-mono); font-size: 11px; font-weight: 600; cursor: pointer; }
.command-picker-group-count { font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }
.command-picker-group-caret { color: var(--ink-3); font-size: 12px; }
.command-picker-group-items { display: grid; gap: 4px; }
.command-picker-item { width: 100%; border: 1px solid var(--line); border-radius: var(--r-badge); background: var(--bg-surface); color: var(--ink-1); text-align: left; padding: 7px 10px; display: grid; gap: 3px; cursor: pointer; transition: background var(--dur-fast), border-color var(--dur-fast); }
.command-picker-item:hover { background: var(--accent-soft); border-color: var(--accent); }
.command-picker-item-main { font-size: var(--t-small); font-weight: 600; }
.command-picker-item-meta { display: flex; gap: 10px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.command-picker-item-id { font-family: var(--font-mono); font-size: 11px; color: var(--info); }

/* ============================================================
   MISC
   ============================================================ */

.grid-checkbox-cell { text-align: center; }
.grid-checkbox { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }

.node-config-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 9px 14px; border-top: 1px solid var(--line); background: var(--bg-surface); position: sticky; bottom: 0; }
.node-config-save-status { margin-right: auto; font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.node-config-save-status[data-status="saving"] { color: var(--warn); font-weight: 600; }
.node-config-save-status[data-status="ok"]     { color: var(--ok);   font-weight: 600; }
.node-config-save-status[data-status="error"]  { color: var(--err);  font-weight: 600; }

.ws2812-color-field { display: flex; align-items: center; gap: 6px; }
.ws2812-color-picker { width: 36px; min-width: 36px; height: 24px; padding: 0; border: 1px solid var(--line-strong); border-radius: var(--r-badge); background: transparent; cursor: pointer; }
.ws2812-row-actions { align-items: center; display: inline-flex; gap: 4px; min-width: 132px; white-space: nowrap; }
.ws2812-actions-header { width: 132px; }

.io-test-panel { display: none; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); margin: 8px 0 12px; padding: 12px; }
.io-test-panel-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.io-test-panel h3 { font-family: var(--font-mono); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 3px; color: var(--ink-2); }
.io-test-panel p { color: var(--ink-3); font-size: var(--t-small); margin: 0; }
.io-test-panel-status { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.io-event-list { display: grid; gap: 4px; margin-top: 10px; max-height: 150px; overflow: auto; }
.io-event-row { display: grid; grid-template-columns: 130px minmax(180px, 1fr) 90px 90px; gap: 8px; align-items: center; border-top: 1px solid var(--line); padding-top: 4px; font-family: var(--font-mono); font-size: 11px; }
.io-event-source, .io-event-value { font-weight: 600; color: var(--ink-1); }
.io-event-time { color: var(--ink-3); text-align: right; }
.io-live-indicator { width: 12px; height: 12px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--bg-sunk); display: inline-block; vertical-align: middle; }
.io-live-indicator.has-seen-event.is-active { border-color: var(--ok); background: var(--ok); box-shadow: 0 0 5px rgba(47,122,77,0.65); }
.io-live-indicator.has-seen-event.is-inactive { border-color: var(--ink-4); background: var(--ink-4); }
.io-live-value { border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--bg-sunk); color: var(--ink-1); display: inline-flex; align-items: center; max-width: 120px; overflow: hidden; padding: 1px 8px; text-overflow: ellipsis; white-space: nowrap; font-family: var(--font-mono); font-size: 10px; font-weight: 700; }
.analog-calibration-live { border: 1px solid var(--line); border-radius: var(--r-card); background: var(--bg-surface); display: grid; gap: 6px; padding: 8px; }
.analog-calibration-live.is-calibrated { border-color: rgba(31,138,76,0.4); background: var(--ok-soft); }
.analog-calibration-live.is-reset-pending { border-color: rgba(217,139,20,0.4); background: var(--warn-soft); }
.analog-calibration-meter { background: var(--bg-sunk); border-radius: var(--r-pill); height: 6px; overflow: hidden; }
.analog-calibration-meter-fill { background: linear-gradient(90deg, var(--info), var(--ok)); display: block; height: 100%; min-width: 2px; transition: width 120ms ease-out; width: 0; }
.analog-calibration-values { display: flex; flex-wrap: wrap; gap: 4px 10px; font-family: var(--font-mono); font-size: 10px; color: var(--ink-3); }
.analog-calibration-values strong { color: var(--ink-1); }
.gpio-card.has-live-io-flash { border-color: var(--info); background: var(--info-soft); }
.io-output-actions { display: inline-flex; align-items: center; gap: 3px; min-width: 0; }
.io-toggle-control { gap: 0; }
.io-test-actions.io-toggle-control { gap: 0; }
.io-output-button { border: 1px solid var(--line-strong); background: var(--bg-surface); color: var(--ink-2); cursor: pointer; font-family: var(--font-mono); font-size: 10px; font-weight: 700; line-height: 1; min-width: 32px; padding: 3px 8px; transition: background var(--dur-fast), border-color var(--dur-fast); }
.io-toggle-control .io-output-button:first-child { border-radius: var(--r-pill) 0 0 var(--r-pill); }
.io-toggle-control .io-output-button:not(:first-child) { border-left: 0; }
.io-toggle-control .io-output-button:last-of-type { border-radius: 0 var(--r-pill) var(--r-pill) 0; }
.io-output-button:hover { background: var(--bg-hover); border-color: var(--accent); }
.io-output-button.is-selected { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.io-output-value-input { border: 1px solid var(--line-strong); border-radius: var(--r-pill); font-family: var(--font-mono); font-size: 10px; height: 18px; max-width: 58px; padding: 1px 6px; }
.io-output-actions .inline-command-status { max-width: 32px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pca-probe-control { align-items: center; display: inline-flex; gap: 6px; max-width: 180px; min-width: 170px; }
.pca-probe-slider { width: 120px; accent-color: var(--accent); }
.pca-probe-value { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); min-width: 34px; text-align: right; }
.pca-inline-status { overflow: hidden; width: 9px; }
.io-probe-toolbar { align-items: center; background: var(--bg-sunk); border: 1px solid var(--line); border-radius: var(--r-card); display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; padding: 9px; }
.io-test-actions { display: flex; align-items: center; gap: 6px; margin-top: 8px; min-width: 0; }
.io-test-actions-compact { margin-top: 0; white-space: nowrap; }
.io-test-actions .inline-command-status { max-width: 44px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.io-test-value-input { max-width: 120px; }
.io-test-hint { color: var(--ink-3); margin: 8px 0 0; font-size: var(--t-small); }
.capability-grid tr[data-node-config-draft-ws2812-row="true"].is-dragging { opacity: 0.55; }
.capability-grid tr[data-node-config-draft-ws2812-row="true"].is-drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.empty-row { color: var(--ink-3); font-style: italic; text-align: left; }
.broker-switcher { margin: 0; }

/* ============================================================
   DISCONNECTED BANNER
   ============================================================ */

.disconnected-banner {
  background: var(--err-soft);
  border: 1px solid rgba(183,60,44,0.35);
  border-left: 3px solid var(--err);
  color: var(--err-ink);
  padding: 11px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-radius: var(--r-card);
  font-family: var(--font-mono);
  font-size: 12px;
}

.disconnected-banner-icon {
  color: var(--err);
  flex-shrink: 0;
  display: inline-flex;
}

.disconnected-banner-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.disconnected-banner-title {
  font-weight: 600;
  font-size: 12.5px;
}

.disconnected-banner-detail {
  font-size: 11.5px;
  color: var(--err-ink);
  opacity: 0.75;
  margin-top: 2px;
}

/* ============================================================
   HOVER-ONLY SET BUTTON (signals table)
   ============================================================ */

.set-btn {
  opacity: 0;
  transition: opacity var(--dur-fast);
}

tr:hover .set-btn {
  opacity: 1;
}

/* ============================================================
   SEGMENTED CONTROL (GPIO filter)
   ============================================================ */

.segmented-control {
  display: inline-flex;
  background: var(--bg-sunk);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-badge);
  padding: 2px;
  gap: 2px;
}

.segmented-control-btn {
  padding: 4px 11px;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast);
}

.segmented-control-btn.is-active {
  background: var(--bg-surface);
  color: var(--ink-1);
  font-weight: 600;
  box-shadow: var(--elev-1);
}

/* ============================================================
   GPIO CARD — CONFIGURED ACCENT
   ============================================================ */

.gpio-card.is-configured {
  border-left: 3px solid var(--accent);
}

.gpio-card.is-unconfigured {
  opacity: 0.78;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 1280px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100dvh; flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; overflow-y: visible; }
  .sidebar-nav { flex-direction: row; flex: 0 0 auto; padding: 6px; }
  .sidebar-brand, .sidebar-section, .sidebar-footer { border: none; }
  .dashboard-page { height: auto; min-height: 100vh; grid-template-rows: auto auto; overflow: visible; }
  .dashboard-overview, .dashboard-tab-bar, .compact-grid { grid-template-columns: 1fr; }
  .top-bar { flex-direction: column; }
  .top-bar-summary { flex-wrap: wrap; overflow: visible; }
  .dashboard-status-stack { border-right: none; border-bottom: 1px solid var(--line); }
  .panel-header-row { flex-direction: column; align-items: flex-start; }
  .panel-tools { width: 100%; flex-wrap: wrap; }
  .panel-tools input[type="search"] { min-width: 180px; width: 100%; }
  .table-wrap { max-height: 320px; }
  .signal-hover-card { width: calc(100vw - 24px); left: 12px !important; }
  .node-modal-grid { grid-template-columns: 1fr; }
  .gpio-card-controls { grid-template-columns: 1fr; }
  .gpio-card { grid-template-columns: 1fr; grid-template-areas: "header" "summary" "controls" "details"; }
  .command-picker-tools { grid-template-columns: 1fr; }
  .command-picker-count { text-align: left; }
  .broker-form-grid { grid-template-columns: 1fr; }
  .broker-token-card { max-width: none; }
  .broker-field-grid { grid-template-columns: 1fr; }
  .broker-field-grid label,
  .broker-field-label { padding-top: 0; }
}

/* ============================================================
   AUTH / LOGIN
   ============================================================ */

.app-shell.is-guest .app-main {
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 16%, rgba(196, 106, 71, 0.16), transparent 28%),
    radial-gradient(circle at 12% 82%, rgba(47, 122, 77, 0.10), transparent 24%),
    var(--bg-app);
}

.sidebar-brand-static {
  cursor: default;
}

.sidebar-lock-card {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr);
  gap: 9px;
  align-items: start;
  padding: 9px 10px;
  border: 1px solid #2c2820;
  border-radius: 4px;
  background: var(--bg-mono-2);
}

.sidebar-lock-card strong,
.sidebar-lock-card span {
  display: block;
}

.sidebar-lock-card strong {
  color: #f6f4ef;
  font-size: 11px;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-lock-card span:last-child {
  margin-top: 4px;
  color: var(--ink-4);
  font-size: 10px;
  line-height: 1.35;
}

.sidebar-nav-item.is-disabled {
  color: #696257;
  cursor: default;
  opacity: 0.72;
}

.sidebar-nav-item.is-disabled:hover {
  background: transparent;
  color: #696257;
}

.sidebar-sign-out-form {
  margin: 0;
  line-height: 0;
}

.sidebar-sign-out {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 3px;
  color: var(--ink-4);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-sign-out:hover {
  color: #f6f4ef;
}

.auth-page {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 480px) minmax(220px, 360px);
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vw, 72px);
  padding: clamp(22px, 5vw, 72px);
  overflow: hidden;
}

.auth-backdrop-grid {
  position: absolute;
  inset: 0;
  opacity: 0.42;
  background-image:
    linear-gradient(to right, rgba(210, 204, 186, 0.55) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(210, 204, 186, 0.45) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 52% 48%, black, transparent 72%);
  pointer-events: none;
}

.auth-card,
.auth-status-panel {
  position: relative;
  z-index: 1;
  border: 1px solid var(--line-strong);
  border-radius: 14px;
  background: color-mix(in srgb, var(--bg-surface) 94%, white 6%);
  box-shadow: var(--elev-3);
}

.auth-card {
  padding: clamp(22px, 3vw, 34px);
}

.auth-brand-lockup {
  display: flex;
  gap: 16px;
  align-items: center;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.auth-brand-mark {
  width: 58px;
  height: 58px;
  filter: drop-shadow(0 14px 24px rgba(26, 24, 19, 0.18));
}

.auth-eyebrow,
.auth-status-label {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.auth-brand-lockup h1 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: clamp(22px, 2.4vw, 31px);
  line-height: 1.02;
  letter-spacing: -0.03em;
  color: var(--ink-1);
}

.auth-brand-lockup p:last-child {
  margin-top: 7px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
}

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

.auth-field {
  display: grid;
  gap: 7px;
}

.auth-field label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.auth-field input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--ink-1);
  font-family: var(--font-mono);
  font-size: 13px;
  padding: 0 13px;
  outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast), background var(--dur-fast);
}

.auth-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  background: #fffdf8;
}

.auth-check-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 13px;
}

.auth-check-row input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.auth-submit {
  height: 44px;
  border: 1px solid color-mix(in srgb, var(--accent) 78%, black 22%);
  border-radius: 10px;
  background: linear-gradient(135deg, #d27a51, var(--accent));
  color: #fffaf4;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(196, 106, 71, 0.24);
  transition: transform var(--dur-fast), box-shadow var(--dur-fast), filter var(--dur-fast);
}

.auth-submit:hover {
  transform: translateY(-1px);
  filter: saturate(1.04);
  box-shadow: 0 16px 28px rgba(196, 106, 71, 0.30);
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.auth-links a {
  color: var(--ink-3);
  font-family: var(--font-sans);
  font-size: 13px;
  text-decoration: none;
}

.auth-links a:hover {
  color: var(--accent);
}

.auth-status-panel {
  align-self: center;
  padding: 20px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg-surface) 86%, white 14%), var(--bg-sunk));
}

.auth-status-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 12px;
}

.auth-status-row span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-soft);
}

@media (max-width: 980px) {
  .auth-page {
    grid-template-columns: minmax(280px, 520px);
    align-content: center;
  }

  .auth-status-panel {
    display: none;
  }
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }

  .app-shell,
  .app-shell.is-guest {
    min-height: 100%;
  }

  .auth-page {
    padding: 18px;
  }

  .auth-brand-lockup {
    align-items: flex-start;
  }
}
