:root {
  --bg: #f1f5f9;
  --card: #ffffff;
  --ink: #0f172a;
  --ink2: #475569;
  --line: #e2e8f0;
  --accent: #6366f1;
  --ok: #059669;
  --err: #dc2626;
  --c-awake: #fb923c;
  --c-rem: #22d3ee;
  --c-core: #6366f1;
  --c-deep: #1e40af;
  --c-unspec: #9ca3af;
  --c-inbed: #eef2f7;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过所有 display 规则(如 .controls 的 flex) */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-text-size-adjust: 100%;
}

header {
  padding: 20px 16px 4px;
  max-width: 1080px;
  margin: 0 auto;
}
header h1 { font-size: 22px; margin: 0; }
header h1 span { font-size: 14px; font-weight: 500; color: var(--ink2); margin-left: 6px; }
header .sub { margin: 6px 0 0; font-size: 13px; color: var(--ink2); }

main { max-width: 1080px; margin: 0 auto; padding: 12px 12px 40px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  margin-top: 12px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}
.card h2 { font-size: 15px; margin: 0 0 10px; }

.uploads { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .uploads { grid-template-columns: 1fr; } }

.upload-card .card-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; }

.drop {
  display: block;
  border: 1.5px dashed #c7d2fe;
  border-radius: 10px;
  padding: 18px 12px;
  text-align: center;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.drop:hover, .drop.dragover { background: #eef2ff; border-color: var(--accent); }
.drop input[type=file] { display: none; }
.drop-hint { font-size: 13px; color: var(--ink2); }

.progress { height: 8px; background: var(--line); border-radius: 4px; margin-top: 10px; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--accent); border-radius: 4px; transition: width .1s; }

.status { font-size: 13px; margin-top: 8px; color: var(--ink2); min-height: 1em; word-break: break-all; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

.controls { display: flex; flex-wrap: wrap; gap: 14px 24px; align-items: center; }
.controls label { font-size: 13px; color: var(--ink2); display: flex; align-items: center; gap: 8px; }
.controls select, .controls input[type=number] {
  font-size: 14px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.controls input[type=number] { width: 88px; }

.notice {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
}

.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: var(--ink2); margin-bottom: 8px; }
.legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

#chart-wrap { position: relative; width: 100%; }
#chart { display: block; width: 100%; touch-action: pan-y; }

.tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, .92);
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.5;
  padding: 6px 9px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 5;
  transform: translate(-50%, 0);
}

.prop-row { margin: 10px 0 14px; }
.prop-label { font-size: 12px; color: var(--ink2); margin-bottom: 4px; }
.prop-bar { display: flex; height: 26px; border-radius: 7px; overflow: hidden; background: var(--line); }
.prop-seg { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 11px; min-width: 0; overflow: hidden; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { color: var(--ink2); font-weight: 600; background: #f8fafc; }
tr.hl td { font-weight: 600; background: #f8fafc; }
td.pos { color: var(--ok); }
td.neg { color: var(--err); }

.agree-top { display: flex; flex-wrap: wrap; gap: 10px 28px; align-items: baseline; margin-bottom: 10px; }
.agree-big { font-size: 34px; font-weight: 700; color: var(--accent); }
.agree-big small { font-size: 13px; color: var(--ink2); font-weight: 500; margin-left: 4px; }
.agree-kv { font-size: 13px; color: var(--ink2); }
.agree-kv b { color: var(--ink); }

.conf-table td, .conf-table th { text-align: center; padding: 6px 8px; }
.conf-table td.diag { font-weight: 700; }

.agree-notes { margin: 10px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--ink2); }
.agree-notes li { margin: 3px 0; }

.del-btn, .view-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
}
.del-btn { color: var(--err); }
.del-btn:hover { background: #fef2f2; }
.view-btn { color: var(--accent); margin-right: 6px; }
.view-btn:hover { background: #eef2ff; }

footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px 30px;
  font-size: 12px;
  color: #94a3b8;
  text-align: center;
}

/* ---------- 服务端版追加样式 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 32px 28px; width: 320px; max-width: 90vw; text-align: center;
  box-shadow: 0 4px 24px rgba(15,23,42,.08);
}
.login-card h2 { margin: 0 0 4px; }
.login-card p { margin: 0 0 16px; font-size: 13px; color: var(--ink2); }
.login-card input {
  width: 100%; font-size: 15px; padding: 10px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px;
}
.login-card button {
  width: 100%; font-size: 15px; padding: 10px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; cursor: pointer;
}
.login-card button:hover { opacity: .92; }
.controls input[type=text] { font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; width: 180px; }
tr.night-row { cursor: pointer; }
tr.night-row:hover td { background: #f8fafc; }
tr.night-row.active td { background: #eef2ff; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 9px; margin-left: 4px; }
.tag.apple { background: #ffedd5; color: #9a3412; }
.tag.radar { background: #e0e7ff; color: #3730a3; }

/* ================= 两 Tab 外壳 ================= */
.topbar { max-width: 1080px; margin: 0 auto; display: flex; align-items: center; gap: 18px; }
.topbar h1 { font-size: 20px; margin: 0; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--ink2);
  font-size: 15px; padding: 8px 14px; cursor: pointer; border-radius: 0; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px;
  font-size: 17px; cursor: pointer; color: var(--ink2); }
.icon-btn:hover { background: #f1f5f9; }
#logout-link { font-size: 13px; color: #94a3b8; }
.tab-panel { }

/* 通用按钮 */
.primary-btn { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 8px 16px;
  font-size: 14px; cursor: pointer; }
.primary-btn:hover { opacity: .92; }
.primary-btn.danger { background: var(--err); }
.ghost-btn { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 7px 14px;
  font-size: 14px; cursor: pointer; color: var(--ink); text-decoration: none; display: inline-block; }
.ghost-btn:hover { background: #f1f5f9; }

/* ================= 实时监测 Tab ================= */
.rt-bar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rt-status-group { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink2); }
.sep-v { width: 1px; height: 22px; background: var(--line); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; display: inline-block; flex-shrink: 0; }
.dot.green { background: #22c55e; } .dot.amber { background: #f59e0b; }
.dot.red { background: #ef4444; } .dot.gray { background: #cbd5e1; }
.badge { padding: 3px 12px; border-radius: 12px; font-size: 12px; font-weight: 600; margin-left: auto; }
.badge.live { background: #dcfce7; color: #15803d; }
.badge.standby { background: #f1f5f9; color: #64748b; }

.rt-offline h2 { font-size: 16px; margin: 0 0 8px; }
.rt-offline p { font-size: 14px; color: var(--ink2); margin: 0 0 10px; line-height: 1.6; }
.rt-steps { margin: 0 0 14px; padding-left: 22px; font-size: 14px; color: var(--ink2); line-height: 1.9; }
.rt-steps code, .rt-offline code, .field-hint code, .modal-sub code { background: #f1f5f9; padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.rt-offline-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.rt-hint { font-size: 12px; color: #94a3b8; margin: 12px 0 0; }

.rt-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.rt-controls label { font-size: 13px; color: var(--ink2); display: flex; align-items: center; gap: 6px; }
.rt-controls select { font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.lat-group { display: flex; gap: 4px; }
.lat-btn { background: #f1f5f9; color: var(--ink2); border: 1px solid transparent; border-radius: 7px;
  padding: 5px 12px; font-size: 13px; cursor: pointer; }
.lat-btn:hover { background: #e2e8f0; }
.lat-btn.active { background: var(--accent); color: #fff; }
.lat-btn:disabled { opacity: .45; cursor: not-allowed; }

.rt-grid { display: grid; grid-template-columns: 300px 1fr; gap: 12px; margin-top: 12px; }
@media (max-width: 760px) { .rt-grid { grid-template-columns: 1fr; } }
.rt-left { display: flex; flex-direction: column; gap: 12px; }
.rt-right { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.stage-card { text-align: center; padding: 22px 16px; }
.rt-muted { font-size: 13px; color: var(--ink2); }
.rt-stage-name { font-size: 34px; font-weight: 700; margin: 4px 0; }
.rt-prob { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; color: var(--ink2); }
.rt-prob > span:first-child { width: 52px; }
.rt-prob > span:last-child { width: 44px; text-align: right; }
.rt-prob-bg { flex: 1; height: 14px; background: #f1f5f9; border-radius: 4px; overflow: hidden; }
.rt-prob-bar { height: 100%; width: 0%; border-radius: 4px; transition: width .3s; }
.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--ink2); }
.stat-row b { font-weight: 500; }
.stat-row b.small { font-size: 11px; color: var(--ink2); font-weight: 400; }
.rt-chart { position: relative; height: 200px; padding: 0; overflow: hidden; }
.rt-chart canvas { width: 100%; height: 100%; display: block; }
.rt-chart-title { position: absolute; top: 8px; left: 12px; font-size: 12px; color: var(--ink2); z-index: 1; pointer-events: none; }
.rt-chart-badge { position: absolute; top: 8px; right: 12px; font-size: 11px; color: #94a3b8; z-index: 1; pointer-events: none; }
.rt-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #0f172a; color: #f8fafc;
  padding: 12px 18px; border-radius: 10px; font-size: 13px; max-width: 90vw; z-index: 60; box-shadow: 0 4px 16px rgba(0,0,0,.2); }

/* ================= 设置弹窗 ================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center;
  justify-content: center; z-index: 80; }
.modal-card { background: var(--card); border-radius: 14px; padding: 24px; width: 460px; max-width: 92vw;
  box-shadow: 0 8px 40px rgba(15,23,42,.2); }
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-sub { font-size: 13px; color: var(--ink2); margin: 0 0 18px; line-height: 1.6; }
.field { display: block; font-size: 13px; color: var(--ink); margin-bottom: 4px; }
.field input { width: 100%; font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-top: 6px; }
.field-hint { font-size: 12px; color: #94a3b8; margin: 4px 0 16px; line-height: 1.5; }
.modal-buttons { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* 实时模式切换与标签 */
.rt-mode-switch { margin-left: auto; font-size: 12px; color: var(--accent); text-decoration: none; }
.rt-mode-switch:hover { text-decoration: underline; }
.rt-rec-tag { font-size: 12px; font-weight: 500; color: #15803d; background: #dcfce7; padding: 2px 10px; border-radius: 10px; margin-left: 6px; vertical-align: middle; }
.rt-controls input[type=text] { font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }

/* 设置分区 */
.modal-card { max-height: 86vh; overflow-y: auto; }
.set-section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.set-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.set-section-title { font-size: 14px; font-weight: 600; margin-bottom: 10px; color: var(--ink); }
#set-download { margin-top: 6px; }
.set-spec { margin-top: 8px; }
.set-spec summary { font-size: 13px; color: var(--accent); cursor: pointer; }
.set-spec pre { background: #f8fafc; border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  font-size: 11.5px; line-height: 1.6; overflow-x: auto; margin-top: 8px; color: var(--ink2);
  white-space: pre-wrap; word-break: break-word; }
