:root {
  --bg0: #070b09;
  --bg1: #0d1511;
  --bg2: #131c17;
  --line: #24352c;
  --line-soft: rgba(61, 206, 122, 0.12);
  --text: #e8f3ec;
  --muted: #7f9789;
  --accent: #3dce7a;
  --accent-dim: #1f6b42;
  --warn: #d4a04a;
  --danger: #d65a4c;
  --info: #5eb0c9;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "Heebo", system-ui, sans-serif;
  --shell-pad: 0.75rem;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background:
    linear-gradient(180deg, #0c1410 0%, var(--bg0) 40%, #050807 100%);
  min-height: 100vh;
}
body.shell-app {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.shell-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

/* —— Shell top / drawer / stage —— */
.shell-top {
  position: relative;
  z-index: 40;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  overflow: hidden;
  padding: 0.45rem var(--shell-pad);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 11, 9, 0.94);
}
.shell-menu-btn {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0 0.4rem;
  cursor: pointer;
}
.shell-menu-btn span {
  display: block;
  height: 1.5px;
  border-radius: 1px;
  background: var(--muted);
}
.shell-menu-btn:hover span { background: var(--accent); }
.shell-brand {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}
.shell-brand .brand {
  margin: 0;
  font-size: 0.58rem;
  letter-spacing: 0.22em;
}
.shell-brand h1 {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}
.shell-conn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-width: 0;
  margin-inline-start: auto;
  justify-content: flex-end;
}
.shell-port {
  width: 7.2rem;
  max-width: 28vw;
  min-width: 0;
  flex: 0 1 7.2rem;
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.28rem 0.4rem;
  font-family: var(--mono);
  font-size: 0.68rem;
}
.shell-view-title {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding-inline: 0.65rem;
  border-inline-start: 1px solid var(--line);
}
.shell-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.5);
  border: 0;
  padding: 0;
  cursor: pointer;
}
.shell-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 60;
  width: min(16.5rem, 84vw);
  padding: 1.25rem 0.85rem 1.5rem;
  background: #0a100d;
  border-left: 1px solid var(--line);
  transform: translateX(105%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
body.shell-drawer-open .shell-drawer {
  transform: translateX(0);
}
.shell-drawer-label {
  margin: 0 0 0.75rem;
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: var(--mono);
}
.shell-nav-item {
  appearance: none;
  border: 0;
  border-inline-end: 2px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: right;
  padding: 0.7rem 0.85rem;
  border-radius: 0;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
}
.shell-nav-item:hover { background: rgba(61, 206, 122, 0.06); color: var(--accent); }
.shell-nav-item.active {
  background: rgba(61, 206, 122, 0.08);
  color: var(--accent);
  border-inline-end-color: var(--accent);
  font-weight: 700;
}
.shell-stage {
  position: relative;
  z-index: 1;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.shell-view {
  display: none;
  height: 100%;
  min-height: 0;
}
.shell-view.is-active {
  display: flex;
  flex-direction: column;
}
.shell-view-scroll.is-active {
  overflow: auto;
  padding: 0.65rem var(--shell-pad) 1rem;
}
#view-home.is-active {
  overflow: auto;
  padding: 0.85rem;
  align-items: flex-start;
  background: #101814;
}

/* —— Instrument panel (home): compact cards, not full-bleed tiles —— */
.gauge-grid {
  flex: 0 0 auto;
  width: 100%;
  height: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  grid-auto-rows: auto;
  gap: 0.65rem;
  background: transparent;
  border: 0;
}
@media (max-width: 720px) {
  .gauge-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .shell-view-title { display: none; }
  .shell-conn .btn { padding: 0.28rem 0.4rem; }
  .shell-port { max-width: 5.5rem; }
}
.gauge {
  appearance: none;
  border: 1px solid #31483c;
  border-radius: 10px;
  background: #1c2c24;
  color: inherit;
  font: inherit;
  text-align: right;
  padding: 0.65rem 0.75rem 0.55rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.28rem;
  min-height: 0;
  position: relative;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.gauge::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.85rem;
  bottom: 0.85rem;
  width: 2px;
  background: transparent;
  transition: background 0.15s ease;
}
.gauge:hover {
  background: #24382e;
  border-color: #3dce7a;
}
.gauge:hover::before,
.gauge.ok::before {
  background: var(--accent);
}
.gauge.warn::before { background: var(--warn); }
.gauge.bad::before { background: var(--danger); }
.gauge:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  z-index: 2;
}
.gauge-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.gauge-label {
  font-family: var(--sans);
  font-size: 0.78rem;
  font-weight: 700;
  color: #d7e8de;
  letter-spacing: 0;
  text-transform: none;
}
.gauge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #2a3d34;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.gauge.ok .gauge-dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(61, 206, 122, 0.55);
}
.gauge.warn .gauge-dot {
  background: var(--warn);
  box-shadow: 0 0 8px rgba(212, 160, 74, 0.45);
}
.gauge.bad .gauge-dot {
  background: var(--danger);
  box-shadow: 0 0 8px rgba(214, 90, 76, 0.45);
}
.gauge-readout {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 0.2rem 0.35rem;
  min-height: 0;
}
.gauge-readout-signal {
  align-items: center;
  gap: 0.55rem;
}
.gauge-value {
  font-family: var(--mono);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  color: #f4fff8;
}
.gauge-value-sm {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.gauge-unit {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.gauge-meta {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: #b7cfc2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.gauge-bar {
  height: 3px;
  border-radius: 0;
  background: #0a100e;
  overflow: hidden;
  margin: 0.15rem 0 0;
}
.gauge-bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.gauge.warn .gauge-bar i { background: var(--warn); }
.gauge.bad .gauge-bar i { background: var(--danger); }
.gauge-bars-row {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 1.15rem;
  margin: 0;
}
.gauge-bars-row i {
  display: block;
  width: 5px;
  border-radius: 1px;
  background: #24352c;
}
.gauge-bars-row i:nth-child(1) { height: 28%; }
.gauge-bars-row i:nth-child(2) { height: 48%; }
.gauge-bars-row i:nth-child(3) { height: 72%; }
.gauge-bars-row i:nth-child(4) { height: 100%; }
.gauge-bars-row[data-bars="1"] i:nth-child(1),
.gauge-bars-row[data-bars="2"] i:nth-child(-n+2),
.gauge-bars-row[data-bars="3"] i:nth-child(-n+3),
.gauge-bars-row[data-bars="4"] i:nth-child(-n+4),
.gauge-bars-row.on-1 i:nth-child(1),
.gauge-bars-row.on-2 i:nth-child(-n+2),
.gauge-bars-row.on-3 i:nth-child(-n+3),
.gauge-bars-row.on-4 i:nth-child(-n+4) {
  background: var(--accent);
}
.gauge.warn .gauge-bars-row[data-bars] i,
.gauge.warn .gauge-bars-row.on-1 i:nth-child(1),
.gauge.warn .gauge-bars-row.on-2 i:nth-child(-n+2),
.gauge.warn .gauge-bars-row.on-3 i:nth-child(-n+3),
.gauge.warn .gauge-bars-row.on-4 i:nth-child(-n+4) {
  background: var(--warn);
}
.gauge.bad .gauge-bars-row[data-bars] i,
.gauge.bad .gauge-bars-row.on-1 i:nth-child(1),
.gauge.bad .gauge-bars-row.on-2 i:nth-child(-n+2),
.gauge.bad .gauge-bars-row.on-3 i:nth-child(-n+3),
.gauge.bad .gauge-bars-row.on-4 i:nth-child(-n+4) {
  background: var(--danger);
}
.gauge.warn .gauge-value { color: var(--warn); }
.gauge.bad .gauge-value { color: var(--danger); }
.gauge.ok .gauge-value { color: var(--accent); }
.foot-inline {
  margin: 0.75rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
}
#view-map .map-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: min(70dvh, 32rem);
  margin: 0;
}
#view-map .gps-map {
  flex: 1;
  min-height: 18rem;
}
#view-fw .fw-panel,
#view-auto .auto-banner,
#view-guard .guard-panel {
  margin: 0;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.top, .status-strip, .dashboard, .auto-banner, .fw-panel, .guard-panel, .foot,
.shell-top, .shell-stage { position: relative; z-index: 1; }
/* Expanded map */
body.map-is-expanded .shell-top,
body.map-is-expanded .shell-drawer,
body.map-is-expanded .shell-backdrop {
  z-index: 0 !important;
  pointer-events: none;
}
body.map-is-expanded .shell-stage,
body.map-is-expanded #view-map {
  z-index: 6000 !important;
}
body.map-is-expanded .map-panel.map-expanded {
  z-index: 6100 !important;
  pointer-events: auto;
}

.guard-panel {
  margin: 0.35rem 0.75rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(165deg, #1a1810 0%, #0e1612 100%);
}
.guard-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.guard-panel input[type="tel"],
.guard-panel input[type="text"],
.guard-panel input[type="number"] {
  background: #0c1411;
  color: var(--text);
  border: 1px solid #2a4036;
  border-radius: 6px;
  padding: 0.28rem 0.4rem;
  font-size: 0.72rem;
  min-width: 7rem;
}
.guard-panel input[type="tel"],
.guard-panel input[type="text"] {
  flex: 1 1 10rem;
}
.guard-bt-box {
  margin: 0.15rem 0 0.35rem;
  padding: 0.4rem 0.45rem;
  border: 1px solid #2a4036;
  border-radius: 8px;
  background: #0a1210;
}
.guard-bt-list {
  max-height: 9.5rem;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.3rem;
}
.guard-bt-empty {
  font-size: 0.72rem;
  color: #8aa396;
  padding: 0.45rem 0.2rem;
}
.guard-bt-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.1rem;
  text-align: right;
  width: 100%;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  border: 1px solid #243830;
  background: #101a16;
  color: var(--text);
  cursor: pointer;
  font: inherit;
}
.guard-bt-item:hover {
  border-color: #3dce7a;
  background: #14241c;
}
.guard-bt-item.selected {
  border-color: #3dce7a;
  background: #1a3226;
  box-shadow: inset 0 0 0 1px rgba(61, 206, 122, 0.35);
}
.gbt-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #e8f2ec;
}
.gbt-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.68rem;
  color: #8aa396;
}
.gbt-rssi {
  white-space: nowrap;
  color: #c9b65e;
}

.fw-panel {
  margin: 0;
  padding: 0.85rem 0.9rem 1rem;
  width: 100%;
  max-width: 36rem;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(165deg, #14221c 0%, #0e1612 100%);
  overflow: hidden;
}
.fw-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.fw-head h2 {
  margin: 0;
  font-size: 0.85rem;
}
.fw-sub {
  margin: 0.1rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}
.fw-grid {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}
.fw-col { min-width: 0; max-width: 100%; }
.fw-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
  min-width: 0;
  max-width: 100%;
}
.fw-row > .as-label {
  flex: 0 0 7.2rem;
}
.fw-ver {
  font-family: var(--mono);
  color: var(--accent);
  font-size: 0.95rem;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fw-select {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  max-width: 100%;
  background: #0c1411;
  color: var(--text);
  border: 1px solid #2a4036;
  border-radius: 6px;
  padding: 0.35rem 0.45rem;
  font-size: 0.78rem;
}
.fw-actions { margin-top: 0.35rem; }
.fw-actions > .btn { flex: 1 1 8rem; }
.fw-progress-wrap { margin-bottom: 0.35rem; }
.fw-progress-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
  margin-bottom: 0.25rem;
}
.fw-progress-track {
  height: 10px;
  border-radius: 999px;
  background: #0a100e;
  border: 1px solid #2a4036;
  overflow: hidden;
}
.fw-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1f6b42, var(--accent));
  transition: width 0.15s ease;
}
.fw-flash-meta {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  min-height: 1.1em;
  white-space: normal;
  overflow-wrap: anywhere;
  unicode-bidi: plaintext;
}
#fw-cart-pair.ok {
  color: var(--accent);
}
#fw-cart-peer {
  margin: 0.15rem 0 0.25rem;
  font-family: var(--mono);
  direction: ltr;
  unicode-bidi: embed;
  text-align: right;
}
.link-meter {
  margin: 0.35rem 0 0.45rem;
  padding: 0.35rem 0.45rem;
  border: 1px solid #2a4036;
  border-radius: 8px;
  background: #0c1411;
}
.rssi-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 1.1rem;
  margin-inline: 0.25rem;
}
.rssi-bars i {
  display: block;
  width: 5px;
  border-radius: 1px;
  background: #2a4036;
}
.rssi-bars i:nth-child(1) { height: 25%; }
.rssi-bars i:nth-child(2) { height: 45%; }
.rssi-bars i:nth-child(3) { height: 70%; }
.rssi-bars i:nth-child(4) { height: 100%; }
.rssi-bars.on-1 i:nth-child(1),
.rssi-bars.on-2 i:nth-child(-n+2),
.rssi-bars.on-3 i:nth-child(-n+3),
.rssi-bars.on-4 i:nth-child(-n+4) {
  background: var(--accent);
}
.rssi-bars.bad i {
  background: #6b3a3a;
}
#fw-link-range.in { color: var(--accent); }
#fw-link-range.out { color: #e07070; }
#fw-link-range.back { color: #7ec8a0; }
.link-debug-wrap {
  margin-top: 0.55rem;
  border: 1px solid var(--line);
  background: #070b09;
}
.link-debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.link-debug {
  margin: 0;
  padding: 0.45rem 0.55rem;
  max-height: 9.5rem;
  overflow: auto;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #9bb5a6;
  white-space: pre-wrap;
  word-break: break-word;
}
#fw-link-phone {
  max-width: 11rem;
}
#fw-status-msg {
  min-height: 1.2em;
}
.fw-steps {
  margin: 0.35rem 0 0;
  padding: 0 0 0 1.1rem;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}
.fw-steps[hidden] { display: none; }
.fw-steps li.done {
  color: var(--accent);
}
.fw-check {
  display: inline-block;
  width: 1rem;
  margin-inline-end: 0.25rem;
  font-family: var(--mono);
}
.fw-hint {
  margin: 0.35rem 0 0;
  padding: 0.4rem;
  background: #120e0c;
  border: 1px solid #5a3a28;
  border-radius: 6px;
  color: #e0b08a;
  font-size: 0.8rem;
  white-space: pre-wrap;
  max-height: 12rem;
  overflow: auto;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: center;
  padding: 0.35rem 0.75rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}

.brand {
  margin: 0;
  font-family: var(--mono);
  letter-spacing: 0.16em;
  font-size: 0.55rem;
  color: var(--accent);
  font-weight: 600;
}

.top h1 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.sub { margin: 0; color: var(--muted); font-size: 0.65rem; }

.link-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: end;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  font-size: 0.65rem;
  color: var(--muted);
}

.field select {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.4rem;
  font-family: var(--mono);
  min-width: 5.5rem;
  font-size: 0.72rem;
}

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 6px;
  padding: 0.28rem 0.5rem;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 0.75rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--accent-dim); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(180deg, #2f9a5c, #1f6b42);
  border-color: #3dce7a66;
}
.btn.ghost { background: transparent; }
.btn.tiny { padding: 0.25rem 0.55rem; font-size: 0.75rem; }
.btn.danger {
  background: linear-gradient(180deg, #b44538, #8a2f26);
  border-color: #e25b4a88;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem 0.15rem;
  min-height: 1.7rem;
  align-items: center;
}
body.is-flashing .dashboard,
body.is-flashing .auto-banner,
body.is-flashing .guard-panel {
  pointer-events: none;
  opacity: 0.72;
}
body.is-flashing #serial-log {
  max-height: 14rem;
}

.tip {
  margin: 0.25rem 0.75rem 0.35rem;
  padding: 0.35rem 0.55rem;
  border: 1px solid #3a5a48;
  border-radius: 8px;
  background: #122019;
  color: #b9d2c4;
  font-size: 0.72rem;
  line-height: 1.3;
}
.tip .mono {
  font-family: var(--mono);
  color: var(--accent);
  direction: ltr;
  unicode-bidi: embed;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  padding: 0.12rem 0.4rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg1) 88%, black);
  font-size: 0.65rem;
  color: var(--muted);
}
.pill .dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: #566;
}
.pill.ok { color: var(--text); border-color: #2f6b4a; }
.pill.ok .dot { background: var(--accent); box-shadow: 0 0 0 3px #3dce7a22; }
.pill.warn { color: var(--warn); border-color: #6d5228; }
.pill.warn .dot { background: var(--warn); }
.pill.bad { color: var(--danger); border-color: #6d3028; }
.pill.bad .dot { background: var(--danger); }

.auto-banner {
  margin: 0.25rem 0.75rem 0;
  padding: 0.35rem 0.45rem 0.4rem;
  border-radius: 8px;
  border: 1px solid #2a4a38;
  background: #101a16;
}
.auto-banner-head {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.25rem;
}
.auto-banner-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
}
.rules-persist-hint {
  margin-inline-start: auto;
  font-size: 0.65rem;
  color: #7d9a8a;
  white-space: nowrap;
}
.auto-sentence {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  align-items: center;
  padding: 0.25rem 0.3rem;
  border-radius: 6px;
  background: #0b1411;
  border: 1px solid #24362e;
}
.auto-sentence select,
.auto-sentence input[type="number"],
.auto-sentence input[type="text"] {
  background: #0c1411;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.22rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  max-width: 4.8rem;
}
.auto-sentence input[type="text"] { max-width: 6rem; }
.auto-sentence .chk {
  font-size: 0.72rem;
  gap: 0.15rem;
}
.as-label {
  font-weight: 700;
  color: var(--accent);
  font-size: 0.78rem;
}
.as-unit {
  font-size: 0.68rem;
  color: var(--muted);
  font-family: var(--mono);
}
.auto-sentence .hidden { display: none !important; }
.rules-log-wrap {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.rules-log-wrap summary {
  cursor: pointer;
  user-select: none;
}

.dashboard {
  display: grid;
  grid-template-columns: minmax(300px, 1.15fr) minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.4rem 0.75rem 0.7rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .dashboard { grid-template-columns: 1fr; }
}
.dash-visuals {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  position: sticky;
  top: 0.3rem;
}
.viz-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
}
.viz-stack > .panel {
  width: 100%;
}
.dash-controls {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 0;
}
.section-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-transform: uppercase;
}

.components {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 0.65rem;
  align-content: start;
  width: 100%;
  min-width: 0;
}
.card-focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.buzzer-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem 0.45rem;
  border-radius: 8px;
  border: 1px solid #2a4a38;
  background: #0f2418;
}
.bz-field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.7rem;
  color: var(--muted);
}
.bz-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.bz-row input {
  width: 4.2rem;
  background: #0c1411;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 0.22rem 0.35rem;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.card {
  background: linear-gradient(165deg, #15221c, #101915 70%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.45rem 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-height: 0;
  animation: rise 0.35s ease both;
}
.card:nth-child(2) { animation-delay: 0.04s; }
.card:nth-child(3) { animation-delay: 0.08s; }
.card:nth-child(4) { animation-delay: 0.12s; }
.card:nth-child(5) { animation-delay: 0.16s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: start;
}
.card h3 {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
}
.card .en {
  margin: 0.05rem 0 0;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
}
.tag {
  font-size: 0.6rem;
  font-family: var(--mono);
  padding: 0.1rem 0.3rem;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.tag.core { color: var(--info); border-color: #2a5a6a; }
.tag.ui { color: var(--accent); border-color: #2a5a40; }
.tag.sensor { color: #c9b65e; border-color: #5a5230; }
.tag.radio { color: #8aa8ff; border-color: #3a4a7a; }
.tag.actuator { color: var(--danger); border-color: #6a3530; }
.tag.power { color: var(--warn); border-color: #6a5230; }

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-readout {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.35rem;
  row-gap: 0.1rem;
  align-items: baseline;
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  border: 1px solid #2a4a38;
  background: linear-gradient(160deg, #0f2418, #0c1612 70%);
}
.live-value {
  font-family: var(--mono);
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
  letter-spacing: -0.02em;
  grid-row: 1;
  grid-column: 1;
}
.live-value.bad { color: var(--danger); }
.live-unit {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  grid-row: 1;
  grid-column: 2;
}
.live-meta {
  grid-column: 1 / -1;
  font-size: 0.65rem;
  color: var(--muted);
}

.live-readout.gps .live-value {
  font-size: 0.78rem;
  letter-spacing: 0;
  line-height: 1.2;
}
.live-readout.modem {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.live-readout.modem .live-value {
  font-size: 0.95rem;
  grid-column: auto;
  grid-row: auto;
}
.signal-row {
  display: flex;
  align-items: flex-end;
  gap: 0.35rem;
}
.signal-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 1.05rem;
}
.signal-bars span {
  width: 4px;
  border-radius: 2px;
  background: #2a3d34;
  display: block;
}
.signal-bars span:nth-child(1) { height: 35%; }
.signal-bars span:nth-child(2) { height: 55%; }
.signal-bars span:nth-child(3) { height: 75%; }
.signal-bars span:nth-child(4) { height: 100%; }
.signal-bars[data-bars="1"] span:nth-child(1),
.signal-bars[data-bars="2"] span:nth-child(-n+2),
.signal-bars[data-bars="3"] span:nth-child(-n+3),
.signal-bars[data-bars="4"] span:nth-child(-n+4) {
  background: var(--accent);
  box-shadow: 0 0 6px #3dce7a44;
}
.modem-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}
.sim-badge, .net-badge {
  font-family: var(--mono);
  font-size: 0.62rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1rem 0.3rem;
  color: var(--muted);
}
.sim-badge.ok, .net-badge.ok {
  color: var(--accent);
  border-color: #2f6b4a;
}
.sim-badge.bad {
  color: var(--danger);
  border-color: #6d3028;
}
.map-badge.cell {
  color: #c9b65e;
  border-color: #5a5230;
}

.cam-panel { min-height: 0; }
.cam-preview-wrap {
  min-height: 0;
  height: 220px;
  border-radius: 8px;
  border: 1px solid #24362e;
  background: #0c1411;
  overflow: hidden;
  position: relative;
  display: flex;
  align-items: center;
}
.cam-preview {
  display: none;
  width: 100%;
  height: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #000;
}
.cam-preview.on { display: block; }
.cam-hint {
  margin: 0;
  padding: 0.35rem 0.45rem;
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.25;
}
.net-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.35rem 0 0.15rem;
}
.net-select {
  width: 100%;
  min-height: 6.2rem;
  background: #0c1411;
  color: #d7ebe0;
  border: 1px solid #2a4036;
  border-radius: 6px;
  font-size: 0.72rem;
  padding: 0.2rem;
}
.net-select option {
  padding: 0.2rem 0.3rem;
}
.net-picker .bz-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}
.net-picker input[type="text"],
.net-picker input[type="password"] {
  flex: 1 1 7rem;
  min-width: 6rem;
  background: #0c1411;
  color: #d7ebe0;
  border: 1px solid #2a4036;
  border-radius: 6px;
  padding: 0.28rem 0.4rem;
  font-size: 0.72rem;
}

.cam-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.25rem;
  font-size: 0.65rem;
}

.rules-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  color: var(--muted);
}
.auto-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(160px, 0.9fr);
  gap: 0.35rem;
  align-items: start;
}
@media (max-width: 900px) {
  .auto-row { grid-template-columns: 1fr; }
}
.rules-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.3rem;
  margin: 0;
  max-height: 92px;
  overflow: auto;
}
.rule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  background: #0f1814;
}
.rule-card.off { opacity: 0.55; }
.rule-top {
  display: flex;
  justify-content: space-between;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
  font-size: 0.8rem;
}
.rule-meta { font-family: var(--mono); font-size: 0.62rem; color: var(--muted); }
.rule-card p { margin: 0 0 0.3rem; font-size: 0.7rem; color: var(--muted); }
.rule-actions { display: flex; gap: 0.25rem; }
.rule-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}
.rule-form input,
.rule-form select {
  background: #0c1411;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.rule-form .hidden { display: none; }
.rule-form .chk {
  font-size: 0.8rem;
  color: var(--muted);
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
}
.rules-log { max-height: 90px; margin-top: 0.25rem; font-size: 0.68rem; }

.map-panel { min-height: 0; }
.map-head-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.map-source {
  margin: 0 0 0.3rem;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}
.gps-map {
  height: 280px;
  min-height: 280px;
  border-radius: 8px;
  border: 1px solid #2a4a38;
  background: #0a1010;
  z-index: 0;
}
.gps-map .leaflet-container {
  font-family: var(--sans);
  height: 100%;
}
.map-panel.map-expanded {
  position: fixed;
  inset: 0.5rem;
  z-index: 5000;
  margin: 0;
  padding: 0.6rem 0.75rem;
  border-radius: 12px;
  background: #0e1612;
  border: 1px solid #2a4a38;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  isolation: isolate;
}
.map-panel.map-expanded .gps-map {
  flex: 1;
  height: auto;
  min-height: 0;
}
.map-coords {
  margin: 0.25rem 0 0;
  font-size: 0.65rem;
  color: var(--muted);
  direction: ltr;
  text-align: left;
}
.map-badge {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 0.1rem 0.3rem;
}
.map-badge.ok {
  color: var(--accent);
  border-color: #2f6b4a;
}

.pins {
  display: flex;
  flex-wrap: wrap;
  gap: 0.18rem;
  max-height: 1.35rem;
  overflow: hidden;
}
.pin {
  font-family: var(--mono);
  font-size: 0.58rem;
  background: #0c1411;
  border: 1px solid #24362e;
  border-radius: 4px;
  padding: 0.08rem 0.22rem;
  color: #b7d0c2;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: auto;
}
.actions .btn { font-size: 0.72rem; padding: 0.28rem 0.45rem; }
.actions .btn.soft-warn { border-color: #6d5228; color: var(--warn); }

.side {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 60vh;
}
.panel {
  background: #0e1613;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.6rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel.grow { flex: 1; min-height: 140px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.3rem;
}
.panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
}

.mono-block {
  margin: 0;
  flex: 1;
  overflow: auto;
  background: #070c0a;
  border: 1px solid #1c2b24;
  border-radius: 8px;
  padding: 0.4rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  line-height: 1.35;
  color: #c5ddcf;
  white-space: pre-wrap;
  word-break: break-word;
  direction: ltr;
  text-align: left;
  max-height: 88px;
}
.mono-block.log { max-height: 140px; }

.foot {
  padding: 0.35rem 0.75rem 0.5rem;
  color: var(--muted);
  font-size: 0.65rem;
  border-top: 1px solid var(--line);
}

.fw-sms-text {
  width: 100%;
  min-width: 0;
  margin: 0.25rem 0 0.35rem;
  background: #0c1411;
  color: var(--text);
  border: 1px solid #2a4036;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.8rem;
  resize: vertical;
}
.app-toast {
  position: fixed;
  z-index: 80;
  bottom: 1.1rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: #1c2c24;
  color: #f4fff8;
  font-weight: 700;
}
.app-toast[hidden] { display: none; }
.indoor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(220px, 0.8fr);
  gap: 0.75rem;
  align-items: start;
}
.indoor-canvas {
  width: 100%;
  height: auto;
  background: #0b1210;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.indoor-side h3 {
  margin: 0.8rem 0 0.35rem;
  font-size: 0.95rem;
}
.indoor-field {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-bottom: 0.35rem;
  color: var(--muted);
  font-size: 0.8rem;
}
.indoor-field input {
  background: #0b1210;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font: inherit;
}
.indoor-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  font-size: 0.82rem;
}
.indoor-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--line-soft);
}
@media (max-width: 800px) {
  .indoor-grid { grid-template-columns: 1fr; }
}

dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg1);
  color: var(--text);
  padding: 0;
  max-width: 420px;
}
dialog::backdrop { background: #00000088; }
.dlg { padding: 1.1rem 1.2rem 1.2rem; }
.dlg h3 { margin: 0 0 0.5rem; }
.dlg p { margin: 0 0 1rem; color: var(--muted); }
.dlg-actions { display: flex; gap: 0.5rem; justify-content: flex-start; }

/* Readability floor: nothing the operator has to read is smaller than ~12px. */
:is(#rules-persist-hint, .rules-persist-hint, .as-unit, .rule-meta, .rules-log, .cam-badge, .cam-hint,
    .fw-ready-badge, #fw-ready-badge, .guard-badge, .guard-bt-scan-status, #guard-bt-scan-status,
    .guard-bt-picked, #guard-bt-picked, .guard-hint, #guard-hint, .basket-badge, .indoor-badge,
    .map-badge, .map-coords, #map-coords, .section-label, .en, .tag, .hint, .pin, .us-live-meta,
    #us-live-meta, .modem-sim, #modem-sim, .fw-sub, .fw-flash-meta, .fw-steps, .fw-hint) {
  font-size: max(0.76rem, 12px);
}
/* LTE tile subtitle was cut off; let it wrap instead. */
:is(#g-lte-meta, .g-lte-meta) {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}
:is([id$="-live-meta"], [class$="-live-meta"], [class*=" live-meta"], #modem-net, .modem-net, #map-source, .map-source) {
  font-size: max(0.76rem, 12px);
}
:is(#batt-state, .batt-state, #foot-inline, .foot-inline) { font-size: max(0.76rem, 12px); }

/* Scrolling views are flex columns: never let a child shrink below its content (clipped cards/panels at 100% zoom). */
.shell-view-scroll.is-active > * { flex-shrink: 0; }
.components .card { min-width: 0; overflow-wrap: anywhere; }
