:root {
  /* EverHire brand palette — slate-blue #8EA3BA, #1E1E1E, #898989, #EFEFEF, #FFFFFF */
  --bg: #eef1f4;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --line: #e1e6ec;
  --text: #1e1e1e;
  --muted: #6f7680;
  --accent: #8ea3ba;          /* brand primary */
  --accent-strong: #5f7c99;   /* deeper slate for buttons/active so white text stays legible */
  --accent-2: #8ea3ba;
  --green: #1f9d6b;
  --amber: #b07d05;
  --red: #d64545;
  --radius: 12px;
  --shadow: 0 4px 18px rgba(30,30,30,.08);
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; flex-direction: column; min-height: 100%; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 12px 22px; background: var(--panel);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo { width: 34px; height: 34px; display: block; object-fit: contain; }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tabs button {
  background: transparent; border: 0; color: var(--muted); font-size: 14px;
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600;
}
.tabs button:hover { background: var(--panel-2); color: var(--text); }
.tabs button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.viewtoggle { display: flex; gap: 2px; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.viewtoggle button { background: transparent; border: 0; color: var(--muted); font-weight: 700; font-size: 12px; padding: 5px 10px; border-radius: 7px; cursor: pointer; }
.viewtoggle button.active { background: var(--accent-strong); color: #fff; }
.status { color: var(--muted); font-size: 12px; min-width: 64px; text-align: right; }
.status.saving { color: var(--amber); }
.status.error { color: var(--red); }

/* Shown when the file on disk has moved on beneath this window and saving has stopped.
   Deliberately loud and un-dismissable: quietly carrying on is what loses data. */
.stale-banner {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px;
  background: #fdf3f3; border-bottom: 2px solid var(--red);
}
.stale-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 260px; }
.stale-text strong { color: var(--red); }
.stale-text span { color: var(--muted); font-size: 13px; }
.stale-actions { display: flex; gap: 8px; }

/* ── Layout ── */
main { padding: 22px; max-width: 1600px; width: 100%; margin: 0 auto; }
main.wide-view { max-width: 2000px; }
/* Pipeline deals: many columns, so long client/role text wraps instead of forcing a scrollbar */
.fc-table th, .fc-table td { padding: 9px 8px; }
.fc-table th { white-space: normal !important; vertical-align: bottom; }
.fc-table td:nth-child(2), .fc-table td:nth-child(3) { white-space: normal; min-width: 100px; }
.fc-table td:nth-child(2) { max-width: 150px; overflow-wrap: anywhere; }
.fc-table td:nth-child(3) { min-width: 160px; }
.fc-table .btn.sm { padding-left: 8px; padding-right: 8px; }
.fc-table td:nth-child(6) { white-space: normal; max-width: 120px; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 16px; gap: 12px; flex-wrap: wrap; }
.section-head h1 { font-size: 22px; margin: 0; }
.section-head .sub { color: var(--muted); font-size: 13px; }

/* ── Cards / KPIs ── */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.kpi .value.small { font-size: 20px; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
.kpi .value.green { color: var(--green); }
.kpi .value.amber { color: var(--amber); }
.kpi .value.red { color: var(--red); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; display:flex; justify-content:space-between; align-items:center; }
.panel-body { padding: 6px 0; overflow-x: auto; }
/* Force a visible horizontal scrollbar on wide tables — macOS overlay scrollbars
   hide until you scroll, which made the right-hand columns (Billing, edit/delete)
   look missing. This keeps the affordance on screen. */
.panel-body { scrollbar-width: thin; scrollbar-color: var(--accent) var(--panel-2); }
.panel-body::-webkit-scrollbar { height: 10px; }
.panel-body::-webkit-scrollbar-track { background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }
.panel-body::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 999px; border: 2px solid var(--panel-2); }
.panel-body::-webkit-scrollbar-thumb:hover { background: var(--accent-strong); }

/* ── Tables ── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.job-cell { white-space: normal; max-width: 230px; min-width: 160px; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.clickable { cursor: pointer; }
tbody tr.expandable { cursor: pointer; }
.caret { display: inline-block; width: 12px; color: var(--muted); font-size: 10px; }
.badge.clickable { cursor: pointer; }
.badge.clickable:hover { filter: brightness(1.25); }
tbody tr.client-detail > td { padding: 0; background: var(--panel-2); }
.client-breakdown { padding: 4px 0 8px; }
.breakdown-stats { display: flex; flex-wrap: wrap; gap: 28px; padding: 14px 16px 10px; }
.bd-stat-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.bd-stat-val { font-size: 18px; font-weight: 800; margin-top: 3px; }
.bd-stat-val.green { color: var(--green); }
.bd-stat-val.amber { color: var(--amber); }
.bd-stat-val.red { color: var(--red); }
.bd-stat-val.muted { color: var(--muted); }
.bd-stat-hint { color: var(--muted); font-size: 11px; margin-top: 2px; }
.client-breakdown table { background: var(--panel); }
tbody tr.deal-detail { background: var(--panel-2); }
tbody tr.deal-detail:hover { background: var(--panel-2); }
tbody tr.deal-detail td:first-child { padding-left: 30px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Detail view (read-only) ── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.detail-label { color: var(--muted); font-size: 13px; }
.detail-val { font-weight: 600; text-align: right; }
.detail-val.strong { font-weight: 800; }
.detail-row.clickable { cursor: pointer; }
.detail-row.clickable:hover { background: var(--panel-2); }
.note-warn { background: rgba(176,125,5,.12); border: 1px solid rgba(176,125,5,.35); color: var(--amber); border-radius: 9px; padding: 9px 12px; font-size: 12px; margin-bottom: 12px; }
.detail-val .inline-edit { padding: 4px 8px; font-weight: 600; font-size: 13px; }
.detail-val .status-select { font-weight: 700; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.row-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }

/* ── Inline status picker ── */
.status-cell { display: flex; align-items: center; gap: 8px; }
.paid-btn { color: var(--green); border-color: rgba(31,157,107,.4); background: rgba(31,157,107,.08); white-space: nowrap; }
.paid-btn:hover { background: rgba(31,157,107,.16); border-color: var(--green); }
.status-select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid transparent; border-radius: 999px;
  padding: 3px 24px 3px 11px; font-size: 12px; font-weight: 700; cursor: pointer;
  background-repeat: no-repeat; background-position: right 8px center;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%236f7680' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
}
.status-select.s-pending { background-color: rgba(176,125,5,.16); color: var(--amber); }
.status-select.s-sent { background-color: #e7edf3; color: #4a627d; }
.status-select.s-paid { background-color: rgba(31,157,107,.14); color: var(--green); }
.status-select:focus { border-color: var(--accent-strong); }
.status-select:hover { filter: brightness(.97); }

/* ── Badges ── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge.draft { background: #e6e9ed; color: var(--muted); }
.badge.pending { background: rgba(176,125,5,.16); color: var(--amber); }
.badge.sent  { background: #e7edf3; color: #4a627d; }
.badge.paid  { background: rgba(31,157,107,.14); color: var(--green); }
.badge.overdue { background: rgba(214,69,69,.14); color: var(--red); }
.badge.partial { background: rgba(176,125,5,.16); color: var(--amber); }
.badge.yes { background: rgba(31,157,107,.14); color: var(--green); }
.badge.no  { background: #e6e9ed; color: var(--muted); }

/* ── Buttons ── */
.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: white; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: rgba(214,69,69,.4); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn { background:transparent;border:0;color:var(--muted);cursor:pointer;padding:4px 6px;border-radius:6px;font-size:13px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }

/* ── Filters / inputs ── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
input, select, textarea {
  background: var(--bg); border: 1px solid var(--line); color: var(--text);
  padding: 8px 10px; border-radius: 9px; font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-strong); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field { margin-bottom: 14px; }
.field.inline { display:flex; align-items:center; gap:10px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.search { min-width: 220px; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50;
  padding: 20px;
}
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto;
}
.modal.wide { max-width: 760px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 16px; display:flex; justify-content:space-between; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }

/* ── Toast ── */
#toastRoot { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--panel-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); }
.toast.ok { border-color: rgba(31,157,107,.5); }
.toast.err { border-color: rgba(214,69,69,.5); }

.tier-row { display:grid; grid-template-columns: 1fr 1fr auto; gap:8px; margin-bottom:8px; align-items:center; }
.split-row { display:grid; grid-template-columns: 1fr 96px auto; gap:8px; margin-bottom:8px; align-items:center; }
.split-row .pct-wrap { position:relative; display:flex; align-items:center; }
.split-row .pct-wrap input { width:100%; padding-right:22px; }
.split-row .pct-sign { position:absolute; right:10px; color:var(--muted); font-size:12px; pointer-events:none; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.pill { background: var(--panel-2); border:1px solid var(--line); border-radius:999px; padding:3px 10px; font-size:12px; }
/* Billing month on a contractor row. Must never break across lines — "Aug" on one line
   and "2026" on the next is unreadable in a column of near-identical monthly rows. */
.pill.month {
  white-space: nowrap; margin-left: 6px; padding: 2px 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: rgba(142,163,186,.22); border-color: transparent; color: #4a627d;
}
a.link { color: var(--accent-strong); cursor: pointer; text-decoration: none; }
hr.sep { border:0; border-top:1px solid var(--line); margin:18px 0; }
.bar-track { background: var(--panel-2); border-radius: 6px; height: 8px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); }

/* ── Budget tab ── */
/* First column (row labels) stays pinned while the 12 month columns scroll. */
.budget-table th:first-child, .budget-table .budget-rowlabel { position: sticky; left: 0; z-index: 1; }
.budget-table thead th:first-child { background: var(--panel); }
.budget-table .budget-rowlabel { background: var(--panel); color: var(--muted); font-weight: 700; text-transform: uppercase; font-size: 11px; letter-spacing: .5px; }
.budget-table tbody tr:hover .budget-rowlabel { background: var(--panel-2); }
.budget-input { width: 84px; padding: 4px 6px; text-align: right; font-variant-numeric: tabular-nums; }
/* Auto-calculated actual cells show their value as a muted placeholder; a manual
   override is shown solid with an accent border so it's clear which months are typed. */
.budget-actual-input::placeholder { color: var(--muted); opacity: .8; }
.budget-actual-input.ovr { border-color: var(--accent-strong); font-weight: 700; background: rgba(142,163,186,.12); }
/* Read-only auto-calculated actual cells (months past the manual cutover). */
.budget-auto { background: rgba(142,163,186,.06); }
.budget-total { font-weight: 800; border-left: 2px solid var(--line); }
.budget-group td { background: var(--panel-2); border-top: 2px solid var(--line); padding-top: 12px; }
.budget-group.budget-business td { background: #e7edf3; border-top: 3px solid var(--accent-strong); }
/* Team section header and the subtotal block that closes each team. */
.budget-team td { background: var(--accent-strong); color: #fff; border-top: 3px solid var(--accent-strong); }
.budget-subtotal td, .budget-subtotal .budget-rowlabel { background: #eef2f6; font-weight: 700; }
.budget-business td, .budget-business .budget-rowlabel { background: #e7edf3; }
.budget-pct td { font-size: 12px; }
/* Per-consultant month-label line — a light repeat of the column headers. */
.budget-monthrow .budget-monthline { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; padding-top: 8px; padding-bottom: 2px; border-bottom: 1px solid var(--line); }
.budget-monthrow .budget-rowlabel { background: var(--panel); }
.budget-monthrow:hover .budget-rowlabel { background: var(--panel-2); }
/* YTD %-to-target badge shown on each consultant, team-subtotal and business-total banner. */
.ytd-badge { display: inline-block; margin-left: 10px; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; vertical-align: middle; }
.ytd-badge.green { background: rgba(31,157,107,.16); color: var(--green); }
.ytd-badge.amber { background: rgba(176,125,5,.18); color: var(--amber); }
.ytd-badge.red { background: rgba(214,69,69,.16); color: var(--red); }
.ytd-badge.muted { background: var(--panel-2); color: var(--muted); }
.budget-table td.pos { color: var(--green); }
.budget-table td.neg { color: var(--red); }
.budget-table td.amber { color: var(--amber); }

/* ── Sign-in page ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 28px;
}
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 13px; }
.login-card input { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.login-card input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.login-card .btn { padding: 10px; font-size: 14px; }
.login-error { color: var(--red); font-size: 13px; min-height: 18px; }
/* Signed-in user + scope in the top bar */
.whoami { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.whoami .scope-badge { background: var(--panel-2); color: var(--text); border-radius: 6px; padding: 2px 7px; font-weight: 700; }
.whoami button { background: transparent; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; font-size: 12px; cursor: pointer; color: var(--muted); }
.whoami button:hover { color: var(--text); }

/* ── Week Plan tab ── */
.wp-section-title {
  margin: 26px 0 10px; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  color: var(--accent-strong); border-bottom: 2px solid var(--accent); padding-bottom: 6px;
}
.wp-q { margin-bottom: 12px; }
.wp-q-head { padding: 14px 16px 4px; }
.wp-q-title { font-weight: 700; font-size: 15px; }
.wp-q-hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.wp-q-body { padding: 8px 16px 14px; }
.wp-q-body > .panel-body { margin: 0 -16px; }
.wp-input { width: 100%; min-width: 90px; }
textarea.wp-input { resize: vertical; min-height: 64px; }
.wp-input.num { width: 72px; min-width: 60px; text-align: right; }
.wp-input.below { border-color: rgba(214,69,69,.55); color: var(--red); }
.wp-input:disabled { background: transparent; border-color: transparent; color: var(--text); opacity: 1; }
.wp-table td { vertical-align: middle; }
.wp-total td { background: var(--panel-2); }
.wp-priority { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.wp-priority > span:first-child { font-weight: 800; width: 18px; }
.wp-priority .wp-field { flex: 1; }
.green { color: var(--green); }
.amber { color: var(--amber); }
.red { color: var(--red); }
.wp-field { display: block; }
.wp-print { display: none; }
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  .topbar, .btn-group, .btn, .icon-btn, a.link, .stale-banner, #toastRoot { display: none !important; }
  html, body { background: #fff; font-size: 11px; }
  #view { padding: 0 !important; max-width: none !important; }
  .panel { box-shadow: none; border-color: #ccc; }
  .wp-q { break-inside: avoid; margin-bottom: 8px; }
  .wp-section-title { break-after: avoid; margin: 14px 0 6px; }
  .wp-q-head { padding: 8px 10px 2px; }
  .wp-q-title { font-size: 12px; }
  .wp-q-hint { font-size: 10px; }
  .wp-q-body { padding: 4px 10px 8px; }
  .panel-body { overflow: visible !important; }
  .wp-table th, .wp-table td { padding: 4px 6px; white-space: normal; font-size: 10.5px; }
  /* Print the typed values as plain text instead of empty-looking form boxes. */
  .wp-field > input, .wp-field > select, .wp-field > textarea { display: none !important; }
  .wp-print { display: block; white-space: pre-wrap; min-height: 1em; }
  .wp-field.multiline .wp-print { border-left: 2px solid var(--line); padding-left: 8px; min-height: 1.4em; }
  .wp-field.multiline .wp-print:empty::after { content: '—'; color: var(--muted); }
  td.num .wp-print { text-align: right; }
  .section-head .sub { font-size: 11px; }
}
