/* Roster — membership roster import (BRIEF §14 Batch C).
   Tokens only (--navy/--blue/--red/--surface/--line/--ink…) so light and dark
   both come out right; nothing here hardcodes a colour except the two
   transparent tints, which are built with color-mix off a token. */

.roster-wrap {
  display: block;
}

.roster-card {
  margin-bottom: var(--s-4);
}

.roster-h2 {
  margin: 0 0 var(--s-2);
  font-size: 1.22rem;
  line-height: 1.25;
  letter-spacing: -.01em;
}

.roster-h3 {
  margin: 0 0 var(--s-3);
  font-size: 1rem;
  font-weight: 700;
}

.roster-h4 {
  margin: var(--s-4) 0 var(--s-2);
  font-size: .86rem;
  font-weight: 700;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.roster-lede {
  margin: 0 0 var(--s-4);
  color: var(--ink-2);
  font-size: .93rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------------- tabs */

.roster-tabs {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-4);
  padding-bottom: 2px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
}
.roster-tabs::-webkit-scrollbar { display: none; }

.roster-tab {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 8px var(--s-4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font: inherit;
  font-size: .87rem;
  font-weight: 600;
  cursor: pointer;
  scroll-snap-align: start;
}
.roster-tab:hover { background: var(--surface-2); }
.roster-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

/* ------------------------------------------------------------------ stats */

.roster-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
}
@media (min-width: 600px) {
  .roster-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.roster-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.roster-stat.tone-ok { border-left-color: var(--success); }
.roster-stat.tone-accent { border-left-color: var(--blue); }
.roster-stat.tone-warn { border-left-color: var(--warn); }

.roster-stat-value {
  font-size: 1.5rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -.02em;
  color: var(--ink);
}
.roster-stat-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
}

/* --------------------------------------------------------------- switches */

.roster-switch { align-items: flex-start; }
.roster-switch-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.roster-switch-label { font-size: .92rem; font-weight: 600; cursor: pointer; }

.switch-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 22px;
  min-height: 22px;
  height: 22px;
  margin: 2px 0 0;
  accent-color: var(--navy);
}

/* -------------------------------------------------------------- coverage */

.roster-cov { margin-bottom: var(--s-3); }
.roster-cov:last-of-type { margin-bottom: 0; }

.roster-cov-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: 5px;
}
.roster-cov-label { font-size: .86rem; font-weight: 600; color: var(--ink-2); }

.roster-cov-track {
  height: 9px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.roster-cov-fill {
  height: 100%;
  min-width: 2px;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--navy), var(--blue));
}

/* ------------------------------------------------------------------- rows */

.roster-rows { display: flex; flex-direction: column; gap: 2px; }

.roster-group + .roster-group { margin-top: var(--s-4); }

.roster-group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  margin: 0 0 var(--s-2);
  padding: 6px var(--s-3);
  border-radius: var(--r-xs);
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.roster-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 10px var(--s-3);
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.roster-row:last-child { border-bottom: 0; }
.roster-row:hover { background: var(--surface-2); }

.roster-row-main { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
.roster-row-name { font-size: .95rem; font-weight: 600; }
.roster-row-sub { font-size: .8rem; color: var(--muted); }
/* The status pill must never wrap to two lines — the name column gives way. */
.roster-row > .badge, .roster-diff-head > .badge { flex: 0 0 auto; white-space: nowrap; }

.roster-count { margin: var(--s-3) 0 0; }

.roster-search { margin-bottom: var(--s-3); }

.roster-chips {
  display: flex;
  gap: var(--s-2);
  margin-bottom: var(--s-2);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  padding-bottom: 2px;
}
.roster-chips::-webkit-scrollbar { display: none; }
.roster-chips .chip { flex: 0 0 auto; scroll-snap-align: start; }

/* ------------------------------------------------------------ person sheet */

.roster-sheet-head {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.roster-sheet-id { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.roster-sheet-name { margin: 0; font-size: 1.08rem; }
.roster-sheet-sub { margin: 0; }
.roster-sheet-id .badge { align-self: flex-start; }

.roster-details {
  margin-bottom: var(--s-4);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.roster-detail {
  display: flex;
  gap: var(--s-3);
  padding: 9px var(--s-3);
  border-bottom: 1px solid var(--line);
  font-size: .87rem;
}
.roster-detail:last-child { border-bottom: 0; }
.roster-detail:nth-child(odd) { background: var(--surface-2); }
.roster-detail-label { flex: 0 0 38%; color: var(--muted); font-weight: 600; }
.roster-detail-value { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

.btn.danger-text { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--line-strong)); }
.btn.danger-text:hover { background: color-mix(in srgb, var(--red) 10%, var(--surface)); }

/* --------------------------------------------------------------- importer */

.roster-paste {
  min-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: auto;
}

.roster-msg {
  margin: var(--s-3) 0 0;
  padding: 9px var(--s-3);
  border-radius: var(--r-sm);
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 600;
}
.roster-msg.kind-ok {
  background: color-mix(in srgb, var(--success) 14%, var(--surface));
  color: var(--success);
}
.roster-msg.kind-warn {
  background: color-mix(in srgb, var(--warn) 16%, var(--surface));
  color: var(--warn);
}

.roster-map {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--s-3);
  margin-top: var(--s-3);
}
@media (min-width: 620px) {
  .roster-map { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.roster-map-col {
  min-width: 0;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.roster-map-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  margin-bottom: 2px;
}
.roster-map-col-name { font-size: .9rem; font-weight: 700; min-width: 0; }
.roster-map-example { margin: 0 0 var(--s-2); }

.roster-preview-wrap { display: flex; flex-direction: column; gap: var(--s-2); }

.roster-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: 6px var(--s-3);
  padding: var(--s-3);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-sm);
}
.roster-preview-cell { display: flex; flex-direction: column; min-width: 0; }
.roster-preview-label { font-size: .7rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.roster-preview-value { font-size: .87rem; }

/* ---------------------------------------------------------------- dry run */

.roster-sums {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
@media (min-width: 600px) {
  .roster-sums { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.roster-sum {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-top: 3px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.roster-sum:hover { background: var(--surface-2); }
.roster-sum.tone-ok { border-top-color: var(--success); }
.roster-sum.tone-accent { border-top-color: var(--blue); }
.roster-sum.tone-warn { border-top-color: var(--warn); }
.roster-sum-value { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.roster-sum-label { font-size: .78rem; font-weight: 600; color: var(--muted); }

.roster-matched {
  margin: 0 0 var(--s-3);
  padding: 9px var(--s-3);
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--blue) 14%, var(--surface));
  color: var(--ink-2);
}

.roster-diff-panels { margin-bottom: var(--s-4); }
.roster-diff-list { display: flex; flex-direction: column; gap: var(--s-2); }

.roster-diff-row {
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.roster-diff-row.kind-create { border-left-color: var(--success); }
.roster-diff-row.kind-update { border-left-color: var(--blue); }

.roster-diff-head { display: flex; align-items: center; gap: var(--s-3); }
.roster-diff-avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: .75rem;
  font-weight: 700;
}
.roster-diff-id { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
.roster-diff-name { font-size: .93rem; font-weight: 700; }
.roster-diff-sub { color: var(--muted); }

.roster-changes {
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px dashed var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.roster-change {
  display: grid;
  grid-template-columns: minmax(0, 96px) minmax(0, 1fr) 14px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  font-size: .8rem;
}
.roster-change-field { color: var(--muted); font-weight: 700; }
.roster-change-from { color: var(--muted); text-decoration: line-through; }
.roster-change-to { font-weight: 600; }
.roster-map-arrow { color: var(--muted); text-align: center; }

.roster-errors, .roster-mapping {
  margin-bottom: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.roster-errors > summary, .roster-mapping > summary {
  cursor: pointer;
  font-size: .87rem;
  font-weight: 700;
  color: var(--ink-2);
}
.roster-error-list { margin: var(--s-2) 0 0; padding-left: 20px; font-size: .82rem; color: var(--ink-2); }
.roster-error-list li { margin-bottom: 4px; }

.roster-map-list { display: flex; flex-direction: column; gap: 4px; margin-top: var(--s-2); }
.roster-map-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px minmax(0, 1fr);
  align-items: center;
  gap: var(--s-2);
  font-size: .82rem;
}
.roster-map-from { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.roster-map-to { font-weight: 600; }

/* ---------------------------------------------------------------- history */

.roster-run-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-2);
}
.roster-run-note { margin: 0 0 var(--s-3); color: var(--ink-2); }
.roster-run-counts { display: flex; flex-wrap: wrap; gap: 6px; }
.roster-run-file { margin: 0 0 var(--s-2); }

/* ----------------------------------------------------------------- set-up */

.roster-step { display: flex; gap: var(--s-3); margin-bottom: var(--s-4); }
.roster-step:last-child { margin-bottom: 0; }
.roster-step-n {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: .82rem;
  font-weight: 800;
}
.roster-step-body { min-width: 0; }
.roster-step-line { margin: 0 0 6px; color: var(--ink-2); line-height: 1.5; }
.roster-step-line:last-child { margin-bottom: 0; }

.roster-todo { margin: 0 0 var(--s-3); padding-left: 20px; font-size: .88rem; color: var(--ink-2); }
.roster-todo li { margin-bottom: 6px; line-height: 1.45; }

/* --------------------------------------------------------------- dark mode */

@media (prefers-color-scheme: dark) {
  /* Shell bug, scoped fix: app.css keeps `.badge.accent`/`.btn.secondary` at
     color: var(--navy) while --blue-soft flips to a DARK blue in dark mode, so
     those pills and buttons render navy-on-navy and cannot be read. This is
     app-wide (every feature using .badge.accent has it) — fixing it properly
     belongs in app.css, which this module does not own, so the override is
     scoped to roster surfaces only. See the integrator note in exports. */
  .roster-wrap .badge.accent,
  .roster-sheet .badge.accent { color: #cfe0f7; }
  .roster-wrap .btn.secondary,
  .roster-sheet .btn.secondary { color: #dce8fa; }

  .roster-msg.kind-ok { color: #7fe0ab; }
  .roster-msg.kind-warn { color: #ffbd6b; }
  .btn.danger-text { color: #ff9a9a; }
  .roster-cov-fill { background: linear-gradient(90deg, var(--blue), #7fb0e8); }
  .roster-diff-avatar, .roster-step-n { background: var(--blue); color: #08101f; }
}

/* -------------------------------------------------------------- print/a11y */

@media (prefers-reduced-motion: reduce) {
  .roster-tab, .roster-row, .roster-sum { transition: none; }
}
