:root {
  --primary: #2b6cb0;
  --primary-dark: #1a4971;
  --bg: #f4f6f8;
  --panel-bg: #ffffff;
  --border: #dde3ea;
  --text: #1f2937;
  --muted: #6b7280;
  --green: #2f9e44;
  --orange: #e8590c;
  --red: #c92a2a;
  --gray: #868e96;
  --male: #1769aa;
  --male-soft: #e7f3ff;
  --male-border: #8fc5ee;
  --female: #b52b69;
  --female-soft: #fff0f6;
  --female-border: #f0a6c6;
  --tap: 40px; /* 최소 터치 타깃 높이 */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; max-width: 100%; overflow-x: hidden; }

body {
  margin: 0;
  max-width: 100%;
  overflow-x: hidden;
  font-family: "Noto Sans KR Variable", "Noto Sans KR", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* ---------------------------------------------------------------- */
/* 상단바 - 모바일 기준으로 세로 스택, 큰 화면에서 가로 배치           */
/* ---------------------------------------------------------------- */
.top-bar {
  width: 100%;
  background: var(--primary);
  color: white;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.top-bar-row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top-bar-left { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; min-width: 0; }
.top-bar-left h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -0.035em;
  white-space: nowrap;
}
.today-date { font-size: 12px; opacity: 0.85; }
.top-bar-summary {
  display: flex; gap: 10px; font-size: 12px; flex-wrap: wrap;
  background: rgba(255,255,255,0.12); border-radius: 6px; padding: 5px 8px;
}
.top-bar-summary b { font-size: 13px; font-weight: 900; }
.top-bar-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.login-user-label { display: inline-block; margin-right: 6px; font-size: 12px; font-weight: 750; }
.league-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 116px;
  min-height: 34px;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  background: rgba(255,255,255,0.18);
}
.league-badge.open { background: #2f9e44; }
.league-badge.closed { background: rgba(255,255,255,0.18); }
.top-bar-actions > .btn { min-width: 116px; }

@media (max-width: 519px) {
  .top-bar-row1 { gap: 4px; }
  .top-bar-left { flex: 1 1 auto; flex-wrap: nowrap; }
  .top-bar-left h1 { font-size: clamp(13px, 4vw, 15px); letter-spacing: -0.055em; }
  .today-date, .login-user-label { display: none; }
  #auth-area .btn.small { min-height: 30px; padding: 4px 7px; font-size: 10.5px; }
  .top-bar-actions > .btn, .top-bar-actions > .league-badge {
    flex: 1 1 calc(50% - 6px);
    min-width: 0;
  }
  .league-badge { min-height: 34px; padding: 4px 6px; font-size: 11px; }
}

@media (max-width: 719px) {
  .top-bar {
    width: calc(100% - 16px);
    margin: 8px 8px 0;
    top: 8px;
    border-radius: 12px;
    box-shadow: 0 5px 16px rgba(25, 69, 107, .2);
  }
  .layout, .management-layout { width: 100%; padding: 8px; }
  .layout > *, .courts-area, .side-area { min-width: 0; }
}

/* ---------------------------------------------------------------- */
/* 버튼 - 터치 타깃 확보                                              */
/* ---------------------------------------------------------------- */
.btn {
  border: none;
  background: white;
  color: var(--primary-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  min-height: var(--tap);
}
.btn.small { padding: 6px 10px; font-size: 12.5px; min-height: 34px; }
.btn.mini { padding: 4px 7px; font-size: 11px; min-height: 27px; border: 1px solid var(--border); }
.btn.mini.primary { border-color: transparent; }
.btn.primary { background: var(--green); color: white; }
.btn.danger { background: var(--red); color: white; }
.btn:hover { filter: brightness(0.95); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.hidden, .admin-only.hidden { display: none !important; }

/* ---------------------------------------------------------------- */
/* 레이아웃 - 모바일: 1열 / 태블릿 이상: 2열                          */
/* ---------------------------------------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 10px;
}
@media (min-width: 1100px) {
  .layout {
    grid-template-columns: minmax(430px, 0.9fr) minmax(580px, 1.4fr);
    max-width: 1600px;
    margin: 0 auto;
    padding: 16px;
    gap: 16px;
  }
}
@media (min-width: 720px) {
  .top-bar { padding: 12px 18px; }
  .top-bar-left h1 { font-size: 19px; }
  .top-bar-summary { font-size: 13px; gap: 16px; }
}

.courts-area h2, .side-area h2 { font-size: 14px; margin: 2px 0 8px; font-weight: 850; }

.court-group {
  background: rgba(255,255,255,0.5);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 12px;
}
.court-group h3 { margin: 0 0 8px; font-size: 13px; color: var(--primary-dark); }
.court-group h3 small { margin-left: 4px; color: var(--muted); font-size: 11px; font-weight: 500; }
.waiting-court-group { background: #f0f7ff; border-color: #b8d8f3; }

.courts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}
@media (min-width: 520px) {
  .courts-grid { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
}

/* ---------------------------------------------------------------- */
/* 코트 카드 - 단순화된 버전: 박스 중첩 없이 한 눈에 보이는 요약형     */
/* ---------------------------------------------------------------- */
.court-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.court-card.waiting-court-card { border-style: dashed; background: #f8fbff; }
.court-card.status-empty { border-left: 4px solid var(--gray); }
.court-card.status-pending { border-left: 4px solid var(--orange); }
.court-card.status-playing { border-left: 4px solid var(--green); }
.court-card.status-disabled { border-left: 4px solid var(--red); opacity: 0.6; }

.court-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.court-card-header .court-title { font-weight: 850; font-size: 14px; }
.court-status-badge {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  background: #eef2f6;
  color: var(--muted);
}

.court-members {
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 8px;
  color: var(--text);
  flex: 1;
  min-width: 0;
}
.court-members .empty-label { color: #adb5bd; }
.match-teams {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
}
.match-team {
  min-width: 0;
  padding: 6px;
  border: 1px solid #e6ebf0;
  border-radius: 8px;
  background: #f9fbfd;
}
.team-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
}
.team-player-list { display: grid; gap: 5px; min-width: 0; }
.court-player-row { display: flex; align-items: center; gap: 4px; min-width: 0; }
.court-player-row .member-identity { flex: 1; }
.court-player-remove {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid #f0a4a4;
  border-radius: 50%;
  background: #fff0f0;
  color: #bd2323;
  font: inherit;
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.match-vs {
  align-self: center;
  color: #8491a1;
  font-size: 10px;
  font-weight: 900;
}
.empty-team { color: #adb5bd; font-size: 11px; }
.underfilled-label {
  display: block;
  width: fit-content;
  margin-top: 4px;
  padding: 2px 6px;
  border-radius: 8px;
  background: #fff3bf;
  color: #9c5600;
  font-size: 10.5px;
  font-weight: 700;
}
.empty-courts { color: var(--muted); font-size: 12.5px; padding: 14px 4px; text-align: center; }

.court-meta { font-size: 10.5px; color: var(--muted); margin-bottom: 6px; }
.court-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  padding-top: 6px;
  border-top: 1px solid #edf0f3;
}
.court-actions:empty { display: none; }
.court-actions .btn { flex: 0 0 auto; min-width: 0; }
.court-action-btn { min-height: 28px !important; padding: 4px 8px !important; font-size: 11px !important; }
.waiting-promote-btn { background: #1971c2; color: white; }

/* ---------------------------------------------------------------- */
/* 패널 / 테이블                                                     */
/* ---------------------------------------------------------------- */
.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; }
.panel-count { color: var(--primary); font-size: 12.5px; font-weight: 700; }
.attendee-panel { border-top: 4px solid var(--primary); }
.panel-tools select { padding: 6px; border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px; }

/* ---------------------------------------------------------------- */
/* 회원 공통 카드 - 성별 색상 + 이름 앞 급수 심볼                    */
/* ---------------------------------------------------------------- */
.member-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.member-card {
  min-width: 0;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(31, 41, 55, .05);
}
.member-card.gender-male { background: var(--male-soft); border-color: var(--male-border); }
.member-card.gender-female { background: var(--female-soft); border-color: var(--female-border); }
.member-card-head { display: flex; align-items: center; gap: 5px; min-width: 0; }
.member-identity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  padding: 3px 6px 3px 3px;
  border: 1px solid;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 850;
  line-height: 1.2;
}
.member-identity.gender-male { color: #0f568e; background: #d7ebfc; border-color: var(--male-border); }
.member-identity.gender-female { color: #9e255d; background: #ffe0ed; border-color: var(--female-border); }
.card-identity { flex: 1; }
.member-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grade-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  border-radius: 6px;
  color: white;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.35);
}
.grade-a { background: #6f42c1; }
.grade-b { background: #2563a8; }
.grade-c { background: #16836b; }
.grade-d { background: #d97706; }
.grade-other { background: #68717d; }
.grade-e {
  width: 35px;
  padding: 0 3px;
  gap: 1px;
  color: #176b3a;
  background: #d8f5df;
  border: 1px solid #76c88b;
  box-shadow: none;
}
.sprout-icon { font-size: 15px; line-height: 1; }
.grade-letter { font-size: 9px; font-weight: 900; }
.gender-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  color: white;
  font-size: 10px;
  font-weight: 800;
}
.gender-male > .member-card-head .gender-label { background: var(--male); }
.gender-female > .member-card-head .gender-label { background: var(--female); }
.member-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  min-height: 19px;
}
.member-stat { color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.member-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
  padding-top: 5px;
  border-top: 1px solid rgba(100,116,139,.18);
}
.member-card-absent { opacity: .72; border-style: dashed; }
.member-card-locked { box-shadow: 0 0 0 2px rgba(232,89,12,.2); }
.empty-card-grid {
  grid-column: 1 / -1;
  padding: 18px 8px;
  color: #9aa3ad;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: 8px;
}
.waiting-player { min-width: 112px; }
.court-player { display: flex; width: 100%; padding-right: 5px; font-size: 12.5px; }

/* ---------------------------------------------------------------- */
/* 관리자 전용 회원명부 페이지                                      */
/* ---------------------------------------------------------------- */
.management-body { min-height: 100vh; }
.management-top-bar { position: sticky; }
.management-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.management-layout {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 14px;
}
.management-summary-bar { justify-content: flex-start; }
.management-summary-bar .summary-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 27px;
  padding: 4px 9px;
  border-radius: 14px;
  background: rgba(255,255,255,.92);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 800;
  box-shadow: 0 1px 3px rgba(13, 52, 83, .16);
}
.management-summary-bar .summary-chip b { font-size: 13px; }
.summary-present { color: #17733a !important; background: #e8f8ed !important; }
.summary-absent { color: #8b5d00 !important; background: #fff6d8 !important; }
.summary-male { color: var(--male) !important; background: var(--male-soft) !important; }
.summary-female { color: var(--female) !important; background: var(--female-soft) !important; }
.summary-grade-a { color: #5f31a8 !important; background: #f1eaff !important; }
.summary-grade-b { color: #165c9b !important; background: #e5f2ff !important; }
.summary-grade-c { color: #08715d !important; background: #e4f8f2 !important; }
.summary-grade-d { color: #a55400 !important; background: #fff0dc !important; }
.summary-grade-e { color: #176b3a !important; background: #dff6e5 !important; }
.management-title-row { align-items: flex-start; }
.management-title-row h2, .management-list-panel h2 { margin: 0; font-size: 16px; }
.management-title-row .hint-text { margin-top: 4px; }
.management-filter-grid {
  display: grid;
  grid-template-columns: minmax(230px, 2fr) repeat(5, minmax(115px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.management-filter-grid label { display: flex; flex-direction: column; min-width: 0; }
.management-filter-grid label > span {
  margin: 0 0 4px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.management-filter-grid input,
.management-filter-grid select {
  width: 100%;
  min-width: 0;
  min-height: 38px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: white;
  color: var(--text);
  font-size: 13px;
}
.management-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #edf0f3;
}
.management-list-panel { min-height: 260px; }
.management-card-grid { grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); }
.management-member-card {
  display: flex;
  flex-direction: column;
  min-height: 205px;
}
.member-card-select {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin: -1px 0 4px;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
}
.member-card-select input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }
.member-card-select.disabled { opacity: .55; cursor: not-allowed; }
.attendance-days-stat {
  padding: 2px 6px;
  border-radius: 9px;
  background: #fff7d6;
  color: #8a5a00;
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.management-member-details {
  display: grid;
  gap: 2px;
  margin-top: 5px;
  color: #536171;
  font-size: 10.5px;
}
.management-member-details span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.management-member-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, 29px);
  gap: 4px;
  min-height: 67px;
  margin-top: auto;
  padding-top: 6px;
}
.management-member-actions .btn.mini {
  width: 100%;
  min-width: 0;
  min-height: 29px;
  padding: 3px 4px;
}
.member-action-placeholder { visibility: hidden; pointer-events: none; }
.management-locked-note {
  grid-column: 1 / -1;
  grid-row: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 62px;
  text-align: center;
}
.member-color-legend { display: flex; gap: 5px; flex-wrap: wrap; font-size: 10.5px; font-weight: 700; }
.member-color-legend > span { padding: 3px 7px; border-radius: 10px; }
.legend-male { background: var(--male-soft); color: var(--male); border: 1px solid var(--male-border); }
.legend-female { background: var(--female-soft); color: var(--female); border: 1px solid var(--female-border); }
.legend-sprout { background: #d8f5df; color: #176b3a; border: 1px solid #76c88b; }
.bulk-select-control {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  color: var(--primary-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.bulk-select-control input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
.selected-count { min-width: 58px; color: var(--primary); font-size: 12px; font-weight: 800; }

.member-quick-filters {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
}
.quick-filter-label { color: var(--muted); font-size: 11px; font-weight: 800; }
.quick-filter-divider { width: 1px; height: 22px; margin: 0 2px; background: var(--border); }
.member-quick-filters label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  min-height: 28px;
  padding: 3px 7px;
  border: 1px solid var(--border);
  border-radius: 14px;
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
  user-select: none;
}
.member-quick-filters input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
.grade-a-filter { color: #5f31a8; background: #f4efff; }
.grade-b-filter { color: #165c9b; background: #eaf5ff; }
.grade-c-filter { color: #08715d; background: #e9faf5; }
.grade-d-filter { color: #a55400; background: #fff3e4; }
.grade-e-filter { color: #176b3a; background: #e5f8ea; }
.quick-male { color: var(--male); background: var(--male-soft); }
.quick-female { color: var(--female); background: var(--female-soft); }
.member-quick-filters label:has(input:not(:checked)) { opacity: .42; filter: grayscale(.5); }

@media (max-width: 1050px) {
  .management-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .management-filter-grid .filter-search { grid-column: span 2; }
}

.hint-text { font-size: 11.5px; color: var(--muted); margin: 8px 0 0; line-height: 1.5; }

.table-wrap { max-height: 320px; overflow: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 7px 6px; border-bottom: 1px solid #eef1f4; white-space: nowrap; }
th { position: sticky; top: 0; background: white; color: var(--muted); font-weight: 600; }
td .btn.small { padding: 5px 8px; min-height: 30px; margin: 1px; }
.empty-table-cell { color: #adb5bd; text-align: center; padding: 18px 8px; }
.locked-note { color: var(--muted); font-size: 11px; }

.status-pill {
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-대기중 { background: #e7f5ff; color: #1971c2; }
.status-매칭예정 { background: #fff3bf; color: #e8590c; }
.status-경기중 { background: #ebfbee; color: #2f9e44; }
.status-레슨중 { background: #f3e8ff; color: #862e9c; }
.status-일시제외 { background: #f1f3f5; color: #495057; }
.status-참석종료 { background: #f1f3f5; color: #adb5bd; }
.status-미참석 { background: #fff9db; color: #e67700; }
.attendee-status-pill {
  min-width: 68px;
  padding: 4px 9px;
  border: 1px solid currentColor;
  text-align: center;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.2;
  box-shadow: 0 1px 2px rgba(31, 41, 55, .12);
}
.attendee-status-pill.status-경기중 { background: #dcf7e4; color: #176b32; }
.attendee-status-pill.status-대기중 { background: #dceeff; color: #125f9f; }
.attendee-status-pill.status-레슨중 { background: #f0e0ff; color: #74269a; }
.attendee-status-pill.status-매칭예정 { background: #ffedaa; color: #a44700; }
.attendee-status-pill.status-일시제외 { background: #e7e9ec; color: #46515e; }
.attendee-member-card .member-card-meta { min-height: 27px; }
.attendance-pill {
  display: inline-block;
  min-width: 44px;
  padding: 2px 7px;
  border-radius: 10px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
}
.attendance-pill.present { background: #ebfbee; color: var(--green); }
.attendance-pill.absent { background: #f1f3f5; color: var(--muted); }

@media (max-width: 519px) {
  body { font-size: 16px; }
  .layout { padding: 8px; gap: 8px; }
  .panel, .court-group { padding: 10px 8px; }
  .table-wrap { max-height: 360px; }
  table { font-size: 13px; }
  th, td { padding: 9px 7px; }
  td .btn.small { min-height: 34px; }
  .member-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .member-card { padding: 6px; }
  .member-identity { font-size: 12.5px; }
  .member-card-actions .btn.mini { flex: 1 1 auto; }
  .court-card { padding: 9px 8px; }
  .match-team { padding: 5px 4px; }
  .court-player { font-size: 12px; }
  .management-layout { padding: 8px; }
  .management-top-bar .top-bar-row1 { align-items: flex-start; }
  .management-nav .btn { min-height: 32px; padding: 5px 8px; font-size: 11px; }
  .management-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .management-filter-grid .filter-search { grid-column: 1 / -1; }
  .management-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-actions .btn { width: 100%; }
  .bulk-select-control { justify-content: center; }
  .selected-count { display: flex; align-items: center; justify-content: center; }
  .management-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .management-member-actions .btn.mini { width: 100%; }
  .member-quick-filters { justify-content: flex-start; width: 100%; }
  .quick-filter-divider { display: none; }
}

@media (max-width: 350px) {
  .member-card-grid { grid-template-columns: 1fr; }
  .management-filter-grid, .management-actions { grid-template-columns: 1fr; }
}

.manual-match-bar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
  margin-top: 8px; font-size: 12.5px;
}

.csv-tools { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

.stats-box { font-size: 13px; line-height: 1.9; }

.stats-history-controls {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px;
}
.stats-history-controls input[type="date"] {
  padding: 6px; border: 1px solid var(--border); border-radius: 6px; font-size: 12.5px; min-height: 34px;
}

/* ---------------------------------------------------------------- */
/* 모달 - 모바일에서는 전체 화면에 가깝게                             */
/* ---------------------------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: flex-end; justify-content: center; z-index: 50;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white; border-radius: 12px 12px 0 0; padding: 18px; width: 100%;
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 640px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 10px; width: 340px; max-height: 85vh; }
  .modal.wide { width: min(720px, calc(100vw - 32px)); }
}
.modal h3 { margin-top: 0; }
.modal label { display: block; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.modal input, .modal select, .modal textarea {
  width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: 6px; margin-top: 3px;
  font-size: 14px; min-height: var(--tap);
}
.modal textarea { min-height: 118px; resize: vertical; font-family: inherit; line-height: 1.55; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }
.modal-actions .btn { flex: 1; }
@media (min-width: 640px) {
  .modal-actions .btn { flex: initial; }
}

.bulk-attendance-modal { max-width: 620px; }
.bulk-attendance-tools { display: flex; justify-content: flex-end; margin-top: 8px; }
.bulk-attendance-preview {
  min-height: 62px;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.bulk-attendance-preview.checked { display: grid; gap: 10px; }
.bulk-preview-section { display: grid; gap: 6px; }
.bulk-preview-title { font-size: 12px; font-weight: 900; }
.matched-title { color: #17733a; }
.unmatched-title { color: #b24a22; }
.ambiguous-title { color: #8b5d00; }
.bulk-name-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.bulk-name-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 7px;
  border: 1px solid;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 800;
}
.bulk-name-chip small { font-size: 9.5px; font-weight: 750; opacity: .78; }
.bulk-name-chip.matched { color: #176b32; background: #e4f8e9; border-color: #8bc99b; }
.bulk-name-chip.unmatched { color: #a13a18; background: #fff0e8; border-color: #eab093; }
.bulk-name-chip.ambiguous { color: #805400; background: #fff6d8; border-color: #dec46b; }
.bulk-preview-empty { color: #9aa3ad; }

@media (max-width: 519px) {
  .bulk-attendance-modal .modal-actions { display: grid; grid-template-columns: 1fr; }
  .bulk-attendance-modal .modal-actions .btn { width: 100%; }
}

.settings-section { margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.settings-section h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.settings-help { margin: -2px 0 8px; color: var(--muted); font-size: 11.5px; line-height: 1.5; }

.levels-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.level-row {
  display: flex; align-items: center; gap: 6px; font-size: 12.5px;
  background: #f8fafc; padding: 6px 8px; border-radius: 6px;
}
.level-row input { flex: 1; padding: 5px; border: 1px solid var(--border); border-radius: 4px; min-height: 30px; }
.level-row .btn.small { min-height: 28px; padding: 4px 8px; }
.level-add-row { display: flex; gap: 6px; }
.level-add-row input { flex: 1; padding: 7px; border: 1px solid var(--border); border-radius: 6px; }

.settings-form { display: grid; grid-template-columns: 1fr; gap: 8px 12px; }
@media (min-width: 480px) {
  .settings-form { grid-template-columns: 1fr 1fr; }
}
.settings-form .field { display: flex; flex-direction: column; font-size: 12px; }
.settings-form label { color: var(--muted); margin-bottom: 3px; }
.settings-form input, .settings-form select { padding: 7px; border: 1px solid var(--border); border-radius: 6px; }

.users-list { display: grid; gap: 8px; margin-bottom: 10px; }
.user-row, .user-add-row {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(180px, 1.2fr) 120px 132px;
  align-items: end;
  gap: 8px;
}
.user-row {
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.user-field { display: flex; flex-direction: column; min-width: 0; }
.user-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-height: 18px;
  margin: 0 2px 3px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 800;
}
.user-row input, .user-row select, .user-add-row input, .user-add-row select {
  width: 100%;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font: inherit;
  font-size: 12px;
}
.user-current-badge {
  overflow: hidden;
  color: var(--green);
  font-size: 9.5px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.user-row-actions .btn { width: 100%; min-width: 0; min-height: 34px; padding-inline: 6px; }
.user-add-actions { grid-template-columns: 1fr; }
@media (max-width: 639px) {
  .user-row, .user-add-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 399px) {
  .user-row, .user-add-row { grid-template-columns: 1fr; }
}

.toast {
  position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: white; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.hidden { display: none; }
.toast.error { background: var(--red); }

/* ---------------------------------------------------------------- */
/* 로그인 화면                                                        */
/* ---------------------------------------------------------------- */
.login-body {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg); padding: 16px;
}
.login-box {
  background: white; padding: 26px 22px; border-radius: 10px; width: 100%; max-width: 320px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.08); text-align: center;
}
.login-box h1 { font-size: 20px; margin-bottom: 4px; font-weight: 850; }
.login-box h2 { font-size: 14px; color: var(--muted); font-weight: 500; margin-top: 0; }
.login-box label { display: block; text-align: left; font-size: 12.5px; margin-top: 10px; color: var(--muted); }
.login-box input {
  width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; margin-top: 3px;
  font-size: 15px; min-height: var(--tap);
}
.login-box button {
  width: 100%; margin-top: 16px; padding: 11px; background: var(--primary); color: white;
  border: none; border-radius: 6px; font-weight: 600; cursor: pointer; min-height: var(--tap);
}
.flash-error { color: var(--red); font-size: 12.5px; margin-top: 8px; }
.login-hint { font-size: 11px; color: var(--muted); margin-top: 14px; }
.back-link { display: block; margin-top: 8px; font-size: 12px; color: var(--primary); }

.checkbox-cell { text-align: center; }
.checkbox-cell input[type="checkbox"] { width: 20px; height: 20px; }

.import-result {
  margin-top: 9px;
  padding: 9px 11px;
  border: 1px solid #b8daff;
  border-radius: 7px;
  background: #eef7ff;
  color: #1a4971;
  font-size: 12.5px;
  line-height: 1.5;
}
.import-result.hidden { display: none; }
.import-result.error { border-color: #ffc9c9; background: #fff5f5; color: var(--red); }
.import-result ul { margin: 4px 0 0; padding-left: 18px; }
