:root {
  color-scheme: light;
  --bg: #f7f7f4;
  --panel: #ffffff;
  --ink: #111113;
  --muted: #626262;
  --line: #deded8;
  --brand: #173b8f;
  --danger: #9b1c1c;
  --ok: #0f6b3f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell { width: min(1180px, calc(100% - 32px)); margin: 32px auto; }
.login-card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,.04);
}
.login-card { width: min(460px, 100%); margin: 10vh auto; }
.eyebrow { margin: 0 0 6px; text-transform: uppercase; letter-spacing: .08em; color: var(--brand); font-size: 12px; font-weight: 800; }
h1, h2 { margin: 0; line-height: 1.1; }
h1 { font-size: 34px; }
h2 { font-size: 22px; }
.muted { color: var(--muted); line-height: 1.5; }
.stack, form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; line-height: 1.45; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
button {
  border: 0;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  padding: 11px 14px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
button.secondary { background: #eceef5; color: var(--brand); }
button.danger { background: var(--danger); }
button:disabled { opacity: .55; cursor: not-allowed; }
.message { min-height: 20px; color: var(--muted); margin: 4px 0 0; }
.message.error { color: var(--danger); }
.message.success { color: var(--ok); }
.topbar, .panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar { margin-bottom: 24px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
#userBadge { color: var(--muted); font-weight: 700; }
.grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr); gap: 18px; margin-bottom: 18px; }
.settings-grid { grid-template-columns: 1fr 1fr; }
.settings-grid button { grid-column: 1 / -1; }
#writersPanel { grid-column: 1 / -1; }
.jobs { display: grid; gap: 12px; }
.job {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
}
.job strong { font-size: 17px; }
.job-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.job-meta { color: var(--muted); font-size: 13px; line-height: 1.45; }
.job-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 8px;
  white-space: nowrap;
}
.status-generated { border-color: rgba(15, 107, 63, .25); color: var(--ok); background: #eef8f2; }
.status-generating { border-color: rgba(23, 59, 143, .25); color: var(--brand); background: #eef2fb; }
.status-failed { border-color: rgba(155, 28, 28, .22); color: var(--danger); background: #fff1f1; }
.status-source-saved { background: #fafafa; }
.writers-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}
.writer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 12px;
}
.writer-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}
.writer-summary strong,
.writer-summary span,
.writer-costs span {
  display: block;
  line-height: 1.4;
}
.writer-summary span,
.writer-costs {
  color: var(--muted);
  font-size: 13px;
}
.writer-costs { text-align: right; }
.writer-edit {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}
.extractor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.extract-list {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fafafa;
}
.extract-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.extract-item:last-child { border-bottom: 0; padding-bottom: 0; }
.extract-item strong,
.extract-item span {
  display: block;
  line-height: 1.35;
}
.extract-item span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.advanced-source {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fafafa;
}
.advanced-source summary {
  color: var(--brand);
  cursor: pointer;
  font-weight: 800;
}
.advanced-source label { margin-top: 12px; }
.report {
  white-space: pre-wrap;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  max-height: 260px;
  overflow: auto;
  font-size: 13px;
}
@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .writer-summary { flex-direction: column; }
  .writer-costs { text-align: left; }
  .writer-edit { grid-template-columns: 1fr; }
  .topbar, .panel-head { align-items: flex-start; flex-direction: column; }
}
