:root {
  --canvas: #f2f4ef;
  --surface: #fbfcf9;
  --ink: #17201c;
  --muted: #56615b;
  --line: #d6dbd2;
  --cobalt: #2742c4;
  --cobalt-soft: #e3e8fb;
  --on-cobalt: #ffffff;
  --ok: #2c7548;
  --ok-soft: #e1efe5;
  --warn: #9a6a00;
  --warn-soft: #f6ecd2;
  --bad: #a2412f;
  --bad-soft: #f5e2dd;
  --new: #c98a00;
  --seg-1: #2742c4;
  --seg-2: #5b74de;
  --seg-3: #2c7548;
  --seg-4: #8aa39a;
  --display: "Bricolage Grotesque", "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius-s: 6px;
  --radius-m: 10px;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --canvas: #101512;
    --surface: #171d19;
    --ink: #e5eae3;
    --muted: #9ba79f;
    --line: #2b342e;
    --cobalt: #93a6ff;
    --cobalt-soft: #1f2748;
    --on-cobalt: #0d1230;
    --ok: #7fcf9a;
    --ok-soft: #173123;
    --warn: #e5b94f;
    --warn-soft: #33290f;
    --bad: #f0907c;
    --bad-soft: #3a1c16;
    --new: #f1bb3c;
    --seg-1: #93a6ff;
    --seg-2: #5f73c9;
    --seg-3: #7fcf9a;
    --seg-4: #4f6158;
  }
}
:root[data-theme="dark"] {
  --canvas: #101512; --surface: #171d19; --ink: #e5eae3; --muted: #9ba79f; --line: #2b342e;
  --cobalt: #93a6ff; --cobalt-soft: #1f2748; --on-cobalt: #0d1230; --ok: #7fcf9a; --ok-soft: #173123; --warn: #e5b94f;
  --warn-soft: #33290f; --bad: #f0907c; --bad-soft: #3a1c16; --new: #f1bb3c;
  --seg-1: #93a6ff; --seg-2: #5f73c9; --seg-3: #7fcf9a; --seg-4: #4f6158;
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
*, *::before, *::after { box-sizing: inherit; }
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font: 400 1rem/1.5 var(--body);
  -webkit-text-size-adjust: 100%;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header ---------- */
.top {
  display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 1rem 2rem;
  max-width: 76rem; margin: 0 auto; padding: 2rem 1.25rem 1.25rem;
}
h1 {
  font: 800 clamp(2.4rem, 7vw, 4.2rem)/0.9 var(--display);
  font-stretch: 78%;
  letter-spacing: -0.02em;
  margin: 0;
}
.tagline { margin: 0.5rem 0 0; color: var(--muted); max-width: 36rem; }
.scan { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.updated { margin: 0; color: var(--muted); font-size: 0.92rem; }

.btn {
  font: 600 0.95rem/1 var(--body);
  border-radius: var(--radius-s);
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--cobalt); border-color: var(--cobalt); color: var(--on-cobalt); }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: 0.6; cursor: progress; }

/* ---------- Filters ---------- */
.filters {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: color-mix(in srgb, var(--canvas) 92%, transparent);
  backdrop-filter: blur(8px);
  border-block: 1px solid var(--line);
}
.filters .row {
  max-width: 76rem; margin: 0 auto; padding: 0.75rem 1.25rem 0;
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; align-items: center;
}
.filters .row:last-child { padding-bottom: 0.75rem; }
.search-field { flex: 1 1 18rem; }
input[type="search"], select {
  width: 100%;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-s);
  padding: 0.6rem 0.75rem;
}
.select, .range { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.92rem; }
.select select { width: auto; }
.range input { accent-color: var(--cobalt); width: 8rem; }
.range output { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }

.chipset { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.chipset legend { float: left; margin-right: 0.35rem; color: var(--muted); font-size: 0.88rem; }
.chipset label {
  display: inline-flex; align-items: center; white-space: nowrap;
  font-size: 0.88rem; padding: 0.35rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; user-select: none;
}
.chipset input { position: absolute; opacity: 0; pointer-events: none; }
.chipset label:has(input:checked) { background: var(--cobalt-soft); border-color: var(--cobalt); color: var(--ink); font-weight: 600; }
.chipset label:has(input:focus-visible) { outline: 3px solid var(--cobalt); outline-offset: 2px; }

@media (max-width: 40rem) {
  .filters { position: static; backdrop-filter: none; }
}

/* ---------- View tabs ---------- */
.views {
  max-width: 76rem; margin: 0 auto; padding: 1rem 1.25rem 0;
  display: flex; gap: 0.25rem; overflow-x: auto;
  box-shadow: inset 0 -1px 0 var(--line);
}
.views button {
  font: 600 0.95rem/1 var(--body); color: var(--muted);
  background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 0.6rem 0.75rem 0.8rem; cursor: pointer; white-space: nowrap;
}
.views button[aria-pressed="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.views .count { font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.views button[data-view="new"] .count:not(:empty) { color: var(--new); font-weight: 700; }

/* ---------- List ---------- */
main { max-width: 76rem; margin: 0 auto; padding: 0 1.25rem 4rem; }
.result-line { color: var(--muted); font-size: 0.92rem; margin: 1rem 0 0.5rem; }
.list { list-style: none; margin: 0; padding: 0; }
.job {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 0.25rem 1.25rem;
  align-items: center;
  padding: 0.9rem 0.75rem 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid transparent;
  content-visibility: auto;
  contain-intrinsic-size: auto 5.5rem;
}
.job[data-elig="yes"] { border-left-color: var(--ok); }
.job[data-elig="relocation"] { border-left-color: var(--warn); }
.job[data-elig="unclear"] { border-left-color: var(--line); }
.job[data-elig="no"] { border-left-color: var(--bad); }
.job[data-elig="no"] .title, .job[data-elig="no"] .score-num { opacity: 0.7; }
.job:hover { background: var(--surface); }

.score { display: grid; gap: 0.3rem; }
.score-num {
  font: 800 2.1rem/0.9 var(--display);
  font-stretch: 80%;
  font-variant-numeric: tabular-nums;
}
.fitbar { display: flex; height: 5px; width: 3.6rem; background: var(--line); border-radius: 3px; overflow: hidden; }
.fitbar i { display: block; height: 100%; }
.fitbar i:nth-child(1) { background: var(--seg-1); }
.fitbar i:nth-child(2) { background: var(--seg-2); }
.fitbar i:nth-child(3) { background: var(--seg-3); }
.fitbar i:nth-child(4) { background: var(--seg-4); }

.main-col { min-width: 0; }
.title-btn {
  all: unset; cursor: pointer; display: block;
  font: 700 1.05rem/1.3 var(--body);
}
.title-btn:focus-visible { outline: 3px solid var(--cobalt); outline-offset: 3px; border-radius: 4px; }
.title-btn:hover .title { text-decoration: underline; text-underline-offset: 3px; }
.meta { color: var(--muted); font-size: 0.92rem; margin-top: 0.15rem; display: flex; flex-wrap: wrap; gap: 0 0.9rem; }
.meta .company { color: var(--ink); font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; }
.tag {
  font-size: 0.8rem; padding: 0.1rem 0.5rem; border-radius: var(--radius-s);
  background: var(--canvas); border: 1px solid var(--line); color: var(--muted);
}
.tag.fam { color: var(--ink); }
.tag.elig-yes { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.tag.elig-relocation { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.tag.elig-no { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.tag.new { background: var(--new); border-color: var(--new); color: #1b1400; font-weight: 700; }
.tag.ai { background: var(--cobalt-soft); border-color: transparent; color: var(--cobalt); }

.side { text-align: right; display: grid; gap: 0.4rem; justify-items: end; }
.age { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.side a { font-weight: 600; color: var(--cobalt); text-decoration: none; white-space: nowrap; font-size: 0.92rem; }
.side a:hover { text-decoration: underline; }
.status-pill { font-size: 0.78rem; color: var(--muted); }

@media (max-width: 40rem) {
  .job { grid-template-columns: 3.4rem 1fr; }
  .score-num { font-size: 1.7rem; }
  .fitbar { width: 2.8rem; }
  .side { grid-column: 2; justify-items: start; text-align: left; grid-auto-flow: column; justify-content: start; gap: 1rem; }
}

.more { display: block; margin: 1.5rem auto 0; }
.empty {
  margin: 2rem 0; padding: 2rem; border: 1px dashed var(--line); border-radius: var(--radius-m);
  background: var(--surface); max-width: 40rem;
}
.empty h2 { font: 700 1.6rem/1.1 var(--display); margin: 0 0 0.5rem; }
.empty p { margin: 0 0 1rem; color: var(--muted); }

/* ---------- Health ---------- */
.health { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.health summary { cursor: pointer; font-weight: 700; }
.health h3 { font: 700 1.15rem/1.2 var(--display); margin: 1.5rem 0 0.5rem; }
.table-wrap { overflow-x: auto; }
.health table { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.health th, .health td { text-align: left; padding: 0.4rem 0.75rem 0.4rem 0; border-bottom: 1px solid var(--line); }
.health th { color: var(--muted); font-weight: 600; }
.health td.num { font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); }
.bad { color: var(--bad); }
.setup li { margin-bottom: 0.6rem; }
.setup code, .detail code { background: var(--surface); border: 1px solid var(--line); padding: 0 0.3rem; border-radius: 4px; font-size: 0.88em; }
.failed-boards { color: var(--muted); font-size: 0.9rem; }

/* ---------- Detail dialog ---------- */
dialog {
  width: min(46rem, calc(100vw - 1.5rem));
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
  padding: 1.5rem;
}
dialog::backdrop { background: rgb(10 15 12 / 0.45); }
dialog[open] { animation: rise 180ms ease-out; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }
.close-form { float: right; margin: -0.5rem -0.5rem 0 1rem; }
.detail h2 { font: 800 clamp(1.6rem, 4vw, 2.2rem)/1.05 var(--display); font-stretch: 85%; margin: 0 0 0.35rem; }
.detail .company-line { color: var(--muted); margin: 0 0 1rem; }
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0 0 1.25rem; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }
.breakdown { display: grid; gap: 0.4rem; margin: 0 0 1.25rem; }
.breakdown .b-row { display: grid; grid-template-columns: 7rem 1fr 3.5rem; gap: 0.75rem; align-items: center; font-size: 0.92rem; }
.breakdown .b-track { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.breakdown .b-track, .breakdown .b-fill { display: block; }
.breakdown .b-fill { height: 100%; width: calc(var(--v) * 1%); }
.breakdown .b-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.why { background: var(--cobalt-soft); color: var(--ink); border-radius: var(--radius-s); padding: 0.75rem 1rem; margin: 0 0 1.25rem; }
.desc { white-space: pre-line; color: var(--ink); max-height: 22rem; overflow: auto; border-top: 1px solid var(--line); padding-top: 1rem; font-size: 0.95rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0 0 1.25rem; }
.actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
