:root {
  --bg: #f6f7f9; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6eb;
  --accent: #2f5bea; --accent-text: #fff; --ok: #1a7f4b; --warn: #b45309; --bad: #c0362c;
  --ok-bg: #e6f4ec; --warn-bg: #fdf1e1; --bad-bg: #fbe9e7; --info-bg: #e8eefc;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --card: #1c2027; --text: #e6e8eb; --muted: #9aa3ae; --line: #2c323b;
    --accent: #6d8cff; --accent-text: #0d1020; --ok: #5cc98f; --warn: #f0a44b; --bad: #ff7a6e;
    --ok-bg: #173226; --warn-bg: #3a2a14; --bad-bg: #3b1d1a; --info-bg: #1c2645;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1em; }
code { background: var(--bg); padding: 1px 4px; border-radius: 4px; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--card);
}
textarea { min-height: 70px; resize: vertical; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 7px 12px; }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.link { border: none; background: none; color: var(--accent); padding: 4px 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
h1, h2 { margin: 0 0 8px; }
h2 { font-size: 16px; }

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login form { width: min(340px, 100%); display: grid; gap: 10px; }

header { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
nav button { border: none; background: none; padding: 6px 10px; }
nav button.active { background: var(--info-bg); color: var(--accent); font-weight: 600; }
main { padding: 20px; max-width: 1500px; margin: 0 auto; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--accent); }

.start { display: flex; gap: 8px; }
.start input { flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.chips button.active { border-color: var(--accent); color: var(--accent); }

.session { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 1000px) { .session { grid-template-columns: 1fr; } }
.live, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.live { position: sticky; top: 12px; }
.live-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.viewport { position: relative; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; }
.viewport img { display: block; width: 100%; cursor: crosshair; min-height: 200px; }
.spinner { position: absolute; top: 10px; right: 10px; width: 22px; height: 22px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.controls { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.controls input { flex: 1; min-width: 180px; }

.message { background: var(--info-bg); padding: 10px 12px; border-radius: 6px; margin: 0 0 10px; }
.message.bad { background: var(--bad-bg); }
.message.ok { background: var(--ok-bg); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--line); }
td { padding: 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.fields td:first-child { width: 42%; }
.fields tr.need td:first-child { box-shadow: inset 3px 0 var(--warn); }
.fields .req { color: var(--bad); }
.fields label.remember { font-size: 12px; color: var(--muted); display: flex; gap: 4px; align-items: center; margin-top: 4px; }
.fields label.remember input { width: auto; }
.grid td input, .grid td textarea { min-width: 120px; }
.log pre { white-space: pre-wrap; font-size: 12px; color: var(--muted); }

#profile-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px 14px; }
#profile-form h2 { grid-column: 1 / -1; margin-top: 10px; text-transform: capitalize; }
#profile-form label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
#profile-form .wide { grid-column: 1 / -1; }
#profile-form .save { grid-column: 1 / -1; display: flex; gap: 10px; align-items: center; }
.uploads { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.uploads label { display: grid; gap: 4px; }

@media (max-width: 600px) {
  header { gap: 8px 12px; padding: 10px 12px; }
  nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; }
  nav button { white-space: nowrap; }
  #ai-badge { margin-left: auto; }
  main { padding: 12px; }
  .start { flex-direction: column; }
  .fields td:first-child { width: auto; }
}

/* ---------------------------------------------------------------- jobs */
.count { font-size: 11px; background: var(--bg); color: var(--muted); border-radius: 99px; padding: 0 7px; margin-left: 2px; }
nav .count { background: var(--accent); color: var(--accent-text); }
.inline { display: inline-flex; align-items: center; gap: 6px; }
.inline input[type=checkbox] { width: auto; }
.inline select { width: auto; padding: 4px 6px; }
.warn-text { color: var(--warn); }
a.button { display: inline-block; text-decoration: none; color: inherit; border: 1px solid var(--line); background: var(--card);
  border-radius: 6px; padding: 7px 12px; }

.agent { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.agent h2 { margin: 0 0 2px; }
.agent p { margin: 0; }
.agent-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.agent .runlog { grid-column: 1 / -1; }
.agent .runlog summary { cursor: pointer; color: var(--muted); font-size: 12px; }

.jobs-toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.views { display: flex; gap: 4px; flex-wrap: wrap; }
.views button { border-radius: 99px; padding: 5px 12px; }
.views button.active { border-color: var(--accent); color: var(--accent); background: var(--info-bg); }
.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tools input[type=search] { width: 220px; }
.tools select { width: auto; }

#search-settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 16px; align-items: end; }
#search-settings label:not(.inline) { display: grid; gap: 3px; font-size: 12px; color: var(--muted); }
#search-settings .wide { grid-column: 1 / -1; }
#search-settings h2 { margin: 8px 0 0; }
#search-settings .sources { display: flex; flex-wrap: wrap; gap: 8px 18px; }
#search-settings .save { display: flex; gap: 10px; align-items: center; }

.job-list { display: grid; gap: 10px; }
.job { display: grid; grid-template-columns: 64px 1fr; gap: 14px; margin: 0; padding: 14px 16px; }
.score { width: 56px; height: 56px; border-radius: 12px; display: grid; place-items: center; align-content: center; line-height: 1.1; }
.score strong { font-size: 20px; }
.score small { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.score.high { background: var(--ok-bg); color: var(--ok); }
.score.mid { background: var(--warn-bg); color: var(--warn); }
.score.low { background: var(--bg); color: var(--muted); }
.job-main { min-width: 0; display: grid; gap: 5px; }
.job-title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.job-title a { font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; }
.job-title a:hover { color: var(--accent); text-decoration: underline; }
.reasons { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 1px 9px; }
.ai-reason { margin: 0; font-size: 13px; color: var(--accent); }
.job details summary { cursor: pointer; color: var(--muted); }
.job .desc { white-space: pre-line; font-size: 13px; color: var(--muted); max-height: 260px; overflow: auto; margin: 6px 0 0; }
.job .actions { margin: 4px 0 0; }

@media (max-width: 700px) {
  .agent { grid-template-columns: 1fr; }
  .agent-actions { justify-content: flex-start; }
  .job { grid-template-columns: 1fr; }
  .score { width: auto; height: auto; grid-auto-flow: column; gap: 6px; justify-content: start; padding: 4px 10px; }
  .tools input[type=search] { width: 100%; }
}

/* ---------------------------------------------------------------- freelance */
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; margin-bottom: 12px; background: var(--card); }
.mode-switch button { border: none; background: none; border-radius: 7px; padding: 7px 16px; font-weight: 600; color: var(--muted); }
.mode-switch button.active { background: var(--accent); color: var(--accent-text); }
.mode-switch button.active .count { background: var(--accent-text); color: var(--accent); }
.mode-switch .count:empty { display: none; }
.gig .scores { display: grid; gap: 6px; align-content: start; }
.trust { width: 56px; height: 44px; border-radius: 10px; display: grid; place-items: center; align-content: center; line-height: 1.1; }
.trust strong { font-size: 16px; }
.trust small { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; }
.trust.ok { background: var(--ok-bg); color: var(--ok); }
.trust.warn { background: var(--warn-bg); color: var(--warn); }
.trust.bad { background: var(--bad-bg); color: var(--bad); }
.chip-good { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip-bad { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.gig.flagged { border-color: var(--bad); }
.proposal { display: grid; gap: 8px; border-top: 1px dashed var(--line); padding-top: 10px; margin-top: 4px; }
.proposal textarea { min-height: 180px; font-size: 13px; }
@media (max-width: 700px) {
  .gig .scores { grid-auto-flow: column; justify-content: start; }
  .trust { width: auto; height: auto; grid-auto-flow: column; gap: 6px; padding: 4px 10px; }
}

/* ---------------------------------------------------------------- bulk apply */
.queue-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.queue-head h2 { margin: 0 0 2px; }
.queue-head .actions { margin: 0; }
#queue-add { margin: 8px 0; }
#queue-add summary { cursor: pointer; color: var(--accent); }
.queue-form { display: grid; gap: 8px; margin-top: 8px; }
.queue-form button { justify-self: start; }
.queue-table td { vertical-align: middle; }
.q-title { font-weight: 600; }
.q-actions { text-align: right; white-space: nowrap; }
.q-actions button { margin-left: 6px; }
.q-review td:first-child { box-shadow: inset 3px 0 var(--ok); }
.q-needs_answers td:first-child, .q-needs_you td:first-child { box-shadow: inset 3px 0 var(--warn); }
.q-failed td:first-child { box-shadow: inset 3px 0 var(--bad); }
@media (max-width: 700px) {
  .queue-table tr { display: grid; }
  .q-actions { text-align: left; white-space: normal; }
  .q-actions button { margin: 4px 6px 0 0; }
}
