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

/* ──────────────────────── CHARCOAL MONO TOKENS ──────────────────────── */
:root {
  --bg:           #121212;   /* page */
  --surface:      #1A1A1A;   /* cards / table */
  --surface-hi:   #232323;   /* hovered / striped */
  --line:         rgba(255,255,255,0.07);
  --line-hi:      rgba(255,255,255,0.14);

  --fg:           #F2EFE8;   /* bone */
  --fg-soft:      #C8C6BF;
  --fg-mute:      #7A7A78;
  --fg-dim:       #555350;

  --danger:       #E06C5C;   /* used sparingly — PR badge, reject */
  --good:         #C8C6BF;   /* high score gets weight, not hue */

  --font-body:    'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:    'Fira Code', ui-monospace, SFMono-Regular, monospace;

  --t-fast: 120ms cubic-bezier(.4,0,.2,1);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body);
  font-size: 13px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 600; color: var(--fg); letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--fg-mute); }

a {
  color: var(--fg);
  text-decoration: underline;
  text-decoration-color: var(--fg-mute);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--t-fast), color var(--t-fast);
}
a:hover { text-decoration-color: var(--fg); color: var(--fg); }
a.unstyled, a.unstyled:hover { text-decoration: none; }

::selection { background: var(--fg); color: var(--bg); }

/* ──────────────────────── TOP NAV ──────────────────────── */
.topnav {
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
  font-size: 13px;
}
.topnav-left {
  display: flex; align-items: center; gap: 20px; min-width: 0;
}
.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
}
.topnav-links { display: flex; gap: 2px; list-style: none; margin: 0; padding: 0; }
.topnav-links a {
  display: inline-flex; align-items: center;
  height: 30px;
  padding: 0 10px;
  border-radius: 4px;
  color: var(--fg-mute);
  text-decoration: none;
  font-size: 12px;
}
.topnav-links a:hover { background: var(--surface-hi); color: var(--fg); }
.topnav-links a.active { color: var(--fg); background: var(--surface-hi); }
.topnav-right { display: flex; align-items: center; gap: 8px; }

/* ──────────────────────── BUTTONS / FORMS ──────────────────────── */
.btn, button.btn {
  appearance: none; cursor: pointer;
  font-family: var(--font-body); font-size: 12px; font-weight: 500;
  padding: 5px 11px; min-height: 28px;
  border-radius: 4px;
  border: 1px solid var(--line-hi);
  background: transparent;
  color: var(--fg);
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.btn:hover { border-color: var(--fg); }
.btn:focus-visible { outline: 1px solid var(--fg); outline-offset: 2px; }
.btn-primary { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.btn-primary:hover { background: var(--fg-soft); border-color: var(--fg-soft); }
.btn-ghost { border-color: transparent; color: var(--fg-mute); }
.btn-ghost:hover { background: var(--surface-hi); color: var(--fg); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-sm { padding: 3px 8px; min-height: 24px; font-size: 11px; }

input, select, textarea {
  font-family: var(--font-body); font-size: 12px;
  padding: 5px 9px; min-height: 28px;
  border-radius: 4px;
  border: 1px solid var(--line-hi);
  background: var(--bg);
  color: var(--fg);
  width: 100%;
}
input::placeholder, textarea::placeholder { color: var(--fg-dim); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--fg); }
textarea { min-height: 80px; resize: vertical; font-family: var(--font-mono); font-size: 11.5px; }
label {
  display: block;
  font-size: 10px; font-weight: 600;
  color: var(--fg-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px; margin-top: 12px;
}

/* ──────────────────────── PAGE WRAPPER ──────────────────────── */
.page {
  padding: 16px 24px 64px;
}
.page-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px; gap: 16px; flex-wrap: wrap;
}
.page-subtitle { color: var(--fg-mute); font-size: 12px; }

/* ──────────────────────── INLINE FILTER ROW ──────────────────────── */
.filter-row {
  display: flex; gap: 6px; align-items: center;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.filter-row input, .filter-row select { width: auto; min-height: 28px; padding: 4px 8px; font-size: 12px; }
.filter-row .grow { flex: 1; min-width: 220px; }
.filter-row label { margin: 0; }
.filter-row .sep { width: 1px; height: 22px; background: var(--line); margin: 0 4px; }

.source-chips { display: flex; gap: 4px; flex-wrap: wrap; }
.source-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-family: var(--font-mono); font-size: 11px;
  color: var(--fg-mute);
  text-decoration: none;
}
.source-chip:hover { border-color: var(--fg-mute); color: var(--fg); }
.source-chip.active { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.source-chip .n { font-size: 10px; opacity: 0.7; }
.source-chip.active .n { opacity: 1; }

/* ──────────────────────── COMPACT TABLE ──────────────────────── */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  overflow-x: auto;
}
table.jobs {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
table.jobs thead th {
  text-align: left;
  font-weight: 600; font-size: 10px;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-mute);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  white-space: nowrap;
}
table.jobs thead th a { color: var(--fg-mute); text-decoration: none; }
table.jobs thead th a:hover { color: var(--fg); }
table.jobs thead th.active { color: var(--fg); }
table.jobs tbody td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
table.jobs tbody tr { transition: background var(--t-fast); }
table.jobs tbody tr:hover { background: var(--surface-hi); }

/* Column-specific styling */
.col-fit { width: 90px; }
.col-title { min-width: 260px; }
.col-company { min-width: 140px; color: var(--fg-soft); }
.col-loc { min-width: 110px; color: var(--fg-soft); }
.col-sen { width: 80px; }
.col-type { width: 90px; }
.col-arr { width: 80px; }
.col-salary { width: 130px; color: var(--fg-soft); }
.col-posted { width: 70px; color: var(--fg-mute); font-family: var(--font-mono); font-size: 11px; }
.col-status { width: 90px; }
.col-actions { width: 130px; text-align: right; white-space: nowrap; }

.t-title {
  font-weight: 600; color: var(--fg);
  text-decoration: none;
  display: inline-block;
}
.t-title:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Score column: tiny bar + number */
.fit-cell { display: flex; align-items: center; gap: 8px; }
.fit-bar {
  width: 48px; height: 5px;
  background: var(--line-hi);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.fit-bar .fill { height: 100%; background: var(--fg); }
.fit-num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px; min-width: 28px;
}
.fit-num.dim { color: var(--fg-mute); font-weight: 400; }

/* Match-line: have / missing */
.match-line {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-mute);
  margin-top: 3px;
  line-height: 1.4;
}
.match-line .have { color: var(--fg); }
.match-line .sep { color: var(--fg-dim); margin: 0 5px; }
.match-line .miss { color: var(--fg-mute); }

/* Tags / badges (deliberately monochrome) */
.tag {
  display: inline-flex; align-items: center;
  padding: 1px 6px;
  border: 1px solid var(--line-hi);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 500;
  color: var(--fg-soft);
  background: transparent;
  white-space: nowrap;
}
.tag.dim { color: var(--fg-mute); border-color: var(--line); }
.tag.solid { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.tag.danger { color: var(--danger); border-color: var(--danger); }

/* Status tag uses weight, not colour */
.status-tag { font-family: var(--font-mono); font-size: 10px; font-weight: 600; }
.status-tag[data-s="new"]       { color: var(--fg-mute); }
.status-tag[data-s="saved"]     { color: var(--fg-soft); font-weight: 700; }
.status-tag[data-s="applied"]   { color: var(--fg); font-weight: 700; }
.status-tag[data-s="interview"] { color: var(--fg); font-weight: 700; text-decoration: underline; }
.status-tag[data-s="rejected"]  { color: var(--fg-dim); text-decoration: line-through; }

/* PR badge — only red thing in the UI */
.pr-badge {
  display: inline-flex; align-items: center;
  padding: 1px 5px;
  margin-left: 4px;
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 700;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 3px;
  letter-spacing: 0.02em;
}

/* ──────────────────────── PAGINATION ──────────────────────── */
.pager {
  display: flex; align-items: center; justify-content: center;
  gap: 4px; margin-top: 14px; flex-wrap: wrap;
  font-size: 12px;
}
.pager a, .pager strong, .pager span {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px;
  padding: 0 8px;
  border-radius: 3px;
  color: var(--fg-mute);
  text-decoration: none;
}
.pager a:hover { background: var(--surface-hi); color: var(--fg); }
.pager strong { background: var(--fg); color: var(--bg); }
.jump {
  display: inline-flex; align-items: center; gap: 4px;
  margin-left: 10px;
  font-size: 11px; color: var(--fg-mute);
}
.jump input { width: 56px; min-height: 26px; font-size: 11px; padding: 2px 6px; }

/* ──────────────────────── CARDS (used on detail, profile, stats) ──────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 16px;
}
.card-title {
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-mute);
  margin-bottom: 10px;
  display: flex; justify-content: space-between;
}

/* ──────────────────────── DETAIL PAGE ──────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 14px; }
@media (max-width: 800px) { .detail-grid { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 10px;
      padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 12px; }
.kv-key { color: var(--fg-mute); font-size: 10px; font-weight: 600;
          text-transform: uppercase; letter-spacing: 0.08em; padding-top: 2px; }

.match-breakdown { list-style: none; padding: 0; margin: 0;
                    display: flex; flex-direction: column; gap: 4px; }
.match-breakdown li {
  font-family: var(--font-mono); font-size: 11px;
  padding: 4px 8px;
  background: var(--bg);
  border-left: 2px solid var(--fg-mute);
  color: var(--fg-soft);
}
.match-breakdown li[data-neg="1"] { border-left-color: var(--danger); color: var(--fg-mute); }

/* ──────────────────────── EMPTY / TOAST ──────────────────────── */
.empty {
  text-align: center;
  padding: 48px 16px;
  background: var(--surface);
  border: 1px dashed var(--line-hi);
  border-radius: 6px;
  color: var(--fg-mute);
}
.empty h3 { margin-bottom: 6px; color: var(--fg); }
.empty code { background: var(--bg); color: var(--fg); padding: 2px 6px;
              border-radius: 3px; font-family: var(--font-mono); font-size: 11px; }

.toast {
  position: fixed; bottom: 18px; right: 18px;
  padding: 8px 14px;
  background: var(--fg); color: var(--bg);
  border-radius: 4px;
  font-size: 12px; font-weight: 500;
  z-index: 100;
}

/* ──────────────────────── COLUMNS POPOVER ──────────────────────── */
details.cols { position: relative; }
details.cols > summary {
  list-style: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--fg-mute);
  padding: 4px 8px;
  border: 1px solid var(--line-hi);
  border-radius: 4px;
}
details.cols > summary::-webkit-details-marker { display: none; }
details.cols > summary:hover { border-color: var(--fg); color: var(--fg); }
details.cols[open] > summary { background: var(--surface-hi); color: var(--fg); }
.cols-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--line-hi);
  border-radius: 6px;
  padding: 10px;
  min-width: 180px;
  z-index: 20;
  display: flex; flex-direction: column; gap: 4px;
}
.cols-menu label {
  margin: 0; text-transform: none; letter-spacing: normal;
  font-size: 11px; font-weight: 400;
  color: var(--fg);
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.cols-menu label input { width: auto; min-height: 0; }

/* Hide columns when classes set */
table.jobs.hide-company    .col-company { display: none; }
table.jobs.hide-loc        .col-loc { display: none; }
table.jobs.hide-sen        .col-sen { display: none; }
table.jobs.hide-type       .col-type { display: none; }
table.jobs.hide-arr        .col-arr { display: none; }
table.jobs.hide-salary     .col-salary { display: none; }
table.jobs.hide-posted     .col-posted { display: none; }
table.jobs.hide-status     .col-status { display: none; }
table.jobs.hide-actions    .col-actions { display: none; }

/* KANBAN */
.kanban-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 14px;
}
@media (max-width: 1100px) { .kanban-grid { grid-template-columns: repeat(5, 240px); } }

.kanban-col {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: flex; flex-direction: column;
  min-height: 320px;
}
.kanban-col-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.kanban-col-body {
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  overflow-y: auto;
  max-height: 70vh;
}
.kanban-card {
  display: block;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 10px;
  text-decoration: none;
  color: var(--fg);
  transition: border-color var(--t-fast);
}
.kanban-card:hover { border-color: var(--fg); text-decoration: none; }
.kanban-card-row {
  display: flex; align-items: baseline; gap: 8px;
}
.kanban-card-title {
  font-size: 12px; font-weight: 500;
  display: block; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}
.kanban-card-meta { font-size: 10.5px; margin-top: 4px; }

/* SIMPLE CARD LIST (the new compact job card) */
.cardlist { display: flex; flex-direction: column; gap: 6px; }
.jobcard {
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: 14px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  transition: border-color var(--t-fast);
}
.jobcard:hover { border-color: var(--fg-mute); }
.jobcard .fit-cell { flex-direction: column; align-items: flex-start; gap: 3px; }
.jobcard .fit-bar { width: 56px; }
.jobcard .fit-num { font-size: 16px; }
.jobcard-title-row {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  margin-bottom: 2px;
}
.jobcard-title {
  font-weight: 600; color: var(--fg);
  text-decoration: none; font-size: 14px;
  line-height: 1.3;
}
.jobcard-title:hover { text-decoration: underline; text-underline-offset: 3px; }
.jobcard-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  color: var(--fg-mute); font-size: 11.5px;
  font-family: var(--font-mono);
}
.jobcard-meta strong { color: var(--fg-soft); font-weight: 500; }
.jobcard-actions { display: flex; gap: 4px; }

/* AI/Heuristic indicator badge */
.score-source {
  display: inline-flex; align-items: center;
  padding: 1px 5px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 600;
  border: 1px solid var(--line-hi); border-radius: 3px;
  color: var(--fg-mute);
  letter-spacing: 0.04em;
}
.score-source[data-src="ai"]    { color: var(--fg); border-color: var(--fg-soft); }
.score-source[data-src="heur"]  { color: var(--fg-mute); }

/* A11y */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* Utilities */
.mono { font-family: var(--font-mono); }
.mute { color: var(--fg-mute); }
.muted { color: var(--fg-mute); }
.right { text-align: right; }
.hidden { display: none !important; }
