:root {
  --bg: #12151a;
  --panel: #1b2027;
  --panel2: #232a33;
  --line: #2e3742;
  --text: #e8edf2;
  --muted: #8c99a6;
  --green: #1f9d55;
  --green-bg: #133d26;
  --yellow: #d6a21e;
  --orange: #e2701d;
  --red: #e0393e;
  --red-bg: #4a1517;
  --gray: #59636e;
  --blue: #3b82f6;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Microsoft YaHei", "PingFang SC", sans-serif; }
[hidden] { display: none !important; }
a { color: var(--text); text-decoration: none; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Consolas, monospace; }
.err { color: var(--red); min-height: 1.5em; margin: 0; }
.warn-text { color: var(--yellow); font-weight: 600; }

.btn { background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 14px; font: inherit; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: #4a5664; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.small { padding: 3px 10px; }
.btn.danger { background: var(--red-bg); border-color: var(--red); color: #fff; }
.btn.on { background: var(--blue); border-color: var(--blue); color: #fff; }

/* 登录 */
#v-login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 28px 24px; display: grid; gap: 14px; }
.login-card h1 { margin: 0 0 6px; font-size: 20px; }
.login-card label { display: grid; gap: 4px; color: var(--muted); }
.login-card input { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 9px 10px; font: inherit; font-size: 16px; }

/* 顶栏 */
#topbar { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; }
.spacer { flex: 1; }
.conn::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--yellow); margin-right: 6px; vertical-align: middle; }
.conn.ok::before { background: var(--green); }
.conn.bad::before { background: var(--red); }

.view { padding: 14px 16px; }

/* 狗列表 */
.list-head { display: flex; align-items: baseline; gap: 12px; }
.list-head h2 { margin: 0 0 10px; font-size: 18px; }
.dog-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.dog-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px;
  display: grid; gap: 10px; cursor: pointer; }
.dog-card:hover { border-color: #4a5664; }
.dog-card.offline { opacity: .7; }
.dog-card .top { display: flex; align-items: baseline; gap: 8px; }
.dog-card .top b { font-size: 17px; }
.dog-card .blocks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dog-card .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; color: var(--muted); }
.dog-card .facts b { color: var(--text); font-weight: 500; }
.pill { padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--gray); color: #fff; }
.pill.on { background: var(--green); }
.pill.off { background: var(--gray); }
.pill.right { margin-left: auto; }

/* 避障色块、电量色块 */
.avoid, .batt { border-radius: 8px; padding: 8px 12px; font-weight: 700; font-size: 16px; text-align: center;
  color: #fff; line-height: 1.25; display: flex; flex-direction: column; justify-content: center; min-height: 52px; }
.avoid small, .batt small { display: block; font-weight: 400; font-size: 12px; opacity: .92; }
.avoid.on { background: var(--green); }
.avoid.off { background: var(--red); animation: blink 1s steps(2, start) infinite; }
.avoid.unknown { background: var(--gray); }
.batt.ok { background: var(--green-bg); border: 1px solid var(--green); }
.batt.low { background: #4a3a0c; border: 1px solid var(--yellow); }
.batt.lower { background: #4d2a0b; border: 1px solid var(--orange); }
.batt.critical { background: var(--red); animation: blink 1s steps(2, start) infinite; }
.batt.unknown { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); }
@keyframes blink { to { opacity: .55; } }

/* 单只狗 */
.dog-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.dog-bar .back { color: var(--muted); }
.dog-title b { font-size: 18px; }
.dog-bar .avoid { min-width: 130px; font-size: 18px; }
.dog-bar .batt { min-width: 140px; }
.kv { display: grid; line-height: 1.2; }
.kv span { color: var(--muted); font-size: 12px; }
.kv b { font-size: 15px; font-weight: 600; }
.link-bar { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 10px 0; padding: 6px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; color: var(--muted); }
.lk i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--gray);
  margin-right: 6px; vertical-align: middle; }
.lk.g i { background: var(--green); } .lk.y i { background: var(--yellow); } .lk.r i { background: var(--red); }
.lk b { color: var(--text); font-weight: 600; }

.dog-main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; }
.video-box { position: relative; background: #000; border-radius: 8px; overflow: hidden; aspect-ratio: 16 / 9;
  user-select: none; }
.video-box video { width: 100%; height: 100%; object-fit: contain; display: block; }
.video-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 16px;
  background: rgba(0,0,0,.55); }
.video-hud { position: absolute; left: 8px; bottom: 8px; font: 12px ui-monospace, Consolas, monospace;
  color: #fff; background: rgba(0,0,0,.45); padding: 2px 6px; border-radius: 4px; }
.watermark { position: absolute; inset: 0; pointer-events: none; color: rgba(255,255,255,.10);
  font-size: 22px; font-weight: 700; display: grid; grid-template-columns: repeat(3, 1fr); place-items: center;
  transform: rotate(-18deg); overflow: hidden; }

.side { display: grid; gap: 12px; align-content: start; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.panel-h { font-weight: 600; margin-bottom: 6px; }
.panel-h small { font-weight: 400; }
#radar { width: 100%; max-width: 356px; aspect-ratio: 1; display: block; margin: 0 auto; background: #0b0e12;
  border-radius: 6px; }
.ranges { display: flex; justify-content: space-between; margin-top: 6px; color: var(--muted); }
.ranges b { color: var(--text); font-size: 18px; }
.ranges b.near { color: var(--red); }
.ranges b.mid { color: var(--yellow); }

.dog-bottom { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) 210px; gap: 12px; margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12px; }
.hint.center { text-align: center; }
.events { list-style: none; margin: 0; padding: 0; max-height: 210px; overflow: auto; font-size: 13px; }
.events li { padding: 2px 0; border-bottom: 1px solid #222a33; }
.events li time { color: var(--muted); margin-right: 6px; font-family: ui-monospace, Consolas, monospace; }
.events li.warn { color: var(--yellow); }
.events li.error { color: #ff7b7f; }
.stop-panel { display: grid; gap: 8px; align-content: start; }
.btn.stop { background: var(--red); border-color: var(--red); color: #fff; font-size: 30px; font-weight: 800;
  padding: 18px 10px; letter-spacing: 8px; }
.btn.stop:active { transform: translateY(1px); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h3 { margin: 0 0 8px; }
.reasons { display: grid; gap: 6px; margin: 8px 0; }
.reasons input[type=text], #dlg-other { background: var(--bg); color: var(--text); border: 1px solid var(--line);
  border-radius: 4px; padding: 3px 6px; }
.dlg-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b333d;
  border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.toast.bad { border-color: var(--red); }

@media (max-width: 1100px) {
  .dog-main { grid-template-columns: 1fr; }
  .dog-bottom { grid-template-columns: 1fr; }
}
