/* BotC RSVP — mobile-first responsive UI */
:root {
  --bg: #f5f1ea;
  --card: #fffdf9;
  --ink: #2b1d14;
  --muted: #7a6855;
  --accent: #8b1e1e;
  --accent-soft: #b85454;
  --good: #2d6e3e;
  --warn: #c47b1c;
  --bad: #7a2424;
  --core: #6b4e8a;
  --inconsistent: #4e7a8a;
  --new: #6b8a4e;
  --border: #e0d6c6;
  --tap: 44px;  /* iOS minimum tap target */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;  /* prevent iOS zoom-on-focus */
}

/* ---------- Header ---------- */
header {
  background: var(--ink);
  color: var(--bg);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.nav-toggle {
  background: transparent;
  color: var(--bg);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  font-size: 20px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  display: none;
}

header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

header nav a {
  color: var(--bg);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}

header nav a:hover, header nav a:active {
  background: rgba(255,255,255,0.1);
}

/* Mobile nav drawer */
@media (max-width: 640px) {
  .nav-toggle { display: block; }
  header nav {
    display: none;
    flex-direction: column;
    gap: 0;
    margin-top: 12px;
    border-top: 1px solid rgba(255,255,255,0.15);
    padding-top: 8px;
  }
  body.nav-open header nav { display: flex; }
  header nav a {
    padding: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
  }
}

/* ---------- Flash messages ---------- */
.flash-container {
  max-width: 1200px;
  margin: 12px auto 0;
  padding: 0 16px;
}

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 14px;
  border-left: 4px solid;
}

.flash-success { background: #f3fdf4; border-color: var(--good); color: var(--good); }
.flash-error   { background: #fdf3f3; border-color: var(--bad);  color: var(--bad); }
.flash-info    { background: #f3f8fd; border-color: var(--inconsistent); color: var(--inconsistent); }

/* ---------- Layout ---------- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
}

@media (min-width: 640px) {
  main { padding: 24px; }
}

.event-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.event-header h2 {
  margin: 0;
  font-size: 22px;
}

.event-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

/* ---------- Status badges ---------- */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  background: var(--border);
  color: var(--muted);
  margin-left: 8px;
}

.status-draft     { background: #f4e8d0; color: #8a6d2c; }
.status-scheduled { background: #f4e8d0; color: #8a6d2c; }
.status-sent      { background: #d0e4f4; color: #2c5e8a; }
.status-confirmed { background: #d4ecd6; color: var(--good); }
.status-completed { background: #e8d4f4; color: var(--core); }

/* In table cells the badge should align with its column, not be indented. */
.events-table .status-badge, .players-table .status-badge { margin-left: 0; }

.status-active   { color: var(--good); font-weight: 600; }
.status-archived { color: var(--muted); font-style: italic; }

/* ---------- Headcount hero ---------- */
.headcount {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  text-align: center;
}

.headcount-low  { border-color: var(--bad);  background: #fdf3f3; }
.headcount-good { border-color: var(--good); background: #f3fdf4; }
.headcount-high { border-color: var(--warn); background: #fdf9f3; }

.headcount-number {
  font-size: 56px;
  font-weight: 700;
  line-height: 1;
}

@media (min-width: 640px) {
  .headcount-number { font-size: 64px; }
}

.headcount-label {
  font-size: 15px;
  color: var(--muted);
  margin-top: 6px;
}

.earliest {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

.headcount-range {
  margin-top: 8px;
  font-size: 15px;
  color: var(--ink);
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.headcount-range strong { font-size: 17px; }
.range-sep { color: var(--muted); }

.back-bar {
  margin-bottom: 12px;
}

/* ---------- SMS bar (location + send button) ---------- */
.sms-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.location-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 200px;
}

.location-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  min-height: 36px;
}

.btn-sms {
  background: #1a7f5e;
  color: white;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-height: 36px;
  white-space: nowrap;
}

.btn-sms:hover { background: #156b4f; }
.btn-sms:disabled { background: var(--muted); cursor: not-allowed; opacity: 0.6; }

/* ---------- Invitation comment ---------- */
.inv-comment {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  margin-top: 3px;
  word-break: break-word;
}

/* ---------- Stats row ---------- */
.stats-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.stat {
  background: var(--card);
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  flex: 1 1 auto;
  text-align: center;
  min-width: 70px;
}

.stat-num {
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  margin-right: 4px;
}

.stats-row > a { margin-left: auto; }

@media (max-width: 480px) {
  .stats-row > a { width: 100%; text-align: center; margin-left: 0; }
}

/* ---------- RSVP columns ---------- */
.columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

@media (min-width: 640px) {
  .columns { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
}

.rsvp-col {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  border-top: 4px solid;
}

.col-yes   { border-top-color: var(--good); }
.col-maybe { border-top-color: var(--warn); }
.col-no    { border-top-color: var(--bad);  }

.rsvp-col h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.rsvp-list { list-style: none; margin: 0; padding: 0; }

.rsvp-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rsvp-list li:last-child { border-bottom: none; }

.name-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.arrival {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--good);
}

/* ---------- Arrow-based column movement & justification ---------- */
.rsvp-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.rsvp-item .item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.rsvp-item .item-arrows {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

/* Justification per column */
.align-left  .name-line { justify-content: flex-start; }
.align-left  .item-main { align-items: flex-start; text-align: left; }
.align-center .name-line { justify-content: center; }
.align-center .item-main { align-items: center; text-align: center; }
.align-right .name-line { justify-content: flex-end; }
.align-right .item-main { align-items: flex-end; text-align: right; }

/* Arrow buttons */
.arrow-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  min-height: 36px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.arrow-btn:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  opacity: 1;
}

/* Inline time selector */
.time-form { margin: 0; }

.time-select {
  font-size: 12px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: white;
  color: var(--good);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  min-height: 32px;
  max-width: 110px;
}

.align-center .time-select { color: var(--warn); }

/* On mobile, keep arrows comfortably tappable */
@media (max-width: 640px) {
  .arrow-btn { width: 44px; height: 44px; min-height: 44px; }
}


.empty {
  color: var(--muted);
  font-style: italic;
  margin: 0;
}

/* ---------- Pending section (mobile-friendly cards) ---------- */
.pending-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.pending-section h3 { margin: 0 0 12px; }

.pending-mobile-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pending-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg);
}

.pending-card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.inline-rsvp {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-rsvp select {
  padding: 10px 8px;
  font-size: 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  min-height: var(--tap);
  flex: 1 1 auto;
  min-width: 100px;
}

.inline-rsvp button { min-height: var(--tap); }

/* ---------- Tier tags ---------- */
.tier-tag {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: white;
  white-space: nowrap;
}

.tier-regular      { background: var(--core); }
.tier-inconsistent { background: var(--inconsistent); }
.tier-base-3       { background: #8a6b4e; }
.tier-shiny        { background: var(--new); }
.tier-outside-usa  { background: #888; }
.tier-graveyard    { background: #444; }

/* ---------- Metrics ---------- */
.metric {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-strong {
  font-weight: 700;
  font-size: 15px;
  color: var(--ink);
  margin-right: 6px;
}

.metric-detail {
  font-size: 12px;
  color: var(--muted);
  display: block;
}

/* ---------- Buttons ---------- */
.btn-primary, .btn-secondary, .btn-mini, button[type="submit"] {
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  transition: opacity 0.15s, transform 0.05s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-secondary { background: white; color: var(--ink); border: 1px solid var(--border); }
.btn-mini {
  padding: 6px 10px;
  font-size: 12px;
  background: var(--border);
  color: var(--ink);
  min-height: 32px;
}

.btn-danger { background: #f4d0d0; color: var(--bad); }
.btn-warn   { background: #f4e8d0; color: var(--warn); }
.btn-sm     { padding: 8px 12px; font-size: 13px; }
.btn-large  { padding: 14px 24px; font-size: 16px; }

button:hover, .btn-primary:hover, .btn-secondary:hover { opacity: 0.85; }
button:active { transform: scale(0.97); }

/* ---------- Roster page ---------- */
.quick-tier-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tier-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
}

.tier-section summary {
  padding: 14px 16px;
  cursor: pointer;
  background: var(--bg);
  font-weight: 600;
  list-style: none;
  min-height: var(--tap);
  display: flex;
  align-items: center;
}

.tier-section summary::-webkit-details-marker { display: none; }
.tier-section summary::before {
  content: '▶';
  display: inline-block;
  margin-right: 8px;
  transition: transform 0.2s;
  font-size: 10px;
}
.tier-section[open] summary::before { transform: rotate(90deg); }

.tier-section summary h3 {
  display: inline;
  margin: 0;
  font-size: 16px;
}

.player-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  padding: 12px;
}

@media (min-width: 480px) {
  .player-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

.player-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: white;
  min-height: var(--tap);
}

.player-card input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; }
.player-card:hover { background: var(--bg); }
.player-card.invited { background: #e8f4ea; border-color: var(--good); }

.player-info { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.player-name { font-weight: 500; }
.player-metric { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.player-notes { font-size: 11px; color: var(--muted); font-style: italic; }
.invited-tag { color: var(--good); font-weight: 700; font-size: 18px; }

.sticky-submit {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 16px 0;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  z-index: 50;
}

.sticky-submit > * { flex: 1; }

@media (min-width: 640px) {
  .sticky-submit > * { flex: 0 0 auto; }
}

/* ---------- Players table ---------- */
.player-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  flex: 1 1 200px;
  min-height: var(--tap);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
}

.checkbox-label input[type="checkbox"] { width: 18px; height: 18px; }

.players-table, .events-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.players-table thead, .events-table thead {
  background: var(--bg);
}

.players-table th, .events-table th {
  padding: 12px;
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.players-table td, .events-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

.players-table tr:last-child td, .events-table tr:last-child td { border-bottom: none; }
.archived-row { opacity: 0.55; }

.phone-cell { font-variant-numeric: tabular-nums; font-size: 13px; }
.email-cell { font-size: 13px; word-break: break-all; }
.address-cell { font-size: 13px; color: var(--muted); max-width: 200px; }
.notes-cell { font-size: 13px; color: var(--muted); font-style: italic; max-width: 200px; }

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

@media (max-width: 768px) {
  /* Stack players & events tables on mobile */
  .players-table, .events-table { border: none; background: transparent; }
  .players-table thead, .events-table thead { display: none; }
  .players-table tr, .events-table tr {
    display: block;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 8px;
    padding: 12px;
  }
  .players-table td, .events-table td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 6px 0;
    border: none;
    gap: 12px;
  }
  .players-table td::before, .events-table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--muted);
    flex-shrink: 0;
    min-width: 80px;
  }
  .notes-cell { max-width: none; }
}

/* ---------- Modals ---------- */
.player-modal {
  border: none;
  border-radius: 12px;
  padding: 20px;
  max-width: 460px;
  width: 92%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.player-modal::backdrop {
  background: rgba(0,0,0,0.4);
}

.player-modal h3 { margin: 0 0 16px; }

.player-modal label {
  display: block;
  margin-bottom: 14px;
  font-weight: 600;
  font-size: 13px;
  color: var(--muted);
}

.player-modal input[type="text"],
.player-modal input[type="tel"],
.player-modal select,
.player-modal textarea {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 4px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  font-family: inherit;
  background: white;
}

.player-modal textarea { resize: vertical; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ---------- Import page ---------- */
.import-section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
}

.import-section h3 { margin-top: 0; }

.code-block {
  background: var(--ink);
  color: #f0e8d8;
  padding: 12px;
  border-radius: 8px;
  font-size: 12px;
  overflow-x: auto;
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

.import-form {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-label input[type="file"] {
  padding: 10px;
  border: 2px dashed var(--border);
  border-radius: 8px;
  background: var(--bg);
  width: 100%;
  font-size: 14px;
}

.import-note {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--card);
  border-radius: 10px;
  border: 1px solid var(--border);
}

.empty-state p { color: var(--muted); }

.event-footer {
  margin-top: 20px;
  text-align: center;
}

/* ============ Phase 3 enhancements ============ */

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}
.login-card h1 { margin: 0 0 8px; }
.login-sub { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-input {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
}
.login-btn { width: 100%; padding: 12px; }
.nav-logout { opacity: 0.8; }

/* Character distribution table */
.distribution {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.distribution h3 { margin: 0 0 4px; font-size: 16px; }
.dist-sub { margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.dist-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dist-table th, .dist-table td {
  padding: 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}
.dist-table th { font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; }
.dist-table td:first-child, .dist-table th:first-child { text-align: left; }

.headcount-note { font-size: 12px; color: var(--muted); margin-top: 6px; }

/* Pending bulk-save section */
.pending-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.pending-header h3 { margin: 0; }
.pending-footer { margin-top: 16px; text-align: center; }
.pending-remove-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.remove-chip-form { margin: 0; }
.remove-chip {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  min-height: 32px;
}
.remove-chip:hover { background: #fdeaea; color: var(--bad); border-color: var(--bad); }

/* Player filters */
.player-filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.player-filters select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 38px;
  font-size: 14px;
}

/* Sortable headers */
.sort-link {
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.sort-link:hover { color: var(--accent); }
.sort-active { color: var(--accent); font-weight: 700; }

/* First/last name row in modals */
.name-row { display: flex; gap: 10px; }
.name-row label { flex: 1; }

/* Masked phone */
.phone-masked { font-variant-numeric: tabular-nums; letter-spacing: 1px; color: var(--muted); }

/* ============ Batch 2 enhancements ============ */

/* Combined summary panel: attendance left, distribution right */
.summary-panel {
  display: flex;
  gap: 24px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.summary-left { flex: 1; min-width: 240px; }
.summary-right { flex: 1.2; min-width: 260px; border-left: 1px solid var(--border); padding-left: 24px; }
.summary-panel.headcount-low .headcount-number { color: var(--bad); }
.summary-panel.headcount-good .headcount-number { color: var(--good); }
.summary-panel.headcount-high .headcount-number { color: var(--warn, #b8860b); }
.summary-left .headcount-number { font-size: 48px; font-weight: 800; line-height: 1; }
.summary-left .headcount-label { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.summary-stats { display: flex; gap: 16px; margin: 12px 0; }
.mini-stat { font-size: 14px; color: var(--muted); }
.mini-stat strong { color: var(--ink); font-size: 16px; }
.summary-right h3 { margin: 0 0 4px; font-size: 16px; }
.dist-tag {
  font-size: 10px; background: var(--bg); color: var(--muted);
  padding: 1px 5px; border-radius: 6px; vertical-align: middle;
}
.dist-empty { color: var(--muted); }
@media (max-width: 640px) {
  .summary-right { border-left: none; padding-left: 0; border-top: 1px solid var(--border); padding-top: 16px; }
}

/* Inline arrival time next to name */
.time-form-inline { display: inline-block; margin: 0 0 0 6px; }
.time-form-inline .time-select {
  font-size: 12px; padding: 1px 4px; border-radius: 5px;
  border: 1px solid var(--border); background: var(--bg);
}
.name-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* Location display bar */
.loc-display { font-size: 14px; color: var(--muted); align-self: center; }

/* Action row: keep Edit/Archive/etc on one line */
.action-row { display: flex; gap: 4px; flex-wrap: nowrap; align-items: center; }
.action-row form { margin: 0; }

/* Year-group collapsible on Events */
.year-group { margin-bottom: 16px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.year-summary {
  cursor: pointer; padding: 12px 16px; background: var(--bg);
  font-weight: 700; font-size: 16px; user-select: none;
}
.year-summary:hover { background: #f0e8e0; }
.year-count { color: var(--muted); font-weight: 400; font-size: 14px; }
.year-group .events-table { margin: 0; }

/* Modal hint + name row reuse */
.modal-hint { font-size: 12px; color: var(--muted); margin: 4px 0 0; }

/* Import preview */
.import-intro { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.import-intro ul { margin: 8px 0 0; padding-left: 20px; }
.import-form { background: white; border: 1px solid var(--border); border-radius: 10px; padding: 20px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.import-preview { }
.preview-summary { background: #fff8e8; border: 1px solid #e8d8a8; border-radius: 8px; padding: 12px; }
.import-confirm { margin-top: 16px; background: white; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }

/* ============ Batch 3 enhancements ============ */

/* Events table column sizing: prevent wrapping on Date and Location,
   let the Event name take the slack. */
.events-table th, .events-table td { vertical-align: top; }
.events-table td[data-label="Date"],
.events-table td[data-label="Location"] { white-space: nowrap; }
.events-table td[data-label="Headcount"] { white-space: nowrap; width: 1%; }
.events-table td[data-label="Status"] { width: 1%; white-space: nowrap; }
.events-table th:first-child, .events-table td[data-label="Event"] { min-width: 240px; }

/* Frequency group headers reuse the year-group styling */
.freq-group .players-table { margin: 0; }

/* ============ Batch 4: inline edit, audit log, active tab ============ */

/* Active nav tab — reversed color scheme */
#main-nav a.nav-active {
  background: var(--bg);
  color: var(--ink);
  border-radius: 6px;
}

/* Inline-editable table inputs */
.inline-input {
  width: 100%;
  min-width: 90px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  font-size: 13px;
  font-family: inherit;
  color: var(--ink);
}
.inline-input:hover { border-color: var(--border); background: #fff; }
.inline-input:focus {
  border-color: var(--accent, #8a4e6b);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(138, 78, 107, 0.12);
}
.players-editable td { vertical-align: middle; }
select.inline-input { min-width: 110px; }

/* History popup */
.history-body { max-height: 60vh; overflow-y: auto; margin: 8px 0; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th, .history-table td {
  padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left;
  vertical-align: top;
}
.history-table th {
  font-size: 11px; text-transform: uppercase; color: var(--muted);
  position: sticky; top: 0; background: #fff;
}
.history-table td:first-child { white-space: nowrap; color: var(--muted); }

/* ============ Batch 5: bold active tab, dirty highlight, wider history ============ */

/* Bold the active nav tab text (in addition to the reversed colors) */
#main-nav a.nav-active { font-weight: 700; }

/* Uncommitted inline edits */
.inline-input.dirty {
  background: #fff8d6 !important;
  border-color: #e0c659 !important;
  box-shadow: 0 0 0 2px rgba(224, 198, 89, 0.25);
}

/* Unsaved-changes banner */
.unsaved-banner {
  background: #fff8d6;
  border: 1px solid #e0c659;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-save-inline { background: var(--accent, #8a4e6b); color: #fff; border: none; }

/* Wider Change History popup */
#history-modal {
  max-width: 920px;
  width: 90vw;
}
#history-modal .history-table th,
#history-modal .history-table td { white-space: nowrap; }
#history-modal .history-table td:nth-child(3),
#history-modal .history-table td:nth-child(4) { white-space: normal; }
