:root {
  --bg: #0b0e14;
  --panel: #12161f;
  --panel2: #171c27;
  --line: #232b3a;
  --txt: #e6edf3;
  --dim: #8b96a8;
  --acc: #2f81f7;
  --acc2: #58a6ff;
  --ok: #3fb950;
  --err: #f85149;
  --warn: #d29922;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--txt);
  height: 100vh;
  overflow: hidden;
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", sans-serif;
}

button {
  background: var(--acc);
  border: 0;
  border-radius: 8px;
  color: #fff;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s;
  font-family: inherit;
}
button:hover:not(:disabled) { filter: brightness(1.12); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.ghost {
  background: var(--panel2);
  border: 1px solid var(--line);
  color: var(--txt);
}
button.danger {
  background: rgba(248, 81, 73, 0.12);
  border: 1px solid rgba(248, 81, 73, 0.35);
  color: var(--err);
}
button.sm { padding: 5px 11px; font-size: 12px; border-radius: 6px; }
button.link {
  background: none;
  border: 0;
  color: var(--dim);
  padding: 6px 0;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
button.link:hover { color: var(--err); filter: none; }

input, textarea {
  width: 100%;
  background: #0a0d13;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--txt);
  padding: 10px 13px;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus { border-color: var(--acc); }
textarea {
  min-height: 92px;
  resize: vertical;
  font: 12.5px/1.65 ui-monospace, Consolas, monospace;
}

/* ---------------- 登录 ---------------- */
.login-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(900px 500px at 50% 0%, #16203a 0%, var(--bg) 70%);
  z-index: 100;
}
.login-box {
  width: 340px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-box h1 { font-size: 18px; font-weight: 600; margin-bottom: 4px; }
.login-box .muted { margin-bottom: 22px; font-size: 12.5px; }
.login-box input { padding: 12px 14px; font-size: 15px; }
.login-box button { width: 100%; margin-top: 14px; padding: 12px; font-size: 14.5px; }
.login-err { color: var(--err); font-size: 12.5px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ---------------- 布局 ---------------- */
.app { display: none; height: 100vh; grid-template-columns: 196px 1fr; }
.app.on { display: grid; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 0;
}
.brand { padding: 0 18px 18px; font-size: 14.5px; font-weight: 600; letter-spacing: 0.2px; }
.brand span { display: block; font-size: 11.5px; color: var(--dim); font-weight: 400; margin-top: 2px; }

nav a {
  display: block;
  padding: 10px 18px;
  color: var(--dim);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: 0.15s;
}
nav a:hover { color: var(--txt); background: var(--panel2); }
nav a.active {
  color: var(--acc2);
  border-left-color: var(--acc);
  background: rgba(47, 129, 247, 0.08);
}

.sidebar-foot { margin-top: auto; padding: 0 18px; }
.clock { font-size: 12px; color: #5a6478; font-variant-numeric: tabular-nums; }

.main { overflow: auto; padding: 24px 28px 60px; }

.page { display: none; }
.page.active { display: block; }

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h2 { font-size: 17px; font-weight: 600; }
.actions { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* ---------------- 面板 ---------------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 {
  font-size: 12px;
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 15px;
}
.stat .k { font-size: 11.5px; color: var(--dim); margin-bottom: 6px; }
.stat .v { font-size: 21px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .v.ok { color: var(--ok); }
.stat .v.err { color: var(--err); }
.stat .v.dim { color: var(--dim); }

/* ---------------- 表格 ---------------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  color: var(--dim);
  font-weight: 500;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 10px;
  border-bottom: 1px solid #1a2130;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}
tr:last-child td { border-bottom: 0; }
td .muted { font-size: 12px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
}
.b-ok, .b-done, .b-active { background: rgba(63, 185, 80, 0.15); color: var(--ok); }
.b-failed, .b-auth, .b-sold_out, .b-rate_limit { background: rgba(248, 81, 73, 0.15); color: var(--err); }
.b-pending { background: rgba(47, 129, 247, 0.15); color: var(--acc2); }
.b-running { background: rgba(210, 153, 34, 0.15); color: var(--warn); }
.b-canceled, .b-unknown, .b-empty, .b-busy, .b-http_error {
  background: #1c2230; color: var(--dim);
}

.progress-mini { display: flex; align-items: center; gap: 8px; min-width: 130px; }
.progress-mini .bar {
  flex: 1;
  height: 6px;
  background: #0a0d13;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
.progress-mini .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--acc), var(--acc2));
}

/* ---------------- 表单 ---------------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--dim);
  margin-bottom: 7px;
}
.checks { display: flex; flex-wrap: wrap; gap: 10px; }
.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}
.checks input { width: auto; }

.muted { color: var(--dim); }
.small { font-size: 12px; }
.empty { color: var(--dim); font-size: 13px; text-align: center; padding: 26px 0; }

/* ---------------- 日志 ---------------- */
.logbox {
  background: #080b10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px 15px;
  height: calc(100vh - 180px);
  overflow: auto;
  font: 12px/1.85 ui-monospace, Consolas, monospace;
  color: #9fb0c0;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------------- Toast ---------------- */
.toast-wrap {
  position: fixed;
  top: 20px;
  right: 22px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--acc);
  border-radius: 8px;
  padding: 11px 16px;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slidein 0.25s ease;
  max-width: 380px;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
@keyframes slidein {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: none; }
}

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .sidebar { flex-direction: row; align-items: center; padding: 10px 12px; overflow-x: auto; }
  .brand { display: none; }
  nav { display: flex; }
  nav a { border-left: 0; border-bottom: 2px solid transparent; padding: 8px 12px; white-space: nowrap; }
  nav a.active { border-bottom-color: var(--acc); }
  .sidebar-foot { margin-left: auto; }
  .clock { display: none; }
  .main { padding: 16px 14px 40px; }
}
