/* ============ Reset & Tokens ============ */
:root {
  --bg-base: #0d0e10;
  --bg-elev: #15171a;
  --bg-hover: #1c1f23;
  --bg-input: #0a0b0d;

  --border-subtle: #25282d;
  --border-strong: #3a3f47;

  --text-primary: #e8e9ea;
  --text-secondary: #9ba2ad;
  --text-muted: #6b7280;
  --text-dim: #4a525c;

  --accent: #ff5b1f;          /* 主强调色, 用于 logo 和主按钮 */
  --accent-dim: #b8421a;
  --accent-glow: rgba(255, 91, 31, 0.15);

  --status-pending: #d4a017;
  --status-running: #4ea1f3;
  --status-completed: #3fb950;
  --status-failed: #f85149;

  --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'SF Mono', 'Menlo', 'Consolas', monospace;
  --font-sans: 'Inter', -apple-system, sans-serif;

  --radius: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: 'liga' 0, 'calt' 1;
  min-height: 100vh;
  /* 微妙的背景纹理: 扫描线感 */
  background-image:
    radial-gradient(ellipse at top, rgba(255, 91, 31, 0.04), transparent 60%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.005) 2px,
      rgba(255, 255, 255, 0.005) 3px
    );
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ Layout ============ */
.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ============ Header ============ */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
}

.header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.logo-mark {
  color: var(--accent);
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
  text-shadow: 0 0 12px var(--accent-glow);
}

.header h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.header-tag {
  color: var(--text-dim);
  font-size: 12px;
}

.logout-form { display: inline; }

/* ============ Submit Section ============ */
.submit-section {
  margin-bottom: 40px;
  padding: 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  position: relative;
}

.submit-section::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius) 0 0 var(--radius);
}

.field-label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 13px;
  transition: border-color 120ms, box-shadow 120ms;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.submit-row {
  display: flex;
  gap: 10px;
}

.submit-row .field-input { flex: 1; }

/* ============ Buttons ============ */
.btn-primary {
  padding: 10px 18px;
  background: var(--accent);
  color: #0d0e10;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius);
  letter-spacing: 0.02em;
  transition: background 120ms, transform 80ms;
  white-space: nowrap;
}

.btn-primary:hover { background: #ff7340; }
.btn-primary:active { transform: translateY(1px); }

.btn-ghost {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 12px;
  border-radius: var(--radius);
  transition: all 120ms;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text-primary);
}

.btn-danger:hover {
  border-color: var(--status-failed);
  color: var(--status-failed);
  background: rgba(248, 81, 73, 0.08);
}

/* ============ Tasks Section ============ */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.section-count {
  color: var(--text-dim);
  font-size: 11px;
}

.poll-indicator {
  margin-left: 8px;
  color: var(--text-dim);
  font-size: 8px;
  opacity: 0.4;
  transition: color 200ms, opacity 200ms;
}

.poll-indicator.polling {
  color: var(--status-running);
  opacity: 1;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ============ Task Card ============ */
.task {
  display: grid;
  grid-template-columns: 3px 1fr;
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 160ms;
}

.task:hover { border-color: var(--border-strong); }

.task-status-bar {
  background: var(--text-dim);
}

.task-pending  .task-status-bar { background: var(--status-pending); }
.task-running  .task-status-bar {
  background: var(--status-running);
  animation: pulse-bar 1.4s ease-in-out infinite;
}
.task-completed .task-status-bar { background: var(--status-completed); }
.task-failed   .task-status-bar { background: var(--status-failed); }

@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.task-body {
  padding: 14px 16px;
}

.task-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.task-status-icon { font-size: 13px; }

.task-type {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-secondary);
}

.task-id {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.task-date {
  margin-left: auto;
  color: var(--text-dim);
}

.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
  word-break: break-word;
}

.task-url-only {
  color: var(--text-secondary);
  font-size: 12px;
  word-break: break-all;
}

.task-url {
  display: block;
  font-size: 11px;
  color: var(--text-dim);
  word-break: break-all;
  margin-bottom: 8px;
}

.task-url:hover { color: var(--accent); }

/* ============ Progress ============ */
.task-progress {
  margin-top: 10px;
  padding: 10px;
  background: var(--bg-input);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
}

.progress-bar-wrap {
  height: 4px;
  background: var(--border-subtle);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--status-running), #6dbdff);
  transition: width 400ms ease;
  box-shadow: 0 0 8px rgba(78, 161, 243, 0.4);
}

.progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.progress-text strong {
  color: var(--text-primary);
  margin-right: 8px;
}

.progress-current {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

/* ============ Error ============ */
.task-error {
  margin-top: 10px;
  padding: 10px;
  background: rgba(248, 81, 73, 0.06);
  border: 1px solid rgba(248, 81, 73, 0.25);
  border-radius: var(--radius);
}

.error-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--status-failed);
  font-weight: 700;
}

.task-error pre {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-mono);
}

/* ============ Actions ============ */
.task-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 56px 20px;
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius);
}

.empty-icon {
  display: block;
  font-size: 32px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-hint {
  font-size: 11px;
  color: var(--text-dim);
}

/* ============ Login Page ============ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.login-card {
  background: var(--bg-elev);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 32px 28px;
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.login-header { margin-bottom: 24px; }
.login-header h1 {
  font-size: 24px;
  font-weight: 600;
  margin: 8px 0 4px;
}
.login-header .subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-form .btn-primary { margin-top: 4px; }

.error-msg {
  font-size: 12px;
  color: var(--status-failed);
  padding: 8px 10px;
  background: rgba(248, 81, 73, 0.08);
  border-radius: var(--radius);
  border-left: 2px solid var(--status-failed);
}

/* ============ Responsive ============ */
@media (max-width: 600px) {
  .page { padding: 20px 16px 48px; }
  .submit-row { flex-direction: column; }
  .header { flex-wrap: wrap; gap: 12px; }
  .header-tag { display: none; }
}
