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

:root {
  --bg: #09090b;
  --surface: #111113;
  --border: #27272a;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #22c55e;
  --yellow: #f59e0b;
  --red: #ef4444;
  --text: #fafafa;
  --text-muted: #71717a;
  --radius: 10px;
  --radius-sm: 6px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Header ===== */
header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
}
.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
}
.logo {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ===== Main ===== */
main { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* ===== Search ===== */
.search-section { margin-bottom: 28px; }

.search-bar {
  display: flex;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  transition: border-color .15s;
}
.search-bar:focus-within { border-color: var(--accent); }

.search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  padding: 6px 10px;
}
.search-bar input::placeholder { color: var(--text-muted); }

.search-bar button {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background .15s;
}
.search-bar button:hover { background: var(--accent-hover); }
.search-bar button:disabled { opacity: 0.5; cursor: not-allowed; }

.quick-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.tag-label { color: var(--text-muted); font-size: 0.78rem; }
.quick-tag {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 3px 12px;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.quick-tag:hover { border-color: var(--accent); color: var(--text); }

/* ===== Results ===== */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.sort-row { display: flex; align-items: center; gap: 8px; }
.sort-row select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
}

.job-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

/* ===== Job Card ===== */
.job-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.job-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.card-left { min-width: 0; }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-company {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.card-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.card-meta span { display: flex; align-items: center; gap: 4px; }

.card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.card-right { text-align: center; flex-shrink: 0; }

/* ===== Score Ring ===== */
.score-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  border: 2px solid var(--border);
  line-height: 1.1;
}
.score-ring small { font-size: 0.58rem; font-weight: 400; color: var(--text-muted); }
.score-high  { border-color: var(--green);  color: var(--green); }
.score-mid   { border-color: var(--yellow); color: var(--yellow); }
.score-low   { border-color: var(--red);    color: var(--red); }
.score-none  { border-color: var(--border); color: var(--text-muted); font-size: 0.85rem; }

.badge-source {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ===== Empty / loading ===== */
.empty-state {
  text-align: center;
  padding: 80px 0;
  color: var(--text-muted);
}
.empty-icon { font-size: 2.4rem; margin-bottom: 12px; }

.hidden { display: none !important; }

/* ===== Spinner ===== */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(8px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 740px;
  max-height: 88vh;
  overflow-y: auto;
  position: relative;
  padding: 28px;
}
.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  transition: color .15s;
}
.modal-close:hover { color: var(--text); }

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding-right: 30px;
}
.modal-header h2 { font-size: 1.4rem; font-weight: 600; margin-bottom: 5px; }
.m-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.m-company { color: var(--text-muted); font-weight: 500; }
.dot { color: var(--border); }
.m-salary { font-size: 0.85rem; color: var(--green); margin-top: 4px; }

.m-score-circle {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
  flex-shrink: 0;
  line-height: 1.1;
  transition: border-color 0.3s, color 0.3s;
}
.m-score-circle small { font-size: 0.6rem; font-weight: 400; color: var(--text-muted); }
.score-scoring {
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  animation: pulse-ring 1.4s ease-in-out infinite;
}
@keyframes pulse-ring {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ===== Tabs ===== */
.modal-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px 16px;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

/* ===== Overview tab ===== */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }

.description-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 0.87rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  max-height: 280px;
  overflow-y: auto;
  line-height: 1.7;
  margin-bottom: 16px;
}

.apply-btn {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  padding: 9px 22px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.88rem;
  transition: background .15s;
}
.apply-btn:hover { background: var(--accent-hover); }

/* ===== Match tab ===== */
.match-summary {
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 12px 16px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.7;
}
.skill-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.skill-heading {
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.skill-heading.matched { color: var(--green); }
.skill-heading.missing  { color: var(--yellow); }
.skill-list { list-style: none; display: flex; flex-direction: column; gap: 5px; }
.skill-list li {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ===== Cover Letter tab ===== */
.cover-hint {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-bottom: 14px;
}
.gen-cover-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 9px 22px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.gen-cover-btn:hover { background: var(--accent-hover); }

.cover-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  color: var(--text-muted);
}
.cover-loading .spinner { width: 26px; height: 26px; border-width: 2px; }

.cover-output textarea {
  width: 100%;
  height: 280px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 16px;
  font-size: 0.87rem;
  line-height: 1.7;
  resize: vertical;
  font-family: inherit;
  margin-bottom: 12px;
}
.cover-actions { display: flex; gap: 10px; }
.copy-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s;
}
.copy-btn:hover { background: var(--accent-hover); }
.regen-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.regen-btn:hover { border-color: var(--accent); color: var(--text); }

/* ===== CV Upload Bar ===== */
.cv-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 8px 24px;
}
.cv-bar-inner {
  max-width: 1100px;
  margin: 0 auto;
}
.cv-upload-area,
.cv-loaded-area {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cv-bar-label {
  color: var(--text-muted);
  font-size: 0.82rem;
  white-space: nowrap;
}
.cv-file-label {
  position: relative;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
  transition: border-color .15s;
}
.cv-file-label:hover { border-color: var(--accent); color: var(--text); }
.cv-file-label input[type="file"] { display: none; }
.cv-upload-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 5px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.cv-upload-btn:not(:disabled):hover { background: var(--accent-hover); }
.cv-upload-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.cv-hint { color: var(--text-muted); font-size: 0.78rem; }
.cv-status-ok { color: var(--green); font-size: 0.85rem; font-weight: 500; }
.cv-remove-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 3px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.cv-remove-btn:hover { border-color: var(--red); color: var(--red); }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

@media (max-width: 768px) {
  .job-list { grid-template-columns: 1fr; }
  .skill-columns { grid-template-columns: 1fr; }
  .modal { padding: 18px; }
  .header-inner { gap: 6px; }
  .job-card { grid-template-columns: 1fr; }
  .card-right { display: flex; justify-content: flex-start; }
}
