:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #dfe4ea;
  --text: #1b2430;
  --muted: #64748b;
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --high: #15803d;
  --mid: #b45309;
  --low: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-top: 1.25rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1.5rem;
  background: #0f172a;
  color: #e2e8f0;
}

.brand { color: #ffffff; font-weight: 700; font-size: 1.05rem; }
.brand span { font-weight: 400; color: #94a3b8; }
.brand:hover { text-decoration: none; }

.nav { display: flex; align-items: center; gap: 1rem; }
.user { color: #94a3b8; font-size: 0.9rem; }

.link-button {
  background: none;
  border: 0;
  color: #cbd5e1;
  cursor: pointer;
  font: inherit;
  padding: 0;
}
.link-button:hover { color: #ffffff; text-decoration: underline; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.5rem;
}

.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.flash {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.page-head p { margin: 0; }

.muted { color: var(--muted); }
.block { display: block; font-size: 0.82rem; }
.nowrap { white-space: nowrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow);
}
.stat-value { display: block; font-size: 1.5rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: 0.82rem; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.filters label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }
.filters input, .filters select { min-width: 160px; }
.filter-actions { display: flex; gap: 0.5rem; }

input, select, button {
  font: inherit;
}
input, select {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  color: var(--text);
}
input:focus, select:focus {
  outline: 2px solid rgba(29, 78, 216, 0.35);
  outline-offset: 1px;
  border-color: var(--accent);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  padding: 0.5rem 0.9rem;
  font-weight: 600;
  white-space: nowrap;
}
.button:hover { background: #f8fafc; text-decoration: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #ffffff; }
.button.primary:hover { background: var(--accent-dark); }
.button.ghost { background: transparent; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}

.jobs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.jobs-table th,
.jobs-table td {
  padding: 0.7rem 0.75rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.jobs-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: #f8fafc;
  white-space: nowrap;
}
.jobs-table tbody tr:last-child td { border-bottom: 0; }
.jobs-table tbody tr:hover { background: #f8fafc; }

.title-cell { min-width: 240px; }
.title-cell a { font-weight: 600; }
.title-cell .company { display: block; color: var(--muted); font-size: 0.82rem; }

.score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 0.35rem;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.85rem;
  color: #ffffff;
}
.score.big { min-width: 56px; height: 56px; font-size: 1.2rem; }
.score-high { background: var(--high); }
.score-mid { background: var(--mid); }
.score-low { background: var(--low); }

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: #e2e8f0;
  color: #334155;
}
.rec-apply { background: #dcfce7; color: #166534; }
.rec-review { background: #fef3c7; color: #92400e; }
.rec-discard { background: #fee2e2; color: #991b1b; }
.status-new { background: #e0e7ff; color: #3730a3; }
.status-shortlisted { background: #dcfce7; color: #166534; }
.status-discarded { background: #e2e8f0; color: #475569; }
.status-prepared { background: #fef3c7; color: #92400e; }
.status-applied { background: #dbeafe; color: #1e40af; }
.status-interview { background: #f3e8ff; color: #6b21a8; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-offer { background: #ccfbf1; color: #115e59; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}
.pagination-links { display: flex; gap: 0.5rem; }

.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.back { display: inline-block; margin-bottom: 1rem; font-size: 0.9rem; }

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
}
.job-head h1 { margin-bottom: 0.35rem; }
.job-head p { margin: 0.2rem 0; }

.job-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 1rem;
  margin-bottom: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.score-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.75rem; }
.score-head h2 { margin: 0; }
.score-head p { margin: 0; }

.flags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.75rem 0; }
.flag {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 6px;
  padding: 0.15rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
}

.reasons { list-style: none; margin: 0.75rem 0 0; padding: 0; }
.reasons li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}
.reasons li:last-child { border-bottom: 0; }
.reasons strong { color: var(--high); white-space: nowrap; }

.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.stack label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.85rem; color: var(--muted); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 0.35rem 0; border-bottom: 1px dashed var(--border); font-size: 0.85rem; }
.timeline time { display: block; font-size: 0.78rem; }

.description p { margin: 0 0 0.6rem; }
.description { font-size: 0.92rem; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}
.login-card h1 { font-size: 1.35rem; }
.login-card > p { margin-top: 0; }
.alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .job-grid { grid-template-columns: 1fr; }
  .job-head { flex-direction: column; }
}

@media (max-width: 640px) {
  .container { padding: 1rem; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-head { flex-direction: column; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select { width: 100%; }
  .pagination { flex-direction: column; align-items: flex-start; }
  h1 { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
