/*
 * Web Awesome (public/assets/webawesome) is the design system: theme tokens, native element styles
 * (buttons, inputs, tables, dialogs) and dark mode. Its CSS sits in cascade layers, so the app styles
 * below win where they overlap. The app's own variables map onto Web Awesome tokens so both follow
 * the theme and the light/dark switch (assets/theme.js).
 */
:root {
  --paper: var(--wa-color-surface-lowered);
  --surface: var(--wa-color-surface-default);
  --ink: var(--wa-color-text-normal);
  --muted: var(--wa-color-text-quiet);
  --line: var(--wa-color-surface-border);
  --brand: var(--wa-color-brand-fill-loud);
  --brand-ink: var(--wa-color-brand-on-loud);
  --brand-soft: var(--wa-color-brand-fill-quiet);
  --ok-bg: var(--wa-color-success-fill-quiet);
  --ok-ink: var(--wa-color-success-on-quiet);
  --bad-bg: var(--wa-color-danger-fill-quiet);
  --bad-ink: var(--wa-color-danger-on-quiet);
  --bad: var(--wa-color-danger-fill-loud);

  --s-new: var(--wa-color-gray-60);
  --s-shortlisted: var(--wa-color-indigo-50);
  --s-applied: var(--wa-color-blue-50);
  --s-interview: var(--wa-color-orange-60);
  --s-offer: var(--wa-color-green-50);
  --s-rejected: var(--wa-color-red-50);
  --s-interested: var(--wa-color-cyan-50);
  --s-not_interested: var(--wa-color-red-40);

  --wa-font-family-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --wa-font-family-heading: var(--wa-font-family-body);
  --font: var(--wa-font-family-body);
  --radius-s: var(--wa-border-radius-s);
  --radius-m: var(--wa-border-radius-m);
}

[hidden] { display: none !important; }
body { background: var(--paper); }

.page { max-width: 1180px; margin: 0 auto; padding: 32px 24px 64px; }

.top { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 2rem; line-height: 1.1; margin: 0; }
h2 { font-size: 1.35rem; line-height: 1.2; margin: 0; }
h3 { font-size: 1rem; margin: 28px 0 8px; }
.sub { margin: 4px 0 0; color: var(--muted); }
.top-actions { display: flex; gap: 8px; }

/* Links that act as buttons (downloads, OAuth). Real <button>s use Web Awesome classes: wa-brand, wa-neutral wa-outlined, wa-size-s. */
a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-weight: var(--wa-font-weight-action, 600); font-size: var(--wa-font-size-m);
  min-height: var(--wa-form-control-height, 2.5rem); padding: 0 var(--wa-space-l);
  border-radius: var(--wa-border-radius-m); text-decoration: none;
  background: var(--brand); color: var(--brand-ink); border: 1px solid var(--brand);
}
a.btn:hover { background: var(--wa-color-brand-fill-loud); filter: brightness(1.08); }
a.btn.btn-quiet { background: transparent; color: var(--wa-color-neutral-on-quiet); border-color: var(--wa-color-neutral-border-loud, var(--line)); }
a.btn.btn-quiet:hover { background: var(--wa-color-neutral-fill-quiet); filter: none; }
label.btn-small { display: inline-flex; align-items: center; font-size: var(--wa-font-size-s); padding: 2px 12px;
  border: 1px solid var(--line); border-radius: var(--wa-border-radius-m); color: var(--ink); background: var(--surface); }
label.btn-small:hover { background: var(--wa-color-neutral-fill-quiet); }
.icon-btn { font-size: 1.6rem; line-height: 1; }

/* Custom controls built on <button>: drop Web Awesome's native button look, keep a visible focus ring. */
:is(.seg, .seg-out, .chip, .closed-chip, .icon-toggle, .link-btn, .msg-head) {
  all: unset; box-sizing: border-box; display: inline-block; cursor: pointer;
}
:is(.seg, .seg-out, .chip, .closed-chip, .icon-toggle, .link-btn, .msg-head):focus-visible {
  outline: var(--wa-focus-ring, 3px solid var(--brand)); outline-offset: 2px;
}

/* The one bold element: the pipeline as a proportional strip. */
.funnel { margin: 28px 0 20px; }
.funnel-bar { display: flex; gap: 3px; min-height: 64px; }
.seg {
  flex: var(--grow, 1) 1 0; min-width: 104px;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 10px 12px; border: 0; cursor: pointer; text-align: left;
  color: #fff; background: var(--c);
}
.seg:first-child { border-radius: var(--radius-m) 0 0 var(--radius-m); }
.seg:last-child { border-radius: 0 var(--radius-m) var(--radius-m) 0; }
.seg .n { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.seg .l { font-size: 0.9rem; opacity: 0.92; }
.seg.is-empty { background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.seg[aria-pressed="true"] { box-shadow: inset 0 -5px 0 rgba(0,0,0,0.28); }
.seg.is-empty[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--line), inset 0 -5px 0 var(--muted); }
.funnel-row { display: flex; gap: 14px; align-items: stretch; }
.funnel-row .funnel-bar { flex: 1; min-width: 0; }
/* Not interested: outside the pipeline, on the right. */

.seg-out { min-width: 130px; display: flex; flex-direction: column; justify-content: center; gap: 4px;
  padding: 10px 16px; text-align: left; border-radius: var(--radius-m); cursor: pointer;
  background: var(--surface); color: var(--s-not_interested); box-shadow: inset 0 0 0 1px var(--s-not_interested); border: 0; }
.seg-out .n { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.seg-out .l { font-size: 0.9rem; }
.seg-out[aria-pressed="true"] { background: var(--s-not_interested); color: var(--surface); }
.funnel-closed { display: flex; gap: 16px; margin-top: 10px; }
.closed-chip { font-size: 0.92rem; padding: 2px 0; color: var(--muted); cursor: pointer; }
.closed-chip[aria-pressed="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 4px; }

.toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.search { flex: 1 1 320px; }
input:not([type="checkbox"], [type="radio"]), select, textarea { width: 100%; }
textarea { resize: vertical; }
.sort { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--muted); }
.sort select { width: auto; }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow-x: auto; }
.list table { width: 100%; margin: 0; }
.list th { text-align: left; font-size: 0.85rem; color: var(--muted); padding: 12px 14px; }
.list td { padding: 12px 14px; vertical-align: top; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.role-title { font-weight: 700; display: block; }
.role-company { color: var(--muted); }
.role-link { display: inline-block; margin-top: 2px; font-size: 0.88rem; }
.col-contacts { white-space: nowrap; }
.job-desc .muted { color: var(--muted); }
.desc-text { white-space: pre-line; font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
.desc-text.clamped { max-height: 16em; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent); mask-image: linear-gradient(to bottom, #000 70%, transparent); }
.desc-actions { margin: 6px 0 0; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 0.88rem; }
.desc-actions:empty { display: none; }
.about p { margin: 0 0 6px; }
.about .muted { color: var(--muted); }
.about-text { font-size: 0.92rem; }
.about code { background: var(--paper); padding: 1px 5px; border-radius: var(--radius-s); }
.btn-link { font-weight: 700; }
.col-date, .col-score { white-space: nowrap; }
.where-mode { display: block; color: var(--muted); font-size: 0.9rem; }

.fit { display: flex; align-items: center; gap: 8px; }
.fit-track { display: block; width: 56px; height: 6px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.fit-fill { display: block; height: 100%; background: var(--brand); }

.status-cell { display: flex; align-items: center; gap: 8px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.status-cell select { width: auto; }

.empty { padding: 48px 24px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); display: block; margin-bottom: 6px; font-size: 1.1rem; }
.empty code { background: var(--paper); padding: 2px 6px; border-radius: var(--radius-s); }

/* Drawer and modal */
dialog { border: 0; padding: 0; color: var(--ink); background: var(--surface); box-shadow: var(--wa-shadow-l); }
dialog::backdrop { background: var(--wa-color-overlay-modal, rgba(29, 40, 51, 0.35)); }
.drawer { margin: 0 0 0 auto; height: 100vh; max-height: 100vh; width: min(560px, 100vw); border-radius: 0; }
.drawer[open] { animation: slide-in 180ms ease-out; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-inner { padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.drawer-head { display: flex; justify-content: space-between; gap: 12px; }
.d-meta { margin: 0; color: var(--muted); }
.d-reason { margin: 0; padding: 10px 12px; background: var(--paper); border-radius: var(--radius-s); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 0.9rem; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.drawer-actions, .modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }
.save-state { color: var(--muted); font-size: 0.9rem; margin-right: auto; }
.history { margin: 0; padding-left: 18px; color: var(--muted); font-size: 0.9rem; }
.history li { margin-bottom: 4px; }
.contacts { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 0.92rem; }
.contacts .muted, .contacts li.muted { color: var(--muted); }
.contacts a { overflow-wrap: anywhere; }
.contacts code { background: var(--paper); padding: 1px 5px; border-radius: var(--radius-s); }

.modal { width: min(620px, calc(100vw - 32px)); border-radius: var(--wa-border-radius-l); }
.modal-inner { padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.form-error { color: var(--bad-ink); margin: 0; min-height: 1.2em; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 760px) {
  .col-where, .col-pay, .col-date, .col-contacts, td.col-where, td.col-pay, td.col-date, td.col-contacts { display: none; }
  .grid2 { grid-template-columns: 1fr; }
  .seg { min-width: 84px; }
  .funnel-bar { overflow-x: auto; }
  .funnel-row { flex-direction: column; }
  .seg-out { min-width: 0; flex-direction: row; align-items: baseline; gap: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer[open] { animation: none; }
}

/* Sections */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 8px 0 18px; }
.tabs a { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 700; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a:hover { color: var(--ink); }
.col-source { font-size: 0.88rem; color: var(--muted); }
.col-num { text-align: right; white-space: nowrap; }
th.col-num { text-align: right; }
tr[data-company], tr[data-person], tr[data-job] { cursor: pointer; }
.detail { display: flex; flex-direction: column; gap: 10px; }
.detail h2 { margin: 0; }
.detail h3 { margin: 18px 0 4px; }
.detail-head p { margin: 4px 0 0; }
.detail-desc { max-width: 75ch; }
.detail textarea { width: 100%; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.tag { display: inline-block; margin-left: 6px; padding: 0 6px; font-size: 0.78rem; border-radius: var(--radius-s);
  background: var(--paper); color: var(--ink); vertical-align: middle; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 28px; margin: 0; }
.facts dt { font-size: 0.8rem; color: var(--muted); }
.facts dd { margin: 0; }
table.mini { width: 100%; margin: 0; }
table.mini th, table.mini td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--paper); vertical-align: top; }
table.mini th { font-size: 0.85rem; color: var(--muted); }
@media (max-width: 760px) {
  .col-source, td.col-source { display: none; }
  .tabs a { padding: 10px 10px; }
}

/* Quick filters and scan */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 22px; margin: 4px 0 14px; }
.chip-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.chip-label { font-size: 0.85rem; color: var(--muted); font-weight: 700; margin-right: 2px; }
.chip { font-size: 0.88rem; padding: 5px 12px; border-radius: var(--wa-border-radius-pill); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); }
.chip:hover { border-color: var(--brand); }
.chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.scan-status { flex-basis: 100%; margin: 0; font-size: 0.88rem; color: var(--muted); }
button:disabled { cursor: wait; }

/* CVs */
.cv-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.cv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 0.92rem; }
.cv-list .muted { color: var(--muted); }
.link-btn { color: var(--wa-color-text-link); text-decoration: underline; }
.cv-warnings { margin-top: 4px; color: var(--muted); font-size: 0.85rem; }
.cv-warnings ul { margin: 4px 0 0; padding-left: 18px; }

/* Interest and fit */
.interest { display: inline-flex; gap: 2px; margin-right: 6px; }
.icon-toggle { width: 28px; height: 28px; padding: 5px; border-radius: 50%; border: 1px solid transparent;
  color: var(--muted); line-height: 0; }
.icon-toggle svg { width: 100%; height: 100%; fill: currentColor; }
.icon-toggle:hover { border-color: var(--line); color: var(--ink); }
.icon-toggle.up[aria-pressed="true"] { background: var(--ok-bg); color: var(--ok-ink); }
.icon-toggle.down[aria-pressed="true"] { background: var(--bad-bg); color: var(--bad-ink); }
.fit.knockout .fit-fill { background: var(--bad); }
.fit-box { display: flex; flex-direction: column; gap: 6px; }
.fit-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fit-reason { margin: 0; padding: 10px 12px; background: var(--paper); border-radius: var(--radius-s); }
.fit-reason.is-knockout { border-left: 3px solid var(--bad); }
.reason-chips { display: flex; flex-wrap: wrap; gap: 6px; }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
label.check input { width: auto; margin: 0; }
.hidden-note { padding: 8px 12px; background: var(--bad-bg); border-radius: var(--radius-s); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
td button { white-space: nowrap; }

/* Sign-in page */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--surface); border-radius: var(--radius-m); padding: 32px;
  box-shadow: var(--wa-shadow-m); display: flex; flex-direction: column; gap: 14px; }
.login-card h1 { margin: 0; }
.login-error { margin: 0; padding: 10px 12px; background: var(--bad-bg); color: var(--bad-ink); border-radius: var(--radius-s); }

/* Admin users */
.user-actions { white-space: nowrap; }
.user-actions button + button { margin-left: 6px; }

/* Pay filter */
.pay-filter select { width: auto; }
.pay-note { flex-basis: 100%; margin: -4px 0 0; }

/* Job matching */
.match-toggle { margin-left: auto; }
.match-note { flex-basis: 100%; margin: 0; }
.match-reason { display: inline-block; margin-top: 2px; }
.match-form { display: flex; flex-direction: column; gap: 12px; }

/* Account */
.tabs .tab-account, .tabs .tab-admin { margin-left: auto; }
.tabs .tab-admin:not([hidden]) + .tab-account { margin-left: 0; }
.account { display: flex; flex-direction: column; gap: 18px; }
.panel { background: var(--surface); border-radius: var(--radius-m); padding: 20px 22px; box-shadow: var(--wa-shadow-s); border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 10px; }
.panel h2 { margin: 0; font-size: 1.2rem; }
.panel h3 { margin: 10px 0 4px; font-size: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.panel-head p { margin: 2px 0 0; }
.panel-actions, .panel-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.panel-foot { justify-content: flex-end; }
.panel-foot .save-state { margin-right: auto; }
.editor-tabs { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.upload { cursor: pointer; margin-left: auto; }
.doc-editor { width: 100%; font-family: var(--wa-font-family-code); font-size: 0.88rem; line-height: 1.5; }
.doc-view { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px 18px; max-height: 70vh; overflow: auto; }
.doc-view h2 { font-size: 1.4rem; } .doc-view h3 { font-size: 1.05rem; text-transform: uppercase; letter-spacing: 0.04em; }
.versions summary, .cv-warnings summary { cursor: pointer; }
.versions ul { margin: 6px 0 0; padding-left: 18px; font-size: 0.9rem; }
.user-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.user-row > div { flex: 1; min-width: 200px; }
.user-row p { margin: 2px 0 0; }
.avatar { width: 48px; height: 48px; border-radius: 50%; }
.setup-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.setup-steps code, .key-state code { overflow-wrap: anywhere; }
.key-list { list-style: none; margin: 0; padding: 0; }
.key-row { display: grid; grid-template-columns: minmax(200px, 2fr) minmax(150px, 1fr) auto; gap: 6px 14px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--paper); }
.key-form, .key-msg { grid-column: 1 / -1; }
.key-form { display: flex; gap: 8px; align-items: center; }
.key-form input { flex: 1; }
.key-msg { margin: 0; }
.key-msg:empty { display: none; }
.key-msg.bad { color: var(--bad-ink); }
.key-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.pill { display: inline-block; font-size: 0.78rem; padding: 1px 8px; border-radius: var(--wa-border-radius-pill); background: var(--paper); color: var(--muted); }
.pill.ok { background: var(--ok-bg); color: var(--ok-ink); }
@media (max-width: 760px) {
  .key-row { grid-template-columns: 1fr; }
  .key-actions { justify-content: flex-start; }
  .tabs .tab-account, .tabs .tab-admin { margin-left: 0; }
}

/* Outreach */
.people-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.people-head h3 { margin: 0; }
.tone { flex-direction: row; align-items: center; gap: 8px; }
.tone select { width: auto; }
.outreach { margin-top: 6px; display: flex; flex-direction: column; gap: 8px; }
.outreach-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.draft { border-left: 3px solid var(--line); padding-left: 10px; display: flex; flex-direction: column; gap: 6px; }
.draft textarea, .draft input { width: 100%; }
.draft .count { float: right; font-size: 0.8rem; color: var(--muted); }
.draft-actions { margin: 0; font-size: 0.88rem; }

/* Outlook */
.send-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 0.9rem; }
.send-bar .inline { flex-direction: row; align-items: center; gap: 6px; color: var(--ink); }
.send-bar select { width: auto; max-width: 220px; }
.sent-note { margin: 0; padding: 8px 12px; background: var(--ok-bg); color: var(--ok-ink); border-radius: var(--radius-s); font-size: 0.9rem; }
.history-box { margin-top: 6px; }
.mail-history { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 0.9rem; }
.mail-history .dir { display: inline-block; min-width: 64px; font-size: 0.78rem; font-weight: 700; }
.mail-history .dir.sent { color: var(--brand); }
.mail-history .dir.received { color: var(--ok-ink); }

/* Add person, conversation */
.people-head #add-person-open { margin-right: auto; }
.add-person { display: flex; flex-direction: column; gap: 10px; padding: 12px; background: var(--paper); border-radius: var(--radius-s); }
.tag.added { background: var(--ok-bg); color: var(--ok-ink); }
.edit-person summary { cursor: pointer; color: var(--muted); }
.edit-person form { margin-top: 10px; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 92%; border-radius: var(--radius-m); padding: 2px 4px 6px; }
.msg.received { align-self: flex-start; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.msg.sent { align-self: flex-end; background: var(--brand-soft); }
.msg-head { text-align: left; width: 100%; padding: 8px 10px 2px;
  display: flex; flex-wrap: wrap; gap: 2px 10px; align-items: baseline; color: var(--ink); }
.msg-head .dir { font-weight: 700; }
.msg-subject { flex-basis: 100%; font-size: 0.92rem; }
.msg-preview { flex-basis: 100%; }
.msg-body { white-space: pre-line; font-size: 0.92rem; padding: 4px 10px 6px; border-top: 1px solid var(--line); margin-top: 6px; }
.msg .small { margin: 2px 10px 0; }

/* Onboarding (views/welcome.php) */
.welcome-steps { list-style: none; margin: 24px 0 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.welcome .todo-list p { margin: 0; }
.welcome .form-error { white-space: pre-line; }
