:root {
  --ibew-red: #c8102e;
  --ibew-red-dark: #a00d24;
  --ibew-red-soft: #fbe6ea;
  --ink: #111418;
  --ink-2: #2f3540;
  --muted: #6b7280;
  --muted-2: #9aa0a8;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e5e7eb;
  --border-strong: #cbd1d9;
  --row-hover: #fafbfc;
  --row-selected: #fff5f6;
  --good: #15803d;
  --good-bg: #e7f4ec;
  --warn: #b45309;
  --warn-bg: #fff3e0;
  --info: #1d4ed8;
  --info-bg: #eaf1ff;
  --neutral-bg: #eef0f3;
  --radius: 8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.04);
  --shadow:    0 2px 6px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.45;
}

/* === Navbar === */
.nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(15,23,42,0.02);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 50;
}
.nav::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px;
  background: linear-gradient(90deg, var(--ibew-red) 0%, var(--ibew-red-dark) 100%);
}
.nav .brand { display: flex; align-items: center; gap: 12px; font-weight: 700; color: var(--ink); }
.nav .brand .mark {
  width: 38px; height: 38px; border-radius: 50%;
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.nav .brand .mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.nav .brand .title { font-size: 15px; font-weight: 700; }
.nav .brand .sub { color: var(--muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; display: block; margin-top: 1px; }
.nav .brand .text { display: flex; flex-direction: column; line-height: 1.15; }
.nav .spacer { flex: 1; }
.nav .me { color: var(--muted); font-size: 13px; }
.nav .me-local {
  background: rgba(200, 16, 46, 0.08); color: var(--ibew-red);
  border: 1px solid rgba(200, 16, 46, 0.18);
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
}
.nav .nav-btn {
  background: transparent; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 7px 12px; font-size: 13px;
  cursor: pointer; color: var(--ink); font-weight: 500;
  transition: background .12s, border-color .12s;
}
.nav .nav-btn:hover { background: #f3f4f6; border-color: var(--border-strong); }

/* === Container === */
.container { max-width: 1200px; margin: 0 auto; padding: 12px 24px 24px; }

/* === Sign-in === */
.signin-shell {
  display: flex; justify-content: center;
  padding: 40px 0 24px;
}
.signin-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 22px 24px 18px; width: 380px; max-width: 100%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.signin-card h1 { margin: 0 0 6px; font-size: 20px; font-weight: 700; }
.signin-card .lede { color: var(--muted); margin: 0 0 18px; font-size: 13px; line-height: 1.5; }
.signin-success-mark {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--good-bg); color: var(--good);
  display: flex; align-items: center; justify-content: center;
  margin: 0 0 14px;
}
.signin-steps {
  list-style: none; padding: 0; margin: 14px 0 0;
  display: flex; flex-direction: column; gap: 10px;
}
.signin-steps li {
  display: flex; gap: 12px; align-items: flex-start;
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
}
.signin-steps .num {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%;
  background: var(--ibew-red-soft); color: var(--ibew-red);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; line-height: 1;
}
.signin-steps strong { color: var(--ink); font-weight: 600; }
.signin-steps em { color: var(--muted); font-style: normal; }
.signin-card label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; }
.signin-card input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border-strong);
  border-radius: 6px; font-size: 14px;
}
.signin-card input:focus { outline: 2px solid var(--ibew-red); outline-offset: 0; border-color: var(--ibew-red); }
.signin-card .msg { margin-top: 10px; font-size: 13px; color: var(--muted); min-height: 1.2em; }

/* === Toolbar === */
.toolbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .search {
  flex: 1 1 280px; padding: 9px 14px 9px 36px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); font-size: 14px; background: #fff;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.5' y2='16.5'/></svg>");
  background-repeat: no-repeat; background-position: 12px center;
  transition: border-color .12s, box-shadow .12s;
}
.toolbar .search:focus { outline: none; border-color: var(--ibew-red); box-shadow: 0 0 0 3px rgba(200,16,46,0.12); }
.toolbar select, .toolbar .file-btn {
  padding: 8px 12px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: #fff; font-size: 13px; cursor: pointer;
  color: var(--ink-2); transition: border-color .12s, background .12s;
}
.toolbar select:hover, .toolbar .file-btn:hover { border-color: var(--ibew-red); }
.toolbar .right { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar .toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); cursor: pointer;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; transition: border-color .12s, color .12s;
}
.toolbar .toggle:hover { border-color: var(--border-strong); color: var(--ink-2); }
.toolbar .toggle input { margin: 0; accent-color: var(--ibew-red); }

/* === Stats === */
.stats {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px;
  margin-bottom: 14px;
}
@media (min-width: 900px) {
  .stats { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
}
.stats-band {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px 12px; box-shadow: var(--shadow-sm);
}
.stats-band .label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 700; margin-bottom: 8px;
}
.stats-row { display: flex; gap: 4px; flex-wrap: wrap; }
.stat {
  flex: 1 1 0; min-width: 80px;
  padding: 6px 10px;
  border-left: 3px solid transparent;
  background: transparent;
  display: flex; flex-direction: column; gap: 1px;
}
.stat .n { font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1.1; letter-spacing: -0.01em; }
.stat .l { color: var(--muted); font-size: 11px; font-weight: 500; }
.stats-band.funnel .stat { border-left-color: var(--border); }
.stats-band.funnel .stat.is-total      { border-left-color: var(--ink-2); }
.stats-band.funnel .stat.is-invited    { border-left-color: var(--info); }
.stats-band.funnel .stat.is-opened     { border-left-color: var(--warn); }
.stats-band.funnel .stat.is-completed  { border-left-color: var(--good); }
.stats-band.funnel .stat.is-followup   { border-left-color: var(--ibew-red); }
.stats-band.buckets .stat.is-journey         { border-left-color: var(--info); }
.stats-band.buckets .stat.is-accelerated     { border-left-color: var(--warn); }
.stats-band.buckets .stat.is-new_apprentice  { border-left-color: var(--ibew-red); }
.stats-band.buckets .stat.is-already_ibew    { border-left-color: var(--good); }
.stats-band.buckets .stat.is-not_interested  { border-left-color: var(--muted-2); }

/* === Table === */
.table-wrap {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm);
}
table.candidates {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
table.candidates thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); font-weight: 700;
  background: #fafbfc; border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}
table.candidates tbody td {
  padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle;
}
table.candidates tbody tr:last-child td { border-bottom: 0; }
table.candidates tbody tr.archived { opacity: 0.55; }
table.candidates tbody tr.archived .name-text::after {
  content: " · archived"; font-size: 11px; color: var(--muted); font-weight: 500;
}
table.candidates tbody tr { cursor: pointer; transition: background .12s; position: relative; }
table.candidates tbody tr:hover { background: var(--row-hover); }
table.candidates tbody tr.selected { background: var(--row-selected); }
table.candidates tbody tr.selected td:first-child {
  box-shadow: inset 3px 0 0 var(--ibew-red);
}
table.candidates .name-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
table.candidates .avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; letter-spacing: 0.02em;
  background: var(--ibew-red-soft); color: var(--ibew-red);
  text-transform: uppercase;
}
table.candidates .avatar.src-WPA { background: var(--info-bg); color: var(--info); }
table.candidates .name-meta { min-width: 0; }
table.candidates .name-text { font-weight: 600; color: var(--ink); }
table.candidates .name-sub { color: var(--muted); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Addressed-state mini-line — hidden on desktop; surfaces on mobile in place of email/phone */
table.candidates .name-sub-status { display: none; }
table.candidates .chev { color: var(--muted-2); width: 18px; text-align: right; font-size: 16px; }
table.candidates .src-pill { font-size: 10px; padding: 2px 8px; border-radius: 999px; font-weight: 700;
  background: var(--neutral-bg); color: #555; letter-spacing: 0.04em; }
table.candidates .src-pill.WPA { background: var(--info-bg); color: var(--info); }

.empty-row { padding: 36px 28px; text-align: center; color: var(--muted); }

/* === Status pills === */
.status-pill {
  font-size: 12px; padding: 3px 10px 3px 8px; border-radius: 999px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.5;
}
.status-pill::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: currentColor;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.6);
}
.status-pill.not_sent  { background: var(--neutral-bg); color: #6b7280; }
.status-pill.sent      { background: var(--info-bg); color: var(--info); }
.status-pill.opened    { background: var(--warn-bg); color: var(--warn); }
.status-pill.completed { background: var(--good-bg); color: var(--good); }

.bucket-pill {
  font-size: 12px; padding: 3px 8px; border-radius: var(--radius-sm); font-weight: 600;
  display: inline-block; line-height: 1.45;
}
.bucket-pill.new_apprentice  { background: var(--ibew-red-soft); color: var(--ibew-red); }
.bucket-pill.accelerated     { background: var(--warn-bg);      color: var(--warn); }
.bucket-pill.journey         { background: var(--info-bg);      color: var(--info); }
.bucket-pill.already_ibew    { background: var(--good-bg);      color: var(--good); }
.bucket-pill.not_interested  { background: var(--neutral-bg);   color: #555; }

/* === Side panel === */
.panel-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,0.32);
  opacity: 0; pointer-events: none; transition: opacity .18s; z-index: 60;
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
}
.panel-backdrop.open { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; right: 0; height: 100vh; width: 480px; max-width: 100%;
  background: var(--bg); border-left: 1px solid var(--border);
  transform: translateX(100%); transition: transform .22s cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 70; display: flex; flex-direction: column;
  box-shadow: -8px 0 24px rgba(15,23,42,0.10);
}
.panel.open { transform: translateX(0); }
.panel header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  background: #fff;
}
.panel header .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--ibew-red-soft); color: var(--ibew-red);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.panel header h2 { margin: 0; font-size: 17px; font-weight: 700; line-height: 1.2; }
.panel header .close {
  margin-left: auto; background: transparent; border: 0;
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .12s, color .12s;
}
.panel header .close:hover { background: var(--neutral-bg); color: var(--ink); }
.panel .body { padding: 14px 16px 24px; overflow-y: auto; flex: 1; }
.panel-section {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.panel-section h3 {
  margin: 0 0 10px; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--muted); font-weight: 700;
}
.panel-section .muted-text { font-size: 12px; color: var(--muted); }
.panel .field { display: grid; grid-template-columns: 100px 1fr; gap: 6px 12px; font-size: 13px; }
.panel .field > div:nth-child(odd) { color: var(--muted); }
.panel .field > div:nth-child(even) { word-break: break-word; color: var(--ink-2); }
.panel .field a { color: var(--info); text-decoration: none; }
.panel .field a:hover { text-decoration: underline; }
.followup-banner {
  margin-top: 10px; padding: 10px 12px;
  background: var(--good-bg); border: 1px solid #cfe6d6; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--good);
}

/* === Buttons === */
.btn {
  background: var(--ibew-red); color: #fff; border: 1px solid var(--ibew-red);
  padding: 8px 14px; border-radius: var(--radius-sm); font-weight: 600; font-size: 13px;
  cursor: pointer; line-height: 1.4; display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; transition: background .12s, border-color .12s, transform .04s, box-shadow .12s;
}
.btn:hover { background: var(--ibew-red-dark); border-color: var(--ibew-red-dark); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(200,16,46,0.22); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ibew-red); border: 1px solid var(--ibew-red); }
.btn.secondary:hover { background: var(--ibew-red-soft); }
.btn.ghost { background: #fff; color: var(--ink-2); border: 1px solid var(--border-strong); }
.btn.ghost:hover { background: #f3f4f6; border-color: var(--muted-2); color: var(--ink); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }

textarea, select.assess-val {
  width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 13px; font-family: inherit;
  background: #fff; transition: border-color .12s, box-shadow .12s;
}
textarea:focus, select.assess-val:focus { outline: none; border-color: var(--ibew-red); box-shadow: 0 0 0 3px rgba(200,16,46,0.12); }
textarea { min-height: 76px; resize: vertical; }

.copy-link { font-size: 12px; color: var(--muted); word-break: break-all; padding: 8px 10px; background: var(--bg); border-radius: var(--radius-sm); }
.copy-link a { color: var(--info); }

/* Responsive */
@media (max-width: 720px) {
  .container { padding: 14px 12px 60px; }

  /* Nav: tighter, hide email pill (Sign out button still shows so you know you're signed in) */
  .nav { padding: 10px 12px; gap: 10px; }
  .nav .brand .title { font-size: 14px; }
  .nav .brand .sub { font-size: 10px; }
  .nav .me { display: none; }
  .nav .nav-btn { min-height: 40px; padding: 8px 14px; }

  /* Inputs: 16px to prevent iOS auto-zoom on focus (pinch-zoom still works) */
  .toolbar .search,
  .toolbar select,
  .toolbar .file-btn,
  .signin-card input,
  textarea,
  select.assess-val { font-size: 16px; }

  /* Toolbar: stack everything; full-width controls with 44px tap targets */
  .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .toolbar .search { flex: 1 1 auto; width: 100%; min-height: 44px; padding: 11px 14px 11px 38px; }
  .toolbar select { width: 100%; min-height: 44px; padding: 10px 12px; }
  .toolbar .right {
    margin-left: 0; width: 100%;
    display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  }
  .toolbar .file-btn { min-height: 44px; padding: 11px 12px; text-align: center; justify-content: center; display: flex; align-items: center; }
  .toolbar .toggle { grid-column: 1 / -1; min-height: 40px; padding: 8px 12px; font-size: 13px; }
  .toolbar .nav-btn#btn-refresh, .toolbar .right .nav-btn { grid-column: 1 / -1; min-height: 40px; }

  /* Stats: 3-col grid so 5 cells stay readable */
  .stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .stat { flex: initial; min-width: 0; padding: 6px 8px; }
  .stat .n { font-size: 18px; }
  .stat .l { font-size: 10px; }

  /* Table: keep hide-sm columns hidden, slightly bigger touch rows */
  table.candidates thead th.hide-sm, table.candidates tbody td.hide-sm { display: none; }
  table.candidates thead th { padding: 10px 12px; }
  table.candidates tbody td { padding: 12px; }
  table.candidates .avatar { width: 28px; height: 28px; font-size: 11px; }

  /* Side panel: full-width, tighter label column */
  .panel { width: 100%; }
  .panel .body { padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px)); }
  .panel .field { grid-template-columns: 88px 1fr; }

  /* Bigger tap targets for primary actions */
  .btn { min-height: 40px; padding: 10px 14px; font-size: 14px; }

  /* Addressed-state line replaces email/phone on mobile when the row has been actioned */
  table.candidates tbody tr.addressed .name-sub-contact { display: none; }
  table.candidates tbody tr.addressed .name-sub-status { display: block; font-weight: 600; }
  table.candidates .name-sub-status.s-followup { color: var(--good); }
  table.candidates .name-sub-status.s-flagged  { color: var(--ibew-red); }
  table.candidates .name-sub-status.s-assessed { color: var(--muted); }

  /* Tint the whole row + add a colored left bar so addressed cards stand out at a glance.
     :not(.selected):not(:hover) lets the existing selected/hover styles still win. */
  table.candidates tbody tr.s-followup:not(.selected):not(:hover) { background: #ecf6ef; }
  table.candidates tbody tr.s-flagged:not(.selected):not(:hover)  { background: #fdebef; }
  table.candidates tbody tr.s-assessed:not(.selected):not(:hover) { background: #f1f3f6; }
  table.candidates tbody tr.s-followup:not(.selected) td:first-child { box-shadow: inset 4px 0 0 var(--good); }
  table.candidates tbody tr.s-flagged:not(.selected)  td:first-child { box-shadow: inset 4px 0 0 var(--ibew-red); }
  table.candidates tbody tr.s-assessed:not(.selected) td:first-child { box-shadow: inset 4px 0 0 var(--muted-2); }
}
