/* Job Autopilot — design system */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root,
:root[data-theme="dark"] {
  --bg: #0a0d13;
  --surface: #111521;
  --surface-2: #171d2c;
  --surface-3: #1e2536;
  --border: #232b3d;
  --border-strong: #32405c;
  --text: #e8ecf4;
  --text-2: #a7b0c3;
  --text-3: #6c7692;
  --accent: #5b7fff;
  --accent-hover: #7793ff;
  --accent-soft: rgba(91, 127, 255, 0.12);
  --success: #3ecf8e;
  --success-soft: rgba(62, 207, 142, 0.12);
  --warn: #e5a54b;
  --warn-soft: rgba(229, 165, 75, 0.13);
  --danger: #ef5a66;
  --danger-soft: rgba(239, 90, 102, 0.12);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f6f9;
  --surface: #ffffff;
  --surface-2: #f0f2f6;
  --surface-3: #e6e9f0;
  --border: #e1e4eb;
  --border-strong: #c7cddb;
  --text: #191d28;
  --text-2: #565f75;
  --text-3: #8189a0;
  --accent: #4a67e0;
  --accent-hover: #3854cc;
  --accent-soft: rgba(74, 103, 224, 0.1);
  --success: #1f9d67;
  --success-soft: rgba(31, 157, 103, 0.1);
  --warn: #b9760f;
  --warn-soft: rgba(185, 118, 15, 0.1);
  --danger: #d6394a;
  --danger-soft: rgba(214, 57, 74, 0.1);
  --shadow: 0 1px 2px rgba(20,25,40,.06), 0 8px 24px rgba(20,25,40,.08);
  --overlay: rgba(30, 34, 46, 0.4);
  color-scheme: light;
}

/* System-preference fallback for a first paint before app.js applies the
   user's saved choice (or if JS is disabled) — matches OS setting. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg: #f5f6f9;
    --surface: #ffffff;
    --surface-2: #f0f2f6;
    --surface-3: #e6e9f0;
    --border: #e1e4eb;
    --border-strong: #c7cddb;
    --text: #191d28;
    --text-2: #565f75;
    --text-3: #8189a0;
    --accent: #4a67e0;
    --accent-hover: #3854cc;
    --accent-soft: rgba(74, 103, 224, 0.1);
    --success: #1f9d67;
    --success-soft: rgba(31, 157, 103, 0.1);
    --warn: #b9760f;
    --warn-soft: rgba(185, 118, 15, 0.1);
    --danger: #d6394a;
    --danger-soft: rgba(214, 57, 74, 0.1);
    --shadow: 0 1px 2px rgba(20,25,40,.06), 0 8px 24px rgba(20,25,40,.08);
    color-scheme: light;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app-shell { display: flex; min-height: 100vh; }

.signed-in-as {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; margin-top: 2px;
}
.signed-in-as #signedInEmail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signed-in-as .link-btn { padding: 2px; flex: none; }

.hidden { display: none !important; }
.muted { color: var(--text-2); font-size: 13px; }
.subtle { color: var(--text-3); font-size: 12.5px; }

svg.ic { width: 16px; height: 16px; flex: none; vertical-align: -3px; }

/* ---------- sidebar ---------- */
.sidebar {
  width: 260px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex: none;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 4px 6px 24px;
}
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--accent), #8a5bff);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 14px rgba(91, 127, 255, 0.28);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; line-height: 1.3; }
.brand-sub { font-size: 11.5px; color: var(--text-3); line-height: 1.3; }

.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-btn {
  display: flex; align-items: center; gap: 12px;
  background: none; border: none; color: var(--text-2);
  text-align: left; padding: 10px 12px; border-radius: 10px;
  font-size: 13.5px; font-weight: 500; font-family: inherit; cursor: pointer;
  transition: background .12s, color .12s;
  width: 100%;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-btn .ic { color: var(--text-3); transition: color .12s; }
.nav-btn.active .ic, .nav-btn:hover .ic { color: var(--accent); }
.nav-btn .lbl { flex: 1; }

.badge {
  background: var(--accent); color: #fff;
  border-radius: 20px; font-size: 10.5px; font-weight: 700;
  min-width: 19px; height: 19px; padding: 0 6px;
  display: inline-grid; place-items: center; flex: none;
}

.sidebar-foot { padding-top: 14px; margin-top: 8px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.sidebar-foot .pill { width: 100%; justify-content: center; }

.theme-toggle {
  width: 100%; justify-content: center; gap: 8px;
  background: var(--surface-2); border-color: var(--border);
  color: var(--text-2); font-size: 12.5px; font-weight: 500;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle .moon-ic { display: none; }
:root[data-theme="light"] .theme-toggle .sun-ic { display: none; }
:root[data-theme="light"] .theme-toggle .moon-ic { display: block; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; padding: 6px 11px; border-radius: 20px;
}
.pill.ok { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.info { background: var(--accent-soft); color: var(--accent-hover); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- main ---------- */
main { flex: 1; padding: 34px 42px 60px; max-width: 1280px; min-width: 0; }

/* ---------- pipeline stepper ---------- */
.stepper {
  display: flex; align-items: center;
  margin-bottom: 26px; user-select: none;
}
.step {
  display: flex; align-items: center; gap: 9px;
  background: none; border: none; padding: 6px 8px 6px 4px;
  color: var(--text-3); font-family: inherit; cursor: pointer;
}
.step:hover { border: none; color: var(--text-2); }
.step:hover .dot { border-color: var(--border-strong); color: var(--text-2); }
.step .dot {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border); display: grid; place-items: center;
  transition: border-color .12s, color .12s, background .12s;
}
.step .dot .ic { width: 13px; height: 13px; }
.step .lbl { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.step .lbl em { font-style: normal; color: var(--accent-hover); font-weight: 700; }
.step.current { color: var(--text); }
.step.current .dot { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.step.has-items .dot { border-color: var(--accent); color: var(--accent); }
.step-line { flex: 1; height: 1px; background: var(--border); margin: 0 2px; min-width: 16px; max-width: 60px; }

@media (max-width: 760px) {
  .stepper { display: none; }
}

.page-head { margin-bottom: 24px; }
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -0.02em; }
.page-head p { color: var(--text-2); font-size: 13.5px; margin-top: 3px; max-width: 640px; }

h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; letter-spacing: -0.01em; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  margin-bottom: 18px;
}

.warning-card {
  background: var(--warn-soft);
  border: 1px solid var(--warn);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
}
.warning-card .ic { flex: none; margin-top: 2px; color: var(--warn); }
.warning-card b { display: block; margin-bottom: 4px; }
.warning-card p { color: var(--text-2); font-size: 13px; margin: 0; }
.warning-card a { color: var(--accent); }

/* ---------- forms ---------- */
input[type="text"], input:not([type]), textarea, select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  transition: border-color .12s, box-shadow .12s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; line-height: 1.6; }
select { cursor: pointer; }
input[type="file"] { padding: 7px; font-size: 12.5px; color: var(--text-2); }
input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

/* ---------- buttons ---------- */
button, .btn-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--surface-3);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  padding: 9px 15px;
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
button:hover, .btn-link:hover { border-color: var(--text-3); }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.success { background: var(--success); border-color: var(--success); color: #06281a; font-weight: 600; }
button.success:hover { filter: brightness(1.08); }
button.danger { background: transparent; border-color: var(--border); color: var(--danger); }
button.danger:hover { border-color: var(--danger); background: var(--danger-soft); }
button.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover { color: var(--text); border-color: var(--border); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- stats ---------- */
.stat-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 16px 18px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat .ic { color: var(--text-3); margin-bottom: 8px; width: 18px; height: 18px; }
.stat .num { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.stat .lbl { color: var(--text-2); font-size: 12px; }

/* ---------- setup checklist ---------- */
.checklist { display: flex; flex-direction: column; gap: 4px; }
.check-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13.5px;
}
.check-item .mark {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border-strong);
  display: grid; place-items: center; color: transparent;
}
.check-item.done { color: var(--text-3); text-decoration: line-through; }
.check-item.done .mark { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.check-item a { color: var(--accent-hover); text-decoration: none; margin-left: auto; font-size: 12.5px; flex: none; }
.check-item a:hover { text-decoration: underline; }

.flow { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.flow-step { padding: 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface-2); }
.flow-step .n { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: .08em; }
.flow-step b { display: block; font-size: 13px; margin: 4px 0 3px; }
.flow-step span { font-size: 12px; color: var(--text-2); line-height: 1.5; display: block; }

/* ---------- discover ---------- */
.search-card { padding-bottom: 14px; }
.search-row { display: flex; gap: 10px; margin-bottom: 0; flex-wrap: wrap; }
.search-row .grow { flex: 2; min-width: 220px; }
.search-row .loc { flex: 1.2; min-width: 180px; }
.search-row select { width: auto; }

.search-foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 12px; flex-wrap: wrap;
}
.link-btn {
  background: none; border: none; color: var(--text-3);
  padding: 4px 2px; font-size: 12.5px; gap: 6px;
}
.link-btn:hover { color: var(--accent-hover); border: none; }

.advanced-search { font-size: 13px; }
.advanced-search summary {
  cursor: pointer; color: var(--text-3); font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px; list-style: none;
  padding: 4px 2px;
}
.advanced-search summary::-webkit-details-marker { display: none; }
.advanced-search summary:hover { color: var(--text); }
.advanced-search[open] summary { color: var(--text); margin-bottom: 12px; }
.advanced-panel {
  padding-top: 4px; border-top: 1px solid var(--border); margin-top: 4px;
}

.search-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 13px; font-size: 12.5px; color: var(--text-2);
  cursor: pointer; user-select: none; transition: all .12s; background: var(--surface-2);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.chip input { display: none; }

.boards-editor { margin-top: 16px; font-size: 13px; }
.boards-editor summary {
  cursor: pointer; color: var(--text-2); font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px; list-style: none;
}
.boards-editor summary::-webkit-details-marker { display: none; }
.boards-editor summary:hover { color: var(--text); }
.boards-editor[open] summary { color: var(--text); margin-bottom: 10px; }
.board-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 5px 7px 5px 13px; margin: 4px 6px 0 0; font-size: 12px;
}
.board-chip small { color: var(--text-3); }
.board-chip button { border: none; background: none; color: var(--text-3); padding: 2px; }
.board-chip button:hover { color: var(--danger); border: none; }
.board-add { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.board-add input, .board-add select { width: auto; flex: 1; min-width: 130px; }

.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 13px 16px; margin-bottom: 16px;
}
.filter-bar input[type="text"] { flex: 1; min-width: 180px; }
.filter-bar select { width: auto; font-size: 12.5px; padding: 7px 10px; }
.filter-bar .chip { padding: 6px 13px; }

.select-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 11px 16px; margin-bottom: 16px;
  position: sticky; top: 12px; z-index: 5;
  box-shadow: var(--shadow);
}
.select-bar .count { font-weight: 600; font-size: 13px; }

/* ---------- job cards ---------- */
.job-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.job-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 16px; display: flex; flex-direction: column; gap: 9px; position: relative;
  cursor: pointer; transition: border-color .12s, transform .12s, box-shadow .12s;
}
.job-card:hover { border-color: var(--border-strong); transform: translateY(-1px); box-shadow: var(--shadow); }
.job-card.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.job-check { position: absolute; top: 14px; right: 14px; }

.job-top { display: flex; gap: 11px; align-items: flex-start; padding-right: 26px; }
.avatar {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff;
}
.job-card .title { font-weight: 600; font-size: 14px; line-height: 1.35; letter-spacing: -0.01em; }
.job-card .co { color: var(--text-2); font-size: 12.5px; margin-top: 1px; }
.job-card .meta {
  color: var(--text-3); font-size: 12px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.job-card .meta .ic { width: 13px; height: 13px; }
.tag {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 7px; font-size: 11px; color: var(--text-2);
}
.tag.salary { color: var(--success); border-color: transparent; background: var(--success-soft); font-weight: 600; }
.job-card .desc { color: var(--text-2); font-size: 12px; line-height: 1.55; max-height: 56px; overflow: hidden; }
.job-card .foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border);
}
.foot-badges { display: flex; align-items: center; gap: 6px; }
.match { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 20px; cursor: help; }
.match.hi { background: var(--success-soft); color: var(--success); }
.match.mid { background: var(--warn-soft); color: var(--warn); }
.match.lo { background: var(--surface-2); color: var(--text-3); }
.cred {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; cursor: help;
}
.cred.hi { background: var(--success-soft); color: var(--success); }
.cred.mid { background: var(--warn-soft); color: var(--warn); }
.cred.lo { background: var(--danger-soft); color: var(--danger); }
.job-links { display: flex; gap: 4px; }
.job-links a {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--text-2); font-size: 12px; text-decoration: none;
  padding: 4px 8px; border-radius: 6px;
}
.job-links a:hover { color: var(--accent-hover); background: var(--accent-soft); }

.load-more {
  grid-column: 1 / -1; padding: 13px; background: transparent;
  border: 1px dashed var(--border-strong); color: var(--text-2); font-weight: 600;
}
.load-more:hover { color: var(--accent-hover); border-color: var(--accent); }

/* skeletons */
@keyframes shimmer { 0% { opacity: .55; } 50% { opacity: 1; } 100% { opacity: .55; } }
.skel { animation: shimmer 1.4s ease-in-out infinite; }
.skel .bar { height: 12px; border-radius: 6px; background: var(--surface-3); margin-bottom: 10px; }

/* ---------- queue ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0;
  color: var(--text-2); padding: 9px 14px; font-size: 13px; font-weight: 500;
}
.tab:hover { color: var(--text); border-color: transparent; }
.tab.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab .n { color: var(--text-3); font-size: 12px; margin-left: 5px; }

.q-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 20px 22px; margin-bottom: 14px;
}
.q-item.sent { opacity: .72; }
.q-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.q-head .t { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; }
.q-head .t small { color: var(--text-2); font-weight: 400; font-size: 13px; }
.q-angle {
  color: var(--text-2); font-size: 12.5px; margin: 4px 0 14px;
  padding: 8px 12px; background: var(--surface-2); border-radius: var(--r-sm);
  border-left: 2px solid var(--accent);
}
.q-body { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.q-body .col label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; color: var(--text-2); margin: 12px 0 5px;
}
.q-body .col label:first-child { margin-top: 0; }
.q-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); }
thead th {
  color: var(--text-3); font-weight: 600; font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--surface-2); position: sticky; top: 0;
}
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: none; }
td select { width: auto; padding: 5px 9px; font-size: 12px; }
td a { color: var(--accent-hover); text-decoration: none; }
td a:hover { text-decoration: underline; }
.env-table td { font-size: 13px; }
.env-table code {
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 7px; border-radius: 5px; font-size: 12px;
  font-family: ui-monospace, "Cascadia Code", monospace;
}

/* ---------- profile form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 16px; }
.form-grid label {
  font-size: 12px; font-weight: 500; color: var(--text-2);
  display: flex; flex-direction: column; gap: 6px;
}
.form-grid .full { grid-column: 1 / -1; }
.file-row { display: flex; gap: 34px; margin-bottom: 18px; font-size: 13px; flex-wrap: wrap; }
.file-row > div { display: flex; flex-direction: column; gap: 6px; }
.file-row b { font-size: 12.5px; font-weight: 600; }
.actions-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.save-bar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  position: sticky; bottom: 16px; z-index: 5;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 13px 18px; box-shadow: var(--shadow);
}

/* ---------- empty states ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 56px 20px; text-align: center; color: var(--text-2);
}
.empty .ic { width: 34px; height: 34px; color: var(--text-3); }
.empty b { color: var(--text); font-size: 14.5px; }
.empty p { font-size: 13px; max-width: 380px; }

/* ---------- modal ---------- */
.modal-wrap {
  position: fixed; inset: 0; z-index: 90;
  background: var(--overlay, rgba(5, 8, 14, 0.72));
  display: grid; place-items: center; padding: 24px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); width: min(680px, 100%);
  max-height: 84vh; display: flex; flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }

.prep-card {
  border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 13px 15px; margin-bottom: 10px; background: var(--surface-2);
}
.prep-q { font-weight: 600; font-size: 13.5px; margin-bottom: 6px; }
.prep-q .tag { font-weight: 500; margin-right: 4px; }
.prep-a { color: var(--text-2); font-size: 13px; line-height: 1.6; }
.prep-card.gaps { border-color: var(--warn); }
.prep-card.gaps ul { margin: 6px 0 0 18px; color: var(--text-2); font-size: 13px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 26px; right: 26px;
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--surface-3); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); padding: 13px 18px;
  font-size: 13.5px; max-width: 400px;
  box-shadow: var(--shadow); z-index: 100;
}
.toast .ic { margin-top: 2px; color: var(--accent); }
.toast.ok .ic { color: var(--success); }
.toast.err .ic { color: var(--danger); }

/* ---------- how-it-works list ---------- */
.how { padding-left: 0; list-style: none; counter-reset: step; }
.how li {
  counter-increment: step; position: relative;
  padding: 8px 0 8px 40px; font-size: 13.5px; color: var(--text-2);
}
.how li b { color: var(--text); }
.how li::before {
  content: counter(step); position: absolute; left: 0; top: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-hover);
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
}

/* ---------- onboarding wizard ---------- */
.wizard-wrap {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; overflow-y: auto;
}
.wizard {
  width: min(560px, 100%);
  display: flex; flex-direction: column; gap: 22px;
}
.wizard-progress { display: flex; align-items: center; justify-content: center; gap: 0; }
.wp-dot {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 1.5px solid var(--border-strong); color: var(--text-3);
  display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
  transition: all .15s;
}
.wp-dot.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.wp-dot.done { border-color: var(--success); color: var(--success); background: var(--success-soft); }
.wp-line { width: 48px; height: 1.5px; background: var(--border-strong); }
.wizard-step h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 6px; }
.wizard-step .muted { font-size: 14px; }
.wizard-actions { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.wizard-actions .ghost:first-child { margin-right: auto; }

/* ---------- responsive ---------- */
@media (max-width: 960px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .q-body { grid-template-columns: 1fr; }
  .job-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: sticky; top: 0; z-index: 20;
    flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px;
    flex-wrap: wrap;
  }
  .brand { padding: 0 8px 0 0; }
  .brand-sub { display: none; }
  .sidebar nav {
    flex-direction: row; flex-wrap: nowrap; overflow-x: auto;
    gap: 2px; flex: 1; -webkit-overflow-scrolling: touch;
  }
  .sidebar nav::-webkit-scrollbar { display: none; }
  .nav-btn { padding: 8px 10px; flex: none; }
  .nav-btn span.lbl { display: none; }
  .sidebar-foot {
    display: flex; flex-direction: row; align-items: center; gap: 8px;
    padding: 0; margin: 0; border: none; width: auto; flex: none;
  }
  .sidebar-foot .pill { width: auto; white-space: nowrap; }
  .theme-toggle { width: auto; padding: 8px; }
  .theme-toggle span:not(.ic) { display: none; }
  .signed-in-as { display: none; } /* redundant with the pill on small screens; sign-out lives in Setup instead */

  main { padding: 16px 14px 50px; }
  .page-head h1 { font-size: 18px; }

  .form-grid { grid-template-columns: 1fr; }
  .file-row { gap: 16px; }

  .search-row { flex-direction: column; }
  .search-row .grow, .search-row .loc, .search-row select { flex: none; width: 100%; min-width: 0; }
  .search-foot { flex-direction: column; align-items: flex-start; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar select, .filter-bar input { width: 100%; }

  .select-bar { position: static; flex-direction: column; align-items: stretch; }
  .select-bar button, .select-bar .count { width: 100%; text-align: center; }

  .job-grid { grid-template-columns: 1fr; }

  .q-item { padding: 16px; }
  .q-actions { flex-direction: column; }
  .q-actions button, .q-actions .btn-link { width: 100%; justify-content: center; }

  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .flow { grid-template-columns: 1fr; }

  .table-wrap { overflow-x: auto; }
  table { min-width: 560px; } /* scrolls within .table-wrap rather than squeezing illegibly */

  .modal { width: 100%; max-height: 92vh; border-radius: var(--r-md); }
  .modal-body { padding: 14px 16px; }

  .wizard, #authWrap .wizard { width: 100%; }
  .wizard-step h1 { font-size: 19px; }
  .wizard-actions { flex-direction: column-reverse; align-items: stretch; }
  .wizard-actions button { width: 100%; }
  .wizard-actions .ghost:first-child { margin-right: 0; }

  .save-bar { flex-direction: column; align-items: stretch; position: static; box-shadow: none; }
  .save-bar button { width: 100%; }

  .env-table, .env-table tr, .env-table td { display: block; width: 100%; }
  .env-table td:first-child { padding-bottom: 2px; border-bottom: none; }
  .env-table td:last-child { padding-top: 0; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
}

@media (max-width: 400px) {
  .stat-row { grid-template-columns: 1fr; }
  .card { padding: 16px 14px; }
  .brand-name { font-size: 13.5px; }
}
