:root {
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #111418;
  --muted: #5b6470;
  --border: #d8dde3;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --info: #2563eb;

  /* 성별 색상 */
  --male-bg: #dbeafe;
  --male-border: #2563eb;
  --male-text: #1e3a8a;
  --female-bg: #fce7f3;
  --female-border: #db2777;
  --female-text: #831843;
  --nogender-bg: #eef2f7;
  --nogender-border: #94a3b8;
  --nogender-text: #334155;

  /* 등급 색상 */
  --grade-S: #7c3aed;
  --grade-A: #dc2626;
  --grade-B: #ea580c;
  --grade-C: #ca8a04;
  --grade-D: #16a34a;
  --grade-E: #2563eb;
  --grade-N: #94a3b8;

  --court-active: #1d4ed8;
  --court-empty: #cbd5e1;
  --court-saving: #d97706;
  --court-error: #dc2626;

  --waiting-empty: #cbd5e1;
  --waiting-partial: #60a5fa;
  --waiting-full: #16a34a;

  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
    "Noto Sans KR", system-ui, sans-serif;
  font-size: 14px; line-height: 1.45; }

header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 16px; }
.statusbar { display: flex; gap: 10px; align-items: center; font-size: 13px; flex-wrap: wrap; }

.badge { display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #eef2f7; color: var(--muted); }
.badge.ok { background: #dcfce7; color: var(--success); }
.badge.warn { background: #fef3c7; color: var(--warning); }
.badge.err { background: #fee2e2; color: var(--error); }
.badge.info { background: #dbeafe; color: var(--info); }
.badge.male { background: var(--male-bg); color: var(--male-text); border: 1px solid var(--male-border); }
.badge.female { background: var(--female-bg); color: var(--female-text); border: 1px solid var(--female-border); }

.btn { display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--border);
  background: #fff; color: var(--text); border-radius: var(--radius);
  cursor: pointer; font-size: 13px; font-weight: 500; }
.btn:hover { background: #f5f7fa; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--info); color: #fff; border-color: var(--info); }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { background: var(--error); color: #fff; border-color: var(--error); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--success); color: #fff; border-color: var(--success); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 28px; padding: 4px 8px; font-size: 12px; }
.btn.xs { min-height: 24px; padding: 2px 6px; font-size: 11px; }
/* 대기그룹 액션 버튼 — 크기 베이스 (색상은 base/ghost/autofill-* 그대로 유지) */
.btn.promote-lg {
  min-height: 32px; padding: 4px 15px; font-size: 13px; font-weight: 700;
  min-width: 0; white-space: nowrap;
}
/* 1~4번 코트 배정 — promote 단독 (5px씩 작게) */
.btn.promote-lg[data-promote] { padding: 4px 13px; min-width: 36px; }
.btn.promote-lg:not(.ghost):not(.autofill-male):not(.autofill-female):not(.autofill-mixed):not(.danger) {
  background: var(--info); color: #fff; border-color: var(--info);
}
.btn.promote-lg:not(.ghost):not(.autofill-male):not(.autofill-female):not(.autofill-mixed):not(.danger):hover:not([disabled]) { background: #1d4ed8; }
.btn.promote-lg[disabled] { background: #cbd5e1; border-color: #cbd5e1; color: #64748b; }
/* 복식 버튼 (남복/여복/혼복) — 10px 더 작게 */
.btn.promote-lg.autofill-male,
.btn.promote-lg.autofill-female,
.btn.promote-lg.autofill-mixed { padding: 4px 10px; font-size: 12px; }
/* 비우기 — refresh 아이콘 only, 가로 콤팩트 */
.btn.ghost.promote-lg {
  padding: 4px 8px; min-width: 32px; font-size: 16px; line-height: 1;
}
/* 자동채우기 그라데이션 버튼 */
.btn.autofill-male { background: linear-gradient(135deg, #2563eb 0%, #60a5fa 100%); color: #fff; border-color: #2563eb; font-weight: 600; }
.btn.autofill-male:hover { background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); }
.btn.autofill-female { background: linear-gradient(135deg, #db2777 0%, #f472b6 100%); color: #fff; border-color: #db2777; font-weight: 600; }
.btn.autofill-female:hover { background: linear-gradient(135deg, #be185d 0%, #ec4899 100%); }
.btn.autofill-mixed { background: linear-gradient(135deg, #2563eb 0%, #db2777 100%); color: #fff; border-color: #7c3aed; font-weight: 600; }
.btn.autofill-mixed:hover { background: linear-gradient(135deg, #1d4ed8 0%, #be185d 100%); }

main { padding: 14px; display: grid; gap: 14px;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
@media (max-width: 1100px) { main { grid-template-columns: 1fr; } }

section.panel { background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
section.panel > h2 { margin: 0 0 10px; font-size: 13px; letter-spacing: 0.02em;
  text-transform: uppercase; color: var(--muted); }

/* === 코트 그리드 === */
.courts-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.court-card {
  border: 2px solid var(--court-empty);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 270px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.court-card .court-number { font-size: 20px; }
.court-card .court-timer { font-size: 18px; }
.court-card .court-teams { min-height: 150px; }
.court-card .team .player-card { height: 48px; font-size: 15px; padding: 0 14px; }
.court-card .team-label { font-size: 11px; }
.court-card.active { border-color: var(--court-active); }
.court-card.saving { border-color: var(--court-saving); background: #fffbeb; }
.court-card.error { border-color: var(--court-error); background: #fef2f2; }
.court-card.drop-over { background: #f0f9ff; border-color: var(--info); transform: scale(1.01); }
.court-head { display: flex; justify-content: space-between; align-items: baseline; }
.court-number { font-weight: 700; font-size: 17px; }
.court-timer { font-family: ui-monospace, monospace; font-weight: 600; font-size: 15px; }
.court-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-height: 92px; }
.slot-empty { border: 1px dashed var(--border); border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 12px; min-height: 36px; }
/* 대기/코트 슬롯 — 채워졌든 비었든 동일 크기 고정 */
/* 대기: 32px (선수카드 + 빈슬롯 동일 높이, 폰트는 12/10 유지) */
.waiting-card .court-teams .player-card,
.waiting-card .court-teams .slot-empty {
  height: 32px; min-height: 32px; width: 100%; box-sizing: border-box;
  font-size: 12px; padding: 0 10px;
}
.waiting-card .court-teams .slot-empty { font-size: 10px; }
.court-card .court-teams .slot-empty {
  height: 48px; min-height: 48px; width: 100%; box-sizing: border-box;
}
.court-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: auto; }
/* 비우기 · 경기종료 버튼: xs 대신 sm 사이즈로 + 여백 강화 */
.court-actions .btn { min-height: 36px; padding: 6px 14px; font-size: 13px; font-weight: 600; }

/* === 코트/대기 2:2 팀 레이아웃 === */
.court-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; min-height: 92px; }
.team { display: flex; flex-direction: column; gap: 4px; }
.team-label { font-size: 10px; font-weight: 700; text-align: center; letter-spacing: 0.06em;
  padding: 2px 0 3px; margin-bottom: 1px; border-bottom: 1.5px solid; border-radius: 0; }
.team-1 .team-label { color: var(--male-text); border-color: var(--male-border); }
.team-2 .team-label { color: var(--female-text); border-color: var(--female-border); }
/* 팀 내 선수카드는 전체 폭 차지 */
.team .player-card { width: 100%; flex: 1 0 auto; box-sizing: border-box; justify-content: center; }

/* === 대기 그룹 === */
.waiting-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.waiting-card {
  border: 2px solid var(--waiting-empty);
  border-radius: var(--radius); padding: 10px 12px; background: #fff;
  display: flex; flex-direction: column; gap: 8px;
  height: 170px;          /* 고정 높이 - 선수 수 무관 동일 */
  min-height: 170px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.waiting-card.partial { border-color: var(--waiting-partial); }
.waiting-card.full { border-color: var(--waiting-full); background: #f0fdf4; }
.waiting-card.drop-over { background: #f0f9ff; border-color: var(--info); transform: scale(1.01); }
/* header row - 같은 줄 강제 (wrap 금지) */
.waiting-head { display: flex; justify-content: space-between; align-items: center;
  gap: 6px; flex-wrap: nowrap; }
.waiting-head-left { display: flex; flex-direction: row; gap: 6px; min-width: 0; align-items: center; flex-shrink: 0; }
.waiting-order { font-weight: 700; font-size: 14px; white-space: nowrap; }
.waiting-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; min-height: 92px; }
.waiting-promote { display: flex; gap: 3px; flex-wrap: nowrap; align-items: center;
  justify-content: flex-end; min-width: 0; }
/* court-teams 도 고정 - 슬롯이 자라지 않도록 */
.waiting-card .court-teams { height: 110px; min-height: 110px; flex: 0 0 110px; }
.waiting-card .team { display: grid; grid-template-rows: auto 32px 32px; gap: 4px; }
.waiting-card .team .player-card { flex: none !important; }

/* === 선수 카드 (공통: 코트/대기/소스 동일 폰트·색상) === */
.player-card {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px;
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--nogender-border);
  background: var(--nogender-bg);
  color: var(--nogender-text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  cursor: grab;
  user-select: none;
  min-width: 0;
  position: relative;
  transition: transform 0.08s, box-shadow 0.08s;
  flex: 0 0 auto;
}
.player-card[draggable="true"]:hover { box-shadow: var(--shadow); }
.player-card[draggable="true"]:active { cursor: grabbing; }
.player-card.dragging { opacity: 0.4; }
.player-card.male { background: var(--male-bg); border-color: var(--male-border); color: var(--male-text); }
.player-card.female { background: var(--female-bg); border-color: var(--female-border); color: var(--female-text); }
.player-card .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* 등급 chip — 단색 (등급별 색상 구분 제거) */
.player-card .grade-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px;
  font-weight: 700; color: #fff; background: var(--grade-N);
  flex-shrink: 0;
}
.player-card .remove-btn {
  border: none; background: transparent; color: inherit; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px;
  opacity: 0.6;
}
.player-card .remove-btn:hover { opacity: 1; }

/* === 선수 목록 (드래그 소스 영역) === */
.players-source {
  display: flex; flex-wrap: wrap; column-gap: 8px; row-gap: 10px;
  max-height: 360px; overflow-y: auto;
  padding: 14px 6px 6px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: #fafbfc;
}
.players-source .player-card { padding: 6px 12px; }

/* === 통계 표 / 히스토리 === */
.stat-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.stat-table th, .stat-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--border); }
.stat-table th { background: #fafbfc; color: var(--muted); font-weight: 600; }

.recent-item { border-bottom: 1px dashed var(--border); padding: 8px 0; font-size: 13px; }
.recent-item:last-child { border-bottom: none; }
.recent-item .head { font-weight: 600; display: flex; gap: 8px; align-items: center; }
.recent-item .players-line { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }

/* === 폼 === */
.form-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.form-row input, .form-row select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; background: #fff;
}

.summary-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.summary-card { border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.summary-card .label { color: var(--muted); font-size: 11px; }
.summary-card .value { font-size: 18px; font-weight: 700; margin-top: 2px; }

.list-empty { color: var(--muted); font-size: 12px; padding: 6px 4px; text-align: center; }

.toast-host { position: fixed; bottom: 20px; right: 20px; display: flex;
  flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: #111418; color: #fff; padding: 10px 14px; border-radius: 6px;
  box-shadow: var(--shadow); font-size: 13px; max-width: 340px; }
.toast.ok { background: var(--success); }
.toast.warn { background: var(--warning); }
.toast.err { background: var(--error); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 20px;
  min-width: 320px; max-width: 520px; width: calc(100% - 40px); }
.modal h3 { margin: 0 0 12px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 11.5px; margin-top: 6px; }

/* swap 시각 표시 — player-card 위에 드롭 시 강조 */
.player-card.swap-target { outline: 2px solid var(--info); outline-offset: 1px; }

/* 쉬는 시간 텍스트 */
.player-card .rest { font-size: 10px; color: var(--muted); margin-left: 4px; opacity: 0.75; }
.player-card.male .rest { color: var(--male-text); }
.player-card.female .rest { color: var(--female-text); }

/* ETA 뱃지 */
.eta { font-size: 11px; color: var(--muted); padding: 2px 6px; background: #eef2f7;
  border-radius: 999px; }

/* Undo 토스트 */
.toast.undo {
  background: #111418; color: #fff;
  display: flex; align-items: center; gap: 10px;
}
.toast.undo button {
  background: #fff; color: #111418; border: none; padding: 4px 10px;
  border-radius: 4px; font-weight: 600; cursor: pointer;
}
.toast.undo .timer { font-family: ui-monospace, monospace; color: #fbbf24; font-weight: 600; }

/* 정렬 토글 */
.sort-toggle { font-size: 11px; color: var(--info); cursor: pointer; user-select: none; }
.sort-toggle:hover { text-decoration: underline; }

/* ============================================================
   관리자 페이지 전용 레이아웃 (index.html)
   ============================================================ */
.admin-layout { padding: 14px; display: grid; gap: 14px;
  grid-template-columns: minmax(0, 2.6fr) minmax(280px, 1fr);
  align-items: stretch; }
@media (max-width: 1100px) { .admin-layout { grid-template-columns: 1fr; } }

.admin-left { display: grid; gap: 14px; min-width: 0;
  grid-auto-rows: min-content; align-content: start; }
.admin-right { display: grid; gap: 14px; min-width: 0; }

/* 코트 4개 한 줄 고정 — 줄바꿈 없음 */
.courts-grid.row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .courts-grid.row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* 대기 그룹 1열 6행 — 패널 높이를 균등 분할 */
.waiting-grid.col-1 { grid-template-columns: 1fr; }

/* 좌측 선수 목록 패널: 자체 max-height 영역 안에서 스크롤 */
.panel.fill { display: flex; flex-direction: column; min-height: 0; }
.panel.fill .players-source { max-height: 520px; min-height: 260px; }

/* 우측 대기 패널: 좌측 컬럼 높이에 맞춰 늘어남 */
.panel.fill-right { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.panel.fill-right .waiting-grid { flex: 1; display: grid;
  grid-auto-rows: minmax(140px, 1fr); align-content: stretch; }
.panel.fill-right .waiting-card { min-height: 140px; }

/* 드래그 소스 영역: 카드 정렬만 담당. 색상/폰트는 공통 .player-card 가 결정 */
.players-source.flat { align-content: flex-start; }
.players-source.flat .player-card .rest { font-size: 11px; opacity: 0.8; }

/* === 선수 통계 (남/여 분리 영역) === */
.stat-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 820px) { .stat-split { grid-template-columns: 1fr; } }
.stat-col { border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; overflow: hidden; display: flex; flex-direction: column; }
.stat-col-male { border-color: var(--male-border); }
.stat-col-male .stat-col-head { background: var(--male-bg); color: var(--male-text); border-bottom: 1px solid var(--male-border); }
.stat-col-female { border-color: var(--female-border); }
.stat-col-female .stat-col-head { background: var(--female-bg); color: var(--female-text); border-bottom: 1px solid var(--female-border); }
.stat-col-other .stat-col-head { background: var(--nogender-bg); color: var(--nogender-text); border-bottom: 1px solid var(--nogender-border); }
.stat-col-head { padding: 8px 12px; font-weight: 700; font-size: 13px;
  display: flex; justify-content: space-between; align-items: center; }
.stat-list { display: flex; flex-direction: column; }
.stat-row { display: grid;
  grid-template-columns: 1.4fr 0.5fr 0.8fr 1fr 0.8fr 1fr;
  gap: 6px; padding: 7px 12px; font-size: 12.5px; align-items: center;
  text-align: center; }
.stat-row > * { justify-self: center; }
.stat-row .stat-name { justify-self: center; }
.stat-row + .stat-row { border-top: 1px solid var(--border); }
.stat-row.header { background: #fafbfc; color: var(--muted);
  font-weight: 600; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.02em; }
.stat-col-male .stat-row:nth-child(even):not(.header) { background: rgba(37, 99, 235, 0.06); }
.stat-col-female .stat-row:nth-child(even):not(.header) { background: rgba(219, 39, 119, 0.06); }
.stat-col-other .stat-row:nth-child(even):not(.header) { background: rgba(100, 116, 139, 0.06); }
.stat-row.inactive { opacity: 0.45; }
.stat-row .stat-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-row .stat-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 12px; }

/* 토글 스위치 */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px;
  cursor: pointer; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider { position: absolute; inset: 0; background: #cbd5e1;
  border-radius: 999px; transition: background 0.15s; }
.toggle .slider::before {
  content: ""; position: absolute; height: 16px; width: 16px;
  left: 2px; top: 2px; background: #fff; border-radius: 50%;
  transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(16px); }
.toggle input:disabled + .slider { opacity: 0.5; cursor: not-allowed; }

/* === 경기 히스토리 카드 그리드 === */
.recent-grid { display: grid; gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1280px) { .recent-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 980px) { .recent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .recent-grid { grid-template-columns: 1fr; } }
.recent-card { border: 1px solid var(--border); border-radius: var(--radius);
  background: #fff; padding: 10px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow); }
.recent-card .head-row { display: flex; align-items: center;
  gap: 8px; flex-wrap: wrap; }
.recent-card .court-tag { display: inline-flex; align-items: center;
  background: var(--court-active); color: #fff; padding: 2px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 700; flex-shrink: 0; }
.recent-card .duration { font-weight: 700; font-size: 13px; color: var(--text);
  font-family: ui-monospace, monospace; flex-shrink: 0; }
.recent-card .time-row { font-size: 11.5px; color: var(--muted);
  font-family: ui-monospace, monospace; margin-left: auto; }
.recent-card .players-line { display: flex; flex-wrap: wrap; gap: 4px; }
/* 히스토리 2:2 팀 그리드 */
.recent-card .recent-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 8px; }
.recent-card .recent-team { display: flex; flex-direction: column; gap: 3px; }
.recent-card .recent-team-label { font-size: 10px; font-weight: 700; text-align: center;
  letter-spacing: 0.06em; padding: 1px 0 2px; border-bottom: 1.5px solid; }
.recent-card .recent-team:first-child .recent-team-label { color: var(--male-text); border-color: var(--male-border); }
.recent-card .recent-team:last-child .recent-team-label { color: var(--female-text); border-color: var(--female-border); }
/* 히스토리 카드 내부의 선수 pill 은 작게 (운영 영역 40px 카드와 분리) */
.recent-card .player-card { height: auto; padding: 3px 8px; font-size: 12px; font-weight: 600; gap: 5px; width: 100%; box-sizing: border-box; justify-content: center; }
.recent-card .player-card .grade-chip { width: 16px; height: 16px; font-size: 10px; }
.recent-empty { grid-column: 1 / -1; text-align: center; padding: 20px;
  color: var(--muted); font-size: 13px; }

/* 헤더 네비게이션 */
.topnav { display: flex; gap: 2px; align-items: center; flex-wrap: wrap; }
.topnav .nav-divider { width: 1px; height: 18px; background: var(--border);
  margin: 0 6px; flex-shrink: 0; }
.topbar .nav-link { text-decoration: none; font-size: 13px; font-weight: 500;
  padding: 5px 10px; border-radius: 6px;
  transition: background 0.1s, color 0.1s; white-space: nowrap; }
/* 공개 메뉴 */
.topbar .nav-link.nav-public { color: var(--info); }
.topbar .nav-link.nav-public:hover { background: #dbeafe; }
.topbar .nav-link.nav-public.active { background: var(--info); color: #fff; }
/* 관리자 메뉴 */
.topbar .nav-link.nav-admin { color: #92400e; }
.topbar .nav-link.nav-admin:hover { background: #fef3c7; }
.topbar .nav-link.nav-admin.active { background: var(--warning); color: #fff; }
/* 잠금 메뉴 (토큰 없음) */
.topbar .nav-link.nav-locked { color: var(--muted); font-size: 12px; cursor: pointer; }
.topbar .nav-link.nav-locked:hover { background: #f1f5f9; color: var(--text); }

/* === 그룹 필터 칩 === */
.group-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
  padding: 8px; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; }
.group-chip { display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; border: 1.5px solid var(--border);
  background: #fff; color: var(--muted); font-size: 12px; font-weight: 600;
  cursor: pointer; user-select: none; transition: background 0.1s, border-color 0.1s, color 0.1s; }
.group-chip:hover { background: #f1f5f9; }
.group-chip.selected { background: var(--info); color: #fff; border-color: var(--info); }
.group-chip.all { font-weight: 700; }
.group-chip.all.selected { background: var(--success); border-color: var(--success); }
.group-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--nogender-border); flex-shrink: 0; }
.group-chip .count { font-size: 10.5px; opacity: 0.85; padding: 0 5px; border-radius: 999px; background: rgba(0,0,0,0.08); }
.group-chip.selected .count { background: rgba(255,255,255,0.22); }
.group-chips-empty { font-size: 12px; color: var(--muted); padding: 6px; }

/* === 선수 관리 페이지 (admin-players.html) === */
.mgmt-layout { padding: 14px; display: grid; gap: 14px;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr) minmax(0, 1.4fr); }
@media (max-width: 1180px) { .mgmt-layout { grid-template-columns: 1fr; } }
.mgmt-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

.group-list { display: flex; flex-direction: column; gap: 4px; max-height: 520px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 6px; background: #fafbfc; padding: 6px; }
.group-row { display: grid; grid-template-columns: 14px 1fr auto; gap: 8px;
  align-items: center; padding: 8px 10px; border-radius: 6px; cursor: pointer;
  background: #fff; border: 1px solid transparent; }
.group-row:hover { background: #f1f5f9; }
.group-row.active { background: #e0f2fe; border-color: var(--info); }
.group-row.inactive { opacity: 0.55; }
.group-row .g-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--nogender-border); }
.group-row .g-name { font-weight: 600; font-size: 13px; }
.group-row .g-count { font-size: 11px; color: var(--muted); padding: 2px 8px;
  border-radius: 999px; background: #eef2f7; }

.player-mgmt-list { display: flex; flex-direction: column; gap: 2px; max-height: 600px;
  overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: #fafbfc; padding: 4px; }
.player-mgmt-row { display: grid;
  grid-template-columns: 24px 1.4fr 0.5fr 0.5fr 1fr 36px;
  gap: 8px; align-items: center; padding: 6px 8px; border-radius: 4px;
  background: #fff; font-size: 12.5px; }
/* 선수전체 list — 우측 끝에 삭제 버튼 컬럼 추가 */
.player-mgmt-row.pm-with-delete { grid-template-columns: 24px 1.4fr 0.5fr 0.5fr 1fr 36px 60px; }
/* 선수전체 list — 누적 컬럼 2개 추가 (9 컬럼) */
.player-mgmt-row.pm-with-cumulative {
  grid-template-columns: 24px 1.4fr 0.5fr 0.5fr 1fr 36px 0.6fr 0.7fr 60px;
}
.player-mgmt-row.pm-with-cumulative .pm-cum-count,
.player-mgmt-row.pm-with-cumulative .pm-cum-dur {
  font-size: 11.5px; color: var(--muted); font-weight: 600;
  text-align: center;
}
.player-mgmt-row.header { background: #f1f5f9; color: var(--muted);
  font-weight: 600; font-size: 11px; text-transform: uppercase; }
.player-mgmt-row.inactive { opacity: 0.5; }
.player-mgmt-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.player-mgmt-row .pm-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-mgmt-row .pm-groups { display: flex; flex-wrap: wrap; gap: 3px; }
.player-mgmt-row .pm-group-tag { font-size: 10.5px; padding: 1px 6px; border-radius: 999px;
  background: #e0f2fe; color: var(--info); border: 1px solid #bae6fd; }

.mgmt-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.mgmt-toolbar input, .mgmt-toolbar select {
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

.color-swatch { display: inline-flex; align-items: center; gap: 6px; }
.color-swatch input[type="color"] { width: 28px; height: 28px; border: 1px solid var(--border);
  border-radius: 4px; padding: 0; cursor: pointer; background: #fff; }

/* === 10색 추천 팔레트 === */
.color-palette {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 6px 0; align-items: center;
}
.color-swatch-btn {
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border);
  cursor: pointer; padding: 0;
  transition: transform 0.08s, box-shadow 0.08s;
}
.color-swatch-btn:hover { transform: scale(1.15); box-shadow: 0 0 0 2px var(--text); }
.color-swatch-btn:active { transform: scale(0.95); }

/* === 클릭 가능한 player-mgmt-row + 체크된 상태 강조 === */
.player-mgmt-row.clickable { cursor: pointer; }
.player-mgmt-row.clickable:hover { background: #f1f5f9; }
.player-mgmt-row.row-checked { background: #e0f2fe; border-left: 3px solid var(--info); padding-left: 5px; }
.player-mgmt-row.row-checked:hover { background: #bae6fd; }

/* === 선수 그룹 콤보박스 === */
.player-group-select {
  width: 100%; padding: 4px 8px; font-size: 12px; border: 1px solid var(--border);
  border-radius: 4px; background: #fff; cursor: pointer;
}
.player-group-select:focus { outline: none; border-color: var(--info); }

/* === 선수 목록 필터바 (이름 입력 100% + 정렬 우측) === */
.filter-row {
  display: flex; gap: 10px; align-items: center; margin-bottom: 10px;
  flex-wrap: nowrap;
}
.filter-row .filter-search {
  flex: 1 1 auto; width: 100%; min-width: 0;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; background: #fff;
}
.filter-row .filter-search:focus { outline: none; border-color: var(--info); }
.sort-buttons {
  display: inline-flex; gap: 4px; flex-shrink: 0; margin-left: auto;
  background: #f1f5f9; border-radius: 6px; padding: 3px;
}
.sort-btn {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 4px;
  cursor: pointer; white-space: nowrap; min-height: 28px;
  transition: background 0.1s, color 0.1s, border-color 0.1s;
}
.sort-btn:hover { background: #e2e8f0; color: var(--text); }
.sort-btn.active.sort-name { background: var(--info); color: #fff; border-color: var(--info); }
.sort-btn.active.sort-grade { background: var(--grade-A); color: #fff; border-color: var(--grade-A); }
.sort-btn.active.sort-added { background: var(--success); color: #fff; border-color: var(--success); }

/* 선수 목록 패널: 좌(선수 추가) 50% + 우(정렬) 50% 분할 툴바 */
.roster-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; align-items: center; }
.roster-toolbar-half { min-width: 0; }
.roster-toolbar-half .form-row { flex-wrap: nowrap; }
.roster-toolbar-half .sort-buttons { margin-left: 0; justify-content: flex-end; }
@media (max-width: 900px) { .roster-toolbar { grid-template-columns: 1fr; } }

/* === 명단 (체크인 영역) === */
.section-head {
  display: flex; align-items: center; gap: 8px; margin: 6px 0;
  padding: 4px 2px; font-size: 12px;
}
.section-head .section-title {
  font-weight: 700; font-size: 13px; color: var(--text); letter-spacing: 0.02em;
}
.roster-section { margin-bottom: 10px; }
.roster-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  max-height: 220px; overflow-y: auto;
  padding: 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fafbfc;
}
/* 명단 — 활성 풀과 동일한 player-card pill + 좌측 체크박스 */
.roster-item {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 6px 3px 6px;
  border-radius: 999px;
  background: #f1f5f9; border: 1.5px solid var(--border);
  cursor: pointer; user-select: none;
  transition: transform 0.08s, box-shadow 0.08s;
}
.roster-item:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.roster-item .check-box {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 5px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #fff;
  font-size: 13px; font-weight: 900; line-height: 1;
  flex-shrink: 0; color: #94a3b8;
}
.roster-item.checked { background: #ecfdf5; border-color: var(--success); }
.roster-item.checked .check-box {
  background: var(--success); border-color: var(--success); color: #fff;
}
/* roster-item 내부 player-card 는 드래그 비활성, cursor inherit */
.roster-item .player-card { cursor: inherit; pointer-events: none; }

/* === 활성 풀 (드래그) === */
.active-pool-section { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.active-pool-section .players-source {
  flex: 1; max-height: none; min-height: 120px;
}
.section-head .pool-stat {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 700;
  background: #eef2f7; color: var(--muted);
}
.section-head .pool-stat.male { background: var(--male-bg); color: var(--male-text); }
.section-head .pool-stat.female { background: var(--female-bg); color: var(--female-text); }
.section-head .pool-stat.total { background: var(--success); color: #fff; }
.section-head .head-hint { margin-left: auto; color: var(--muted); font-size: 11.5px; }

/* === 세션(시간대) UI === */
.banner-empty-sessions {
  margin: 8px 14px 0 14px;
  padding: 10px 14px;
  background: #fef3c7;
  border: 1px solid var(--warning);
  border-left: 4px solid var(--warning);
  color: #92400e;
  border-radius: 6px;
  font-size: 13px; font-weight: 600;
}
#session-current-badge { font-weight: 700; }
.session-modal-tabs .btn { min-height: 30px; }
/* statusbar 가 작아질 때 세션 컨트롤 줄바꿈 허용 */
.statusbar { flex-wrap: wrap; }
