:root {
  --bg: #0f1115;
  --panel: #161922;
  --border: #232838;
  --text: #e6e8ee;
  --muted: #8a93a6;
  --accent: #5b9dff;
  --accent-2: #7df0c2;
  --danger: #ff6b6b;
  --warn: #f4c25b;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { background: #1f2433; color: var(--text); border: 1px solid var(--border); padding: 6px 12px; border-radius: 6px; cursor: pointer; font: inherit; }
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #0f1115; border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
input, select, textarea { background: #1f2433; color: var(--text); border: 1px solid var(--border); padding: 6px 10px; border-radius: 6px; font: inherit; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

header {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--panel);
  position: sticky; top: 0; z-index: 10;
}
header h1 { margin: 0; font-size: 16px; letter-spacing: 0.5px; color: var(--accent-2); }
header nav { display: flex; gap: 8px; }
header nav button.active { background: var(--accent); color: #0f1115; border-color: var(--accent); }
header .actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; justify-content: flex-end; }
header .kpi-strip { flex: 1; min-width: 0; justify-content: flex-end; flex-wrap: nowrap; overflow-x: auto; }

/* KPI strip */
.kpi-strip { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.kpi {
  display: inline-flex; flex-direction: column; align-items: stretch;
  padding: 3px 8px 5px; border-radius: 6px;
  background: #1f2433; border: 1px solid var(--border); min-width: 70px;
  cursor: default;
}
.kpi .kpi-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); line-height: 1; white-space: nowrap; }
.kpi .kpi-value { font-size: 14px; font-weight: 700; line-height: 1.1; margin-top: 2px; color: var(--text); white-space: nowrap; }
.kpi.good .kpi-value { color: var(--accent-2); }
.kpi.warn .kpi-value { color: var(--warn); }
.kpi.bad  .kpi-value { color: var(--danger); }
.kpi.accent .kpi-value { color: var(--accent); }
.kpi .kpi-sub { font-size: 10px; color: var(--muted); line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-divider { width: 1px; height: 28px; background: var(--border); margin: 0 2px; }
@media (max-width: 1400px) { .kpi .kpi-sub { display: none; } }
@media (max-width: 1100px) { .kpi-divider { display: none; } .kpi { min-width: 0; padding: 3px 6px 5px; } }

/* In-tile mini progress bar */
.kpi-bar {
  display: block; height: 4px; margin-top: 4px;
  background: #11151e; border-radius: 3px; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.3);
}
.kpi-bar-fill {
  display: block; height: 100%;
  transition: width 400ms cubic-bezier(.2,.8,.2,1);
  border-radius: 3px;
}

/* ── Funnel progress bar (legacy, may not be used) ───── */
.progress-bar { margin: 8px 0 14px; }
.progress-track {
  display: flex; width: 100%; height: 22px;
  border-radius: 6px; overflow: hidden;
  background: #1a1f2c; border: 1px solid var(--border);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.2);
}
.progress-seg {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #0c1018;
  white-space: nowrap; overflow: hidden;
  transition: width 400ms cubic-bezier(.2,.8,.2,1), filter 150ms;
  position: relative;
}
.progress-seg:hover { filter: brightness(1.15); cursor: default; }
.progress-seg + .progress-seg { border-left: 1px solid rgba(0,0,0,0.25); }
.progress-seg-label {
  padding: 0 6px;
  text-shadow: 0 1px 0 rgba(255,255,255,0.25);
}
/* Stage colors — cool→warm gradient through the funnel */
.seg-pending   { background: linear-gradient(180deg, #4a5568 0%, #3a4252 100%); color: #cbd5e1; }
.seg-evaluated { background: linear-gradient(180deg, #5b9dff 0%, #3b7ad9 100%); color: #0a1628; }
.seg-applied   { background: linear-gradient(180deg, #8b5cf6 0%, #6d3fd0 100%); color: #fff; }
.seg-responded { background: linear-gradient(180deg, #06b6d4 0%, #0891a6 100%); color: #04212a; }
.seg-interview { background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%); color: #2a1a00; }
.seg-offer     { background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%); color: #042818; }
.seg-rejected  { background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%); color: #2a0606; }

.progress-legend {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-top: 6px; font-size: 11px; color: var(--muted);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item.is-empty { opacity: 0.45; }
.legend-item b { color: var(--text); font-weight: 600; margin-left: 2px; }
.legend-swatch {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
}
.swatch-pending   { background: #4a5568; }
.swatch-evaluated { background: #5b9dff; }
.swatch-applied   { background: #8b5cf6; }
.swatch-responded { background: #06b6d4; }
.swatch-interview { background: #f59e0b; }
.swatch-offer     { background: #22c55e; }
.swatch-rejected  { background: #ef4444; }

/* PDF download links */
.pdf-cell { white-space: nowrap; }
.pdf-link {
  display: inline-block; padding: 1px 6px; margin-right: 4px;
  font-size: 11px; font-weight: 600; text-decoration: none;
  border: 1px solid var(--border); border-radius: 4px; color: var(--accent);
  background: #1f2433;
}
.pdf-link:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.pdf-missing { color: var(--muted); opacity: 0.5; margin-right: 4px; }

/* Inline notes editor */
.notes-cell { cursor: text; }
.notes-cell:hover { background: rgba(255,255,255,0.03); }
.notes-placeholder { color: var(--muted); opacity: 0.5; font-style: italic; }
.notes-saving { color: var(--muted); font-style: italic; }
.notes-input {
  width: 100%; min-height: 48px; box-sizing: border-box;
  background: #1f2433; color: var(--text); border: 1px solid var(--accent);
  border-radius: 4px; padding: 4px 6px; font: inherit; resize: vertical;
}
.notes-cell.editing { background: rgba(0,0,0,0.2); }

/* Pipeline decision-support */
.hint-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  text-transform: uppercase; white-space: nowrap;
  background: #1f2433; border: 1px solid var(--border); color: var(--muted);
}
.hint-badge.tone-good   { background: rgba(74,222,128,0.15); color: var(--accent-2); border-color: var(--accent-2); }
.hint-badge.tone-bad    { background: rgba(248,113,113,0.15); color: var(--danger);  border-color: var(--danger); }
.hint-badge.tone-warn   { background: rgba(250,204,21,0.15);  color: var(--warn);    border-color: var(--warn); }
.hint-badge.tone-accent { background: rgba(96,165,250,0.15);  color: var(--accent);  border-color: var(--accent); }
.hint-badge.tone-muted  { background: #1f2433; color: var(--muted); }
.col-history { font-size: 11px; }
.col-history .muted { color: var(--muted); }
.col-source { font-size: 11px; color: var(--muted); }
/* Single scroll context: the wrap fills the viewport below the page header
   and is the only thing that scrolls. Sticky thead pins to the wrap's top. */
html, body { height: 100%; }
body { overflow: hidden; }
main { padding: 12px 18px 0; height: calc(100vh - 56px); display: flex; flex-direction: column; min-height: 0; }
.tab { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab.active { display: flex; }
.table-wrap {
  flex: 1; min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.toolbar {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
}
.toolbar input[type="text"], .toolbar input:not([type]) { flex: 1; min-width: 200px; max-width: 480px; }
.toolbar .count { color: var(--muted); margin-left: auto; }

table.data-table { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data-table th, table.data-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; overflow: hidden; text-overflow: ellipsis; }
table.data-table thead th { color: var(--muted); font-weight: 600; background: var(--panel); position: sticky; top: 0; z-index: 3; white-space: nowrap; box-shadow: inset 0 -1px 0 var(--border); }
/* Cells truncate with an ellipsis when narrower than their content. The full
   value is shown via the row's `title` attribute or per-cell tooltips. */
table.data-table td { white-space: nowrap; max-width: 0; }
/* Opt-out: cells that need to wrap multi-line (editable notes textarea, etc.) */
table.data-table td.wrap { white-space: normal; word-break: break-word; }
table.sortable th[data-sort] { cursor: pointer; user-select: none; }
table.sortable th[data-sort]:hover { color: var(--accent); }
table.data-table tr:hover td { background: rgba(91, 157, 255, 0.04); }
.w-40 { width: 40px; }
.w-200 { width: 220px; }
td.url { word-break: break-all; max-width: 360px; color: var(--muted); font-size: 12px; }
td.notes { color: var(--muted); }
/* Actions cell: never truncate, allow buttons to wrap to a 2nd line if needed. */
table.data-table td.actions, table.data-table td.col-actions {
  white-space: normal; max-width: none; overflow: visible;
  display: flex; gap: 6px; flex-wrap: wrap; align-items: center;
}
/* History cell hosts the multi-chip status timeline; allow it to wrap. */
table.data-table td.col-history { white-space: nowrap; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; background: #232838; color: var(--muted); }
.badge.evaluated { background: #2a3550; color: #b8d0ff; }
.badge.applied { background: #1f4d3c; color: var(--accent-2); }
.badge.responded { background: #3a4d1f; color: #c8f08a; }
.badge.interview { background: #4d3a1f; color: var(--warn); }
.badge.offer { background: #1f4d4d; color: #8af0e8; }
.badge.rejected, .badge.discarded { background: #4d1f1f; color: var(--danger); }
.badge.skip { background: #2a2a2a; color: var(--muted); }

/* Inline status editor — looks like a badge but is a <select> */
select.status-select {
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 18px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 10px) 50%, calc(100% - 6px) 50%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}
select.status-select:hover { border-color: var(--border); }
select.status-select:disabled { opacity: 0.5; cursor: wait; }
select.status-select option { background: var(--panel); color: var(--text); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal.hidden { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 20px; min-width: 380px; max-width: 90vw; max-height: 90vh; display: flex; flex-direction: column; }
.modal-card.wide { width: 900px; max-width: 95vw; }

.modal-card h3 { margin: 0 0 14px; font-size: 15px; color: var(--accent-2); }
.modal-card label { display: block; margin-bottom: 10px; font-size: 12px; color: var(--muted); }
.modal-card label input, .modal-card label select, .modal-card label textarea { display: block; width: 100%; margin-top: 4px; color: var(--text); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.viewer-header { display: flex; align-items: center; justify-content: space-between; padding: 0 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.viewer-header h3 { margin: 0; }
.viewer-header button { font-size: 18px; padding: 2px 10px; }
.viewer-body { overflow: auto; flex: 1; font-size: 13px; line-height: 1.55; padding-right: 6px; }
.viewer-body h1, .viewer-body h2, .viewer-body h3 { color: var(--accent-2); margin-top: 20px; }
.viewer-body code { background: #1f2433; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.viewer-body pre { background: #1f2433; padding: 10px; border-radius: 6px; overflow: auto; }
.viewer-body table { border-collapse: collapse; margin: 10px 0; }
.viewer-body th, .viewer-body td { border: 1px solid var(--border); padding: 6px 10px; }
.viewer-body iframe { width: 100%; height: 75vh; border: 0; background: white; }

/* Resizable columns */
table.resizable { table-layout: fixed; }
table.resizable th, table.resizable td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.resizable td.notes, table.resizable td.url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
table.resizable th { position: sticky; }
.col-resize-handle {
  position: absolute; top: 0; right: 0; width: 6px; height: 100%;
  cursor: col-resize; user-select: none; z-index: 5;
}
.col-resize-handle:hover, .col-resize-handle.active { background: var(--accent); opacity: 0.6; }
table.resizable th { position: sticky; top: 0; }
table.resizable th[data-col] { position: sticky; padding-right: 14px; }
table.resizable th[data-col] { position: sticky; }
/* (the position:relative is needed so the handle anchors to the th) */
table.resizable thead th { position: sticky; top: 0; }
table.resizable thead th[data-col] { position: sticky; }

/* The handle is absolute-positioned inside the th. Need relative on the th
   without losing sticky behaviour — sticky already creates a positioning context. */
table.resizable th[data-col] { /* sticky already works; no override needed */ }

/* Hidden columns: applied via class hide-col-{key} on the table */
table.resizable th.col-hidden, table.resizable td.col-hidden { display: none !important; }

/* Columns popover */
.col-popover {
  position: absolute; z-index: 50;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; min-width: 180px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.col-popover h4 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.col-popover label { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; font-size: 13px; }
.col-popover label:hover { color: var(--accent); }
.col-popover .col-actions { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); display: flex; gap: 6px; }
.col-popover .col-actions button { font-size: 11px; padding: 4px 8px; }

/* Per-column filter button + popover */
.col-filter-btn {
  display: inline-block;
  margin-left: 4px;
  padding: 0 4px;
  border-radius: 4px;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  user-select: none;
  border: 1px solid transparent;
}
.col-filter-btn:hover { color: var(--accent); border-color: var(--border); }
.col-filter-btn.active { color: var(--accent); background: rgba(91,157,255,0.15); border-color: var(--accent); }
.col-filter-popover {
  position: absolute; z-index: 60;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px; min-width: 220px; max-width: 320px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.col-filter-popover h4 { margin: 0 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.col-filter-popover input.search { width: 100%; margin-bottom: 6px; padding: 4px 8px; font-size: 12px; }
.col-filter-popover .opts { max-height: 280px; overflow-y: auto; padding-right: 4px; }
.col-filter-popover label { display: flex; align-items: center; gap: 8px; padding: 3px 2px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.col-filter-popover label:hover { color: var(--accent); }
.col-filter-popover label .count { color: var(--muted); font-size: 11px; margin-left: auto; }
.col-filter-popover .actions { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); display: flex; gap: 6px; justify-content: flex-end; }
.col-filter-popover .actions button { font-size: 11px; padding: 4px 8px; }

/* ── career additions ─────────────────────────────────── */
.muted { color: var(--muted); }
.market-pill { display: inline-block; min-width: 26px; text-align: center; padding: 1px 6px; border-radius: 6px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
  background: #1f2433; border: 1px solid var(--border); color: var(--muted); }
.market-pill.m-ca { color: #ff8a8a; border-color: #ff8a8a55; }
.market-pill.m-us { color: var(--accent); border-color: #5b9dff55; }
.market-pill.m-vn { color: var(--warn); border-color: #f4c25b55; }
.market-pill.m-? { color: var(--muted); border-style: dashed; }

/* Next-action inline editor */
.next-cell { cursor: text; }
.next-cell:hover { background: rgba(255,255,255,0.03); }
.next-cell.editing { background: rgba(0,0,0,0.2); }
.next-input { width: 100%; box-sizing: border-box; background: #1f2433; color: var(--text);
  border: 1px solid var(--accent); border-radius: 4px; padding: 2px 6px; font: inherit; }

/* Broken tracker rows banner */
.tracker-errors { margin-bottom: 10px; padding: 8px 12px; border: 1px solid var(--danger); border-radius: 6px;
  background: rgba(255,107,107,0.08); color: var(--text); font-size: 12px; line-height: 1.5; }
.tracker-errors.hidden { display: none; }

/* Modal note + scan result */
.modal-note { margin: -6px 0 12px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.modal-note code { background: #11151e; padding: 1px 5px; border-radius: 3px; color: var(--accent-2); }
.scan-summary { border-collapse: collapse; margin-bottom: 10px; font-size: 13px; }
.scan-summary td { padding: 2px 14px 2px 0; }
.scan-errors { color: var(--danger); font-size: 12px; line-height: 1.6; }
.scan-list { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: 13px; }
.scan-list li { padding: 3px 0; border-bottom: 1px solid var(--border); }
.viewer-body .md-row { font-family: ui-monospace, monospace; font-size: 12px; white-space: pre; color: var(--muted); }
.toolbar select { padding: 5px 8px; }

/* ── Round states (templates/states.yml) — the old career-ops list stopped at "interview" ── */
.badge.recruiter_screen { background: #3a4d1f; color: #c8f08a; }
.badge.tech_screen      { background: #4d3a1f; color: var(--warn); }
.badge.onsite           { background: #4d2f1f; color: #ffb38a; }
.badge.team_match       { background: #2f1f4d; color: #d0b8ff; }
.badge.ghosted          { background: #2a2a2a; color: var(--muted); border: 1px dashed var(--muted); }

/* ── Rounds column: one chip per round attended, from data/rounds.md ── */
.status-timeline { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; line-height: 1.2; }
.tl-chip { display: inline-block; padding: 1px 6px; border-radius: 8px; font-size: 11px; border: 1px solid transparent; white-space: nowrap; }
.tl-chip i { font-style: normal; opacity: 0.8; font-size: 10px; }
.tl-chip.tone-good { background: rgba(74,222,128,0.18); color: var(--accent-2); border-color: var(--accent-2); }
.tl-chip.tone-bad  { background: rgba(248,113,113,0.18); color: var(--danger);  border-color: var(--danger); }
.tl-chip.tone-warn { background: rgba(250,204,21,0.18);  color: var(--warn);    border-color: var(--warn); }
.tl-arrow { color: var(--muted); font-weight: 700; padding: 0 1px; }

/* ── Log-round modal ── */
.round-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
#round-cause-wrap.hidden { display: none; }
.modal-card label .muted { font-weight: 400; }

/* ── PDF download link next to the viewer link ── */
.pdf-dl { margin: 0 6px 0 2px; color: var(--muted); font-size: 12px; }
.pdf-dl:hover { color: var(--accent); text-decoration: none; }

/* ── Email scan modal (ported from career-ops) ── */
.email-intro { font-size: 13px; color: var(--muted); }
.email-intro code { background: #11151e; padding: 1px 5px; border-radius: 3px; color: var(--accent-2); }
.email-actions { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.email-upload { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: #1f2433; color: var(--text); font-size: 14px; }
.email-upload:hover { border-color: var(--accent); }
.email-upload input { display: none; }
.email-paste { margin: 8px 0; }
.email-paste summary { cursor: pointer; font-size: 12px; color: var(--accent); }
.email-paste textarea { width: 100%; margin: 6px 0; font-family: ui-monospace, monospace; font-size: 11px; background: #11151e; color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px; }
.email-results { margin-top: 14px; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.email-card { border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; background: #1a1f2c; }
.email-card.outcome-rejected  { border-left: 3px solid var(--danger); }
.email-card.outcome-interview { border-left: 3px solid var(--warn); }
.email-card.outcome-offer     { border-left: 3px solid var(--accent-2); }
.email-card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.email-card-title { font-weight: 600; }
.email-card-arrow { font-size: 12px; color: var(--muted); }
.email-card-arrow b { color: var(--text); }
.email-card-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.email-card-evidence { margin-top: 6px; padding: 6px 8px; background: #11151e; border-radius: 4px; font-size: 12px; font-style: italic; }
.email-card-actions { margin-top: 8px; display: flex; gap: 6px; }
.email-empty { padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }
