:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1d212a;
  --line: #262b36;
  --text: #e6e9ef;
  --muted: #8b93a3;
  --accent: #4c7dff;
  --ok: #35c07d;
  --warn: #e0a33a;
  --err: #e0574f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- 登录页 ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f6f7f9;
  color: #1c2130;
}

.login-card {
  width: 340px;
  padding: 34px 30px 28px;
  background: #fff;
  border: 1px solid #e6e9ef;
  border-radius: 12px;
}

.login-card .brand {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 3px;
  color: #1c2130;
  margin-bottom: 6px;
}

.login-card .sub {
  font-size: 13px;
  color: #8b93a3;
  margin-bottom: 22px;
}

.field {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  margin-bottom: 12px;
  border: 1px solid #dfe3ea;
  border-radius: 8px;
  font-size: 14px;
  color: #1c2130;
  background: #fff;
  outline: none;
  transition: border-color .15s;
}

.field:focus { border-color: #4c7dff; }

.cap-row { display: flex; gap: 10px; margin-bottom: 12px; }
.cap-row .field { margin-bottom: 0; }
.cap-row img {
  height: 40px;
  width: 104px;
  border: 1px solid #dfe3ea;
  border-radius: 8px;
  cursor: pointer;
  background: #f6f7f9;
}

.btn-primary {
  width: 100%;
  height: 40px;
  border: 0;
  border-radius: 8px;
  background: #1c2130;
  color: #fff;
  font-size: 14px;
}

.btn-primary:hover { background: #2a3143; }
.btn-primary:disabled { opacity: .55; cursor: default; }

.msg { min-height: 18px; margin-top: 12px; font-size: 13px; color: #d0453d; }
.msg.ok { color: #2f9e63; }
.foot { margin-top: 18px; font-size: 12px; color: #98a0ae; text-align: center; }

/* ---------- 控制台 ---------- */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.top .logo { font-weight: 600; letter-spacing: 2px; }
.top .right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: 400px minmax(0, 1fr) 340px;
  gap: 16px;
  padding: 16px 22px 28px;
  align-items: start;
}

@media (max-width: 1180px) {
  .layout { grid-template-columns: 380px minmax(0, 1fr); }
  .col-device { grid-column: 1 / -1; }
  .col-device .card { max-width: 520px; }
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .col-device { grid-column: auto; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  letter-spacing: .5px;
}

.screen {
  position: relative;
  background: #0a0c10;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  height: clamp(340px, 60vh, 720px);
  aspect-ratio: 9 / 19.5;
  width: auto;
  max-width: 100%;
  margin: 0 auto;
}

.screen img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
}
.screen .empty { color: #556; font-size: 13px; padding: 60px 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #222834;
  color: var(--muted);
}

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.off { background: #5a6070; }
.dot.warn { background: var(--warn); }

textarea.task {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
  outline: none;
}

textarea.task:focus { border-color: #3b4a6b; }

.row { display: flex; gap: 10px; margin-top: 10px; }

.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
}

.btn:hover { border-color: #3b4a6b; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f6ce6; }
.btn:disabled { opacity: .45; cursor: default; }

.kv { display: grid; grid-template-columns: 78px 1fr; gap: 6px 12px; font-size: 13px; }
.kv .k { color: var(--muted); }

.tasks { max-height: 420px; overflow: auto; }
.task-item {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--panel-2);
}
.task-item:hover { border-color: #3b4a6b; }
.task-item .t1 { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; }
.task-item .t2 { font-size: 12px; color: var(--muted); margin-top: 4px; }
.task-item .txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-item .t1 > .right { display: flex; align-items: center; gap: 8px; flex: none; }

.del {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: .8;
}
.del:hover { color: #ef7f76; background: rgba(239,127,118,.12); opacity: 1; }

.upd { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.upd .btn { width: 100%; }

.retry {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  cursor: pointer;
  opacity: .85;
}
.retry:hover { color: #7fa6ff; background: rgba(127,166,255,.12); opacity: 1; }
.detail-head .upd { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.upd .btn { width: 100%; }

.retry { border: 1px solid var(--line); padding: 3px 10px; margin-right: 4px; }
.detail-head { gap: 8px; }
.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.detail-head h2 { margin: 0; }
.detail-head .del { border: 1px solid var(--line); padding: 3px 10px; }

.state { font-size: 12px; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.state.running { background: #1e3358; color: #7fa6ff; }
.state.queued { background: #33301f; color: #d8b45c; }
.state.done { background: #17362a; color: #5fd39b; }
.state.failed { background: #3a2020; color: #ef7f76; }
.state.cancelled { background: #2a2d36; color: #9aa2b1; }

.steps { margin-top: 12px; }
.step {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.step .n {
  width: 22px; height: 22px; border-radius: 50%;
  background: #232a38; color: #9aa2b1;
  font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.step .think { color: #b9c0cd; }
.step .act { color: #7fa6ff; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; margin-top: 3px; word-break: break-all; }
.step img { width: 120px; border-radius: 6px; border: 1px solid var(--line); margin-top: 8px; display: block; }

.muted { color: var(--muted); }
.err { color: var(--err); }
.okc { color: var(--ok); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #232a38;
  border: 1px solid var(--line);
  color: var(--text);
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
  z-index: 50;
}
.toast.show { opacity: 1; }
