/* ============ base ============ */
:root {
  --bg: #0f1117;
  --surface: #181b24;
  --surface-2: #20242f;
  --border: #2b303c;
  --text: #e6e8ee;
  --muted: #9aa1b1;
  --primary: #5b8cff;
  --primary-2: #3f6fe0;
  --green: #3fb950;
  --red: #f85149;
  --amber: #d29922;
  --radius: 10px;
}
* { box-sizing: border-box; }
/* The `hidden` attribute must win over component `display:` rules (.nav/.modal/.auth-form
   set display:flex, which would otherwise override the UA [hidden]{display:none}). */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.grow-2 { grid-column: span 2; }
.error { color: var(--red); }
button { font: inherit; cursor: pointer; }

/* ============ nav ============ */
.nav {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  color: var(--muted); padding: 6px 12px; border-radius: 8px; font-weight: 500;
}
.nav-links a:hover { background: var(--surface-2); text-decoration: none; }
.nav-links a.active { color: var(--text); background: var(--surface-2); }
.nav-user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.badge {
  display: inline-block; min-width: 18px; padding: 0 6px; font-size: 11px;
  background: var(--primary); color: #fff; border-radius: 10px; text-align: center;
}

/* ============ buttons ============ */
.btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 8px 14px; border-radius: 8px; }
.btn:hover { border-color: var(--primary); }
.btn-primary { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn-primary:hover { background: var(--primary); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 9px; font-size: 12px; }

/* ============ layout ============ */
main { max-width: 1280px; margin: 0 auto; padding: 18px; }
.view { animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ auth ============ */
.auth-view { display: flex; justify-content: center; padding-top: 8vh; }
.auth-card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px; width: 380px; max-width: 92vw; }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; }
.tabs { display: flex; gap: 6px; margin: 18px 0 14px; }
.tab { flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  padding: 8px; border-radius: 8px; color: var(--muted); }
.tab.active { color: #fff; background: var(--primary-2); border-color: var(--primary-2); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.spinner { width: 34px; height: 34px; margin: 18px auto; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.col-check { width: 32px; text-align: center; padding-left: 6px; padding-right: 6px; }
.col-check input { cursor: pointer; }

label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 8px 10px; border-radius: 8px; font: inherit; width: 100%;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }

/* ============ filters ============ */
.filters { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.filter-row:last-child { margin-bottom: 0; }
.filter-row > input, .filter-row > select { flex: 1; min-width: 140px; width: auto; }
.filter-row > input.grow { flex: 2; }
/* Stack picker: a dropdown of grouped checkbox chips */
.stack-pick { position: relative; flex: 1; min-width: 160px; }
.stack-pick > summary { list-style: none; cursor: pointer; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 10px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack-pick > summary::-webkit-details-marker { display: none; }
.stack-pick > summary::after { content: '▾'; float: right; color: var(--muted); margin-left: 8px; }
.stack-pick[open] > summary { border-color: var(--primary); }
.stack-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: min(560px, 92vw);
  max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.stack-hint { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stack-group { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 0;
  border-top: 1px solid var(--border); }
.stack-group:first-of-type { border-top: 0; }
.stack-group-name { width: 100%; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.stack-chip { flex-direction: row; align-items: center; gap: 5px; color: var(--text); font-size: 13px;
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; cursor: pointer; white-space: nowrap; }
.stack-chip input { width: auto; margin: 0; }
.stack-chip:has(input:checked) { border-color: var(--primary); background: rgba(91, 140, 255, 0.15); }
/* Posted / Fetched range calendars (public/js/rangepicker.js) — same dropdown as Stack */
.date-pick { position: relative; flex: 1; min-width: 170px; }
.date-pick > summary { list-style: none; cursor: pointer; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); padding: 8px 10px; border-radius: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.date-pick > summary::-webkit-details-marker { display: none; }
.date-pick > summary::after { content: '▾'; float: right; color: var(--muted); margin-left: 8px; }
.date-pick[open] > summary { border-color: var(--primary); }
.date-panel { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; width: 300px; max-width: 92vw;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }
.date-quick { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.date-quick .btn { padding: 2px 8px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-wd { text-align: center; font-size: 11px; color: var(--muted); padding: 2px 0; }
.cal-day { background: transparent; border: 1px solid transparent; color: var(--text); border-radius: 6px;
  padding: 5px 0; font-size: 13px; cursor: pointer; text-align: center; width: 100%; }
.cal-day:hover { border-color: var(--primary); }
.cal-day.out { color: var(--muted); opacity: 0.55; }
.cal-day.today { border-color: var(--border); font-weight: 700; }
.cal-day.in-range { background: rgba(91, 140, 255, 0.18); border-radius: 0; }
.cal-day.edge { background: var(--primary); color: #fff; font-weight: 700; }
.date-hint { color: var(--muted); font-size: 11px; margin-top: 6px; }
.date-nodate { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 13px; white-space: normal; }
.toggles { align-items: center; }
.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text);
  white-space: nowrap; cursor: pointer; }
.chk input { width: auto; }

.results-bar { display: flex; align-items: center; gap: 12px; margin: 6px 2px 12px; }
.results-bar h2, .results-bar h3 { margin: 0; }
.results-bar select { width: auto; display: inline-block; }

/* ============ jobs table ============ */
table { width: 100%; border-collapse: collapse; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
thead th { text-align: left; padding: 10px 12px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); border-bottom: 1px solid var(--border);
  background: var(--surface-2); white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { opacity: .5; font-size: 10px; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
.job-title { font-weight: 600; cursor: pointer; }
.job-title:hover { color: var(--primary); }
.tag-new { background: var(--green); color: #04210a; font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 6px; margin-left: 6px; }
.remote-pill { background: #1d3a5f; color: #9cc7ff; font-size: 11px; padding: 1px 7px; border-radius: 6px; }
/* remote possible (remote_possible, not clearly fully remote): same hue, outlined */
.remote-pill.maybe { background: transparent; color: #9cc7ff; border: 1px dashed #4a77a8; padding: 0 6px; }
/* "+N locations" on grouped rows, and the expanded list of that job's postings */
.loc-more { font-size: 11px; padding: 1px 7px; margin-left: 4px; border-radius: 6px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid currentColor; white-space: nowrap; }
.loc-more:hover, .loc-more.open { color: var(--text); }
.group-row > td { background: rgba(127, 127, 127, 0.07); }
.group-list ul { margin: 6px 0 2px 18px; padding: 0; columns: 2 260px; column-gap: 24px; }
.group-list li { margin: 2px 0; break-inside: avoid; }

/* ATS badges */
.ats { font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; white-space: nowrap; }
.ats-greenhouse { background: #16331f; color: #4caf6d; }
.ats-lever { background: #2a1f3a; color: #b58cff; }
.ats-ashby { background: #1d2c3a; color: #6db5ff; }
.ats-rippling { background: #3a2330; color: #ff9ec4; }
.ats-workday { background: #3a3320; color: #e0c060; }
.ats-bamboohr { background: #1f3320; color: #7cc47c; }
.ats-paylocity { background: #20303a; color: #6fd0d0; }
.ats-icims { background: #33231f; color: #d29a7c; }
.ats-workable { background: #1a2e2a; color: #5ec6a8; }
.ats-smartrecruiters { background: #2a2536; color: #a98cff; }
.ats-recruitee { background: #2e2418; color: #e0a85c; }
.ats-breezy { background: #16302e; color: #5fc4c4; }
.ats-pinpoint { background: #301f2a; color: #ff9ec4; }
.ats-recruiterbox { background: #1f2a33; color: #6db5d0; }
.ats-teamtailor { background: #1d2e1d; color: #7cc47c; }
.ats-personio { background: #1d2735; color: #6f9fe0; }
.ats-mercor { background: #2c2c1d; color: #d0d06f; }
.ats-unknown { background: var(--surface-2); color: var(--muted); }

.skill { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.row-actions { display: flex; gap: 6px; }
.row-actions button.active { background: var(--primary-2); border-color: var(--primary-2); color:#fff; }

/* ============ pagination ============ */
.pagination { display: flex; gap: 6px; justify-content: center; align-items: center;
  margin: 16px 0; flex-wrap: wrap; }
.pagination button { min-width: 36px; }
.pagination button.active { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.pagination .gap { color: var(--muted); padding: 0 4px; }

/* ============ admin ============ */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; }
.card h3 { margin: 0 0 12px; }
.card form { display: flex; flex-direction: column; gap: 10px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px,1fr)); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 8px; padding: 10px; }
.stat .n { font-size: 20px; font-weight: 700; }
.stat .l { font-size: 11px; color: var(--muted); }
.status-pill { font-size: 11px; padding: 1px 7px; border-radius: 6px; }
.status-active { background: #16331f; color: #4caf6d; }
.status-disabled { background: var(--surface-2); color: var(--muted); }
.status-unverified { background: #3a3320; color: #e0c060; }
.status-error { background: #3a1f1f; color: var(--red); }

/* ============ modal ============ */
.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.modal-body { position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 720px; max-width: 92vw; max-height: 86vh; overflow: auto; }
.modal-close { position: absolute; top: 10px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 26px; line-height: 1; }
.modal-body h2 { margin-top: 0; }
.job-desc { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 16px; line-height: 1.6; }
.job-desc img { max-width: 100%; }

/* ============ toast ============ */
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); padding: 10px 18px;
  border-radius: 8px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.err { border-color: var(--red); color: #ffb4ae; }
.toast.ok { border-color: var(--green); }

.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ============ admin-only: daily-update status widget ============ */
.admin-status { display: flex; flex-direction: column; align-items: stretch; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }
.admin-status .as-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-status .as-label { flex: 0 0 58px; color: var(--muted); font-weight: 600; }
.admin-status .as-bar { display: block; flex: 1 1 200px; min-width: 140px; height: 10px; border-radius: 6px;
  background: var(--surface-2); overflow: hidden; }
.admin-status .as-fill { display: block; height: 10px; background: var(--green); transition: width .4s ease; }
.admin-status .as-fill.run { background: var(--primary); } /* run-progress bar = blue, distinct from green freshness */
.admin-status .as-pct { font-weight: 700; font-size: 15px; }
.admin-status .as-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); margin-right: 5px; vertical-align: middle; }
.admin-status.running .as-dot { background: var(--green); box-shadow: 0 0 0 0 var(--green);
  animation: as-pulse 1.6s infinite; }
.admin-status .as-chip { color: var(--muted); }
.admin-status .as-chip b { color: var(--text); }
.admin-status .as-chip.warn b { color: var(--amber); }
.admin-status .as-chip.bad b { color: var(--red); }
.admin-status .as-chip.run b { color: var(--primary); }
.admin-status .as-chip.ok b { color: var(--green); }
.admin-status .as-chip.queued { border-style: dashed; opacity: 0.85; }
.admin-status .as-chip .as-fail { color: var(--red); }

/* Speed panel: API vs Browser sections, each with its own accent colour */
.admin-status { --api: #2f9e8f; --browser: #a066e8; }
.admin-status .as-section { margin-top: 8px; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border, rgba(127,127,127,.25)); border-left: 4px solid var(--sec); background: var(--surface-2); }
.admin-status .as-section.api { --sec: var(--api); }
.admin-status .as-section.browser { --sec: var(--browser); }
.admin-status .as-section-head { font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.admin-status .as-tag { display: inline-block; padding: 1px 8px; border-radius: 10px; margin-right: 6px;
  background: var(--sec); color: #fff; font-size: 12px; letter-spacing: .02em; }
.admin-status .as-lane { padding: 4px 0 2px; border-top: 1px dashed rgba(127,127,127,.2); }
.admin-status .as-section-head + .as-lane { border-top: 0; }
.admin-status .as-lane-name { font-weight: 600; color: var(--sec); margin-right: 8px; }
.admin-status .as-lane-name i { font-style: normal; font-weight: 400; color: var(--muted); font-size: 12px; }
.admin-status .as-lane-sum { color: var(--muted); font-size: 12px; }
.admin-status .as-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.admin-status .as-section .as-chip { border-left: 3px solid var(--sec); padding-left: 6px; }
@keyframes as-pulse { 0% { box-shadow: 0 0 0 0 rgba(63,185,80,.5); } 70% { box-shadow: 0 0 0 6px rgba(63,185,80,0); } 100% { box-shadow: 0 0 0 0 rgba(63,185,80,0); } }

/* ============ responsive: table -> cards ============ */
@media (max-width: 760px) {
  .nav { gap: 10px; flex-wrap: wrap; }
  .nav-user #nav-email { display: none; }
  .admin-grid { grid-template-columns: 1fr; }
  .grow-2 { grid-column: auto; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr { background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 10px; padding: 8px 10px; }
  tbody td { border: none; padding: 4px 0; display: flex; justify-content: space-between; gap: 12px; }
  tbody td::before { content: attr(data-label); color: var(--muted); font-size: 12px; font-weight: 600; }
  tbody td.cell-title { display: block; }
  tbody td.cell-title::before { display: none; }
  .row-actions { justify-content: flex-end; }
}
