/* SJRecruitment CRM: the placement ledger look of the original CRM, carried over.
   Slate and brass on warm paper; Newsreader for names, IBM Plex for everything else. */
:root {
  --slate: #4f6a8f; --brass: #c08a3e; --brass-dim: #a5732f; --sage: #4f7a62; --brick: #ab5142;
  --bg: #f7f5f0; --panel: #ffffff; --raised: #eeeae0; --line: rgba(20, 22, 28, .12);
  --ink: #20222b; --ink-dim: #55524a; --ink-faint: #7d7869;
  --restricted: #7a3f6e; --restricted-soft: #f6e8f2; --money: #8a5a14; --money-soft: #fbf1df;
  --radius: 4px; --serif: 'Newsreader', Georgia, serif;
  --sans: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif; --mono: 'IBM Plex Mono', Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c; --panel: #1c1f28; --raised: #262a37; --line: rgba(231, 227, 216, .14);
    --ink: #e8e4d9; --ink-dim: #b3aea1; --ink-faint: #8e8a7d; --sage: #7fb093; --brick: #d77c6c;
    --restricted: #d79bc8; --restricted-soft: #36222f; --money: #e3a94e; --money-soft: #3a2d17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161c; --panel: #1c1f28; --raised: #262a37; --line: rgba(231, 227, 216, .14);
  --ink: #e8e4d9; --ink-dim: #b3aea1; --ink-faint: #8e8a7d; --sage: #7fb093; --brick: #d77c6c;
  --restricted: #d79bc8; --restricted-soft: #36222f; --money: #e3a94e; --money-soft: #3a2d17;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; text-wrap: balance; margin: 0; }
h1 { font-size: 26px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
a { color: var(--slate); }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
.faint { color: var(--ink-faint); } .dim { color: var(--ink-dim); }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar { display: flex; align-items: center; gap: 12px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg); flex-wrap: wrap; }
.brandlink { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; flex: 1; min-width: 0; }
.mark { width: 26px; height: 26px; border-radius: 50%; flex: none; border: 1.5px solid var(--slate);
  background: radial-gradient(circle, transparent 0 30%, var(--slate) 30% 100%), linear-gradient(90deg, var(--slate) 50%, transparent 50%); }
.brand { display: flex; flex-direction: column; line-height: 1.15; }
.brand b { font-family: var(--serif); font-size: 17px; }
.brand span { font-size: 11px; color: var(--ink-faint); letter-spacing: .08em; }
.who { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--ink-dim); }
.who .helplink { color: var(--ink); font-weight: 500; }
.tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10; background: var(--bg); scrollbar-width: none; }
.tabs a { flex: none; padding: 10px 12px 9px; color: var(--ink-dim); text-decoration: none; font-size: 13.5px; font-weight: 500;
  border-bottom: 2px solid transparent; }
.tabs a[aria-current] { color: var(--ink); border-bottom-color: var(--brass); }
main { max-width: 1040px; margin: 0 auto; padding-inline: 16px; padding-block: 20px 60px; }
main.narrow { max-width: 560px; }

/* ---------- page header and toolbars ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pagehead .sub { color: var(--ink-dim); font-size: 13.5px; margin-top: 4px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 8px; flex: 1; min-width: 220px; }
.toolbar select { padding: 8px 12px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); }
.search { flex: 1; min-width: 0; padding: 9px 14px; border-radius: 20px; border: 1px solid var(--line); background: var(--panel); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: var(--panel); }
.seg a { padding: 7px 12px; font-size: 13px; text-decoration: none; color: var(--ink-dim); }
.seg a[aria-current] { background: var(--raised); color: var(--ink); font-weight: 600; }
.crumbs { font-size: 13px; color: var(--ink-faint); margin-bottom: 6px; }
.crumbs a { color: var(--ink-faint); }

/* ---------- buttons ---------- */
.btn, .btn-primary, .btn-danger, .linkbtn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--panel); cursor: pointer; text-decoration: none; color: var(--ink); font-size: 13.5px; font-weight: 500; }
.btn-primary { background: var(--brass); border-color: var(--brass); color: #fff; }
.btn-primary:hover { background: var(--brass-dim); }
.btn-danger { color: var(--brick); border-color: color-mix(in srgb, var(--brick) 40%, transparent); }
.linkbtn { border: none; background: none; padding: 4px; color: var(--slate); text-decoration: underline; }
.btn-small { padding: 4px 10px; font-size: 12.5px; }
form.inline { display: inline; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---------- flash ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border: 1px solid; font-size: 14px; }
.flash-ok { border-color: color-mix(in srgb, var(--sage) 45%, transparent); background: color-mix(in srgb, var(--sage) 10%, var(--panel)); }
.flash-error { border-color: color-mix(in srgb, var(--brick) 50%, transparent); background: color-mix(in srgb, var(--brick) 10%, var(--panel)); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 20px; }
.kpi { background: var(--panel); padding: 14px; }
.kpi .n { font-family: var(--serif); font-size: 28px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.kpi.money { background: var(--money-soft); }
.progress { height: 6px; background: var(--raised); border-radius: 3px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--brass); }

/* ---------- sections, ledgers, cards ---------- */
.section { margin-top: 26px; }
.section > .head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.section > .head .hint { font-size: 12.5px; color: var(--ink-faint); }
.ledger { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); overflow: hidden; }
.ledger > .row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ledger > .row:last-child { border-bottom: none; }
.ledger > .row .t { flex: 1; min-width: 180px; }
.ledger > .row .t b, .ledger > .row .t a.name { display: block; font-weight: 600; }
.ledger > .row .t small { display: block; color: var(--ink-faint); font-size: 12.5px; margin-top: 1px; }
.ledger > .row .amt { font-family: var(--mono); font-size: 13px; color: var(--ink-dim); white-space: nowrap; }
.ledger .empty { padding: 26px 14px; text-align: center; color: var(--ink-faint); }
a.rowlink { color: inherit; text-decoration: none; }
a.rowlink:hover .name, a.rowlink:hover b { text-decoration: underline; }
.cards { display: grid; gap: 8px; }
.card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  text-decoration: none; color: inherit; }
.card:hover { border-color: var(--slate); }
.card .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.card .name { font-family: var(--serif); font-size: 16.5px; font-weight: 600; }
.card .meta { font-size: 12.5px; color: var(--ink-dim); margin-top: 3px; }
.card .meta span + span::before { content: " · "; color: var(--ink-faint); }

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 500; border: 1px solid var(--line);
  color: var(--ink-dim); background: var(--raised); white-space: nowrap; }
.pill-active, .pill-open, .pill-ready, .pill-accepted { color: var(--sage); background: color-mix(in srgb, var(--sage) 12%, var(--panel));
  border-color: color-mix(in srgb, var(--sage) 35%, transparent); }
.pill-prospect, .pill-new, .pill-screening, .pill-on_hold, .pill-invited { color: var(--brass-dim);
  background: color-mix(in srgb, var(--brass) 13%, var(--panel)); border-color: color-mix(in srgb, var(--brass) 35%, transparent); }
.pill-at_risk, .pill-spam, .pill-rejected, .pill-disabled { color: var(--brick); background: color-mix(in srgb, var(--brick) 12%, var(--panel));
  border-color: color-mix(in srgb, var(--brick) 35%, transparent); }
.pill-placeholder { color: var(--restricted); background: var(--restricted-soft); }
.tag { font-size: 11.5px; padding: 1px 7px; border-radius: 4px; background: var(--raised); color: var(--ink-dim); }
.stars { color: var(--brass); letter-spacing: 1px; }

/* ---------- detail pages ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .detail { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel > h2 { margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.panel.money { background: var(--money-soft); border-color: color-mix(in srgb, var(--money) 40%, transparent); }
.panel.restricted { background: var(--restricted-soft); border-color: color-mix(in srgb, var(--restricted) 40%, transparent); }
.panel .note { font-size: 13px; color: var(--ink-dim); margin: 0 0 10px; }
dl.facts { display: grid; grid-template-columns: minmax(120px, 38%) 1fr; gap: 6px 14px; margin: 0; font-size: 14px; }
dl.facts dt { color: var(--ink-faint); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; white-space: pre-line; }
table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th { text-align: left; font-size: 11.5px; color: var(--ink-faint); font-weight: 600; letter-spacing: .04em; padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--line); }
table.list td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.scroll { overflow-x: auto; }

/* ---------- forms ---------- */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.form .full { grid-column: 1 / -1; }
.field { margin-bottom: 14px; min-width: 0; border: none; padding: 0; }
.field label, .field legend { display: block; font-size: 12.5px; color: var(--ink-dim); margin-bottom: 5px; font-weight: 500; }
.field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; padding: 9px 11px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.field textarea { resize: vertical; }
.field .hint { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.req { color: var(--brick); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks legend { width: 100%; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.formbar { display: flex; gap: 10px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.subform { border-top: 1px dashed var(--line); margin-top: 12px; padding-top: 12px; }
details.add > summary { cursor: pointer; color: var(--slate); font-size: 13.5px; font-weight: 500; margin-top: 10px; }
details.add[open] > summary { margin-bottom: 10px; }

/* ---------- history ---------- */
.history { margin-top: 20px; font-size: 13px; }
.history summary { cursor: pointer; color: var(--ink-dim); }
.history ul { list-style: none; padding: 0; margin: 8px 0 0; }
.history li { padding: 4px 0; border-bottom: 1px solid var(--line); }
.history .when { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; }

/* ---------- sign-in and public pages ---------- */
.signin { max-width: 400px; margin: 8vh auto 0; }
.signin .brandlink { justify-content: center; margin-bottom: 24px; flex: none; }
.people { display: grid; gap: 8px; }
.qr { background: #fff; padding: 12px; border-radius: var(--radius); width: 220px; height: 220px; }
.qr img { width: 100%; height: 100%; }
.public { max-width: 760px; }
.consent-text { white-space: pre-line; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; max-height: 360px; overflow-y: auto; font-size: 14px; }
.consent-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.consent-row .yn { display: flex; gap: 14px; }
@media (max-width: 520px) { .consent-row { grid-template-columns: 1fr; } }
