:root {
  --bg: #0c1210;
  --sidebar: #111a16;
  --panel: #16241e;
  --line: #2a4036;
  --text: #e7f1eb;
  --muted: #93ad9f;
  --accent: #3dba7e;
  --accent-dim: rgba(61, 186, 126, 0.14);
  --warn: #d9a116;
  --danger: #e25555;
  --side-w: 220px;
  --alert-w: 300px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
.app-root { min-height: 100vh; display: flex; flex-direction: column; }
.app-root > .login-wrap,
.app-root > .shell { flex: 1 1 auto; }
.icp-footer {
  flex: 0 0 auto;
  text-align: center;
  padding: 0.65rem 1rem 1rem;
  font-size: 0.82rem;
  line-height: 1.4;
}
.icp-footer a {
  color: var(--muted);
  text-decoration: none;
}
.icp-footer a:hover { color: var(--text); text-decoration: underline; }
button, input, select, textarea { font: inherit; }
button {
  border: 0; border-radius: 8px; padding: 0.5rem 0.85rem; cursor: pointer;
  background: var(--accent); color: #062015; font-weight: 600;
}
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
button.danger { background: var(--danger); color: #fff; }
button.warn { background: var(--warn); color: #241800; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.mode-btn {
  background: #2a3832; color: var(--muted); border: 1px solid var(--line);
}
button.mode-btn.active {
  background: var(--accent); color: #062015; border-color: transparent;
}
button.mode-btn:disabled {
  opacity: 1; cursor: default;
}
button.mode-btn:not(.active):disabled {
  opacity: 0.45; cursor: not-allowed;
}
fieldset:disabled {
  opacity: 0.55;
  pointer-events: none;
}
input, select, textarea {
  width: 100%; padding: 0.65rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--line); background: #0c1411; color: var(--text); margin: 0.35rem 0 0.7rem;
}
textarea { min-height: 72px; resize: vertical; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; }
.muted { color: var(--muted); font-size: 0.92rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.pi-ota-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 0.75rem;
  align-items: center;
  margin: 0.35rem 0 0.7rem;
}
.pi-ota-form input[type="text"] { width: auto; min-width: 0; margin: 0; }
.pi-ota-form button { margin: 0; white-space: nowrap; }
.bridge-ota-form {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto minmax(9rem, 16rem) auto;
  gap: 0.75rem;
  align-items: center;
  margin: 0.35rem 0 0.7rem;
}
.bridge-ota-form input[type="text"] { width: auto; min-width: 0; margin: 0; }
.bridge-ota-form button { margin: 0; white-space: nowrap; }
.bridge-ota-form .bridge-note { grid-column: 2 / -1; }
.pi-ota-label { white-space: nowrap; color: var(--muted); font-size: 0.88rem; }
label.file-btn {
  display: inline-flex; align-items: center; margin: 0; white-space: nowrap;
  border-radius: 8px; padding: 0.5rem 0.85rem; cursor: pointer;
  background: var(--accent); color: #062015; font-weight: 600; font-size: 1rem;
}
label.file-btn input { display: none; }
label.file-btn.disabled { opacity: 0.45; pointer-events: none; }
.grid { display: grid; gap: 0.75rem; }
.grid.sites { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.grid.nodes { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.metrics { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.75rem; }
@media (max-width: 1200px) {
  .grid.metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid.metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.metric-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 0.9rem 1rem; min-height: 84px; display: flex; flex-direction: column; justify-content: space-between;
}
.metric-card .metric-label { color: var(--muted); font-size: 0.86rem; }
.metric-card .metric-value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; margin-top: 0.35rem; }
.metric-card .metric-value.ok { color: var(--accent); }
.metric-card .metric-value.bad { color: #ff9b9b; }
.login-wrap { min-height: 0; flex: 1; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(420px, 100%); }
.site-card { cursor: pointer; transition: border-color .15s; }
.site-card:hover { border-color: var(--accent); }
.node {
  border: 1px solid var(--line); border-radius: 12px; padding: 0.85rem 0.9rem 0.95rem;
  background: #121c18; display: flex; flex-direction: column; gap: 0.55rem;
}
.node.open { border-color: rgba(61,186,126,.55); box-shadow: inset 0 0 0 1px rgba(61,186,126,.12); }
.node.disabled { opacity: 0.55; }
.node-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.node-head strong { font-size: 1.05rem; letter-spacing: 0.02em; }
.node-valve {
  display: grid; place-items: center; min-height: 132px;
  background: linear-gradient(180deg, #1a2620 0%, #101814 100%);
  border: 1px solid rgba(255,255,255,0.04); border-radius: 10px; padding: 0.45rem;
}
.node-valve img {
  width: 100%; max-width: 168px; height: 118px; object-fit: contain; display: block;
}
.node-meta { display: grid; gap: 0.38rem; padding-top: 0.15rem; border-top: 1px solid var(--line); }
.node-meta-row {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  font-size: 0.86rem; color: var(--muted);
}
.node-meta-row .v { color: var(--text); }
.node-meta-row .v.on { color: var(--accent); font-weight: 600; }
.node-meta-row .v.off { color: #ff9b9b; font-weight: 600; }
.signal-bars { display: inline-flex; align-items: flex-end; gap: 2px; height: 14px; }
.signal-bars i {
  display: block; width: 3px; border-radius: 1px; background: #3a4f45;
}
.signal-bars i.on { background: var(--accent); }
.signal-bars i:nth-child(1) { height: 4px; }
.signal-bars i:nth-child(2) { height: 6px; }
.signal-bars i:nth-child(3) { height: 8px; }
.signal-bars i:nth-child(4) { height: 11px; }
.signal-bars i:nth-child(5) { height: 14px; }
.tag { display: inline-block; font-size: 0.72rem; padding: 0.12rem 0.4rem; border-radius: 999px; background: #243f34; }
.tag.on { background: rgba(61,186,126,.2); color: var(--accent); }
.tag.off { background: rgba(226,85,85,.15); color: #ff9b9b; }
.tag.idle { background: rgba(90,160,200,.18); color: #9ad4f0; }
.tag.muted { background: rgba(147,173,159,.15); color: var(--muted); }
.node.offline { opacity: 0.88; }
.node.unreg { opacity: 0.55; }
.tag.warn { background: rgba(217,161,22,.2); color: #f0c75a; }
.tag.danger { background: rgba(226,85,85,.2); color: #ff9b9b; }
.stat { font-size: 1.35rem; font-weight: 700; }
.err { color: #ff9b9b; min-height: 1.2em; }
.field-hint { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 400; margin: 0.15rem 0 0; }
/* 轮灌表单：说明文字行数不同时，输入框仍与同行对齐 */
.prog-form-grid > label {
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.prog-form-grid > label > input,
.prog-form-grid > label > select {
  margin-top: auto;
}
.prog-form-grid > label > .field-err {
  margin-top: 0.25rem;
}
.field-err { display: block; font-size: 0.78rem; color: #ff9b9b; margin: -0.35rem 0 0.55rem; }
input.invalid, select.invalid { border-color: #e25555; }
.report-tabs {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
  border-bottom: 1px solid var(--line); padding-bottom: 0.75rem;
}
.report-tab {
  background: #2a3832; color: var(--muted); border: 1px solid var(--line);
  border-radius: 999px; padding: 0.4rem 0.9rem; font-weight: 600;
}
.report-tab.active {
  background: var(--accent); color: #062015; border-color: transparent;
}
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 0.85rem; word-break: break-all; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
td, th { border-bottom: 1px solid var(--line); padding: 0.45rem 0.3rem; text-align: left; }
.radio-log td, .radio-log th {
  padding: 0.45rem 0.3rem;
  line-height: 1.35;
  vertical-align: middle;
}
.radio-log .raw-btn {
  padding: 0.12rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.2;
  border-radius: 6px;
  font-weight: 600;
}
.data-table .col-ops {
  width: 280px;
  min-width: 280px;
  text-align: right;
  white-space: nowrap;
  vertical-align: middle;
}
.data-table .ops {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
  align-items: center;
}
.data-table .ops button { margin: 0; }
.scope-list {
  height: auto;
  min-height: 10rem;
  margin-top: 0.25rem;
}
h1,h2,h3 { margin: 0 0 0.4rem; }
label { display: block; font-size: 0.88rem; color: var(--muted); }
.check-list { display: grid; gap: 0.35rem; margin: 0.5rem 0 0.8rem; }
.check-list label { display: flex; align-items: center; gap: 0.45rem; color: var(--text); }
.check-list input { width: auto; margin: 0; }

.shell { display: flex; min-height: 0; flex: 1; }
.sidebar {
  width: var(--side-w); flex-shrink: 0; background: var(--sidebar);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { padding: 1.1rem 1rem 0.9rem; border-bottom: 1px solid var(--line); }
.side-brand .title { font-weight: 700; font-size: 1.05rem; }
.side-brand .sub { color: var(--muted); font-size: 0.8rem; margin-top: 0.25rem; }
.side-nav { flex: 1; padding: 0.75rem 0.55rem; overflow-y: auto; }
.nav-group { margin-bottom: 0.85rem; }
.nav-label {
  font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); padding: 0.35rem 0.65rem 0.45rem;
}
.nav-item {
  display: block; width: 100%; text-align: left; border: 0; border-radius: 8px;
  background: transparent; color: var(--text); font-weight: 500;
  padding: 0.55rem 0.7rem; margin-bottom: 0.2rem; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.04); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-item.sub { padding-left: 1.1rem; font-size: 0.92rem; }
.side-foot {
  padding: 0.85rem 1rem; border-top: 1px solid var(--line); font-size: 0.85rem;
}
.side-foot .nav-item.active { background: var(--accent-dim); color: var(--accent); }
.side-foot .user { font-weight: 600; margin-bottom: 0.45rem; }

.center-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.workspace { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.work-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0.85rem 1.25rem; border-bottom: 1px solid var(--line);
  background: rgba(14,22,19,0.85); position: sticky; top: 0; z-index: 5;
}
.work-header h2 { margin: 0; font-size: 1.15rem; }
.work-main { padding: 1.1rem 1.25rem 2rem; display: grid; gap: 1rem; width: 100%; }
.menu-toggle {
  display: none; border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 8px; padding: 0.4rem 0.65rem;
}
.sidebar-mask {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 20;
}

.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 90; display: flex; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; width: min(720px, 100%);
  max-height: min(80vh, 760px); overflow: auto;
  padding: 1rem 1.15rem 1.2rem;
  box-shadow: 0 18px 48px rgba(0,0,0,0.5);
}
.modal-panel h3 { margin: 0; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.alert-rail {
  width: var(--alert-w); flex-shrink: 0; border-left: 1px solid var(--line);
  background: #0f1713; height: 100vh; position: sticky; top: 0;
  display: flex; flex-direction: column;
}
.alert-rail .rail-head { padding: 0.95rem 1rem; border-bottom: 1px solid var(--line); }
.alert-rail .rail-head-top {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
}
.alert-rail .rail-head h3 { margin: 0; font-size: 1rem; }
.alert-rail .rail-more {
  padding: 0.2rem 0.55rem; font-size: 0.78rem; font-weight: 600; border-radius: 6px;
}
.alert-rail .rail-body {
  flex: 1; overflow: hidden; padding: 0.75rem; display: grid; gap: 0.65rem; align-content: start;
}
.rail-section-label {
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em;
  color: var(--muted, #8aa090); padding: 0.35rem 0.15rem 0; text-transform: none;
}
.rail-section-head {
  display: flex; justify-content: space-between; align-items: center; gap: 0.5rem;
  padding: 0.2rem 0.15rem 0;
}
.notice-item { border-color: #2f6b4f; }
.ota-file-grid {
  display: grid; gap: 0.85rem; margin-top: 0.5rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.ota-file-grid input[type="file"] { width: 100%; font-size: 0.82rem; }
.ota-status-grid {
  display: grid; gap: 0.75rem; margin-top: 0.65rem;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}
.ota-ver-table { width: 100%; border-collapse: collapse; margin-top: 0.35rem; }
.ota-ver-table th, .ota-ver-table td {
  text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.ota-ver-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.ota-queue-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.ota-queue-table th, .ota-queue-table td {
  text-align: left; padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.ota-queue-table th { color: var(--muted); font-weight: 600; font-size: 0.78rem; }
.ota-queue-table tr.ota-row-active td {
  background: rgba(217, 161, 22, 0.12);
}
.ota-progress {
  border: 1px solid var(--line); border-radius: 10px; padding: 0.75rem 0.85rem;
  background: #0f1713;
}
.bridge-write-progress { margin-top: 0.85rem; }
.bridge-write-bar {
  height: 8px; border-radius: 99px; background: #1c2a22; overflow: hidden; margin-top: 0.35rem;
}
.bridge-write-bar > div { height: 100%; background: var(--accent); width: 0; }
.node-fw-id { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.85rem; }
.node-fw-id input { width: 100%; max-width: 8rem; margin: 0; font-size: 1.05rem; }
.node-fw-actions { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.85rem; }
.node-fw-actions button { width: 100%; margin: 0; min-height: 2.75rem; }
.node-fw-check { display: flex; align-items: flex-start; gap: 0.55rem; margin-top: 0.85rem; color: var(--muted); }
.node-fw-check input { width: 1.15rem; height: 1.15rem; margin: 0.15rem 0 0; flex: 0 0 auto; }
.node-fw-step { margin-top: 0.85rem; word-break: break-word; }
.node-fw-step.bad { color: var(--danger); }
@media (min-width: 720px) {
  .node-fw-actions { flex-direction: row; flex-wrap: wrap; }
  .node-fw-actions button { width: auto; min-width: 8.5rem; }
}
.pager {
  display: flex; justify-content: space-between; align-items: center; gap: 0.75rem;
  flex-wrap: wrap; margin-top: 0.85rem;
}
.pager button:disabled { opacity: 0.45; cursor: not-allowed; }
.pager-actions { align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.pager-jump {
  display: inline-flex; align-items: center; gap: 0.3rem;
  margin: 0; font-size: 0.88rem; color: var(--muted, #8aa090);
}
.pager-jump input {
  width: 3.2rem; padding: 0.28rem 0.35rem; text-align: center; margin: 0;
  border: 1px solid var(--line); border-radius: 6px;
  background: #0f1713; color: var(--text);
}
.alert-item {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem 0.75rem;
}
.alert-item.acked { opacity: 0.55; }
.alert-item .msg { margin: 0.35rem 0; font-size: 0.9rem; line-height: 1.4; }
.alert-toggle {
  display: none; border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 8px; padding: 0.4rem 0.65rem; position: relative;
}
.alert-toggle .badge {
  position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff;
  border-radius: 999px; font-size: 0.65rem; min-width: 1.1rem; height: 1.1rem;
  display: grid; place-items: center; padding: 0 0.2rem;
}
.alert-drawer-mask { display: none; }

@media (max-width: 1100px) {
  .alert-rail {
    position: fixed; right: 0; top: 0; z-index: 35;
    transform: translateX(105%); transition: transform .2s ease;
  }
  .alert-rail.open { transform: translateX(0); }
  .alert-toggle { display: inline-block; }
  .alert-drawer-mask.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 34;
  }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 30;
    transform: translateX(-105%); transition: transform .2s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-mask.show { display: block; }
  .menu-toggle { display: inline-block; }
  .work-main { padding: 1rem; }
}
