/* ── Reset & base ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface2: #f0f1f4;
  --border: #e2e5eb;
  --border-strong: #cdd1da;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;

  --score-excellent-bg: #dcfce7;
  --score-excellent-text: #15803d;
  --score-strong-bg: #d1fae5;
  --score-strong-text: #065f46;
  --score-good-bg: #fef9c3;
  --score-good-text: #854d0e;
  --score-possible-bg: #ffedd5;
  --score-possible-text: #9a3412;
  --score-weak-bg: #fee2e2;
  --score-weak-text: #991b1b;
  --score-disq-bg: #f3f4f6;
  --score-disq-text: #9ca3af;

  --sidebar-width: 236px;
  --header-height: 64px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap;
}

.header-left h1 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  display: block;
  margin-top: 1px;
}

.stats-bar {
  display: flex;
  gap: 4px;
  align-items: center;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 16px;
  border-radius: 8px;
  background: var(--surface2);
  min-width: 64px;
}

.stat span {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.stat label {
  display: block;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 2px;
}

.stat.score-excellent { background: var(--score-excellent-bg); }
.stat.score-excellent span { color: var(--score-excellent-text); }
.stat.stat-pipe { background: #ede9fe; }
.stat.stat-pipe span { color: #5b21b6; }

/* Inputs in the filter sidebar */
.filters input[type="text"],
.filters input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface, #fff);
  color: var(--text, #111);
  box-sizing: border-box;
  margin-bottom: 4px;
}
.filters input[type="text"]:focus,
.filters input[type="number"]:focus {
  outline: none;
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99,102,241,0.15);
}
.stat.score-strong { background: var(--score-strong-bg); }
.stat.score-strong span { color: var(--score-strong-text); }
.stat.score-good { background: var(--score-good-bg); }
.stat.score-good span { color: var(--score-good-text); }

/* ── Layout ────────────────────────────────────────── */
.layout {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

/* ── Sidebar ───────────────────────────────────────── */
aside.filters {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

aside.filters h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-light);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

aside.filters label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 5px;
}

aside.filters select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 28px;
  cursor: pointer;
  transition: border-color 0.15s;
}

aside.filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.score-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-slider-wrap input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
  height: 4px;
  cursor: pointer;
}

.score-slider-wrap output {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  min-width: 36px;
  text-align: right;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.filter-toggle {
  padding-top: 2px;
}

.filter-toggle label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 0;
}

.filter-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* ── Buttons ───────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  flex: 1;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  flex: 1;
  transition: border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.btn-refresh {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s;
}

.btn-refresh:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Main table area ───────────────────────────────── */
main {
  flex: 1;
  padding: 20px 24px;
  overflow: auto;
  min-width: 0;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

#result-count {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
}

.table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

thead th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th:first-child { border-radius: 10px 0 0 0; }
thead th:last-child  { border-radius: 0 10px 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: #fafbfc; }

tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  font-size: 13px;
}

.loading {
  text-align: center;
  color: var(--text-muted);
  padding: 56px;
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}

.empty-state svg {
  display: block;
  margin: 0 auto 12px;
  opacity: 0.3;
}

.error-state {
  text-align: center;
  padding: 48px 24px;
  color: #b91c1c;
}

.error-state strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

/* ── Score badge ───────────────────────────────────── */
.score-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 14px;
}

.score-excellent { background: var(--score-excellent-bg); color: var(--score-excellent-text); }
.score-strong    { background: var(--score-strong-bg);    color: var(--score-strong-text); }
.score-good      { background: var(--score-good-bg);      color: var(--score-good-text); }
.score-possible  { background: var(--score-possible-bg);  color: var(--score-possible-text); }
.score-borderline { background: #fde68a; color: #78350f; }
.score-weak      { background: var(--score-weak-bg);      color: var(--score-weak-text); }
.score-disq      { background: var(--score-disq-bg);      color: var(--score-disq-text); font-size: 11px; font-weight: 700; }
.score-pending   { background: var(--surface2);           color: var(--text-light); font-size: 12px; }

/* ── Table column widths ───────────────────────────── */
.col-score  { width: 56px; }
.col-title  { min-width: 200px; }
.col-type   { width: 80px; }
.col-salary { width: 120px; white-space: nowrap; }
.col-resume { width: 150px; }
.col-date   { width: 80px; white-space: nowrap; }
.col-status { width: 160px; }
.col-notes  { min-width: 130px; }
.col-links  { width: 80px; }

/* ── Title cell ────────────────────────────────────── */
.job-title {
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  transition: color 0.1s;
}

.job-title:hover { color: var(--accent); }

.job-company { color: var(--text-muted); font-size: 12px; margin-top: 1px; }
.job-location { color: var(--text-light); font-size: 11px; margin-top: 1px; }

/* ── Salary ────────────────────────────────────────── */
.salary-text { font-weight: 600; color: var(--text); }
.salary-unavailable { color: var(--text-light); font-style: italic; font-size: 12px; }
.salary-flag { color: #d97706; font-size: 11px; margin-top: 2px; display: block; }

/* ── Work type badge ───────────────────────────────── */
.work-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
}

.work-remote { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.work-hybrid { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.work-onsite { background: #fdf2f8; color: #9d174d; border-color: #fbcfe8; }

/* ── Status dropdown ───────────────────────────────── */
.status-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.status-select:focus {
  outline: none;
  border-color: var(--accent);
}

.status-select.status-will-apply {
  border-color: #a5b4fc;
  color: var(--accent);
  background-color: #eef2ff;
  font-weight: 500;
}

.status-select.status-applied {
  border-color: #86efac;
  color: #15803d;
  background-color: #dcfce7;
  font-weight: 500;
}

.status-select.status-not-fit {
  color: var(--text-light);
}

/* ── Notes textarea ────────────────────────────────── */
.notes-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  padding: 5px 7px;
  border-radius: 6px;
  font-size: 12px;
  resize: none;
  min-height: 32px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color 0.15s, background 0.15s;
}

.notes-input:focus {
  outline: none;
  border-color: var(--border-strong);
  background: var(--surface2);
}

.notes-input::placeholder { color: var(--text-light); }

/* ── Links ─────────────────────────────────────────── */
.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  background: var(--accent-light);
  color: var(--accent);
  border: 1px solid #c7d2fe;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.link-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── Resume version label ──────────────────────────── */
.resume-label {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  display: inline-block;
  font-weight: 500;
}

/* ── Score reasoning ───────────────────────────────── */
.reasoning-text {
  font-size: 11px;
  color: var(--text-light);
  margin-top: 3px;
  line-height: 1.4;
}

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 780px;
  max-width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 32px;
  position: relative;
  box-shadow: 0 20px 48px rgba(0,0,0,0.12);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--text); }

.modal h2 { font-size: 19px; font-weight: 700; letter-spacing: -0.01em; margin-bottom: 4px; }
.modal .modal-company { color: var(--text-muted); font-size: 14px; margin-bottom: 18px; }
.modal-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 8px;
}
.modal-meta span { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.modal-description {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  max-height: 360px;
  overflow-y: auto;
  color: var(--text-muted);
  background: var(--bg);
}

/* ── Scrollbar ─────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
