:root {
  --bg: #0e1116;
  --panel: #161b23;
  --panel-2: #1c232d;
  --line: #262f3d;
  --text: #e6edf6;
  --muted: #8b97a8;
  --accent: #4f9cf9;
  --ok: #35c48a;
  --warn: #e3b341;
  --err: #f26d6d;
  --run: #7b8cff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px 10px;
  flex-wrap: wrap;          /* 药丸多了之后不能让按钮被挤成两行 */
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: #11161d;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { margin-right: 6px; }

.brand { display: flex; gap: 12px; align-items: center; flex: 0 0 auto; }
.logo { color: var(--accent); font-size: 22px; letter-spacing: -2px; }
h1 { font-size: 17px; margin: 0; font-weight: 600; }
.sub { margin: 0; color: var(--muted); font-size: 12px; white-space: nowrap; }

.health { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; min-width: 0; }
button, .ghost, .profile-select { white-space: nowrap; }
.pill {
  padding: 4px 10px; border-radius: 999px; font-size: 12px;
  border: 1px solid var(--line); background: var(--panel); white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: #235c45; }
.pill.bad { color: var(--err); border-color: #6a2b2b; }
.pill.wait { color: var(--muted); }

.layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; min-height: calc(100vh - 62px); }

.sidebar {
  border-right: 1px solid var(--line);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  background: #10151c;
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.panel h2 { font-size: 13px; margin: 0 0 10px; color: var(--muted); font-weight: 600; letter-spacing: .4px; }

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
input, textarea, select {
  width: 100%; margin-top: 4px; background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font: inherit; outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }

button, a.ghost {
  font: inherit; cursor: pointer; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  padding: 8px 14px; transition: .15s; text-decoration: none;
  display: inline-block;
}
a.ghost:hover { border-color: var(--accent); }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: transparent; }
button.danger { color: #ff8080; border-color: #ff808055; }
button.danger:hover { border-color: #ff8080; background: #ff808012; }
button.small { padding: 5px 10px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }

.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.project-list li {
  padding: 9px 36px 9px 11px; border-radius: 8px; border: 1px solid transparent;
  background: var(--panel-2); cursor: pointer; font-size: 13px; position: relative;
}
.project-list li.active { border-color: var(--accent); }
.project-list li .pmeta { color: var(--muted); font-size: 11px; }
.project-list li .proj-del {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; padding: 0; border-radius: 6px; border: 1px solid transparent;
  background: transparent; color: var(--muted); font-size: 15px; line-height: 1;
}
.project-list li .proj-del:hover { color: #ff6b6b; border-color: #ff6b6b66; background: #ff6b6b12; }

.content { padding: 18px 22px; overflow-y: auto; }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }

.detail-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.detail-head h2 { margin: 0 0 4px; font-size: 18px; }
.meta { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.progress-wrap { display: flex; gap: 12px; align-items: center; margin: 16px 0 8px; }
.progress { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
#progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, #4f9cf9, #7b8cff); transition: width .3s; }

.tabs { display: flex; gap: 6px; margin: 16px 0 12px; border-bottom: 1px solid var(--line); }
.tab { border: none; background: transparent; color: var(--muted); padding: 8px 12px; border-radius: 8px 8px 0 0; }
.tab.active { color: var(--text); background: var(--panel); border-bottom: 2px solid var(--accent); }

.shot-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.upload label { display: inline-block; margin: 0; color: var(--text); }

.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.shot {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; gap: 8px;
}
.shot-head { display: flex; justify-content: space-between; align-items: center; }
.shot-seq { font-weight: 700; color: var(--accent); }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.badge.DONE { color: var(--ok); border-color: #235c45; }
.badge.FAILED { color: var(--err); border-color: #6a2b2b; }
.badge.RUNNING { color: var(--run); border-color: #3b45a0; }
.badge.PLANNED, .badge.QUEUED { color: var(--muted); }
.shot video { width: 100%; border-radius: 8px; background: #000; }
.shot .prompt { font-size: 12px; color: #c2cbd8; background: var(--panel-2); border-radius: 8px; padding: 8px; max-height: 96px; overflow-y: auto; }
.shot .err { color: var(--err); font-size: 11px; }
.shot-foot { display: flex; gap: 6px; flex-wrap: wrap; }
.shot textarea { font-size: 12px; }

.scripts, .renders { display: flex; flex-direction: column; gap: 10px; }
.script-card, .render-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.script-card p { white-space: pre-wrap; color: #c2cbd8; font-size: 12px; max-height: 140px; overflow-y: auto; }
.render-card video { width: 100%; max-height: 60vh; border-radius: 10px; background: #000; }

.log {
  background: #0b0f14; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; max-height: 60vh; overflow-y: auto; font-size: 12px; color: #b9c4d3;
  font-family: Consolas, "Cascadia Mono", monospace; white-space: pre-wrap;
}

.hidden { display: none !important; }
.disabled { opacity: .45; pointer-events: none; }

.script-add { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; max-width: 720px; }

/* 硬件档位选择器 */
.profile-select {
  margin-left: 12px; max-width: 260px; padding: 7px 10px;
  background: #131a24; color: #d6dee9; border: 1px solid var(--line);
  border-radius: 999px; font-size: 12px; cursor: pointer;
}
.profile-select:hover { border-color: #2c3a4d; }
.pill.prof { border-color: #2b4a3d; color: #9fe0c0; }
.pill.remote { border-color: #3a3a55; color: #b9b6f0; }

/* 云主机连接弹窗 */
.modal {
  position: fixed; inset: 0; z-index: 30;
  background: rgba(5, 8, 13, .72);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.modal-box {
  width: min(680px, 100%); max-height: 88vh; overflow: auto;
  background: #0f151e; border: 1px solid var(--line); border-radius: 16px;
  padding: 20px 22px; box-shadow: 0 18px 60px rgba(0,0,0,.55);
  display: flex; flex-direction: column; gap: 12px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-hint { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.modal-box label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.modal-box input {
  padding: 9px 11px; background: #131a24; color: #d6dee9;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.remote-current { font-size: 12px; color: var(--muted); }
.remote-current b { color: #d6dee9; font-weight: 600; }
.remote-report { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.remote-report:empty { display: none; }
.rep-row { display: flex; gap: 8px; align-items: baseline; }
.rep-row .k { color: var(--muted); min-width: 72px; }
.rep-list { margin: 0; padding-left: 18px; line-height: 1.7; }
.rep-list.bad li { color: #f0a0a0; }
.rep-list.warn li { color: #e8cf9a; }
.rep-ok { color: #9fe0c0; }
.rep-bad { color: #f0a0a0; }
.rep-warn { color: #e8cf9a; }
.rep-sec { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 6px; }

/* 节点池 */
.modal-box.wide { width: min(880px, 100%); }
.node-list { display: flex; flex-direction: column; gap: 8px; }
.node-row {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1.55fr) max-content auto;
  gap: 10px; align-items: center;
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #121a24;
  font-size: 12px;
}
.node-row .cap { white-space: nowrap; color: var(--muted); }
.node-row.off { opacity: .55; }
.node-row .nm { font-weight: 600; color: #d6dee9; }
.node-row .addr { color: var(--muted); font-family: ui-monospace, monospace; font-size: 11px; }
.node-row .st { display: flex; gap: 6px; align-items: center; white-space: nowrap; }
.node-row .addr { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-row .ops { display: flex; gap: 6px; }
.node-form { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.node-form-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.node-form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); }
.node-form-row input, .node-form-row select {
  padding: 7px 9px; background: #131a24; color: #d6dee9;
  border: 1px solid var(--line); border-radius: 7px; font-size: 12px;
}
.pill.kind { border-color: #2b3a4d; color: #9fb8d0; font-size: 10px; padding: 1px 7px; }
.pill.on { border-color: #2b4a3d; color: #9fe0c0; }
.pill.offp { border-color: #4a2b2b; color: #e0a0a0; }
.pill.auth { border-color: #3a3550; color: #c0b6e0; font-size: 10px; padding: 1px 7px; }
.pill.user { border-color: #2b3a4d; color: #d6dee9; }

/* 成员管理 */
.node-row .q { display: flex; gap: 8px; }
label.mini { display: flex; flex-direction: column; gap: 3px; font-size: 10px; color: var(--muted); }
label.mini input {
  width: 64px; padding: 4px 6px; background: #131a24; color: #d6dee9;
  border: 1px solid var(--line); border-radius: 6px; font-size: 11px;
}
.profile-select.readonly { opacity: .6; }
body:not(.is-admin) .admin-only { display: none !important; }

/* 登录页 */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; margin: 0; }
.login-box {
  width: min(380px, 92vw); padding: 26px 24px; border: 1px solid var(--line);
  border-radius: 16px; background: #101821; display: flex; flex-direction: column; gap: 16px;
}
.login-brand { border: 0; padding: 0; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
.login-form input {
  padding: 9px 11px; background: #131a24; color: #d6dee9;
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.login-form button { margin-top: 4px; padding: 10px; font-size: 13px; }
.login-err { color: #f0a0a0; font-size: 12px; min-height: 16px; }
.login-hint { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0; }
.login-hint code { background: #131a24; padding: 1px 5px; border-radius: 4px; }
