:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --ink: #1a1f24;
  --muted: #6b7280;
  --line: #e6e8ec;
  --line-strong: #d0d4db;
  --accent: #0d6e6e;
  --accent-soft: #e6f4f4;
  --pair: #c45c26;
  --pair-soft: #fff1e8;
  --switch: #2f6fed;
  --switch-soft: #ebf1ff;
  --danger: #b42318;
  --ok: #067647;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 8px 24px rgba(16, 24, 40, 0.04);
  --radius: 14px;
  --font: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Outfit", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% 0%, #eef6f6 0%, transparent 55%),
    radial-gradient(700px 360px at 100% 0%, #f3f0ea 0%, transparent 50%),
    var(--bg);
}

button, input { font: inherit; }
button { cursor: pointer; }
em { font-style: normal; color: var(--muted); font-weight: 400; }

.login-mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(800px 400px at 20% 10%, #e8f4f4 0%, transparent 55%),
    radial-gradient(700px 360px at 90% 80%, #f2eee6 0%, transparent 50%),
    #f7f8fa;
}
.login-mask[hidden] { display: none; }
.login-card {
  width: min(380px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 28px 26px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 6px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.login-btn { width: 100%; margin-top: 4px; }
.login-error {
  margin: 0;
  font-size: 0.84rem;
  color: var(--danger);
}
.app[hidden] { display: none; }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background:
    linear-gradient(145deg, #0d6e6e 0%, #1a3a3a 100%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.brand-name {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 1.15rem;
}
.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-group {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #b45309;
  padding: 16px 12px 8px;
}
.nav-product {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  font-family: var(--display);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--ink);
  padding: 10px 12px;
  line-height: 1.4;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}
.nav-product:hover { background: #f1f3f5; }
.nav-product.open {
  background: #f3fafa;
  color: var(--accent);
}
.nav-caret {
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .18s;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-product.open .nav-caret {
  transform: rotate(45deg);
  margin-top: -2px;
}
.nav-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 2px 0 4px 10px;
  padding-left: 10px;
  border-left: 2px solid #d7e5e5;
}
.nav-children[hidden] { display: none; }
.nav-children .nav-item {
  font-size: 0.9rem;
  padding: 9px 12px;
}
.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 11px 12px;
  border-radius: 10px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #f1f3f5; }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--muted);
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}
.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #c4c8d0;
}
.conn-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(6, 118, 71, 0.15);
}

.main {
  padding: 28px 36px 48px;
  max-width: 960px;
}

.topbar { margin-bottom: 22px; }
.topbar h1 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.topbar-desc {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.page { display: none; }
.page.active { display: block; animation: fade .2s ease; }
@keyframes fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px 26px;
}

.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}
.hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.field > span {
  font-size: 0.84rem;
  color: #374151;
  font-weight: 500;
}
.field-span2 { grid-column: 1 / -1; }
.field.compact { max-width: 220px; }

.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field select {
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fcfcfd;
  color: var(--ink);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  font: inherit;
}
.field select {
  cursor: pointer;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #64748b 50%),
    linear-gradient(135deg, #64748b 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
.field input:focus,
.field select:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.12);
}

.check-field {
  justify-content: flex-end;
}
.toggle {
  display: inline-flex;
  align-items: center;
  width: 46px;
  height: 26px;
  position: relative;
}
.toggle input { display: none; }
.toggle span {
  width: 100%;
  height: 100%;
  border-radius: 999px;
  background: #d1d5db;
  transition: background .15s;
  position: relative;
}
.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform .15s;
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
}
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(20px); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 4px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: transform .1s, background .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: #0a5c5c; }
.btn:disabled,
.btn.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}
.btn.primary:disabled:hover { background: var(--accent); }
.btn.ghost {
  background: #fff;
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn.ghost:hover { background: #f5f6f8; }
.btn.danger {
  background: #fff;
  border-color: #f2c2bf;
  color: var(--danger);
}
.btn.danger:hover { background: #fff5f4; }

.status-line {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: #f5f6f8;
  color: var(--muted);
  font-size: 0.88rem;
  border: 1px dashed var(--line);
}
.status-line.ok {
  background: #ecfdf3;
  color: var(--ok);
  border-color: #abefc6;
}
.status-line.err {
  background: #fef3f2;
  color: var(--danger);
  border-color: #fecdca;
}

.relay-set-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  margin-bottom: 12px;
}
.explain {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.ch-preview,
.ch-board {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 8px 0 16px;
  align-items: stretch;
}

.ch-pair-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 10px 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff7f1 0%, #ffefe3 100%);
  border: 1.5px solid #e8b08a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
  min-width: calc(25% - 12px);
  flex: 1 1 200px;
  max-width: 280px;
}
.ch-pair-group.lit {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.65),
    0 8px 18px rgba(196, 92, 38, 0.12);
}
.ch-pair-tag {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--pair);
  padding: 3px 9px;
  border-radius: 999px;
}
.ch-pair-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: center;
}
.ch-pair-link {
  width: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ch-pair-link span {
  display: block;
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: linear-gradient(90deg, #e8b08a, #c45c26, #e8b08a);
  position: relative;
}
.ch-pair-link span::before,
.ch-pair-link span::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c45c26;
  transform: translateY(-50%);
  box-shadow: 0 0 0 3px rgba(196, 92, 38, 0.15);
}
.ch-pair-link span::before { left: -2px; }
.ch-pair-link span::after { right: -2px; }

.ch-cell {
  aspect-ratio: 1;
  min-width: 64px;
  max-width: 88px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f0f1f3;
  color: #9aa1ab;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: var(--display);
  font-weight: 650;
  font-size: 1.05rem;
  transition: background .2s, border-color .2s, color .2s, box-shadow .2s, transform .15s;
  justify-self: center;
}
.ch-pair-group .ch-cell {
  max-width: none;
  border-color: transparent;
  background: rgba(255, 255, 255, 0.82);
  color: var(--pair);
  box-shadow: 0 1px 2px rgba(196, 92, 38, 0.08);
}
.ch-cell small {
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.ch-cell.pair {
  color: var(--pair);
}
.ch-cell.switch {
  background: var(--switch-soft);
  border-color: #c7d7ff;
  color: var(--switch);
  box-shadow: inset 0 0 0 1px rgba(47, 111, 237, 0.08);
  flex: 0 0 72px;
}
.ch-cell.lit:not(.dim) {
  transform: translateY(-1px);
}
.ch-cell.switch.lit {
  box-shadow: 0 6px 16px rgba(47, 111, 237, 0.12);
}
.ch-cell.dim {
  opacity: 0.55;
  flex: 0 0 72px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  font-size: 0.82rem;
  color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}
.swatch.pair { background: var(--pair); }
.swatch.switch { background: var(--switch); }
.swatch.dim { background: #c5c9d0; }
.swatch.delay-off { background: #c5c9d0; }
.swatch.delay-idle { background: var(--accent); }
.swatch.delay-run { background: #ca8a04; }
.swatch.delay-done { background: var(--pair); }

.delay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 8px 0 4px;
}
.delay-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fcfcfd;
  cursor: default;
}
.delay-ch {
  font-size: 0.86rem;
  font-weight: 700;
  color: #334155;
}
.delay-field {
  display: flex;
  align-items: center;
  gap: 6px;
}
.delay-field input {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}
.delay-field em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.8rem;
}
.delay-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
}
.delay-q-card {
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: #f8fafc;
}
.delay-q-card.off { opacity: 0.72; }
.delay-q-card.idle {
  border-color: #9fd0d0;
  background: var(--accent-soft);
}
.delay-q-card.run {
  border-color: #f0d48a;
  background: #fffbeb;
}
.delay-q-card.done {
  border-color: #e8b08a;
  background: var(--pair-soft);
}
.delay-q-ch {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
}
.delay-q-sec {
  margin-top: 6px;
  font-size: 1.45rem;
  font-weight: 700;
  font-family: var(--display);
  color: var(--ink);
}
.delay-q-sec small {
  margin-left: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
.delay-q-meta {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.query-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.mqtt-raw {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #f8fafb;
}
.feature-body .mqtt-raw {
  margin-top: 16px;
}
.mqtt-raw-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.mqtt-raw-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.02em;
}
.mqtt-raw-row {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 8px;
}
.mqtt-raw-tag {
  margin-top: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  text-align: center;
  white-space: nowrap;
}
.mqtt-raw-row[data-dir="tx"] .mqtt-raw-tag {
  color: #0f766e;
  background: #ccfbf1;
}
.mqtt-raw-row[data-dir="rx"] .mqtt-raw-tag {
  color: #1d4ed8;
  background: #dbeafe;
}
.mqtt-raw-body {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e8edf2;
  color: #0f172a;
  font-size: 0.8rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  min-height: 2.4em;
  max-height: 110px;
  overflow: auto;
}
.mqtt-raw-body.is-empty {
  color: #94a3b8;
  font-family: var(--font, inherit);
}

/* 传感器多套配置 */
.sensor-sets {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 8px;
}
.sensor-set-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfcfd;
  padding: 14px 16px 16px;
}
.sensor-set-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--line);
}
.sensor-set-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 0.98rem;
}
.sensor-addr-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}
.sensor-set-addr {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--muted);
}
.sensor-set-addr em {
  font-size: 0.72rem;
  color: #94a3b8;
}
.sensor-set-addr input {
  width: 72px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
}
.sensor-group-label {
  margin: 12px 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.02em;
}
.sensor-type-chip.soil.on {
  border-color: #f0c3a4;
  background: var(--pair-soft);
}
.sensor-type-chip.soil.on .type-idx {
  background: var(--pair);
}
.sensor-type-chip.soil.on .type-name { color: #7a3b12; }
.sensor-type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 8px;
}
.sensor-type-chip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, color .15s;
}
.sensor-type-chip input { margin-top: 2px; accent-color: var(--accent); }
.sensor-type-chip .type-idx {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 6px;
  background: #eef2f6;
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sensor-type-chip .type-name {
  font-size: 0.8rem;
  line-height: 1.3;
  color: #334155;
}
.sensor-type-chip.on {
  border-color: #9fd0d0;
  background: var(--accent-soft);
}
.sensor-type-chip.on .type-idx {
  background: var(--accent);
  color: #fff;
}
.sensor-type-chip.on .type-name { color: #0f3d3d; font-weight: 600; }
.sensor-sets-empty {
  padding: 22px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #fafbfc;
}
.sensor-sync-tip {
  margin-left: 8px;
  font-family: var(--font);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
}
.sensor-set-card.types-synced .sensor-type-grid {
  opacity: 0.92;
}

/* LED / 232 功能卡 */
.feature-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.feature-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 22px 24px;
  background:
    linear-gradient(120deg, rgba(13, 110, 110, 0.06), transparent 55%),
    #fff;
  border-bottom: 1px solid var(--line);
}
.feature-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  position: relative;
  flex-shrink: 0;
}
.feature-icon.led-ico {
  background: linear-gradient(145deg, #0d9488, #134e4a);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.feature-icon.led-ico::before,
.feature-icon.led-ico::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: rgba(255,255,255,0.85);
}
.feature-icon.led-ico::before {
  width: 18px;
  height: 10px;
  left: 15px;
  top: 14px;
  box-shadow: 0 12px 0 rgba(255,255,255,0.55);
}
.feature-icon.led-ico::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  right: 12px;
  bottom: 12px;
  background: #fde68a;
  box-shadow: 0 0 8px #fbbf24;
}
.feature-icon.uart-ico {
  background: linear-gradient(145deg, #2563eb, #1e3a8a);
}
.feature-icon.uart-ico::before {
  content: "";
  position: absolute;
  inset: 14px 12px;
  border: 2px solid rgba(255,255,255,0.85);
  border-radius: 6px;
}
.feature-icon.uart-ico::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 22px;
  height: 2px;
  background: rgba(255,255,255,0.7);
  box-shadow: 0 6px 0 rgba(255,255,255,0.45);
}
.feature-icon.gps-ico {
  background: linear-gradient(145deg, #059669, #064e3b);
}
.feature-icon.gps-ico::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  border: 2px solid rgba(255,255,255,0.9);
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-sizing: border-box;
}
.feature-icon.gps-ico::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 17px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: #fde68a;
  box-shadow: 0 14px 0 -1px rgba(255,255,255,0.55), 0 14px 0 1px rgba(255,255,255,0.25);
}
.feature-titles h2 {
  margin: 0;
  font-size: 1.15rem;
  font-family: var(--display);
  font-weight: 700;
}
.feature-titles p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}
.feature-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: #f8fafc;
  color: var(--muted);
  white-space: nowrap;
}
.feature-status .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
}
.feature-status[data-state="ok"] {
  background: #ecfdf3;
  border-color: #abefc6;
  color: var(--ok);
}
.feature-status[data-state="ok"] .status-dot {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(6, 118, 71, 0.15);
}
.feature-status[data-state="fail"] {
  background: #fef3f2;
  border-color: #fecdca;
  color: var(--danger);
}
.feature-status[data-state="fail"] .status-dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12);
}
.feature-status[data-state="pending"] {
  background: #fffbeb;
  border-color: #fde68a;
  color: #b45309;
}
.feature-status[data-state="pending"] .status-dot {
  background: #f59e0b;
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.feature-body { padding: 22px 24px 24px; }
.enable-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  border-radius: 12px;
  background: #f8fafb;
  border: 1px solid var(--line);
}
.enable-row.period-row { margin-top: 12px; }
.period-field {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
}
.period-field input {
  width: 100px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
.period-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 110, 110, 0.12);
}
.period-unit {
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 500;
}
.enable-label {
  font-weight: 650;
  font-size: 0.98rem;
}
.enable-desc {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}
.toggle.locked {
  opacity: 0.85;
  cursor: not-allowed;
  pointer-events: none;
}
.toggle.locked span {
  background: #d1d5db;
}
.toggle.locked input:checked + span {
  background: var(--accent);
  opacity: 1;
}
.toggle.big {
  width: 54px;
  height: 30px;
}
.toggle.big span::after {
  width: 24px;
  height: 24px;
}
.toggle.big input:checked + span::after {
  transform: translateX(24px);
}
.feature-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  justify-content: flex-end;
}

@media (max-width: 860px) {
  .feature-top {
    grid-template-columns: auto 1fr;
  }
  .feature-status {
    grid-column: 1 / -1;
    justify-self: start;
  }
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  min-width: 200px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-size: 0.88rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: #065f46; }
.toast.error { background: #912018; }

/* 等待回执：全屏加载圈，拦截点击 */
.wait-mask {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 31, 36, 0.45);
  cursor: wait;
}
.wait-mask.show {
  display: flex;
}
.wait-dialog {
  min-width: 200px;
  padding: 28px 32px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--line);
}
.wait-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 14px;
  border: 3px solid var(--line);
  border-top-color: var(--accent, #1a7f5a);
  border-radius: 50%;
  animation: wait-spin 0.75s linear infinite;
}
@keyframes wait-spin {
  to { transform: rotate(360deg); }
}
.wait-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
.wait-hint {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
}

/* 继电器配置/查询成功弹窗：点击任意处关闭 */
.result-mask {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 31, 36, 0.38);
  cursor: pointer;
}
.result-mask.show {
  display: flex;
}
.result-dialog {
  min-width: 220px;
  max-width: 360px;
  padding: 28px 36px 22px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  border: 1px solid var(--line);
  cursor: pointer;
}
.result-dialog.is-wide {
  max-width: 440px;
  text-align: left;
}
.result-text {
  margin: 0;
  font-family: var(--display);
  font-size: 1.35rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  color: var(--ok);
}
.result-text.is-multiline {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.55;
  white-space: pre-line;
}
.result-text.is-error {
  color: var(--danger);
}
.result-hint {
  margin: 12px 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.confirm-dialog {
  cursor: default;
}
.confirm-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}
.confirm-actions .btn {
  min-width: 88px;
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
  }
  .nav { flex-direction: row; flex-wrap: wrap; gap: 6px; }
  .nav-group { width: 100%; padding-top: 4px; }
  .main { padding: 20px 16px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span2 { grid-column: auto; }
  .ch-preview, .ch-board { gap: 8px; }
  .ch-pair-group { min-width: 100%; max-width: none; }
  .ch-cell { font-size: 0.9rem; border-radius: 8px; }
}
