:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1c2024;
  /* Contrast-checked against every light surface this is used on: 5.15:1 on
     --surface-2, 5.78:1 on --surface, 5.39:1 on --bg. The previous #6b7280
     measured 4.31:1 on --surface-2 (table headers, hidden/n-a badges), under
     the WCAG AA 4.5:1 floor for normal text. Dark mode already passed. */
  --muted: #5f6673;
  --brand: #3457d5;
  --brand-ink: #ffffff;
  --ok-bg: #e6f6ec; --ok-fg: #1a7f43;
  --warn-bg: #fdf0da; --warn-fg: #9a5b0a;
  --err-bg: #fde8e8; --err-fg: #b42318;
  --info-bg: #e8f0fe; --info-fg: #1f4fb8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.10);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1116;
    --surface: #161a21;
    --surface-2: #1c222b;
    --border: #2a313c;
    --text: #e6e9ef;
    --muted: #97a0ad;
    --brand: #5b7cff;
    --brand-ink: #0b1020;
    --ok-bg: #12331f; --ok-fg: #6ee7a0;
    --warn-bg: #3a2a10; --warn-fg: #f2c078;
    --err-bg: #3a1414; --err-fg: #ff9b93;
    --info-bg: #16233f; --info-fg: #9db9ff;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { font-weight: 700; font-size: 1.05rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.nav { margin-left: auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--text); text-decoration: none; }
.who { color: var(--muted); font-size: .85rem; }

.container { width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem; flex: 1; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.25rem; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.1rem 0 .4rem; }
.sub { color: var(--muted); margin: .2rem 0 0; }
.crumb { margin: 0 0 1rem; }
.head-meta { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.strong { font-weight: 600; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.auth-card { max-width: 420px; margin: 3rem auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 780px) { .grid-2 { grid-template-columns: 1fr; } }
.stack { display: flex; flex-direction: column; gap: .9rem; }
.empty { text-align: center; padding: 3rem 1.25rem; }

label { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=file],
input[type=number], select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }

.form-actions { display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .55rem .95rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { text-decoration: none; filter: brightness(1.03); }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .35rem .65rem; font-size: .82rem; }
.inline { display: inline; margin: 0; }

.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error, .alert-error.alert { background: var(--err-bg); color: var(--err-fg); }
.alert-ok { background: var(--ok-bg); color: var(--ok-fg); }
.alert-info { background: var(--info-bg); color: var(--info-fg); }
.pw, code.pw { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(127,127,127,.15); padding: .1rem .4rem; border-radius: 5px; }

.filters { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: .85rem; font-weight: 600;
}
.chip:hover { text-decoration: none; color: var(--text); }
.chip-on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
/* No opacity here: fading muted-on-white dropped the counts to 3.28:1, and the
   counts are the numbers the user scans. Weight carries the de-emphasis now. */
.chip-n { font-size: .75rem; font-weight: 500; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table.listings { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.listings th, table.listings td { text-align: left; padding: .7rem .85rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.listings th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
/* Long free-text columns wrap instead of stretching the row to several hundred
   px; the numeric/badge columns keep nowrap so they stay scannable. */
table.listings td:nth-child(1), table.listings td:nth-child(2) { white-space: normal; max-width: 26ch; }
table.listings tbody tr[data-href] { cursor: pointer; }
table.listings tbody tr:hover { background: var(--surface-2); }
table.listings tr:last-child td { border-bottom: none; }
.num { text-align: right; }
.rowlink { font-weight: 500; }
/* The company cell is now a real link (middle-click, copy, keyboard) but keeps
   its original plain-bold look so a 500-row table is not a wall of blue. */
td.strong .rowlink { color: inherit; font-weight: 600; }
td.strong .rowlink:hover { color: var(--brand); }
.table-legend { margin: .6rem .15rem 0; }

.score { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--text); }
.score-lg { font-size: 1.1rem; padding: .1rem .5rem; background: var(--surface-2); border-radius: 8px; }

.badge {
  display: inline-block; padding: .15rem .5rem; border-radius: 999px;
  font-size: .74rem; font-weight: 700; text-transform: lowercase;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.badge-new { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.badge-applied { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.badge-rejected { background: var(--err-bg); color: var(--err-fg); border-color: transparent; }
.badge-hidden { background: var(--surface-2); color: var(--muted); }
.badge-pipe-drafted { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.badge-pipe-done { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.badge-pipe-delisted { background: var(--err-bg); color: var(--err-fg); border-color: transparent; }

/* ATS keyword-match badge: green >= 85, yellow 70-84, red < 70, muted n/a. */
.badge-ats { text-transform: none; font-variant-numeric: tabular-nums; }
.badge-ats-green { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }
.badge-ats-yellow { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.badge-ats-red { background: var(--err-bg); color: var(--err-fg); border-color: transparent; }
.badge-ats-na { background: var(--surface-2); color: var(--muted); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }

.prose {
  white-space: pre-wrap; word-break: break-word;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: .8rem; font-size: .85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  max-height: 480px; overflow: auto;
}
.profile { max-height: 320px; }

.status-buttons { display: flex; gap: .5rem; flex-wrap: wrap; margin: 0; }
/* The current status is a state readout, not an action, so it must not borrow
   the primary-action blue that Sign in / Upload / Open posting own. */
.btn-current {
  background: var(--surface-2); color: var(--text);
  border: 2px solid var(--brand); font-weight: 700; cursor: default;
}
.btn-current::before { content: "\2713"; margin-right: .35rem; }

.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .7rem; }
.files li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.file-main { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; min-width: 0; }
.file-main .btn { text-decoration: none; }
.file-meta { word-break: break-word; }

/* Apply CTA promoted out of the details list: this is the point of the page. */
.action-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin: 0 0 1.25rem;
}

/* Dashboard onboarding checklist (empty account). */
.onboarding { padding: 1.5rem; }
.checklist { list-style: none; margin: 1rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 1.1rem; }
.checklist li { display: flex; gap: .85rem; align-items: flex-start; text-align: left; }
.checklist p { margin: .2rem 0 .5rem; }
.checklist p:last-child { margin-bottom: 0; }
.check-mark {
  flex: 0 0 1.6rem; width: 1.6rem; height: 1.6rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.checklist li.done .check-mark { background: var(--ok-bg); color: var(--ok-fg); border-color: transparent; }

/* Submit feedback. Never disable the button: listing.ejs status buttons carry
   name/value, and a disabled submit button is omitted from the payload. */
form.is-busy .btn { pointer-events: none; opacity: .7; }
form.is-busy { cursor: progress; }

/* Focus: inputs already had a ring; buttons, chips and links fell back to the
   UA default, which is close to invisible on the brand-blue fills. */
.btn:focus-visible, .chip:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
.btn-primary:focus-visible, .chip-on:focus-visible { outline-color: var(--text); }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 10;
  background: var(--surface); color: var(--brand);
  padding: .6rem .9rem; border: 1px solid var(--border); border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

@media (max-width: 640px) {
  /* The three triage columns must survive on a phone; Pipeline and Added are
     the two that can be recovered from the detail page. */
  table.listings .col-pipeline, table.listings .col-added { display: none; }
  table.listings td:nth-child(1), table.listings td:nth-child(2) { max-width: 18ch; }
  table.listings th, table.listings td { padding: .6rem .55rem; }
  .who { display: none; }
  .topbar { flex-wrap: wrap; gap: .6rem; }
  .nav { gap: .85rem; }
  .action-bar .btn { width: 100%; }
}

/* Section spacing for the settings page; kept in CSS (not a style= attribute)
   so the CSP can stay style-src 'self' with no 'unsafe-inline'. */
.card-gap-b { margin-bottom: 1.25rem; }
.card-gap-t { margin-top: 1.25rem; }
