:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e6ea;
  --accent: #2f6df6;
  --accent-ink: #ffffff;
  --ok: #167a4a;
  --err: #c0392b;
  --warn: #b7791f;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --card: #1c1f25;
    --ink: #e8eaed;
    --muted: #9aa1ac;
    --line: #2c313a;
    --accent: #5b8cff;
    --accent-ink: #0d1017;
    --ok: #4ec98a;
    --err: #ff7a6b;
    --warn: #e0b055;
  }
}

* { box-sizing: border-box; }

/* 下面有若干 .class { display: ... } 规则，会盖掉 UA 的 [hidden]{display:none}，
   必须显式兜底，否则 el.hidden = true 对它们无效。 */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

h1, h2 { margin: 0 0 12px; font-size: 17px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.err { color: var(--err); min-height: 18px; margin: 8px 0 0; font-size: 13px; }
.ok { color: var(--ok); min-height: 18px; margin: 4px 0 0; font-size: 13px; }

/* ---------- 登录 ---------- */
.login-wrap { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 340px;
}
.login-card input { width: 100%; margin: 14px 0 10px; }
.login-card button { width: 100%; }

/* ---------- 布局 ---------- */
header {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 14px 22px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.badge {
  font-size: 11.5px; color: var(--muted); border: 1px solid var(--line);
  padding: 2px 8px; border-radius: 99px; font-family: ui-monospace, Menlo, Consolas, monospace;
}
.quota { flex: 1; min-width: 260px; max-width: 520px; }
.quota-head { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.quota-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.bar { height: 7px; background: var(--line); border-radius: 99px; overflow: hidden; margin-top: 5px; }
.bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.bar-fill.warn { background: var(--warn); }
.bar-fill.full { background: var(--err); }

main {
  display: grid; grid-template-columns: minmax(340px, 440px) 1fr;
  gap: 18px; padding: 18px 22px; align-items: start;
}
@media (max-width: 900px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}

/* ---------- 表单 ---------- */
label { display: block; margin: 12px 0 0; font-size: 13.5px; }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { margin: 0; }
label.indent { margin-left: 24px; }
input, select, textarea, button {
  font: inherit; color: var(--ink);
}
input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
  width: 100%; margin-top: 5px; padding: 8px 10px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

button {
  cursor: pointer; border: 1px solid var(--line); background: var(--card);
  padding: 8px 14px; border-radius: 8px;
}
button:hover { border-color: var(--accent); }
button.primary {
  width: 100%; margin-top: 16px; background: var(--accent);
  color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 11px;
}
button.primary:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: transparent; }
button.small { padding: 4px 10px; font-size: 12.5px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab {
  padding: 6px 12px; font-size: 13px; background: transparent;
  border: 1px solid var(--line); border-radius: 99px;
}
.tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 30px 16px; border: 2px dashed var(--line); border-radius: var(--radius);
  cursor: pointer; text-align: center; transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop-icon { font-size: 22px; color: var(--accent); }
.drop-main { font-size: 14px; }
.drop-sub { font-size: 12px; color: var(--muted); }
.picked {
  margin-top: 10px; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; display: flex; justify-content: space-between; gap: 10px;
}

.opts { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 8px; }
.opts summary { cursor: pointer; font-size: 13.5px; color: var(--muted); padding: 4px 0; }

/* ---------- 任务列表 ---------- */
.jobs-head { display: flex; justify-content: space-between; align-items: center; }
.job-list { display: flex; flex-direction: column; gap: 8px; }
.job {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 11px 13px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.job:hover { border-color: var(--accent); }
.job.done { cursor: pointer; }
.job-name { font-size: 14px; word-break: break-all; }
.job-meta { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.job-actions {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line);
}
.job-actions .dl { font-size: 12.5px; }
.st { font-size: 11.5px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; height: fit-content; }
.st.SUCCEEDED { color: var(--ok); border-color: currentColor; }
.st.FAILED { color: var(--err); border-color: currentColor; }
.st.RUNNING, .st.PENDING, .st.QUEUED { color: var(--accent); border-color: currentColor; }
.empty { color: var(--muted); font-size: 13.5px; padding: 20px 0; text-align: center; }

/* ---------- 详情 ---------- */
.detail {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.detail-card {
  background: var(--card); border-radius: var(--radius); border: 1px solid var(--line);
  width: min(900px, 100%); max-height: 88vh; display: flex; flex-direction: column; padding: 18px;
}
.detail-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.detail-body { overflow: auto; flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.detail-body pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 12.5px; }
.detail-body .full { white-space: pre-wrap; line-height: 1.9; }
.line { display: grid; grid-template-columns: 92px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line time { color: var(--muted); font-size: 12px; font-family: ui-monospace, Menlo, Consolas, monospace; }
.spk { color: var(--accent); font-size: 12px; margin-right: 6px; }
.detail-foot { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.dl { font-size: 13px; color: var(--accent); text-decoration: none; border-bottom: 1px solid transparent; }
.dl:hover { border-bottom-color: var(--accent); }
