/* ────────────────────────────────────────────────────────
   KW Group Resume Screener — Design System
   ──────────────────────────────────────────────────────── */

:root {
  /* Sidebar / dark surface */
  --s-bg:          #0d1117;
  --s-surface:     #161b22;
  --s-hover:       #21262d;
  --s-border:      #30363d;
  --s-text:        #c9d1d9;
  --s-text-muted:  #8b949e;
  --s-accent:      #d4a017;
  --s-accent-dim:  rgba(212, 160, 23, 0.15);

  /* Main content / light surface */
  --m-bg:          #f0f2f5;
  --m-surface:     #ffffff;
  --m-surface2:    #f8f9fb;
  --m-border:      #e1e4e8;
  --m-text:        #1a1f2e;
  --m-text-muted:  #57606a;

  /* Semantic colours */
  --green:   #22c55e;
  --green-bg:#dcfce7;
  --yellow:  #f59e0b;
  --yellow-bg:#fef3c7;
  --orange:  #f97316;
  --orange-bg:#ffedd5;
  --red:     #ef4444;
  --red-bg:  #fee2e2;
  --blue:    #3b82f6;
  --blue-bg: #dbeafe;
  --purple:  #8b5cf6;
  --purple-bg:#ede9fe;

  --gold:    #d4a017;
  --gold-bg: rgba(212,160,23,.12);

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow:    0 4px 12px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.14);

  --sidebar-w: 240px;
  --transition: 0.15s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  /* Prevent any stray child from pushing the whole page sideways */
  overflow-x: hidden;
  max-width: 100vw;
}
body { display: flex; background: var(--m-bg); color: var(--m-text); }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, textarea, select { font-family: inherit; max-width: 100%; }

/* Global safety nets — anything that could otherwise leak out */
img, video, iframe { max-width: 100%; height: auto; }
pre, code { overflow-x: auto; word-wrap: break-word; max-width: 100%; }

/* Cards should never grow beyond their container */
.card { max-width: 100%; min-width: 0; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--s-bg);
  border-right: 1px solid var(--s-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--s-border);
}
.brand-logo {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  background: #ffffff;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }

.sidebar-credit {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--s-border);
  font-size: 11px;
  color: var(--s-text-muted);
  text-align: center;
  letter-spacing: 0.2px;
}
.sidebar-credit strong { color: var(--s-text); font-weight: 600; }

.failure-line {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  line-height: 1.4;
  font-size: 12.5px;
}
.failure-line .failure-file { font-weight: 500; }
.failure-line .failure-reason { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.failure-line .failure-dismiss { margin-left: auto; padding: 0 6px; font-size: 14px; line-height: 1; }

.auth-credit {
  margin-top: 14px;
  text-align: center;
  font-size: 11.5px;
  color: var(--s-text-muted, #888);
}
.auth-credit strong { color: var(--s-text, #222); font-weight: 600; }
.brand-name { display: block; color: var(--s-text); font-weight: 600; font-size: 13.5px; }
.brand-sub  { display: block; color: var(--s-text-muted); font-size: 11px; margin-top: 1px; }

.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--s-text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--s-hover); color: var(--s-text); }
.nav-item.active { background: var(--s-accent-dim); color: var(--s-accent); }

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--s-border);
}
.api-badge {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--s-text-muted);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--s-surface);
}
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--s-text-muted);
}
.api-ok .dot    { background: var(--green); }
.api-error .dot { background: var(--red); }

/* ── Main content ──────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  /* min-width: 0 is critical — without it, flex children default to
     min-width: auto (= content width), so a wide table inside will
     stretch the whole pane instead of letting .table-wrap scroll. */
  min-width: 0;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Same rule for direct children so card/page-body don't leak either */
.page-body,
.page-header { min-width: 0; }

/* ── Page header ───────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 28px 32px 20px;
  border-bottom: 1px solid var(--m-border);
  background: var(--m-surface);
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 20px; font-weight: 700; color: var(--m-text); }
.page-subtitle { font-size: 13px; color: var(--m-text-muted); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; align-items: center; }

/* ── Page body ─────────────────────────────────────────── */
.page-body { padding: 28px 32px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--m-border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Stats grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 0;
}
.stat-card {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card.clickable { cursor: pointer; }
.stat-card.clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,.06);
  border-color: var(--gold);
}
.stat-card.compact { padding: 14px 16px; }
.stat-card.compact .stat-value { font-size: 24px; }
.stat-card.compact .stat-value.small { font-size: 16px; line-height: 1.25; }
.stat-label { font-size: 11px; color: var(--m-text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 32px; font-weight: 700; margin-top: 6px; color: var(--m-text); }
.stat-value.accent { color: var(--gold); }
.stat-hint { font-size: 11px; color: var(--m-text-muted); margin-top: 6px; }

/* ── Dashboard two-column row ────────────────────────── */
.dash-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 20px;
}
.dash-card { min-height: 280px; }
.dash-card .card-header {
  display: flex; align-items: center; justify-content: space-between;
}

/* Verdict breakdown bars */
.verdict-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px 44px;
  gap: 10px; align-items: center;
  padding: 8px 0;
}
.verdict-bar-row + .verdict-bar-row { border-top: 1px solid var(--m-border); }
.verdict-bar-label { font-size: 12.5px; font-weight: 600; }
.verdict-bar-track {
  background: var(--m-surface2); height: 10px;
  border-radius: 5px; overflow: hidden;
  border: 1px solid var(--m-border);
}
.verdict-bar-fill { height: 100%; transition: width .3s ease; border-radius: 4px; }
.verdict-bar-count { font-size: 13px; font-weight: 700; text-align: right; }
.verdict-bar-pct   { font-size: 11.5px; color: var(--m-text-muted); text-align: right; }

/* Top candidates list */
.top-cand-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .12s;
}
.top-cand-row + .top-cand-row { border-top: 1px solid var(--m-border); }
.top-cand-row:hover { background: var(--m-surface2); }
.top-cand-rank {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold-bg); color: var(--gold);
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.top-cand-body { flex: 1; min-width: 0; }
.top-cand-name {
  font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.top-cand-sub {
  font-size: 11px; color: var(--m-text-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Recent activity feed */
.activity-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background .12s;
}
.activity-row + .activity-row { border-top: 1px solid var(--m-border); }
.activity-row:hover { background: var(--m-surface2); }
.activity-score {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
  border: 2px solid transparent;
}
.activity-score.score-high { background: var(--green-bg); color: var(--green); border-color: #86efac; }
.activity-score.score-mid  { background: rgba(212,160,23,.1); color: var(--gold); border-color: rgba(212,160,23,.4); }
.activity-score.score-low  { background: #fef3c7; color: #b45309; border-color: #fcd34d; }
.activity-score.score-bad  { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.activity-score.score-zero { background: var(--m-surface2); color: var(--m-text-muted); }
.activity-body { flex: 1; min-width: 0; }
.activity-name {
  font-weight: 600; font-size: 13px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-sub {
  font-size: 11px; color: var(--m-text-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.activity-sub span { margin-right: 4px; }

/* Role performance bars */
.role-perf-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px; align-items: center;
  padding: 10px 4px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.role-perf-row + .role-perf-row { border-top: 1px solid var(--m-border); }
.role-perf-row:hover { background: var(--m-surface2); }
.role-perf-name {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.role-perf-bar {
  height: 8px; background: var(--m-surface2);
  border-radius: 4px; overflow: hidden;
  border: 1px solid var(--m-border);
}
.role-perf-fill {
  height: 100%; background: linear-gradient(90deg, var(--gold) 0%, #b8860b 100%);
}
.role-perf-stats { display: flex; align-items: center; gap: 8px; }
.role-perf-count {
  font-size: 11px; color: var(--m-text-muted);
  background: var(--m-surface2); padding: 2px 8px;
  border-radius: 999px; font-weight: 600;
}
.role-perf-avg {
  font-size: 13px; font-weight: 700; min-width: 36px; text-align: right;
}
.role-perf-avg.score-high { color: var(--green); }
.role-perf-avg.score-mid  { color: var(--gold); }
.role-perf-avg.score-low  { color: #b45309; }
.role-perf-avg.score-bad  { color: var(--red); }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  border: none; transition: background var(--transition), transform .1s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--gold); color: #0d1117; }
.btn-primary:hover { background: #c49012; }
.btn-secondary { background: var(--m-surface2); color: var(--m-text); border: 1px solid var(--m-border); }
.btn-secondary:hover { background: #ebedf0; }
.btn-danger { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: var(--m-text-muted); }
.btn-ghost:hover { background: var(--m-surface2); color: var(--m-text); }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn svg { width: 15px; height: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--m-text); margin-bottom: 6px; }
.form-label .required { color: var(--red); margin-left: 2px; }
.form-hint { font-size: 11.5px; color: var(--m-text-muted); margin-top: 4px; }
.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--m-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--m-surface);
  color: var(--m-text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,160,23,.15);
}
textarea.form-control { resize: vertical; min-height: 100px; }
select.form-control { cursor: pointer; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row.three { grid-template-columns: 1fr 1fr 1fr; }

/* ── Tags input ─────────────────────────────────────────── */
.tags-container {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 7px;
  border: 1px solid var(--m-border);
  border-radius: var(--radius-sm);
  background: var(--m-surface);
  min-height: 40px;
  cursor: text;
}
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--blue-bg); color: var(--blue);
  border-radius: 4px; padding: 3px 8px;
  font-size: 12px; font-weight: 500;
}
.tag.red { background: var(--red-bg); color: var(--red); }
.tag.green { background: var(--green-bg); color: #16a34a; }
.tag-remove { cursor: pointer; opacity: .7; }
.tag-remove:hover { opacity: 1; }
.tags-input {
  border: none; outline: none; font-size: 13px;
  color: var(--m-text); background: transparent;
  flex: 1; min-width: 80px;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--m-border); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead { background: var(--m-surface2); }
th {
  padding: 11px 14px;
  text-align: left; font-weight: 600; font-size: 12px;
  color: var(--m-text-muted); text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
  cursor: pointer; user-select: none;
}
th:hover { color: var(--m-text); }
th.sort-active { color: var(--gold); }
td { padding: 12px 14px; border-top: 1px solid var(--m-border); vertical-align: middle; }
tr:hover td { background: var(--m-surface2); }
tr.expanded td { background: #fafbfc; }

/* Candidate detail row */
.detail-row td {
  background: #f5f7fa;
  padding: 0;
}
.detail-panel {
  padding: 20px 24px;
  border-top: 2px solid var(--gold);
}

/* ── Verdict badges ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-strong_yes { background: var(--green-bg); color: #16a34a; }
.badge-yes        { background: var(--blue-bg);  color: #1d4ed8; }
.badge-maybe      { background: var(--yellow-bg); color: #92400e; }
.badge-no         { background: var(--red-bg);   color: #b91c1c; }
.badge-error      { background: #f1f5f9; color: var(--m-text-muted); }

/* Score pill */
.score-pill {
  display: inline-block;
  width: 46px; text-align: center;
  padding: 3px 0; border-radius: 20px;
  font-size: 13px; font-weight: 700;
}
.score-high   { background: var(--green-bg); color: #16a34a; }
.score-mid    { background: var(--blue-bg);  color: #1d4ed8; }
.score-low    { background: var(--yellow-bg); color: #92400e; }
.score-bad    { background: var(--red-bg);   color: #b91c1c; }
.score-zero   { background: #f1f5f9; color: var(--m-text-muted); }

/* ── Drop zone ──────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--m-border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  transition: border-color var(--transition), background var(--transition);
  cursor: pointer;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--gold);
  background: var(--gold-bg);
}
.dropzone-icon { font-size: 36px; margin-bottom: 10px; }
.dropzone-text { font-size: 14px; color: var(--m-text-muted); }
.dropzone-text strong { color: var(--m-text); }
.dropzone-hint { font-size: 12px; color: var(--m-text-muted); margin-top: 5px; }

/* ── Progress ───────────────────────────────────────────── */
.progress-bar-wrap {
  background: var(--m-border);
  border-radius: 20px; height: 8px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f59e0b);
  border-radius: 20px;
  transition: width .3s ease;
}
.job-status-card {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.job-status-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.job-count { font-size: 13px; color: var(--m-text-muted); }

/* ── Scores detail grid ─────────────────────────────────── */
.scores-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.score-item {
  background: var(--m-surface2);
  border: 1px solid var(--m-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.score-dim-label { font-size: 11px; font-weight: 600; color: var(--m-text-muted); text-transform: uppercase; letter-spacing: .4px; }
.score-dim-values { display: flex; align-items: baseline; gap: 6px; margin-top: 4px; }
.score-dim-score { font-size: 22px; font-weight: 700; color: var(--m-text); }
.score-dim-weight { font-size: 11px; color: var(--m-text-muted); }
.mini-bar-wrap { height: 4px; background: var(--m-border); border-radius: 2px; margin-top: 4px; }
.mini-bar-fill { height: 100%; border-radius: 2px; background: var(--gold); }

/* Fingerprint badges */
.fingerprint-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.fp-badge {
  background: var(--purple-bg); color: var(--purple);
  border-radius: 4px; padding: 3px 9px; font-size: 12px; font-weight: 500;
}

/* Reasoning section */
.reasoning-section { margin-top: 16px; }
.reasoning-title { font-size: 12px; font-weight: 600; color: var(--m-text-muted); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.reasoning-list { list-style: none; padding: 0; }
.reasoning-list li { font-size: 13px; color: var(--m-text); padding: 3px 0; display: flex; gap: 8px; }
.reasoning-list li::before { content: "→"; color: var(--gold); flex-shrink: 0; }
.flag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.flag-badge { background: var(--orange-bg); color: var(--orange); border-radius: 4px; padding: 2px 8px; font-size: 11.5px; font-weight: 600; }

/* ── Modals ─────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-backdrop.hidden { display: none; }
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 201;
  background: var(--m-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: min(680px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--m-border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; background: var(--m-surface); z-index: 1;
}
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--m-text-muted); padding: 4px 8px; border-radius: 4px; }
.modal-close:hover { background: var(--m-surface2); color: var(--m-text); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--m-border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Toasts ─────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--s-surface);
  color: var(--s-text);
  border: 1px solid var(--s-border);
  border-radius: var(--radius);
  padding: 12px 18px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .2s ease;
  min-width: 250px; max-width: 400px;
}
.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-info    { border-left: 3px solid var(--blue); }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { opacity: 1; } to { opacity: 0; transform: translateX(30px); } }

/* ── Loaders ────────────────────────────────────────────── */
.spinner {
  border: 2px solid var(--m-border);
  border-top-color: var(--gold);
  border-radius: 50%;
  width: 20px; height: 20px;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}
.spinner.lg { width: 36px; height: 36px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loader-full {
  display: flex; align-items: center; justify-content: center;
  height: 60vh;
}

/* ── Empty states ───────────────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: 60px 24px; color: var(--m-text-muted); text-align: center;
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--m-text); margin-bottom: 6px; }
.empty-sub { font-size: 13.5px; }

/* ── Step stepper ───────────────────────────────────────── */
.stepper { display: flex; gap: 0; margin-bottom: 28px; }
.step {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  position: relative; font-size: 12px; color: var(--m-text-muted);
}
.step:not(:last-child)::after {
  content: '';
  position: absolute; top: 14px; left: 50%; width: 100%;
  height: 2px; background: var(--m-border); z-index: 0;
}
.step-num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--m-border); color: var(--m-text-muted);
  font-weight: 600; font-size: 12px;
  display: grid; place-items: center; z-index: 1;
  position: relative; margin-bottom: 5px;
}
.step.active .step-num { background: var(--gold); color: #0d1117; }
.step.done .step-num { background: var(--green); color: white; }
.step.active .step-label { color: var(--m-text); font-weight: 500; }
.step.done .step-label { color: var(--green); }

/* ── Misc helpers ───────────────────────────────────────── */
.text-muted { color: var(--m-text-muted); font-size: 12.5px; }
.text-sm { font-size: 12.5px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.hr { border: none; border-top: 1px solid var(--m-border); margin: 20px 0; }
.chip {
  display: inline-flex; align-items: center;
  background: var(--m-surface2); border: 1px solid var(--m-border);
  border-radius: 20px; padding: 2px 10px;
  font-size: 12px; color: var(--m-text-muted);
}
.section-title { font-size: 14px; font-weight: 600; color: var(--m-text); margin-bottom: 12px; }

/* ── Roles list ─────────────────────────────────────────── */
.role-card {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 16px;
  transition: box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
}
.role-card:hover { box-shadow: var(--shadow); border-color: #c9d1d9; }
.role-icon {
  width: 44px; height: 44px; border-radius: var(--radius-sm);
  background: var(--gold-bg);
  display: grid; place-items: center;
  font-size: 20px; flex-shrink: 0;
}
.role-info { flex: 1; min-width: 0; }
.role-name { font-weight: 600; font-size: 14.5px; color: var(--m-text); }
.role-meta { font-size: 12px; color: var(--m-text-muted); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.role-actions { display: flex; gap: 6px; }
.roles-grid { display: flex; flex-direction: column; gap: 10px; }

/* ── Settings ───────────────────────────────────────────── */
.settings-section { margin-bottom: 28px; }
.settings-label { font-size: 16px; font-weight: 600; margin-bottom: 14px; color: var(--m-text); }

/* ── Weights panel ──────────────────────────────────────── */
.weights-panel {
  background: var(--m-surface2);
  border: 1px solid var(--m-border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.weights-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px;
}
.weight-sum {
  font-size: 13px; font-weight: 700; padding: 4px 12px;
  border-radius: 20px;
}
.weight-sum.ok  { background: var(--green-bg); color: #16a34a; }
.weight-sum.bad { background: var(--red-bg);   color: var(--red); }

.weights-grid { display: flex; flex-direction: column; gap: 10px; }
.weight-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 12px;
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius-sm);
}
.weight-label { flex: 1; }
.weight-label strong { font-size: 13.5px; display: block; }
.weight-label .text-muted { margin-top: 2px; }
.weight-input-wrap { display: flex; align-items: center; gap: 6px; }
.weight-input { width: 72px; text-align: center; font-weight: 700; }
.weight-pct { font-size: 13px; color: var(--m-text-muted); }

/* Confirm grid */
.weights-confirm-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 10px;
}
.weight-confirm-item {
  background: var(--m-surface2); border: 1px solid var(--m-border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.wc-label { font-size: 12px; font-weight: 600; color: var(--m-text-muted); }
.wc-value { font-size: 22px; font-weight: 700; margin-top: 2px; color: var(--gold); }

/* ── Metric breakdown (detail panel) ───────────────────── */
.metrics-breakdown {
  display: flex; flex-direction: column; gap: 10px;
}
.metric-detail-row {
  background: var(--m-surface2);
  border: 1px solid var(--m-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.metric-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.metric-label { font-size: 13px; font-weight: 600; color: var(--m-text); }
.metric-right { display: flex; align-items: center; gap: 10px; }
.metric-score {
  display: inline-block; width: 38px; text-align: center;
  padding: 2px 0; border-radius: 6px;
  font-size: 16px; font-weight: 700;
  background: var(--m-surface); border: 1px solid var(--m-border);
}
.metric-weight { font-size: 12px; color: var(--m-text-muted); }
.metric-weight strong { color: var(--m-text); }
.metric-rationale {
  margin-top: 6px; font-size: 12.5px;
  color: var(--m-text-muted); line-height: 1.5;
  border-top: 1px solid var(--m-border); padding-top: 6px;
}

.calc-row {
  margin-top: 12px; padding: 10px 14px;
  background: var(--gold-bg); border-radius: var(--radius-sm);
  font-size: 12.5px; color: var(--m-text);
}

/* Metric chips in table */
.metrics-cell { white-space: nowrap; }
.m-chip {
  display: inline-block; width: 30px; text-align: center;
  padding: 1px 0; border-radius: 4px;
  font-size: 12px; font-weight: 700;
  background: var(--m-surface2); border: 1px solid var(--m-border);
  color: var(--m-text); margin-right: 2px;
}

/* JD preview in modal */
.jd-preview {
  white-space: pre-wrap; font-size: 12px;
  background: var(--m-surface2); padding: 12px;
  border-radius: var(--radius-sm); max-height: 280px;
  overflow-y: auto; line-height: 1.5;
}

/* ── Status chip (open / closed) ─────────────────────── */
.status-chip {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .2px;
  border: 1px solid transparent; margin-left: 8px;
}
.status-open   { background: var(--green-bg); color: var(--green); border-color: #86efac; }
.status-closed { background: var(--m-surface2); color: var(--m-text-muted); border-color: var(--m-border); }

/* btn-warning for the Close Role button */
.btn-warning {
  background: var(--gold-bg); color: var(--gold);
  border: 1px solid rgba(212,160,23,.35);
}
.btn-warning:hover { background: rgba(212,160,23,.22); }

/* ── JD drop-zone (New Role step 1) ──────────────────── */
.jd-dropzone {
  padding: 26px 20px; text-align: center;
  border: 2px dashed var(--m-border);
  border-radius: var(--radius);
  background: var(--m-surface2);
  cursor: pointer; transition: all .15s ease;
}
.jd-dropzone:hover,
.jd-dropzone.drag-over {
  border-color: var(--gold); background: var(--gold-bg);
}

/* Disabled dropzone — shown when Source field is empty */
.dropzone.dropzone-disabled {
  opacity: .55;
  cursor: not-allowed;
  border-style: dotted;
  background: var(--m-surface2);
}
.dropzone.dropzone-disabled:hover {
  border-color: var(--m-border);
  background: var(--m-surface2);
}
.or-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 18px 0 14px; color: var(--m-text-muted);
  font-size: 12px; text-transform: uppercase; letter-spacing: .5px;
}
.or-divider::before, .or-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--m-border);
}

/* ── Candidates Dashboard filter row + table ─────────── */
.filter-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
}
.filter-row .form-control { flex: 1 1 180px; min-width: 140px; }
.filter-row .form-control[type="number"] { flex: 0 0 120px; }

/* ── Candidates dashboard table — NO horizontal scroll ── */
/* Uses table-layout: fixed so columns respect percentages instead of
   blowing out to fit the widest cell. Contact info stacks inside the
   Candidate cell instead of taking three columns. */
.candidates-dash-table {
  table-layout: fixed;
  width: 100%;
  font-size: 13px;
}
.candidates-dash-table col.col-check     { width: 40px; }
.candidates-dash-table col.col-candidate { width: auto; }
.candidates-dash-table col.col-role      { width: 130px; }
.candidates-dash-table col.col-exp       { width: 50px; }
.candidates-dash-table col.col-date      { width: 100px; }
.candidates-dash-table col.col-uploader  { width: 130px; }
.candidates-dash-table col.col-score     { width: 78px; }
.candidates-dash-table col.col-verdict   { width: 100px; }
.candidates-dash-table col.col-metrics   { width: 130px; }

.candidates-dash-table th,
.candidates-dash-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
  padding: 10px 8px;   /* tighter than the default, so numbers fit */
}
.candidates-dash-table thead th {
  padding: 10px 8px;
  font-size: 11px;
  letter-spacing: .3px;
}
/* Score pill + verdict badge: make sure they don't get chopped by ellipsis */
.candidates-dash-table td.col-score,
.candidates-dash-table td.col-verdict,
.candidates-dash-table td.col-metrics {
  overflow: visible;
}
.candidates-dash-table td.col-score .score-pill,
.candidates-dash-table td.col-verdict .badge {
  display: inline-block; min-width: 0;
}
.candidates-dash-table .metrics-cell .m-chip {
  margin-right: 1px;
  width: 32px;
  padding: 2px 0;
}
/* The Candidate cell stacks name + sub + contact and is the only column
   allowed to wrap, so long emails don't blow out the layout. */
.candidates-dash-table td.col-candidate { white-space: normal; }
.candidates-dash-table .cand-name { font-weight: 600; font-size: 13.5px; }
.candidates-dash-table .cand-sub {
  font-size: 12px; color: var(--m-text-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.candidates-dash-table .cand-contact {
  font-size: 11.5px; margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.candidates-dash-table .cand-contact a { color: var(--gold); text-decoration: none; }
.candidates-dash-table .cand-contact a:hover { text-decoration: underline; }

.candidates-dash-table thead th.sortable { cursor: pointer; user-select: none; }

/* ── Role-detail candidates table ──────────────────────── */
.role-cand-table {
  table-layout: fixed;
  width: 100%;
  font-size: 13px;
}
.role-cand-table th,
.role-cand-table td {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
  padding: 10px 8px;
}
.role-cand-table td.hover-expand {
  max-width: 0;  /* forces text-overflow on fixed-layout cells */
}
.role-cand-table td:nth-child(2) { white-space: normal; } /* Candidate name wraps */
.role-cand-table td.metrics-cell { overflow: visible; }
.candidates-dash-table thead th.sortable:hover { background: var(--gold-bg); color: var(--gold); }
.candidates-dash-table td a.role-link,
.candidates-dash-table td.col-role a { color: var(--gold); text-decoration: none; }
.candidates-dash-table td a:hover { text-decoration: underline; }

/* Row-selection checkbox column */
.cd-row-checkbox {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--gold);
}
#cd-select-all { width: 16px; height: 16px; cursor: pointer; accent-color: var(--gold); }

/* The table-wrap gives every table horizontal scroll on narrow screens */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Expanded row styling for the candidate dashboard detail panel */
.candidates-dash-table tr.candidate-row { cursor: pointer; }
.candidates-dash-table tr.candidate-row:hover { background: var(--m-surface2); }
.candidates-dash-table tr.candidate-row.expanded { background: var(--gold-bg); }
.candidates-dash-table tr.detail-row td {
  padding: 0; background: var(--m-surface2); border-top: none;
}

/* Locked weights-panel visual hint */
.weights-panel.locked {
  background: var(--gold-bg);
  border: 1px dashed rgba(212,160,23,.4);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 14px 0;
}
.weights-panel.locked .weights-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}

/* ── Print styles ─────────────────────────────────────── */
@media print {
  .sidebar, .header-actions, #toast-container, #modal-backdrop, #modal-container { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-header   { border: none; padding: 12px 0; }
  .page-body     { padding: 0; }
  table { font-size: 10px; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ── Responsive ─────────────────────────────────────────── */
/* ══════════════════════════════════════════════════════════
   RESPONSIVE — design targets every viewport from 320px to 4K.
   Nothing overflows, nothing gets cut off, no card "leaks".
   ══════════════════════════════════════════════════════════ */

/* Very wide screens — cap stat grid density */
@media (min-width: 1440px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Tablets / small laptops — collapse the 2-col dashboard layout */
@media (max-width: 1100px) {
  .dash-row { grid-template-columns: 1fr; }
  .form-row.three { grid-template-columns: 1fr 1fr; }
}

/* ════════════════════════════════════════════════════════
   RESPONSIVE — every breakpoint from wide desktop to 320px
   ════════════════════════════════════════════════════════ */

/* ── Wide desktop cap (> 1400px keeps things readable) ── */
@media (min-width: 1400px) {
  .page-body { max-width: 1320px; }
}

/* ── 1280px — dashboard two-col stacks, grids breathe ── */
@media (max-width: 1280px) {
  .dash-row { grid-template-columns: 1fr; }
  .dash-card { min-height: 0; }
}

/* ── 1024px — header stacks, action buttons wrap ──────── */
@media (max-width: 1024px) {
  .page-header {
    flex-direction: column; align-items: flex-start; gap: 12px;
  }
  .page-header .header-actions { flex-wrap: wrap; width: 100%; }
  .header-actions .btn,
  .header-actions a.btn { font-size: 12px; padding: 6px 10px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

  /* Role-detail table: allow horizontal scroll */
  .role-cand-table { min-width: 750px; }
}

/* ── 768px — tablet: sidebar icon-only, tables adapt ──── */
@media (max-width: 768px) {
  /* Sidebar collapses to icon-only */
  .sidebar { width: 60px; }
  .sidebar-brand { padding: 16px 11px; }
  .brand-text, .sidebar-footer { display: none; }
  .nav-item { padding: 9px; justify-content: center; }
  .nav-item span,
  .sidebar-credit { display: none; }
  .main-content { margin-left: 60px; }

  /* Page chrome shrinks */
  .page-header { padding: 16px 14px; }
  .page-body   { padding: 16px 14px; }
  .page-title  { font-size: 18px; }
  .page-subtitle { font-size: 12px; }

  /* Action buttons fill width */
  .header-actions { width: 100%; flex-wrap: wrap; }
  .header-actions .btn,
  .header-actions a.btn { flex: 1 1 auto; justify-content: center; text-align: center; }
  .header-actions select.form-control { flex: 1 1 100%; }

  /* Forms single-column */
  .form-row, .form-row.three { grid-template-columns: 1fr; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row .form-control { flex: 1; max-width: none; }

  /* Roles grid single-column */
  .roles-grid { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 26px; }
  .weights-confirm-grid { grid-template-columns: 1fr 1fr; }

  /* Role-detail table scrolls horizontally */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .role-cand-table { min-width: 750px; }

  /* Candidates dashboard: hide less-essential columns */
  .candidates-dash-table col.col-exp,
  .candidates-dash-table col.col-uploader { width: 0; }
  .candidates-dash-table th:nth-child(4),
  .candidates-dash-table td:nth-child(4),
  .candidates-dash-table th:nth-child(6),
  .candidates-dash-table td:nth-child(6) { display: none; }

  /* Verdict bar — narrower label */
  .verdict-bar-row {
    grid-template-columns: 90px 1fr 32px 38px;
    gap: 8px;
  }
  .role-perf-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 6px 10px;
  }
  .role-perf-bar { grid-column: 1 / -1; }

  /* Modals viewport-fit */
  .modal {
    max-width: 95vw !important;
    max-height: 90vh;
    margin: 20px;
  }
}

/* ── 480px — phone: single-column everything ──────────── */
@media (max-width: 480px) {
  .sidebar { width: 54px; }
  .main-content { margin-left: 54px; }
  .brand-logo { width: 32px; height: 32px; }

  .page-header { padding: 14px 12px; }
  .page-body   { padding: 14px 12px; }
  .page-title { font-size: 17px; }

  .stats-grid { grid-template-columns: 1fr !important; }
  .stat-value { font-size: 22px; }
  .stat-card.compact .stat-value { font-size: 20px; }
  .weights-confirm-grid { grid-template-columns: 1fr; }

  .top-cand-row .badge { display: none; }
  .activity-score { width: 32px; height: 32px; font-size: 11px; }

  .verdict-bar-row {
    grid-template-columns: 78px 1fr 36px;
  }
  .verdict-bar-pct { display: none; }
  .role-card .role-icon { display: none; }

  /* Candidates dashboard: hide metrics column too */
  .candidates-dash-table col.col-metrics { width: 0; }
  .candidates-dash-table th:nth-child(9),
  .candidates-dash-table td:nth-child(9) { display: none; }
}

/* ── 360px — ultra-small ──────────────────────────────── */
@media (max-width: 360px) {
  .sidebar { width: 48px; }
  .main-content { margin-left: 48px; }
  .sidebar-brand { padding: 12px 8px; }
  .page-header, .page-body { padding: 12px 10px; }
  .btn { padding: 7px 12px; font-size: 12.5px; }
  .page-title { font-size: 15px; }
  .candidates-dash-table { font-size: 11px; }
}

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE
   ══════════════════════════════════════════════════════════ */
body.auth-body {
  display: block;
  background: linear-gradient(135deg, #f7f9fc 0%, #e9ecf2 100%);
  min-height: 100vh;
}
.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .08);
  padding: 40px 36px 32px;
  width: 100%;
  max-width: 420px;
}
.auth-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 28px;
}
.auth-brand .brand-logo {
  width: 44px; height: 44px;
  background: linear-gradient(135deg, var(--gold), #b8860b);
  border-radius: var(--radius-sm);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
}
.auth-brand .brand-text .brand-name {
  font-size: 15px; font-weight: 600; color: var(--m-text);
}
.auth-brand .brand-text .brand-sub {
  font-size: 11.5px; color: var(--m-text-muted); margin-top: 2px;
}
.auth-title {
  font-size: 22px; font-weight: 700; color: var(--m-text);
  margin-bottom: 4px;
}
.auth-subtitle {
  font-size: 13px; color: var(--m-text-muted);
  margin-bottom: 24px;
}
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .form-control { padding: 11px 14px; font-size: 14px; }
.auth-submit {
  width: 100%; justify-content: center;
  padding: 12px 18px; font-size: 14px;
  margin-top: 8px;
}
.auth-error {
  padding: 10px 12px;
  background: var(--red-bg); color: var(--red);
  border-radius: var(--radius-sm);
  font-size: 12.5px; margin-bottom: 12px;
  border-left: 3px solid var(--red);
}
.auth-footer {
  margin-top: 20px; padding-top: 18px;
  border-top: 1px solid var(--m-border);
  font-size: 11.5px; color: var(--m-text-muted);
  text-align: center; line-height: 1.6;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR USER CHIP  (logged-in user display)
   ══════════════════════════════════════════════════════════ */
.sidebar-user {
  margin: 8px 14px 0;
  padding: 12px 14px;
  background: var(--s-surface);
  border: 1px solid var(--s-border);
  border-radius: var(--radius-sm);
}
.sidebar-user-name {
  font-size: 12.5px; font-weight: 600; color: var(--s-text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 10.5px; color: var(--s-text-muted);
  text-transform: uppercase; letter-spacing: .5px;
  margin-top: 2px;
}
.sidebar-user-role.admin { color: var(--gold); font-weight: 600; }
.sidebar-logout {
  margin-top: 8px; width: 100%;
  background: transparent;
  border: 1px solid var(--s-border);
  color: var(--s-text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  font-size: 11.5px; cursor: pointer;
  transition: background .12s;
}
.sidebar-logout:hover {
  background: var(--s-hover); color: var(--s-text);
}

/* ══════════════════════════════════════════════════════════
   ADMIN PAGE
   ══════════════════════════════════════════════════════════ */
.admin-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--m-border);
  margin-bottom: 20px;
}
.admin-tab {
  padding: 10px 16px;
  background: transparent; border: none;
  border-bottom: 2px solid transparent;
  font-size: 13px; font-weight: 500;
  color: var(--m-text-muted);
  cursor: pointer;
  transition: all .15s;
}
.admin-tab:hover { color: var(--m-text); }
.admin-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
  font-weight: 600;
}

.user-row-admin { color: var(--gold); font-weight: 600; }
.user-row-inactive { opacity: .5; }

.activity-action-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px; font-weight: 600;
  background: var(--m-surface2);
  color: var(--m-text);
  border: 1px solid var(--m-border);
}
.activity-action-badge.login         { background: #e0e7ff; color: #4338ca; border-color: #c7d2fe; }
.activity-action-badge.login_failed  { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.activity-action-badge.logout        { background: var(--m-surface2); color: var(--m-text-muted); }
.activity-action-badge.create_role,
.activity-action-badge.update_role,
.activity-action-badge.role_open,
.activity-action-badge.role_closed   { background: var(--gold-bg); color: var(--gold); border-color: rgba(212,160,23,.35); }
.activity-action-badge.upload_cvs    { background: var(--green-bg); color: var(--green); border-color: #86efac; }
.activity-action-badge.delete_candidate,
.activity-action-badge.clear_candidates,
.activity-action-badge.delete_role,
.activity-action-badge.deactivate_user { background: var(--red-bg); color: var(--red); border-color: #fca5a5; }
.activity-action-badge.create_user,
.activity-action-badge.update_user   { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }

/* User stats — card grid (admin → User Stats tab) */
.user-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.user-stat-card {
  background: var(--m-surface);
  border: 1px solid var(--m-border);
  border-radius: var(--radius);
  padding: 18px 20px 14px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.user-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0,0,0,.08);
  border-color: var(--gold);
}
.usc-header { margin-bottom: 14px; }
.usc-name-line {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.usc-name {
  font-size: 14.5px; color: var(--m-text);
  max-width: 220px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.usc-email {
  font-size: 11.5px; color: var(--m-text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.usc-section-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--m-text-muted);
  margin: 10px 0 6px;
  border-top: 1px dashed var(--m-border);
  padding-top: 8px;
}
.usc-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}
.usc-row + .usc-row { margin-top: 0; }
.usc-row.four { grid-template-columns: repeat(4, 1fr); }
.usc-stat {
  text-align: center;
  padding: 8px 4px;
  background: var(--m-surface2);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.usc-label {
  font-size: 10px; color: var(--m-text-muted);
  text-transform: uppercase; letter-spacing: .3px;
  margin-bottom: 3px;
}
.usc-val {
  font-size: 16px; font-weight: 700; color: var(--m-text);
}
.usc-val.accent { color: var(--gold); }
.usc-footer {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--m-border);
  font-size: 11px;
  color: var(--m-text);
}
.usc-footer .usc-label { margin-bottom: 2px; }
.usc-click-hint {
  margin-top: 8px;
  padding-top: 8px;
  text-align: center;
  font-size: 10.5px;
  color: var(--m-text-muted);
  border-top: 1px solid var(--m-border);
}
.usc-row .usc-stat:empty { background: transparent; }

@media (max-width: 640px) {
  .user-stats-grid { grid-template-columns: 1fr; }
  .usc-row { grid-template-columns: repeat(3, 1fr); }
}

/* ── User-stats table view (scales to many HR users) ─────────── */
.orphan-banner {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; margin-bottom: 12px;
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.orphan-banner:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.orphan-banner-icon  { font-size: 20px; color: var(--red); }
.orphan-banner-body  { flex: 1; }
.orphan-banner-title { font-weight: 700; color: var(--red); font-size: 13px; }
.orphan-banner-sub   { color: var(--m-text); font-size: 12px; margin-top: 2px; }

.leaderboard {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--gold-bg);
  border: 1px solid rgba(212,160,23,.35);
  border-radius: var(--radius);
  flex-wrap: wrap;
}
.leaderboard-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--gold);
}
.leaderboard-list { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.leaderboard-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  background: var(--m-surface); border: 1px solid var(--m-border);
  border-radius: 999px; font-size: 12px;
  cursor: pointer; transition: border-color .15s ease, transform .15s ease;
}
.leaderboard-item:hover { border-color: var(--gold); transform: translateY(-1px); }
.leaderboard-rank  { font-weight: 700; color: var(--gold); }
.leaderboard-name  { color: var(--m-text); font-weight: 600; }
.leaderboard-metric{ color: var(--m-text-muted); }

.stats-toolbar {
  display: grid;
  grid-template-columns: 1fr 180px 180px auto;
  gap: 10px; align-items: center;
  margin-bottom: 12px;
}
.stats-result-count {
  font-size: 12px; color: var(--m-text-muted);
  text-align: right; white-space: nowrap;
}

.stats-table-wrap { max-height: calc(100vh - 280px); overflow: auto; }
.stats-table { width: 100%; }
.stats-table thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--m-surface2);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--m-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--m-border);
  white-space: nowrap;
}
.stats-table th.num, .stats-table td.num { text-align: right; }
.stats-table th.sortable { cursor: pointer; user-select: none; }
.stats-table th.sortable:hover { color: var(--m-text); }
.stats-table .sort-arrow { font-size: 9px; margin-left: 2px; color: var(--gold); }

.stats-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--m-border);
  font-size: 13px;
}
.stats-table tbody tr { cursor: pointer; transition: background .12s ease; }
.stats-table tbody tr:hover { background: var(--gold-bg); }
.stats-table tbody tr.is-deleted { opacity: .55; }
.stats-table tbody tr.is-disabled { opacity: .75; }
.stats-table tbody tr.is-disabled td:first-child { border-left: 2px solid var(--m-text-muted); }
.stats-table tbody tr.is-deleted td:first-child  { border-left: 2px solid var(--red); }

.stats-table .col-user { min-width: 220px; }
.stats-user-line {
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stats-user-line strong {
  max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.stats-table .row-actions button { padding: 4px 10px; }

.val-accent       { color: var(--gold); font-weight: 700; }
.val-destructive  { color: var(--red);  font-weight: 700; }
.fail-chip {
  display: inline-block; margin-left: 6px;
  padding: 1px 6px; border-radius: 999px;
  background: var(--red-bg); color: var(--red);
  font-size: 11px; font-weight: 600;
}

/* Status dots in row / leaderboard */
.dot-green { color: var(--green); }
.dot-red   { color: var(--red);   }
.dot-muted { color: var(--m-text-muted); }

/* Chips reused outside user list */
.chip-gold  { background: var(--gold-bg); color: var(--gold); border-color: rgba(212,160,23,.35); }
.chip-red   { color: var(--red); border-color: #fca5a5; background: var(--red-bg); }
.chip-muted { color: var(--m-text-muted); background: var(--m-surface2); border-color: var(--m-border); }

/* "Uploaded by" cell on the Candidates dashboard */
.uploader-chip {
  display: inline-block;
  max-width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--m-surface2);
  border: 1px solid var(--m-border);
  color: var(--m-text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: help;
}

/* Drive-folder CTA — distinct "Google blue" tint so HR spots it instantly */
.btn-drive {
  background: #e8f0fe;
  color: #1967d2;
  border: 1px solid #a4c2f4;
  text-decoration: none;
}
.btn-drive:hover { background: #d2e3fc; border-color: #1967d2; }

/* Recency colouring for the "Last active" cell */
.recency-hot   { color: var(--green); font-weight: 600; }
.recency-warm  { color: var(--blue);  font-weight: 600; }
.recency-cool  { color: var(--m-text); }
.recency-stale { color: var(--red);   font-weight: 600; }
.recency-never { color: var(--m-text-muted); font-style: italic; }

@media (max-width: 900px) {
  .stats-toolbar { grid-template-columns: 1fr 1fr; }
  .stats-result-count { grid-column: 1 / -1; text-align: left; }
}

/* Truncated table cells that reveal full content on hover */
.hover-expand {
  position: relative;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: help;
}
.hover-expand:hover::after {
  content: attr(title);
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 100;
  max-width: 520px;
  min-width: 240px;
  white-space: pre-wrap;
  word-break: break-word;
  background: #1f2937;
  color: #f9fafb;
  padding: 8px 12px;
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0,0,0,.25);
  font-size: 12px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  line-height: 1.45;
  pointer-events: none;
}
.note-cell { cursor: help; }
