:root {
  --bg: #F5F6F3;
  --surface: #FFFFFF;
  --ink: #1B2320;
  --muted: #64726C;
  --primary: #2B5D4F;
  --primary-dark: #1E453A;
  --accent: #A6491E;
  --border: #DCE1DC;
  --status-ok: #3F7D5C;
  --status-ok-bg: #E7F1EB;
  --status-warn: #B9791F;
  --status-warn-bg: #FBF0DD;
  --status-bad: #A6491E;
  --status-bad-bg: #F6E7DE;
  --radius: 10px;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  min-height: 100vh;
}

button, input, select {
  font-family: inherit;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 18px;
  color: var(--surface);
  background: var(--primary);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.count-pill {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--primary-dark);
  background: var(--status-ok-bg);
  border: 1px solid var(--status-ok);
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.btn-refresh {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease;
}
.btn-refresh:hover { background: var(--primary-dark); }
.btn-refresh:focus-visible { outline: 2px solid var(--primary-dark); outline-offset: 2px; }
.refresh-icon { display: inline-block; }
.btn-refresh.spinning .refresh-icon { animation: spin 0.8s linear infinite; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Layout ---------- */

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- Filter panel ---------- */

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  align-items: end;
}

.filter-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filter-search { grid-column: span 1; }

.filter-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.filter-field input,
.filter-field select {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  min-width: 0;
  width: 100%;
}

.filter-field input:focus,
.filter-field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(43, 93, 79, 0.12);
}

.btn-clear {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}
.btn-clear:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- State banner ---------- */

.state-banner {
  background: var(--status-bad-bg);
  border: 1px solid var(--status-bad);
  color: var(--status-bad);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ---------- Card grid ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.candidate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.candidate-card:hover {
  box-shadow: 0 4px 16px rgba(27, 35, 32, 0.08);
  transform: translateY(-1px);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.sample-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
}
.status-dot.parsed { background: var(--status-ok); }
.status-dot.needs_review { background: var(--status-warn); }
.status-dot.empty_text, .status-dot.extraction_failed { background: var(--status-bad); }

.candidate-name {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.candidate-contact {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.vitals-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.vital-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 7px;
  color: var(--primary-dark);
  white-space: nowrap;
}
.vital-chip .vital-label {
  color: var(--muted);
  margin-right: 4px;
}

.candidate-course {
  font-size: 12.5px;
  color: var(--ink);
  background: var(--status-ok-bg);
  border-radius: 6px;
  padding: 4px 8px;
  display: inline-block;
  width: fit-content;
}

.candidate-source {
  font-size: 11px;
  color: var(--muted);
  margin-top: auto;
  padding-top: 6px;
}

/* ---------- Empty state ---------- */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-title { font-size: 15px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.empty-sub { font-size: 13px; }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .filter-panel { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 640px) {
  .topbar-inner { padding: 12px 14px; }
  .page { padding: 14px; }
  .filter-panel { grid-template-columns: repeat(2, 1fr); padding: 12px; }
  .filter-clear { grid-column: span 2; }
  .card-grid { grid-template-columns: 1fr; }
  .brand-text p { display: none; }
}

@media (max-width: 380px) {
  .filter-panel { grid-template-columns: 1fr; }
  .filter-clear { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  .candidate-card, .btn-refresh, .refresh-icon { transition: none; animation: none; }
}
