:root {
  --bg: #0f1116;
  --bg2: #171a21;
  --bg3: #1f232c;
  --line: #2b3040;
  --fg: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #4c8dff;
  --ok: #34c759;
  --warn: #ffb020;
  --err: #ff4d4f;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

code, .mono, pre { font-family: ui-monospace, Consolas, "Cascadia Mono", monospace; }

/* ---------- 登录 ---------- */
.login-mask {
  position: fixed; inset: 0; z-index: 100;
  background: radial-gradient(1200px 600px at 50% -10%, #1d2432, #0b0d12 70%);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.login-mask.hidden { display: none; }
.login-card {
  width: 100%; max-width: 420px; background: var(--bg2);
  border: 1px solid var(--line); border-radius: 14px; padding: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.5);
}
.login-card h1 { font-size: 19px; margin: 0 0 8px; }
.login-tip { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.login-card input[type=password] {
  width: 100%; padding: 11px 12px; margin-bottom: 10px;
  background: var(--bg3); border: 1px solid var(--line); border-radius: 8px;
  color: var(--fg); font-size: 15px;
}
.login-remember { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.login-btn { width: 100%; }
.login-err { color: var(--err); font-size: 13px; min-height: 18px; margin-top: 8px; }
.login-help { margin-top: 12px; color: var(--muted); font-size: 12px; }
.login-help code { background: var(--bg3); padding: 1px 5px; border-radius: 4px; }

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; background: rgba(15,17,22,.92);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(6px);
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: .3px; }
.brand span { color: var(--accent); margin-left: 3px; font-weight: 500; }
.statusbar { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.chip {
  background: var(--bg3); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; color: var(--muted); white-space: nowrap;
}
.chip.good { color: var(--ok); border-color: #23512f; }
.chip.bad { color: var(--err); border-color: #5a2427; }
.top-actions { display: flex; gap: 6px; }

/* ---------- 通用控件 ---------- */
button {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 14px; font-size: 14px; cursor: pointer;
}
button:hover { border-color: #3d4557; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.primary:hover { background: #5f9bff; }
button.ghost { background: transparent; }
button.small { padding: 5px 10px; font-size: 12px; }
button.danger { color: var(--err); border-color: #4a2124; }
button:disabled { opacity: .45; cursor: not-allowed; }
input, select {
  background: var(--bg3); color: var(--fg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font-size: 14px;
}
input[type=checkbox] { width: auto; }

.tabs { display: flex; gap: 4px; padding: 10px 14px 0; flex-wrap: wrap; }
.tab { background: transparent; border: 1px solid transparent; border-bottom: none; color: var(--muted); }
.tab.active { background: var(--bg2); border-color: var(--line); color: var(--fg); font-weight: 600; }

main { padding: 14px; max-width: 1200px; margin: 0 auto; }
.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--muted); font-size: 13px; }
.mono { white-space: pre-wrap; word-break: break-all; font-size: 12px; color: var(--muted); margin: 0; }

/* ---------- 拖拽区 ---------- */
.dropzone {
  background: var(--bg2); border: 2px dashed var(--line); border-radius: 14px;
  padding: 26px 16px; text-align: center; cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: #182033; }
.dz-icon { font-size: 30px; color: var(--accent); }
.dz-title { font-size: 16px; font-weight: 600; margin-top: 6px; }
.dz-sub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.dz-opts { display: flex; gap: 14px; justify-content: center; margin-top: 14px; color: var(--muted); font-size: 12.5px; flex-wrap: wrap; }
.dz-opts input { width: 68px; padding: 4px 6px; }

/* ---------- 队列 ---------- */
.queue-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  margin: 16px 0 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px;
}
.queue-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.queue { display: flex; flex-direction: column; gap: 8px; }
.task {
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px;
}
.task-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.task-name { font-weight: 600; word-break: break-all; }
.task-state { font-size: 12px; color: var(--muted); white-space: nowrap; }
.task-state.ok { color: var(--ok); }
.task-state.err { color: var(--err); }
.task-state.warn { color: var(--warn); }
.bar { height: 7px; background: var(--bg3); border-radius: 999px; overflow: hidden; margin: 7px 0 5px; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .18s; }
.bar.done > i { background: var(--ok); }
.bar.err > i { background: var(--err); }
.task-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.task-detail { font-size: 12px; color: var(--muted); margin-top: 5px; word-break: break-all; }
.task-actions { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ---------- 曲库表 ---------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.toolbar input[type=search] { flex: 1; min-width: 180px; }
.inline { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.table-wrap { overflow-x: auto; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--bg3); }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.deleted td { opacity: .5; text-decoration: line-through; }
.badge { font-size: 11px; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; color: var(--muted); }
.badge.on { color: var(--ok); border-color: #23512f; }

/* ---------- APK ---------- */
.apk-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 12px; }
.apk-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.apk-form label.full { grid-column: 1 / -1; }
.apk-form input[type=checkbox] { align-self: flex-start; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: #22283399; border: 1px solid var(--line); color: var(--fg);
  padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none;
  transition: .22s; max-width: min(560px, 92vw); font-size: 13px; z-index: 60;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { border-color: #23512f; }
.toast.err { border-color: #5a2427; }

@media (max-width: 640px) {
  main { padding: 10px; }
  .brand { font-size: 15px; }
  .statusbar { order: 3; width: 100%; }
  .login-card { padding: 18px; }
  th:nth-child(4), td:nth-child(4) { display: none; }
}
