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

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: #e5e5e5;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --accent: #1a1a1a;
  --accent-hover: #333;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-lg: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* ── Login ── */
.overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-card h2 { font-size: 20px; font-weight: 600; margin: 16px 0 6px; }
.login-card .subtitle { color: var(--text-muted); margin-bottom: 28px; font-size: 14px; }
.login-card .field { margin-bottom: 16px; }

/* ── Logo ── */
.logo {
  display: inline-flex; align-items: center; gap: 10px;
}
.logo-mark {
  background: var(--text);
  color: white;
  font-size: 12px; font-weight: 700;
  width: 30px; height: 30px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.5px;
}
.logo-text { font-weight: 600; font-size: 15px; }

/* ── Header ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.header-inner {
  max-width: 860px; margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex; align-items: center; gap: 16px;
}
.header-title {
  flex: 1;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Main ── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  display: flex; flex-direction: column; gap: 24px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.form-card h1 { font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.form-card .subtitle { color: var(--text-muted); font-size: 14px; margin-bottom: 28px; }

/* ── Form ── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.field.full-width { grid-column: 1 / -1; }

label {
  display: block;
  font-size: 13px; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
label .hint {
  font-weight: 400; color: var(--text-muted); margin-left: 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 14px; font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s;
  outline: none;
}
input:focus { border-color: #999; }

.form-actions { display: flex; justify-content: flex-end; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none; border-radius: 7px;
  padding: 10px 20px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 16px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-secondary:hover { border-color: #999; background: var(--bg); }

.btn-ghost {
  background: transparent; border: none;
  color: var(--text-muted);
  font-size: 14px; font-family: inherit;
  cursor: pointer; padding: 8px 4px;
  transition: color .15s;
}
.btn-ghost:hover { color: var(--text); }

/* ── Progress ── */
.progress-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 20px;
}
.progress-header h2 { font-size: 18px; font-weight: 600; margin-bottom: 6px; }

.status-badge {
  display: inline-block;
  font-size: 12px; font-weight: 500;
  padding: 3px 10px; border-radius: 20px;
  background: #fef3c7; color: #92400e;
}
.status-badge.done { background: #dcfce7; color: #166534; }
.status-badge.failed { background: #fee2e2; color: #991b1b; }

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--text);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner.hidden { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-log {
  font-family: 'Inter', monospace;
  font-size: 13px;
  color: var(--text-muted);
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
}
.progress-log .log-line {
  display: flex; gap: 12px;
}
.log-time { color: #d1d5db; flex-shrink: 0; }
.log-msg { color: var(--text-muted); }
.log-msg.highlight { color: var(--text); font-weight: 500; }

/* ── Results ── */
.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.results-header h2 { font-size: 18px; font-weight: 600; }
.results-actions { display: flex; gap: 10px; }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.tab {
  background: transparent; border: none;
  padding: 8px 16px;
  font-size: 14px; font-weight: 500; font-family: inherit;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s, border-color .15s;
}
.tab.active { color: var(--text); border-bottom-color: var(--text); }
.tab:hover { color: var(--text); }

/* ── Markdown ── */
.markdown-body { font-size: 14.5px; line-height: 1.7; }
.markdown-body h1 { font-size: 22px; font-weight: 700; margin: 0 0 8px; }
.markdown-body h2 { font-size: 16px; font-weight: 600; margin: 28px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.markdown-body h3 { font-size: 14px; font-weight: 600; margin: 20px 0 8px; color: #374151; }
.markdown-body p { margin: 0 0 14px; }
.markdown-body ul, .markdown-body ol { padding-left: 22px; margin: 0 0 14px; }
.markdown-body li { margin-bottom: 4px; }
.markdown-body strong { font-weight: 600; }
.markdown-body code { font-size: 13px; background: #f3f4f6; padding: 2px 5px; border-radius: 4px; }
.markdown-body pre { background: #f3f4f6; padding: 14px; border-radius: 8px; overflow-x: auto; margin: 0 0 16px; }
.markdown-body pre code { background: none; padding: 0; }
.markdown-body blockquote { border-left: 3px solid var(--border); padding: 8px 16px; margin: 0 0 14px; background: #fafafa; color: var(--text-muted); }
.markdown-body hr { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.markdown-body table { width: 100%; border-collapse: collapse; margin: 0 0 16px; font-size: 13.5px; }
.markdown-body th { background: #f3f4f6; font-weight: 600; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.markdown-body td { padding: 7px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.markdown-body tr:last-child td { border-bottom: none; }

/* Verdict colors in markdown */
.markdown-body em { font-style: normal; }

/* ── History ── */
.section-heading { font-size: 13px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 12px; }

.jobs-list { display: flex; flex-direction: column; gap: 10px; }
.job-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex; align-items: center; gap: 16px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.job-row:hover { border-color: #ccc; box-shadow: var(--shadow); }

.job-company { font-weight: 600; font-size: 14px; flex: 1; }
.job-contact { font-size: 13px; color: var(--text-muted); }
.job-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.job-status { font-size: 12px; font-weight: 500; padding: 3px 10px; border-radius: 20px; white-space: nowrap; }
.job-status.done { background: #dcfce7; color: #166534; }
.job-status.running { background: #fef3c7; color: #92400e; }
.job-status.failed { background: #fee2e2; color: #991b1b; }
.job-status.pending { background: #f3f4f6; color: #6b7280; }

.muted { color: var(--text-muted); font-size: 14px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .field.full-width { grid-column: 1; }
  .results-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  main { padding: 16px 16px 48px; }
}
