:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface2: #243044;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ok: #22c55e;
  --err: #ef4444;
  --sidebar-w: 260px;
  --radius: 10px;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.5; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
}
.brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 2rem; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.brand small { display: block; color: var(--muted); font-size: 0.75rem; }
.nav { display: flex; flex-direction: column; gap: 0.25rem; flex: 1; }
.nav a {
  padding: 0.55rem 0.75rem; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-size: 0.95rem;
}
.nav a:hover { background: var(--surface2); color: var(--text); }
.nav a.active { background: var(--surface2); color: var(--text); font-weight: 600; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; justify-content: space-between; align-items: center; }
.user-pill { font-size: 0.85rem; background: var(--surface2); padding: 0.25rem 0.6rem; border-radius: 999px; }

.main { flex: 1; padding: 2rem 2.5rem; max-width: 1200px; }
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { margin: 0 0 0.35rem; font-size: 1.65rem; }
.row-between { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.muted { color: var(--muted); }
.hint { font-size: 0.85rem; color: var(--muted); margin-top: 1rem; }
.h-title-sm { font-size: 1.1rem; word-break: break-all; }

.grid.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.grid.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 900px) { .grid.two-col { grid-template-columns: 1fr; } .main { padding: 1.25rem; } }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}
.card h2 { margin: 0 0 1rem; font-size: 1.05rem; }
.stat { display: flex; flex-direction: column; gap: 0.25rem; }
.stat-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-value { font-size: 2rem; font-weight: 700; }
.stat-meta { font-size: 0.85rem; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.55rem 1.1rem; border-radius: 8px; border: none; cursor: pointer;
  font-size: 0.95rem; text-decoration: none; color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface2); border: 1px solid var(--border); }
.btn-secondary:hover { background: #2d3d56; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1rem; }

.alert { padding: 0.75rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-ok { background: rgba(34, 197, 94, 0.15); border: 1px solid rgba(34, 197, 94, 0.4); }
.alert-err { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); }

.form-stack label { display: block; margin: 0.75rem 0 0.35rem; font-size: 0.9rem; color: var(--muted); }
.form-stack input, .form-stack select {
  width: 100%; padding: 0.6rem 0.75rem; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
}
.form-stack input[type=file] { padding: 0.5rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); }
.table-wrap { max-height: 420px; overflow: auto; }
.url-cell { word-break: break-all; font-size: 0.82rem; color: var(--muted); }
.method { font-size: 0.75rem; font-weight: 700; padding: 0.15rem 0.4rem; border-radius: 4px; }
.method-get { background: #064e3b; color: #6ee7b7; }
.method-post { background: #1e3a5f; color: #93c5fd; }
.method-put, .method-patch { background: #422006; color: #fcd34d; }
.method-delete { background: #450a0a; color: #fca5a5; }

.badge { font-size: 0.75rem; padding: 0.2rem 0.5rem; border-radius: 999px; }
.badge-running { background: #1e3a5f; color: #93c5fd; }
.badge-success { background: #064e3b; color: #6ee7b7; }
.badge-failed { background: #450a0a; color: #fca5a5; }

.report-list { list-style: none; padding: 0; margin: 0; }
.report-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.report-list a { color: var(--text); text-decoration: none; word-break: break-all; }
.report-list a:hover { color: var(--primary); }
.link-muted { color: var(--muted); font-size: 0.85rem; text-decoration: none; }
.link-muted:hover { color: var(--text); }

.log-view {
  background: #0a0e14; border: 1px solid var(--border); border-radius: 8px;
  padding: 1rem; max-height: 480px; overflow: auto; font-size: 0.78rem;
  font-family: ui-monospace, Consolas, monospace; white-space: pre-wrap;
}

.steps { padding-left: 1.2rem; color: var(--muted); }
.steps a { color: var(--primary); }

/* Auth */
body.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 2rem;
}
.auth-card h1 { margin: 0 0 0.5rem; font-size: 1.35rem; }
.auth-card hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }
.prose h2 { margin-top: 1.5rem; font-size: 1.1rem; }
code { background: var(--bg); padding: 0.15rem 0.35rem; border-radius: 4px; font-size: 0.88em; }

/* 单页模式 */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.5rem; background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.main-narrow { max-width: 640px; margin: 0 auto; padding: 2rem 1.25rem; }

.status-bar {
  padding: 0.85rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem;
  border: 1px solid var(--border); font-size: 0.95rem;
}
.status-idle { background: var(--surface); color: var(--muted); }
.status-running { background: rgba(59, 130, 246, 0.12); border-color: rgba(59, 130, 246, 0.45); }
.status-done { background: rgba(34, 197, 94, 0.12); border-color: rgba(34, 197, 94, 0.4); }

.flow { padding: 0; overflow: hidden; }
.flow-step {
  display: flex; gap: 1rem; padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.flow-step:last-child { border-bottom: none; }
.step-num {
  flex-shrink: 0; width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2); display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.9rem;
}
.step-body h2 { margin: 0 0 0.75rem; font-size: 1rem; }
.form-inline { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.form-inline input[type=file] { flex: 1; min-width: 180px; }
.btn-disabled { pointer-events: none; opacity: 0.45; }
.log-details { margin-top: 1.25rem; }
.log-details summary { cursor: pointer; color: var(--muted); padding: 0.25rem 0; }
