:root {
  --bg: #f6f5f2;
  --card: #ffffff;
  --ink: #211d18;
  --muted: #746c60;
  --muted-2: #a29b8d;
  --line: #e8e3da;
  --line-strong: #d8d1c3;
  --accent: #a8471f;
  --accent-ink: #ffffff;
  --accent-soft: #fbeee5;
  --accent-soft-ink: #8a3a19;
  --ok: #2e7d4f;
  --ok-bg: #e7f4ec;
  --err: #c0392b;
  --err-bg: #fbecea;
  --wait: #9a6c11;
  --wait-bg: #fbf1da;
  --info: #2f6fa8;
  --info-bg: #eaf3fa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(33,29,24,.04), 0 4px 16px rgba(33,29,24,.05);
  --shadow-lift: 0 4px 10px rgba(33,29,24,.06), 0 12px 32px rgba(33,29,24,.08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Inter", "Segoe UI", -apple-system, Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 1.05rem; margin: 0 0 4px; font-weight: 650; }
h3 { font-size: 0.95rem; margin: 0; font-weight: 650; }
p { margin: 0 0 10px; }

/* ── Layout ─────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.brand .logo { font-size: 1.3rem; }
.topnav { display: flex; gap: 14px; align-items: center; }
.container { max-width: 1040px; margin: 0 auto; padding: 28px 24px 60px; }
.footer { max-width: 1040px; margin: 0 auto; padding: 24px 24px 48px; color: var(--muted-2); font-size: 0.82rem; border-top: 1px solid var(--line); margin-top: 40px; }
.footer a { color: var(--muted); }

/* ── User menu ──────────────────────────────────────────────────────── */
.user-menu { position: relative; }
.user-chip {
  display: flex; align-items: center; gap: 6px; background: none; border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 12px 5px 6px; cursor: pointer; font-size: 0.85rem; color: var(--ink);
}
.user-chip .avatar {
  width: 22px; height: 22px; border-radius: 999px; background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 0.72rem; font-weight: 700;
}
.user-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lift); min-width: 190px; padding: 6px; z-index: 30;
}
.user-dropdown a, .user-dropdown button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px; border: none; background: none;
  font-size: 0.88rem; color: var(--ink); text-decoration: none; cursor: pointer;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--bg); }

/* ── Cards / sections ───────────────────────────────────────────────── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.subtle { color: var(--muted); font-size: 0.88rem; }

/* ── Stepper (project page) ────────────────────────────────────────── */
.stepper { display: flex; gap: 10px; margin: 4px 0 26px; flex-wrap: wrap; }
.step-pill {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px 7px 8px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line); font-size: 0.85rem; color: var(--muted);
}
.step-pill .num {
  width: 22px; height: 22px; border-radius: 999px; background: var(--line); color: var(--muted);
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 700; flex-shrink: 0;
}
.step-pill.active { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.step-pill.active .num { background: var(--accent); color: #fff; }
.step-pill.done .num { background: var(--ok); color: #fff; }
.step-pill.done { color: var(--ink); }

/* ── Forms ──────────────────────────────────────────────────────────── */
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-tight { display: flex; gap: 6px; align-items: center; }
label { display: block; margin-bottom: 12px; font-size: 0.88rem; color: var(--muted); font-weight: 500; }
input[type=text], input[type=email], input[type=password], select {
  display: block; width: 100%; padding: 10px 12px; margin-top: 5px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font-size: 0.95rem;
  background: #fff; color: var(--ink); font-family: inherit;
}
input:focus, select:focus, button:focus-visible {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=file] {
  font-size: 0.85rem; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg); width: 100%;
}

/* ── Buttons ────────────────────────────────────────────────────────── */
button, .btn-primary, .btn-small, .btn-ghost {
  cursor: pointer; border-radius: var(--radius-sm); font-size: 0.9rem; font-family: inherit;
  transition: filter .1s, background .12s;
}
.btn-primary {
  background: var(--accent); color: var(--accent-ink); padding: 11px 18px; font-weight: 650;
  border: none; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-small {
  background: var(--bg); color: var(--ink); border: 1px solid var(--line-strong); padding: 7px 12px;
  text-decoration: none; display: inline-flex; align-items: center; gap: 5px;
}
.btn-small:hover { background: var(--line); }
.btn-ghost { background: none; border: none; color: var(--muted); text-decoration: underline; padding: 0; font-size: 0.85rem; }
.btn-ghost:hover { color: var(--ink); }

/* ── Tables ─────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.9rem; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 650; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.list tbody tr:hover { background: var(--bg); }

/* ── Tags / status ──────────────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px;
  font-size: 0.78rem; font-weight: 600; background: var(--line); text-decoration: none; color: var(--ink); white-space: nowrap;
}
.tag-ok { background: var(--ok-bg); color: var(--ok); }
.tag-wait { background: var(--wait-bg); color: var(--wait); }
.tag-err { background: var(--err-bg); color: var(--err); }
.tag-info { background: var(--info-bg); color: var(--info); }

/* ── Progress bar ───────────────────────────────────────────────────── */
.progress-wrap { margin: 14px 0; }
.progress-track { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0%; transition: width .25s ease; }
.progress-label { font-size: 0.82rem; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.spinner {
  display: inline-block; width: 13px; height: 13px; border: 2px solid var(--line-strong);
  border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 36px 20px; color: var(--muted); }
.empty-state .big { font-size: 2rem; margin-bottom: 8px; }

/* ── Candidate picker ───────────────────────────────────────────────── */
.candidate-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.candidate-list li { display: flex; align-items: center; gap: 8px; }
.candidate-list a { font-size: 0.82rem; word-break: break-word; flex: 1; }

/* ── Chat ───────────────────────────────────────────────────────────── */
.chat-panel { display: flex; flex-direction: column; height: 480px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 4px 4px 12px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 0.9rem; white-space: pre-wrap; }
.chat-bubble.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.chat-bubble.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.chat-input-row { display: flex; gap: 8px; border-top: 1px solid var(--line); padding-top: 12px; }
.chat-input-row input { flex: 1; margin: 0; }
.chat-empty { color: var(--muted-2); font-size: 0.85rem; text-align: center; margin-top: 40px; }

/* ── Misc ───────────────────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--err); background: var(--err-bg); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; font-size: 0.88rem; }
.notice { background: var(--info-bg); color: var(--info); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; font-size: 0.88rem; }
.success-box { background: var(--ok-bg); color: var(--ok); border-radius: var(--radius-sm); padding: 10px 12px; margin: 0 0 14px; font-size: 0.88rem; }
.auth-card { max-width: 380px; margin: 60px auto; }
.auth-card h1 { font-size: 1.35rem; }
.auth-links { margin-top: 16px; font-size: 0.87rem; color: var(--muted); text-align: center; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .container { padding: 18px 14px 40px; }
  .card { padding: 16px; }
  table.list { font-size: 0.82rem; }
}
