/* Colors come from the palette chosen in the dashboard (Settings → Colors).
   These defaults are the "Harbor" palette, used until the palette loads and on the login page. */
:root {
  --bg: #F4F6F8;
  --surface: #FFFFFF;
  --ink: #172230;
  --muted: #566374;
  --line: #DDE3EA;
  --accent: #1F5FBF;
  --accent-ink: #FFFFFF;
  --soft: #E7EFFB;
  --good: #1E7A4F;
  --warn: #A35F00;
  --bad: #B4443A;
  --perfect: #0F6E6A;
  --high: #1F5FBF;
  --low: #7F8998;

  /* older names used across the stylesheet */
  --paper: var(--bg);
  --focus: var(--accent);
  --medium: var(--warn);

  --radius-s: 6px;
  --radius-m: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", sans-serif;
  --font-letter: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  font-variant-numeric: tabular-nums;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
}
a.btn { text-decoration: none; display: inline-block; }
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); opacity: .92; }
.btn-danger { color: var(--bad); }
.btn-small { padding: 4px 10px; font-size: 13px; }
input[type="text"], input[type="url"], input[type="search"], input[type="password"], input[type="number"], select, textarea {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 10px;
}

/* ---------- app frame ---------- */
.app { min-height: 100vh; }
.app[data-layout="inbox"] { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.app[data-layout="inbox"] .topbar,
.app[data-layout="board"] .sidebar,
.app[data-layout="inbox"] .board,
.app[data-layout="board"] .inbox,
.app[data-layout="board"] .jobs-head { display: none; }
.main { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.app[data-layout="board"] .main { min-height: calc(100vh - 61px); }

.brand { font-weight: 700; font-size: 18px; margin: 0; letter-spacing: -0.01em; }
.conn { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); border: 0; background: none; padding: 0; cursor: pointer; text-align: left; }
.conn:hover { color: var(--ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--low); flex: none; }
.dot.on { background: var(--good); }
.dot.warn { background: var(--warn); }
.dot.off { background: var(--bad); }

/* Inbox: sidebar */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow: auto;
  display: flex; flex-direction: column; gap: 20px;
  padding: 22px 14px; background: var(--surface); border-right: 1px solid var(--line);
}
.sidebar .brand { padding: 0 8px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none;
  color: var(--ink); text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--bg); }
.nav-item[aria-current="page"] { background: var(--soft); color: var(--accent); font-weight: 600; }
.nav-item .n { color: var(--muted); font-size: 13px; }
.nav-item[aria-current="page"] .n { color: inherit; }
.nav-item.attention .n { color: var(--bad); font-weight: 600; }
.nav-label { font-size: 12px; color: var(--muted); padding: 0 12px; margin: 4px 0 2px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 8px; font-size: 13px; }

.view-switch { display: flex; border: 1px solid var(--line); border-radius: 8px; padding: 2px; gap: 2px; background: var(--bg); }
.view-switch button { flex: 1; border: 0; background: none; padding: 6px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; }
.view-switch button[aria-pressed="true"] { background: var(--surface); color: var(--accent); font-weight: 600; box-shadow: 0 0 0 1px var(--line); }

/* Board: top bar */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .views { display: flex; gap: 2px; }
.views button { border: 0; background: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.views button:hover { color: var(--ink); }
.views button[aria-current="page"] { color: var(--accent); background: var(--soft); font-weight: 600; }
.topbar .spacer { flex: 1; }
.topbar { gap: 12px; }
.topbar input[type="search"] { width: 200px; }
@media (max-width: 1360px) { .topbar .conn span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

.banner { margin: 14px 28px 0; padding: 10px 14px; border-radius: var(--radius-m); border: 1px solid var(--line); background: var(--surface); }
.banner.error { border-color: var(--bad); color: var(--bad); }

/* ---------- jobs: shared pieces ---------- */
.jobs-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 22px 28px; border-bottom: 1px solid var(--line); }
.jobs-head h1 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.jobs-head p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: color-mix(in srgb, var(--muted) 14%, transparent); color: var(--muted); white-space: nowrap; }
.chip.perfect_match { background: color-mix(in srgb, var(--perfect) 16%, transparent); color: var(--perfect); }
.chip.high { background: color-mix(in srgb, var(--high) 14%, transparent); color: var(--high); }
.chip.medium { background: color-mix(in srgb, var(--warn) 14%, transparent); color: var(--warn); }
.chip.low { color: var(--low); }
.chip.bad { background: color-mix(in srgb, var(--bad) 14%, transparent); color: var(--bad); }

.score-bar { display: block; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.score-bar i { display: block; height: 100%; background: var(--low); }
.score-bar.perfect_match i { background: var(--perfect); }
.score-bar.high i { background: var(--high); }
.score-bar.medium i { background: var(--warn); }

.wait-now { color: var(--perfect); font-weight: 600; }
.wait-next { color: var(--high); }
.wait-now::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.empty { padding: 32px 20px; color: var(--muted); list-style: none; }
.list-note { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 14px; list-style: none; }
.list-note.is-running { color: var(--perfect); }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); flex: 1; min-height: 0; }
.list-col { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-tools { display: flex; gap: 8px; padding: 12px; }
.list-tools input { flex: 1; min-width: 0; }
.list-tools select { width: auto; }
.job-list { list-style: none; margin: 0; padding: 0 12px 12px; display: flex; flex-direction: column; gap: 6px; }
.job-row {
  width: 100%; text-align: left; cursor: pointer; color: inherit;
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; border-radius: 10px; border: 1px solid transparent; background: none;
}
.job-row:hover { background: var(--surface); }
.job-row[aria-current="true"] { background: var(--surface); border-color: var(--accent); }
.job-row .t, .card .t { font-weight: 600; line-height: 1.35; }
.job-row .m, .card .m { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13px; color: var(--muted); }
.job-row .s, .card .s { font-size: 13px; color: var(--muted); }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; color: var(--muted); font-size: 13px; }
.reader { padding: 26px 36px 40px; min-width: 0; }

/* ---------- Board ---------- */
.board { display: grid; grid-template-columns: minmax(0, 1fr); flex: 1; min-height: 0; }
.board.has-drawer { grid-template-columns: minmax(0, 1fr) minmax(380px, 480px); }
.board-tools { display: flex; gap: 12px; align-items: center; padding: 14px 24px 0; font-size: 14px; color: var(--muted); }
.columns { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 16px; padding: 16px 24px 32px; overflow-x: auto; align-items: start; }
.col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.col-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; color: var(--muted); }
.col-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.card {
  width: 100%; text-align: left; cursor: pointer; color: inherit;
  display: flex; flex-direction: column; gap: 8px;
  padding: 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.card:hover { border-color: var(--muted); }
.card[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.s-error { border-color: var(--bad); }
.drawer { border-left: 1px solid var(--line); background: var(--surface); overflow: auto; position: sticky; top: 61px; max-height: calc(100vh - 61px); padding: 22px 26px 36px; }

/* ---------- job view (Inbox reader + Board drawer) ---------- */
.jv { display: flex; flex-direction: column; gap: 16px; max-width: 780px; }
.jv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.jv .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.jv h2 { margin: 6px 0 4px; font-size: 22px; line-height: 1.3; letter-spacing: -0.01em; }
.jv h2 a { color: inherit; }
.jv-facts { margin: 0; color: var(--muted); font-size: 14px; }
.notice { padding: 14px 16px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.notice h3 { margin: 0; font-size: 14px; }
.notice p { margin: 0; }
.notice .row { gap: 8px; }
.icon-btn { width: 40px; height: 40px; flex: none; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.back-btn { display: none; }

.letter {
  font-family: var(--font-letter);
  font-size: 16.5px; line-height: 1.65;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px 26px;
  white-space: pre-wrap;
  width: 100%;
  min-height: 300px;
  resize: vertical;
}
.app[data-layout="board"] .letter { background: var(--bg); min-height: 260px; }
.actions, .letter-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.byline { margin: 0; font-size: 13px; color: var(--muted); }

.more { border-top: 1px solid var(--line); padding-top: 12px; }
.more > summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.more[open] > summary { margin-bottom: 4px; }
.section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h3 { font-size: 14px; margin: 0 0 8px; }
.section p { margin: 0 0 8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px 16px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12px; }
.facts dd { margin: 0; font-weight: 600; }
.reasons { margin: 0; padding-left: 18px; }
.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); }
.scores { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.scores div span { font-size: 12px; color: var(--muted); }
.scores b { display: block; font-size: 18px; }
.match { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.match .row { justify-content: space-between; }
.desc { white-space: pre-wrap; font-size: 14px; }
.notes { width: 100%; min-height: 70px; }
.form-error { color: var(--bad); margin: 0; }

/* ---------- Activity (list + detail) ---------- */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 28px 0; }
.toolbar .grow { flex: 1; min-width: 180px; }
.desk { display: grid; grid-template-columns: minmax(300px, 2fr) 3fr; gap: 16px; margin: 12px 28px 24px; align-items: start; }
.queue { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.queue ol { list-style: none; margin: 0; padding: 0; }
.item {
  display: grid; grid-template-columns: 4px 1fr auto; gap: 0 12px; width: 100%; text-align: left;
  border: 0; border-bottom: 1px solid var(--line); cursor: pointer; padding: 10px 14px 10px 0; background: none; color: inherit;
}
.item:hover, .item[aria-current="true"] { background: var(--bg); }
.item .spine { grid-row: 1 / span 2; border-radius: 0 2px 2px 0; background: var(--low); }
.item .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.item .meta { grid-column: 2 / span 2; color: var(--muted); font-size: 13px; display: flex; gap: 12px; flex-wrap: wrap; }
.item .score { font-size: 13px; color: var(--muted); text-align: right; }
.detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow: auto; }
.detail header { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.detail h2 { margin: 6px 0 4px; font-size: 20px; line-height: 1.3; }
.detail .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.detail .section { padding: 16px 22px; }
.detail .empty { padding: 32px 20px; }
.tag { display: inline-block; color: #fff; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--low); }
.tag.plain { background: none; color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.tag.bad { background: var(--bad); }

/* ---------- runs & settings ---------- */
.panel { margin: 16px 28px 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px 22px; }
.panel h2 { margin: 0 0 12px; font-size: 17px; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.form-row label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; }
pre.config { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px; overflow: auto; font-size: 13px; max-height: 480px; }

/* ---------- Settings → Colors ---------- */
.colors-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 24px; align-items: start; }
.colors-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.colors-bar label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 18px; }
.color-field { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 2px 12px; align-items: center; }
.color-field input[type="color"] { grid-row: 1 / span 2; width: 44px; height: 44px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.color-field .name { font-weight: 600; font-size: 14px; }
.color-field .help { font-size: 12px; color: var(--muted); }
.color-field input[type="text"] { grid-column: 2; width: 110px; padding: 3px 8px; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.color-field.invalid input[type="text"] { border-color: var(--bad); }
.preview { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); position: sticky; top: 76px; }
.preview .pv-page { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.preview .pv-card { padding: 14px; border-radius: 10px; border: 1px solid; display: flex; flex-direction: column; gap: 8px; }
.preview .pv-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.preview .pv-chip { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.preview .pv-btn { padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; border: 1px solid; }
.contrast-warn { color: var(--warn); font-size: 13px; margin: 8px 0 0; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: var(--radius-m); font-size: 14px;
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; width: min(360px, 100%); display: grid; gap: 12px; }
.login h1 { font-size: 20px; margin: 0; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.login .error { color: var(--bad); font-size: 14px; min-height: 1.5em; }

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .app[data-layout="inbox"] { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 14px 16px; gap: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav-list { flex-direction: row; overflow-x: auto; }
  .nav-item { width: auto; white-space: nowrap; }
  .nav-label { display: none; }
  .side-foot { flex-direction: row; flex-wrap: wrap; align-items: center; padding: 0; }
  .inbox { grid-template-columns: 1fr; }
  .inbox.reading .list-col { display: none; }
  .inbox:not(.reading) .reader { display: none; }
  .back-btn { display: inline-flex; }
  .reader { padding: 18px 16px 32px; }
  .jobs-head, .banner, .panel, .toolbar, .desk { margin-left: 16px; margin-right: 16px; }
  .jobs-head { margin: 0; padding: 16px; }
  .topbar { padding: 10px 16px; }
  .topbar input[type="search"] { width: 100%; order: 5; }
  .board.has-drawer { grid-template-columns: minmax(0, 1fr); }
  .drawer { position: fixed; inset: 0; z-index: 30; max-height: none; border-left: 0; }
  .columns { padding: 12px 16px 24px; }
  .desk { grid-template-columns: 1fr; }
  .detail { position: static; max-height: none; }
  .scores { grid-template-columns: repeat(2, 1fr); }
  .colors-editor { grid-template-columns: 1fr; }
  .preview { position: static; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------- Upwork access ---------- */
.auth-facts { padding: 0 0 12px; border-bottom: 0; }
.auth-bar { max-width: 480px; margin-bottom: 8px; }
.auth-bar i { background: var(--good); }
.auth-bar.warn i { background: var(--medium); }
.auth-facts { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }

.retry-all { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--paper); }

.wait-now { color: var(--perfect); font-weight: 600; }
.wait-next { color: var(--high); }
.wait-now::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: currentColor; margin-right: 6px; vertical-align: middle; animation: pulse 1.2s ease-in-out infinite; }
.retry-all.is-running { color: var(--perfect); }
@keyframes pulse { 50% { opacity: .25; } }

/* ---------- settings form ---------- */
.settings-form { margin: 0; }
.settings-form fieldset.panel { border: 1px solid var(--line); min-width: 0; }
.settings-form legend { font-weight: 650; font-size: 17px; padding: 0 6px; margin-left: -6px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px 24px; margin-top: 10px; }
.field { display: grid; gap: 4px; align-content: start; }
.field > label { font-size: 13px; color: var(--muted); }
.field small { font-size: 12px; }
.field-check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.field.field-check { align-self: end; padding-bottom: 6px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 4px; }
.guidelines { width: 100%; min-height: 320px; font-family: var(--font-letter); font-size: 15px; line-height: 1.6; }
.save-bar {
  position: sticky; bottom: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin: 0 20px 20px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
}
.form-error { color: var(--bad); margin: 0; flex-basis: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 900px) { .save-bar { margin-left: 16px; margin-right: 16px; } }

/* ---------- activity ---------- */
.act-warn .spine { background: var(--medium); }
.act-error .spine { background: var(--bad); }
.act-info .spine { background: var(--line); }
#act-list .title { font-weight: 500; }
#act-detail pre.config { white-space: pre-wrap; word-break: break-word; max-height: 60vh; }
#act-job { display: inline-flex; gap: 8px; align-items: center; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--paper); }

/* ---------- AI providers ---------- */
table.providers td { vertical-align: top; }
.prov-off td { color: var(--muted); }
.prov-state { font-weight: 600; }
.prov-state-ready { color: var(--good); }
.prov-state-cooling, .prov-state-quota { color: var(--medium); }
.prov-state-broken { color: var(--bad); }
.prov-state-off { color: var(--muted); font-weight: 500; }
@media (max-width: 700px) { table.providers th:nth-child(5), table.providers td:nth-child(5) { display: none; } }

/* ---------- rewrite & versions ---------- */
.rewrite { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); max-width: 70ch; }
.rewrite-input { width: 100%; resize: vertical; }
.prompt-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip { display: inline-flex; align-items: stretch; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); overflow: hidden; }
.chip button { border: 0; background: none; cursor: pointer; font-size: 13px; padding: 3px 10px; }
.chip .chip-remove { padding: 3px 8px 3px 4px; color: var(--muted); }
.chip .chip-use:hover { background: var(--paper); }
.chip .chip-remove:hover { color: var(--bad); }
.versions-box { margin-top: 14px; max-width: 70ch; }
.versions-box summary { cursor: pointer; color: var(--muted); font-size: 14px; }
.versions { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 12px; }
.versions li { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; }
.versions .row { justify-content: space-between; }
.version-text { white-space: pre-wrap; font-family: var(--font-letter); font-size: 14px; max-height: 160px; overflow: auto; margin: 6px 0; }
.version-instr { margin: 4px 0 0; font-size: 13px; }

/* ---------- status picker & undo toast ---------- */
.status-pick { display: inline-flex; align-items: center; gap: 6px; }
.status-pick select { padding: 5px 8px; }
.toast { display: flex; align-items: center; gap: 14px; }
.toast-action { border: 0; background: none; color: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }
.colors-bar label.field-check { display: flex; align-items: center; gap: 8px; padding-bottom: 8px; color: var(--ink); }

/* score number next to the bar (Board cards) */
.score-line { display: flex; align-items: center; gap: 8px; }
.score-line .score-bar { flex: 1; }
.score-num { font-size: 12px; font-weight: 700; color: var(--ink); min-width: 4ch; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Board columns as distinct panels ---------- */
.columns { gap: 14px; align-items: stretch; }
.col {
  --col-color: var(--low);
  background: color-mix(in srgb, var(--ink) 4%, var(--bg));
  border: 1px solid var(--line);
  border-top: 3px solid var(--col-color);
  border-radius: 12px;
  padding: 12px 12px 14px;
  min-height: 420px;
}
.col-waiting { --col-color: var(--warn); }
.col-ready { --col-color: var(--accent); }
.col-applied { --col-color: var(--good); }
.col-closed { --col-color: var(--low); }
.col-filtered { --col-color: var(--bad); }
.col-head { color: var(--ink); padding: 2px 2px 6px; justify-content: flex-start; }
.col-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--col-color); flex: none; }
.col-name { flex: 1; min-width: 0; }
.col-count {
  min-width: 26px; padding: 1px 8px; border-radius: 999px; text-align: center;
  font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--col-color) 16%, transparent); color: var(--col-color);
}
.col .card { box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 8%, transparent); }
.col .card[aria-current="true"] { box-shadow: 0 0 0 1px var(--accent); }
.col .empty {
  padding: 22px 12px; text-align: center; font-size: 14px;
  border: 1px dashed var(--line); border-radius: 10px;
}
.col .list-note { background: var(--surface); }
.board-tools { padding: 14px 24px 0; }

/* full fact line on Board cards */
.card .f { font-size: 13px; line-height: 1.45; color: var(--muted); }
.nb { white-space: nowrap; }
.job-row .f { font-size: 13px; line-height: 1.45; color: var(--muted); }

/* jobs view fills the page height, so the Inbox divider runs all the way down */
#view-jobs { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---------- job panel full screen ---------- */
.jv-tools { display: flex; gap: 8px; align-items: center; flex: none; }
.board.detail-full.has-drawer { grid-template-columns: minmax(0, 1fr); }
.board.detail-full > div:first-child { display: none; }
.board.detail-full .drawer { border-left: 0; padding: 28px 32px 48px; }
.inbox.detail-full { grid-template-columns: minmax(0, 1fr); }
.inbox.detail-full .list-col { display: none; }
.detail-full .jv { max-width: 900px; margin: 0 auto; }
.detail-full .letter { min-height: 440px; }
@media (max-width: 900px) { .expand-btn { display: none; } }

/* ---------- Settings → Colors: template gallery ---------- */
.palette-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.pal-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.pal-card.in-use { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.pal-preview { padding: 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.pal-mini-card { padding: 12px; border-radius: 10px; border: 1px solid; display: flex; flex-direction: column; gap: 6px; }
.pal-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pal-chip { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pal-title { font-size: 13px; line-height: 1.35; }
.pal-meta { font-size: 12px; }
.pal-bar { display: block; height: 4px; border-radius: 2px; overflow: hidden; }
.pal-bar i { display: block; height: 100%; }
.pal-btn { padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; border: 1px solid; }
.pal-status { font-size: 12px; gap: 10px; }
.pal-swatches { display: flex; height: 10px; border-radius: 5px; overflow: hidden; }
.pal-swatches span { flex: 1; }
.pal-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--line); }
.pal-kind { font-size: 12px; }
.pal-actions { display: flex; gap: 8px; align-items: center; }
.pal-inuse { font-size: 13px; font-weight: 700; color: var(--accent); }
.pal-add { margin-top: 20px; border-top: 1px solid var(--line); padding-top: 14px; }
.pal-add > summary { cursor: pointer; font-weight: 600; }
.pal-add-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 340px); gap: 18px; align-items: start; margin-top: 8px; }
.pal-template { width: 100%; min-height: 400px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.pal-live { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 8px; }
.pal-msg { margin: 0 0 10px; font-size: 13px; }
@media (max-width: 900px) { .pal-add-grid { grid-template-columns: 1fr; } }

/* ---------- job panel: at a glance + job post beside the draft ---------- */
.glance {
  display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; font-size: 14px;
  border: 1px solid var(--line); border-radius: 10px; background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.glance p { margin: 0; }
.glance-flags { color: var(--warn); }
.glance-flags .reasons { color: var(--ink); margin-top: 2px; }
.glance-skills { display: flex; flex-wrap: wrap; gap: 6px; }
.skill { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.jv-body { display: grid; gap: 18px; }
.post h3, .draft-block h3 { margin: 0 0 8px; font-size: 14px; }
.post-text {
  white-space: pre-wrap; font-size: 14px; line-height: 1.6; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg);
  max-height: 240px; overflow: auto;
}
.post.open .post-text { max-height: none; }
.post-toggle { margin-top: 8px; }
.draft-block { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.draft-block .letter { margin: 0; }
/* Full screen: post on the left, draft on the right */
.detail-full .jv { max-width: 1440px; }
.detail-full .jv-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: start; }
.detail-full .post { position: sticky; top: 0; }
.detail-full .post-text, .detail-full .post.open .post-text { max-height: calc(100vh - 220px); }
.detail-full .post-toggle { display: none; }

/* scores at the top of the job panel */
.glance-scores { gap: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.glance-scores b { font-size: 17px; }

/* ---------- Usage & cost ---------- */
.usage-title { margin: 0; font-size: 20px; }
.usage-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin: 16px 28px 0; }
.usage-tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 18px; display: flex; flex-direction: column; gap: 2px; }
.usage-tile b { font-size: 26px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.usage-tile span { color: var(--muted); font-size: 13px; }
.usage-tile small { color: var(--muted); font-size: 12px; }
.usage-chart { position: relative; }
.chart-scale { font-size: 12px; margin-bottom: 6px; }
.chart-plot { display: flex; align-items: flex-end; gap: 2px; height: 160px; border-bottom: 1px solid var(--line); padding-top: 4px; }
.chart-col { flex: 1; max-width: 48px; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: default; outline-offset: 2px; }
.chart-bar { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; }
.chart-col:hover .chart-bar, .chart-col:focus .chart-bar { opacity: .8; }
.chart-x { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.usage-chart .chart-plot { margin-bottom: 26px; }
.chart-tip { position: absolute; top: 0; left: 0; white-space: nowrap; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 13px; padding: 6px 10px; border-radius: 8px; }
.table-scroll { overflow-x: auto; }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.call-bad td { color: var(--muted); }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; text-align: left; font: inherit; }
.linkish:hover { text-decoration: underline; }
@media (max-width: 900px) { .usage-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 16px 16px 0; } }
th.num { text-align: right; }

/* ---------- Portfolio ---------- */
.pf-note { margin: 8px 28px 0; max-width: 80ch; }
.pf-import { margin-bottom: 0; }
.pf-import .checks { margin: 12px 0; }
.pf-import-actions, .pf-form .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pf-result ul { margin: 4px 0 0; padding-left: 20px; font-size: 14px; }
.pf-form { display: grid; gap: 14px; }
.pf-form input[type="text"], .pf-form input[type="url"], .pf-form textarea { width: 100%; }
.pf-form textarea { resize: vertical; line-height: 1.5; }
.pf-finished { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--bg); }
#view-portfolio .queue { max-height: calc(100vh - 220px); overflow: auto; }
@media (max-width: 900px) { #view-portfolio .desk { grid-template-columns: 1fr; margin: 12px 16px 24px; } .pf-note { margin: 8px 16px 0; } }

/* Settings → Layout and colors */
.settings-look { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.settings-look > span:first-child { font-weight: 600; }
.settings-look .view-switch { width: 200px; }

.usage-section { margin: 26px 28px 0; font-size: 16px; }
.usage-sub { margin: 4px 28px 0; }
@media (max-width: 900px) { .usage-section, .usage-sub { margin-left: 16px; margin-right: 16px; } }

/* AI menu */
.ai-menu { position: relative; }
.ai-menu > summary { list-style: none; }
.ai-menu > summary::-webkit-details-marker { display: none; }
.ai-pop { position: absolute; z-index: 50; width: min(380px, calc(100vw - 32px)); max-height: min(78vh, 680px); overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.18); padding: 14px 16px; display: grid; gap: 12px; font-size: 13px; }
/* The sidebar scrolls (overflow: auto), so its menu is fixed next to it instead of inside it. */
.ai-menu-up .ai-pop { position: fixed; left: 252px; bottom: 16px; }
@media (max-width: 900px) { .ai-menu-up .ai-pop { left: 16px; } }
.ai-menu-down .ai-pop { top: calc(100% + 10px); right: 0; }
.ai-pop-head b { font-size: 14px; }
.ai-pop-head p { margin: 4px 0 0; }
.ai-pop-sec { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.ai-pop-label { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ai-pop-foot { margin: 0; border-top: 1px solid var(--line); padding-top: 10px; }
.row.wrap { flex-wrap: wrap; gap: 6px; }
.ai-bar { height: 6px; }
.ai-bar.is-high i { background: var(--bad); }
.model-list { display: grid; gap: 6px; }
.model-card { display: grid; gap: 2px; text-align: left; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 8px 10px; cursor: pointer; font: inherit; }
.model-card:hover { border-color: var(--accent); }
.model-card.is-on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: var(--soft); }
.model-card:disabled { opacity: .55; cursor: not-allowed; }
.model-name { display: flex; align-items: center; gap: 8px; }
.tier { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; border: 1px solid currentColor; }
.tier-cheap { color: var(--good); }
.tier-premium { color: var(--perfect); }
.field { min-width: 0; }
.field select { max-width: 100%; }
.field-wide { grid-column: span 2; }
@media (max-width: 640px) { .field-wide { grid-column: auto; } }
.sidebar:has(.ai-menu[open]) { z-index: 40; }
