/* ==========================================================================
   羽毛球场地 · 视觉系统（浅色版）
   浅灰白底 + 草绿主色，干净通透
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #f4f6f3;
  --bg-soft: #f8faf7;

  --surface: #ffffff;
  --surface-2: #f7f9f6;
  --surface-3: #eef2ed;

  --line: rgba(23, 42, 32, 0.1);
  --line-2: rgba(23, 42, 32, 0.16);

  --text: #14201a;
  --text-2: #55645c;
  --text-3: #8a978f;

  --accent: #1f9d63;
  --accent-bright: #148a52;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 157, 99, 0.1);
  --accent-line: rgba(31, 157, 99, 0.32);
  --glow: rgba(31, 157, 99, 0.18);

  --gold: #8a5a12;
  --danger: #c94a44;
  --warn: #a8741a;

  --radius-xl: 26px;
  --radius-lg: 20px;
  --radius: 14px;
  --radius-sm: 10px;

  --shadow-sm: 0 4px 16px rgba(19, 38, 28, 0.06);
  --shadow-lg: 0 30px 70px rgba(19, 38, 28, 0.16);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: rgba(23, 42, 32, 0.2) transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 560px at 50% -300px, rgba(31, 157, 99, 0.06), rgba(31, 157, 99, 0) 70%),
    radial-gradient(780px 460px at 92% -60px, rgba(120, 170, 200, 0.045), rgba(120, 170, 200, 0) 68%),
    linear-gradient(180deg, #f7f8f5 0%, #f2f4f1 48%, #eef1ed 100%);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  padding-bottom: calc(48px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 极淡的场地网格，只在顶部可见 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image:
    linear-gradient(rgba(23, 42, 32, 0.022) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 42, 32, 0.022) 1px, transparent 1px);
  background-size: 64px 64px;
  -webkit-mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 62%);
  mask-image: radial-gradient(circle at 50% 0%, #000 0%, transparent 62%);
  pointer-events: none;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: rgba(31, 157, 99, 0.2);
  color: #10231a;
}

/* ---------- 顶栏 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 62px;
  padding: 11px max(24px, env(safe-area-inset-left)) 11px max(24px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  border: 1px solid var(--accent-line);
  background: linear-gradient(160deg, rgba(31, 157, 99, 0.16), rgba(31, 157, 99, 0.04));
  color: var(--accent-bright);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.brand h1 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #c4cec7;
  flex: none;
  transition: background 0.3s, box-shadow 0.3s;
}

.conn-dot.is-online {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 157, 99, 0.14), 0 0 8px rgba(31, 157, 99, 0.5);
}

.conn-dot.is-offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(201, 74, 68, 0.14), 0 0 8px rgba(201, 74, 68, 0.4);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  justify-content: flex-end;
  min-width: 0;
}

.user-button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  max-width: 100%;
  transition: border-color 0.18s, background 0.18s, transform 0.12s, box-shadow 0.18s;
}

.user-button:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  box-shadow: var(--shadow-sm);
}

.user-button:active {
  transform: scale(0.99);
}

.user-name {
  font-weight: 600;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.level-pill {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.role-pill {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(40, 100, 180, 0.1);
  color: #2b5f9e;
  font-size: 11px;
  font-weight: 700;
}

.role-pill.is-owner {
  background: rgba(180, 130, 40, 0.13);
  color: var(--gold);
}

.user-menu {
  position: absolute;
  top: calc(100% - 4px);
  right: max(24px, env(safe-area-inset-right));
  z-index: 40;
  display: flex;
  flex-direction: column;
  min-width: 176px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  animation: menu-in 0.16s ease;
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.user-menu button {
  padding: 9px 12px;
  border: none;
  border-radius: 9px;
  background: none;
  font-size: 13.5px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}

.user-menu button:hover {
  background: var(--surface-2);
}

.danger-text {
  color: var(--danger);
}

.icon-btn {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--text-2);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.1s;
}

.icon-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- 主体 ---------- */

main {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 40px max(24px, env(safe-area-inset-left)) 0 max(24px, env(safe-area-inset-right));
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.page-title-block {
  min-width: 0;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 10px;
  color: var(--accent-bright);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.eyebrow .live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 157, 99, 0.13);
  animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.page-title {
  margin: 0;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.14;
}

.slot-summary {
  margin: 10px 0 0;
  color: var(--text-3);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.page-stats {
  display: flex;
  gap: 8px;
  flex: none;
  padding-bottom: 3px;
}

.stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text-3);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.stat-chip strong {
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.stat-chip.is-free strong {
  color: var(--accent-bright);
}

/* ---------- 时段切换 ---------- */

.slot-tabs {
  display: flex;
  gap: 3px;
  width: fit-content;
  max-width: 100%;
  padding: 4px;
  margin-bottom: 22px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 15px;
  overflow-x: auto;
  scrollbar-width: none;
}

.slot-tabs::-webkit-scrollbar {
  display: none;
}

.slot-tab {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.slot-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
}

.slot-tab[aria-selected="true"] {
  background: #fff;
  border-color: var(--line);
  color: var(--accent-bright);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(19, 38, 28, 0.08);
}

.slot-tab .tab-date {
  margin-right: 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.slot-tab:hover .tab-date,
.slot-tab[aria-selected="true"] .tab-date {
  color: var(--accent-bright);
}

.slot-tab .tab-label {
  margin-right: 7px;
}

.slot-tab .tab-time {
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  opacity: 0.62;
}

.slot-tab[aria-selected="true"] .tab-time {
  opacity: 0.8;
}

/* ---------- 场地网格 ---------- */

.courts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.court-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 180px;
  padding: 17px 17px 15px;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(19, 38, 28, 0.035), 0 8px 22px rgba(19, 38, 28, 0.05);
  cursor: pointer;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.22s,
    box-shadow 0.22s, background 0.22s;
}

/* 悬停时右上角透出一点场地绿的光 */
.court-card::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -50px;
  width: 190px;
  height: 190px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(31, 157, 99, 0.1), transparent 66%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}

/* 占用进度：卡片底部一条极细的容量线 */
.court-card::after {
  content: "";
  position: absolute;
  left: 17px;
  right: 17px;
  bottom: 0;
  height: 1px;
  border-radius: 1px;
  transform-origin: left center;
  transform: scaleX(var(--fill, 0));
  background: linear-gradient(90deg, rgba(31, 157, 99, 0.12), var(--accent));
  opacity: 0.9;
  transition: transform 0.4s cubic-bezier(0.2, 0.9, 0.2, 1);
}

.court-card:hover {
  transform: translateY(-3px);
  border-color: rgba(31, 157, 99, 0.28);
  box-shadow: 0 2px 4px rgba(19, 38, 28, 0.04), 0 18px 40px rgba(19, 38, 28, 0.1);
}

.court-card:hover::before {
  opacity: 1;
}

.court-card:active {
  transform: translateY(-1px);
}

.court-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.court-card.is-empty {
  background: #fcfdfb;
  border-color: rgba(23, 42, 32, 0.07);
}

.court-card.is-empty::after {
  opacity: 0;
}

.court-card.is-full {
  background: #fbfcfb;
}

.court-card.is-mine {
  border-color: rgba(31, 157, 99, 0.45);
  background: linear-gradient(180deg, rgba(31, 157, 99, 0.055), #fff 62%);
  box-shadow: 0 0 0 1px rgba(31, 157, 99, 0.12), 0 14px 34px rgba(31, 157, 99, 0.09);
}

.court-card.is-mine::before {
  opacity: 0.7;
}

.court-card.is-empty .court-badges {
  display: none;
}

/* 空场设置了固定项目时也要显示，成员点进去前就能看到限制 */
.court-card.is-empty.has-project-override .court-badges {
  display: flex;
}

.court-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.court-id {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

.court-no {
  font-size: 42px;
  font-weight: 700;
  line-height: 0.94;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.court-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--text-3);
  text-transform: uppercase;
}

.court-count {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.court-count.is-full-badge {
  border-color: rgba(201, 74, 68, 0.24);
  background: rgba(201, 74, 68, 0.08);
  color: #b23c36;
}

.court-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 21px;
}

.mine-tag {
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(180, 130, 40, 0.13);
  color: var(--gold);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.court-people {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 28px;
  min-width: 0;
}

.court-empty-text {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-3);
  font-size: 12.5px;
  letter-spacing: 0.02em;
}

.court-empty-text::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 157, 99, 0.1);
}

.avatar-stack {
  display: flex;
  flex: none;
}

.avatar-stack .avatar {
  margin-left: -7px;
  border: 2px solid #fff;
}

.avatar-stack .avatar:first-child {
  margin-left: 0;
}

.people-names {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
  font-size: 12.5px;
}

.court-action {
  margin-top: auto;
  padding-top: 2px;
}

/* ---------- 头像 ---------- */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: 50%;
  background: linear-gradient(160deg, rgba(31, 157, 99, 0.2), rgba(31, 157, 99, 0.07));
  color: var(--accent-bright);
  font-weight: 700;
  line-height: 1;
  user-select: none;
  box-shadow: inset 0 0 0 1px rgba(31, 157, 99, 0.12);
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs {
  width: 26px;
  height: 26px;
  font-size: 11px;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 12px;
}

.avatar-md {
  width: 40px;
  height: 40px;
  font-size: 16px;
}

.avatar-lg {
  width: 76px;
  height: 76px;
  font-size: 28px;
}

.avatar-more {
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 10px;
  margin-left: -7px;
  border: 2px solid #fff;
}

.avatar-editor {
  display: flex;
  align-items: center;
  gap: 16px;
}

.avatar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}

label.btn {
  cursor: pointer;
}

/* ---------- 等级 / 性别 / 项目 ---------- */

.field-label {
  margin: 18px 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-2);
  text-transform: uppercase;
}

.field-label:first-of-type {
  margin-top: 0;
}

.gender-grid {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
}

.gender-option {
  flex: 1;
  padding: 11px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, color 0.16s;
}

.gender-option:hover {
  border-color: var(--line-2);
  color: var(--text);
}

.gender-option.is-selected {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-weight: 600;
}

.gender-option[data-gender="male"].is-selected {
  border-color: rgba(40, 100, 180, 0.32);
  background: rgba(40, 100, 180, 0.08);
  color: #2b5f9e;
}

.gender-option[data-gender="female"].is-selected {
  border-color: rgba(190, 70, 130, 0.3);
  background: rgba(190, 70, 130, 0.08);
  color: #a83a6d;
}

.gender-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.gender-male {
  background: rgba(40, 100, 180, 0.1);
  color: #2b5f9e;
}

.gender-female {
  background: rgba(190, 70, 130, 0.1);
  color: #a83a6d;
}

.project-ms {
  --project-bg: rgba(20, 130, 190, 0.1);
  --project-fg: #166a94;
}

.project-ws {
  --project-bg: rgba(200, 70, 130, 0.1);
  --project-fg: #a13a68;
}

.project-md {
  --project-bg: rgba(31, 157, 99, 0.1);
  --project-fg: #147a4d;
}

.project-wd {
  --project-bg: rgba(120, 90, 200, 0.1);
  --project-fg: #5b45a8;
}

.project-xd {
  --project-bg: rgba(200, 115, 45, 0.11);
  --project-fg: #9c5a17;
}

.project-any {
  --project-bg: rgba(90, 110, 100, 0.09);
  --project-fg: #56655c;
}

.project-badge {
  display: inline-flex;
  align-items: center;
  flex: none;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--project-bg, rgba(90, 110, 100, 0.09));
  color: var(--project-fg, #56655c);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.75;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.16s, border-color 0.16s, color 0.16s, transform 0.1s,
    box-shadow 0.16s;
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(180deg, #25a96b, #1a9159);
  border-color: rgba(20, 120, 74, 0.35);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(19, 100, 60, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #29b574, #1d9c60);
  box-shadow: 0 6px 18px rgba(31, 157, 99, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* 卡片内的加入按钮：安静一点，把注意力留给场地本身 */
.court-action .btn {
  width: 100%;
  min-height: 38px;
  font-size: 13px;
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--text);
  box-shadow: none;
}

.court-action .btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-line);
  color: var(--accent-bright);
}

.court-action .btn.btn-primary {
  color: var(--text);
}

.court-action .btn.btn-primary.is-leave {
  background: rgba(31, 157, 99, 0.08);
  border-color: rgba(31, 157, 99, 0.4);
  color: var(--accent-bright);
}

.court-action .btn.btn-primary.is-leave:hover {
  background: rgba(31, 157, 99, 0.15);
}

.court-action .btn.btn-primary.is-locked {
  background: var(--surface-2);
  border-color: transparent;
  color: var(--text-3);
}

#save-level,
#confirm-project,
.auth-submit {
  width: 100%;
}

.btn-ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--text);
}

.btn-ghost:hover {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.btn-warn {
  background: rgba(168, 116, 26, 0.08);
  border-color: rgba(168, 116, 26, 0.26);
  color: var(--warn);
}

.btn-warn:hover {
  background: rgba(168, 116, 26, 0.14);
}

.btn-danger {
  background: rgba(201, 74, 68, 0.07);
  border-color: rgba(201, 74, 68, 0.24);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(201, 74, 68, 0.13);
}

.btn-text {
  min-height: 0;
  padding: 4px 0;
  background: none;
  border: none;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-2);
}

.btn-text:hover {
  color: var(--text);
  text-decoration-color: var(--text-3);
}

.btn-small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 9px;
}

.empty-state {
  margin: 72px auto;
  max-width: 400px;
  text-align: center;
  color: var(--text-2);
  font-size: 13.5px;
  line-height: 1.8;
}

.page-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 34px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--text-3);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(28px + env(safe-area-inset-bottom));
  transform: translate(-50%, 12px);
  max-width: min(92vw, 460px);
  padding: 11px 18px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: rgba(255, 255, 255, 0.97);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  z-index: 60;
  box-shadow: 0 18px 46px rgba(19, 38, 28, 0.18);
  backdrop-filter: blur(12px);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  border-color: rgba(201, 74, 68, 0.3);
  background: #fff6f5;
  color: #a8342e;
}

/* ---------- 弹层 ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  animation: fade-in 0.18s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 34, 27, 0.34);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: min(86vh, 790px);
  overflow-y: auto;
  padding: 26px;
  background: #fff;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: pop-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  overscroll-behavior: contain;
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.988);
  }
}

.modal-narrow {
  width: min(470px, 100%);
}

.modal-wide {
  width: min(680px, 100%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* ---------- 表单元件 ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-2);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="time"],
input[type="date"],
select {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  color: var(--text);
  outline: none;
  min-width: 0;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

input::placeholder {
  color: var(--text-3);
}

input:focus,
select:focus {
  border-color: var(--accent-line);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(31, 157, 99, 0.12);
}

select {
  cursor: pointer;
}

select option {
  background: #fff;
  color: var(--text);
}

.hint {
  margin: 0 0 16px;
  color: var(--text-2);
  font-size: 12.5px;
  line-height: 1.7;
}

.hint.small {
  margin: 9px 0 0;
  font-size: 11.5px;
  color: var(--text-3);
}

.form-error {
  margin: 10px 0 0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 74, 68, 0.2);
  background: rgba(201, 74, 68, 0.06);
  color: #a8342e;
  font-size: 12.5px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}

.row .field {
  margin-bottom: 0;
  flex: 0 1 140px;
}

.row .field input {
  width: 100%;
}

.readonly-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.readonly-row:last-of-type {
  border-bottom: none;
}

.readonly-row span {
  color: var(--text-2);
}

/* ---------- 管理面板 ---------- */

.admin-section {
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.admin-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.admin-section h3 {
  margin: 0 0 13px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.slot-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.slot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.slot-row input[type="text"] {
  flex: 1 1 96px;
}

.slot-row input[type="time"] {
  flex: 0 1 98px;
}

.slot-row .slot-date {
  flex: 0 1 128px;
  min-height: 38px;
  padding: 6px 8px;
  font-size: 13px;
}

.slot-row .btn,
.slot-create .btn {
  padding: 7px 11px;
  font-size: 12px;
  min-height: 36px;
}

.slot-create {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.slot-create input[type="text"] {
  flex: 1 1 130px;
}

.slot-create input[type="time"] {
  flex: 0 1 108px;
}

.password-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.password-form input {
  flex: 1 1 150px;
}

.capacity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(134px, 1fr));
  gap: 8px;
  margin: 10px 0 14px;
}

.capacity-cell {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12px;
  color: var(--text-2);
  white-space: nowrap;
}

.capacity-cell input {
  width: 54px;
  min-height: 32px;
  padding: 5px 4px;
  text-align: center;
}

.capacity-unit {
  color: var(--text-3);
}

/* ---------- 账号管理 ---------- */

.import-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.import-result {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12.5px;
}

.import-result.is-loading {
  color: var(--text-2);
}

.import-result.is-error {
  background: rgba(201, 74, 68, 0.06);
  border-color: rgba(201, 74, 68, 0.22);
  color: #a8342e;
}

.import-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin: 0;
  font-size: 12.5px;
}

.import-summary strong {
  color: var(--accent-bright);
}

.import-summary span {
  color: #a8342e;
}

.import-errors {
  margin: 10px 0 0;
  padding-left: 18px;
  color: #a8342e;
}

.import-errors li {
  margin: 4px 0;
  line-height: 1.55;
}

.import-row {
  margin-right: 4px;
  font-weight: 700;
}

.user-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.user-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.user-row.is-disabled {
  opacity: 0.5;
}

.user-info {
  display: flex;
  flex: 1 1 140px;
  flex-direction: column;
  min-width: 0;
}

.user-info strong {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta {
  color: var(--text-3);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-select {
  min-height: 32px;
  padding: 5px 9px;
  font-size: 12px;
  border-radius: 9px;
}

.user-create {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.user-create input {
  flex: 1 1 130px;
}

.user-create select {
  flex: 0 0 auto;
}

/* ---------- 等级与项目选择 ---------- */

.level-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}

.level-btn {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.16s, border-color 0.16s, color 0.16s;
}

.level-btn:hover {
  border-color: var(--line-2);
  color: var(--text);
}

.level-btn.is-selected {
  background: linear-gradient(180deg, #25a96b, #1a9159);
  border-color: rgba(20, 120, 74, 0.35);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(31, 157, 99, 0.18);
}

.level-desc {
  min-height: 22px;
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 12.5px;
}

.project-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.project-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 18px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s, box-shadow 0.16s;
}

.project-option:hover {
  border-color: var(--line-2);
  background: #fff;
}

.project-option .project-option-name {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--project-fg, var(--text));
}

.project-option.is-selected {
  border-color: var(--project-fg, var(--accent));
  background: var(--project-bg, var(--accent-soft));
  box-shadow: inset 0 0 0 1px var(--project-fg, var(--accent));
}

/* ---------- 场地详情 ---------- */

.court-detail-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.meta-count {
  font-size: 14.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.meta-slot {
  color: var(--text-3);
  font-size: 11.5px;
}

.person-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
}

.person-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.person-row.is-me {
  border-color: rgba(31, 157, 99, 0.35);
  background: rgba(31, 157, 99, 0.06);
}

.person-name {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 等级/性别/项目/签到状态：宽屏融入成员行，窄屏整体换到第二行 */
.person-meta {
  display: contents;
}

.person-empty {
  padding: 24px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.court-actions {
  display: flex;
  gap: 8px;
}

.court-actions .btn {
  flex: 1;
}

/* ---------- 登录页 ---------- */

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  background:
    radial-gradient(900px 520px at 50% -10%, rgba(31, 157, 99, 0.13), rgba(31, 157, 99, 0) 66%),
    radial-gradient(600px 420px at 90% 105%, rgba(120, 170, 200, 0.07), transparent 70%),
    linear-gradient(180deg, #f8faf6 0%, #f2f5f1 60%, #eef2ee 100%);
}

/* 背景里一张巨大的球场线稿 */
.auth-page::before {
  content: "";
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(820px, 96vw);
  aspect-ratio: 2 / 1;
  transform: translate(-50%, -50%);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 60' fill='none'%3E%3Crect x='1' y='1' width='118' height='58' stroke='%2314261c' stroke-opacity='.13'/%3E%3Cpath d='M60 1v58M1 13h118M1 47h118M30 13v34M90 13v34M1 30h118' stroke='%2314261c' stroke-opacity='.06'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  padding: 34px 30px 30px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line-2);
  border-radius: 24px;
  box-shadow: 0 30px 70px rgba(19, 38, 28, 0.12), inset 0 1px 0 #fff;
  backdrop-filter: blur(18px) saturate(120%);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 9px;
}

.auth-logo {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 13px;
  border: 1px solid var(--accent-line);
  background: linear-gradient(160deg, rgba(31, 157, 99, 0.18), rgba(31, 157, 99, 0.04));
  color: var(--accent-bright);
  box-shadow: inset 0 1px 0 #fff;
  font-size: 21px;
  font-weight: 700;
  line-height: 1;
}

.auth-brand h1 {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-sub {
  margin: 0 0 28px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

.auth-form .field input {
  width: 100%;
  min-height: 46px;
}

.auth-submit {
  min-height: 46px;
  margin-top: 8px;
  font-size: 14.5px;
}

.auth-error {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201, 74, 68, 0.2);
  background: rgba(201, 74, 68, 0.06);
  color: #a8342e;
  font-size: 12.5px;
}

.auth-hint {
  margin: 24px 0 0;
  text-align: center;
  color: var(--text-3);
  font-size: 11.5px;
}

/* ---------- 响应式 ---------- */

@media (max-width: 860px) {
  .courts {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  }
}

@media (max-width: 720px) {
  main {
    padding-top: 28px;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .page-title {
    font-size: 27px;
  }

  .slot-summary {
    margin-top: 8px;
  }

  .page-stats {
    padding-bottom: 0;
  }

  .court-no {
    font-size: 38px;
  }
}

@media (max-width: 560px) {
  .topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  main {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }

  .courts {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* 手机上改成横向一条：场号 · 状态/人 · 按钮，单手一屏能看全 */
  .court-card {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    min-height: 0;
    padding: 13px 15px;
  }

  .court-head {
    flex: none;
    gap: 8px;
  }

  .court-no {
    font-size: 32px;
  }

  .court-count {
    position: static;
    padding: 3px 8px;
    font-size: 11px;
  }

  .court-badges {
    order: 3;
    flex: 1 1 100%;
    min-height: 0;
  }

  .court-people {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
  }

  .court-empty-text {
    font-size: 12px;
  }

  .court-action {
    order: 2;
    margin: 0 0 0 auto;
    padding: 0;
    flex: none;
  }

  .court-action .btn {
    width: auto;
    min-width: 76px;
    min-height: 36px;
    padding: 0 15px;
    font-size: 12.5px;
    border-radius: 10px;
  }

  .slot-tab {
    padding: 8px 13px;
    font-size: 13px;
  }

  .level-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 480px) {
  /* 标题较长，窄屏下品牌独占一行，用户区换到第二行 */
  .brand {
    flex: 1 1 100%;
  }

  .topbar-actions {
    flex: 1 1 100%;
  }

  .user-button {
    flex: 1;
    justify-content: flex-end;
  }

  .brand h1 {
    font-size: 16px;
  }

  /* 窄屏优先保证用户名和时间段可读，只隐藏顶栏自己的等级；场地详情/成员列表的等级保留 */
  .user-button .level-pill {
    display: none;
  }

  .user-name {
    max-width: 90px;
  }

  .slot-tabs {
    width: 100%;
  }

  .slot-tab {
    flex: 1;
    justify-content: center;
  }

  .page-title {
    font-size: 24px;
  }

  .stat-chip {
    padding: 6px 11px;
  }
}

@media (max-width: 400px) {
  .project-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .user-name {
    max-width: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* ==========================================================================
   报名时间窗口
   ========================================================================== */

.slot-window {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.5;
}

.slot-window.is-open {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.slot-window.is-upcoming {
  border-color: rgba(168, 116, 26, 0.3);
  background: rgba(168, 116, 26, 0.08);
  color: var(--warn);
}

.slot-window.is-closed {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--text-3);
}

.slot-window-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.slot-window.is-open .slot-window-dot {
  box-shadow: 0 0 0 3px rgba(31, 157, 99, 0.16);
}

.slot-window-text {
  font-weight: 600;
}

.slot-window-note {
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  opacity: 0.85;
  white-space: nowrap;
}

.slot-window-chip {
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.8;
}

.slot-window-chip.is-open {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.slot-window-chip.is-upcoming {
  background: rgba(168, 116, 26, 0.1);
  color: var(--warn);
}

.slot-window-chip.is-closed {
  background: var(--surface-3);
  color: var(--text-3);
}

/* 管理面板：每个时段的容器与窗口设置行 */

.slot-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--line);
}

.slot-block:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.slot-window-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.slot-window-field {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
}

.slot-window-field input {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 12.5px;
}

.slot-window-state {
  margin-left: auto;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.slot-window-state.is-open {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.slot-window-state.is-upcoming {
  background: rgba(168, 116, 26, 0.1);
  color: var(--warn);
}

.slot-window-state.is-closed {
  background: rgba(201, 74, 68, 0.1);
  color: var(--danger);
}

@media (max-width: 560px) {
  .slot-window {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .slot-window-note {
    width: 100%;
    margin-left: 15px;
  }

  .slot-window-row {
    flex-direction: column;
    align-items: stretch;
  }

  .slot-window-field {
    justify-content: space-between;
  }

  .slot-window-field input {
    flex: 1;
    min-width: 0;
  }

  .slot-window-state {
    margin-left: 0;
    align-self: flex-start;
  }
}

/* ---------- 管理者、签到、成员选择、活动统计 ---------- */

.meta-manager {
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.person-row {
  flex-wrap: wrap;
}

.person-actions {
  display: flex;
  gap: 6px;
}

.attendance-chip {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.attendance-chip.is-none {
  background: var(--surface-3);
  color: var(--text-3);
}

.attendance-chip.is-in {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.attendance-chip.is-out {
  background: rgba(100, 116, 139, 0.12);
  color: var(--text-2);
}

.person-action {
  flex: none;
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.court-actions {
  flex-wrap: wrap;
}

.court-actions .btn {
  flex: 1 1 40%;
}

.member-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 230px;
  overflow-y: auto;
  margin: 10px 0 14px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.member-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.member-item:hover {
  border-color: var(--accent-line);
}

.member-item.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.member-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.member-empty {
  margin: 0;
  padding: 18px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.stats-row {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.stat-cell {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.stat-cell strong {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent-bright);
  font-variant-numeric: tabular-nums;
}

.stat-cell span {
  font-size: 12px;
  color: var(--text-2);
}

.activity-history {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 13px;
}

.activity-date {
  flex: none;
  color: var(--text-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.activity-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-kind {
  flex: none;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.activity-kind.is-join {
  background: var(--accent-soft);
  color: var(--accent-bright);
}

.activity-kind.is-manage {
  background: rgba(251, 191, 36, 0.16);
  color: var(--warn);
}

.activity-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
  list-style: none;
}

/* ---------- 历史活动 ---------- */

.report-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  margin-bottom: 10px;
}

.report-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.report-check {
  flex: none;
  margin-left: 8px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.report-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 8px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.report-main:hover {
  background: var(--accent-soft);
}

.report-date {
  flex: none;
  color: var(--text-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.report-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-count {
  flex: none;
  color: var(--text-2);
  font-size: 12px;
}

.report-manager {
  flex: none;
  color: var(--text-3);
  font-size: 12px;
}

.report-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.report-select-all {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
}

.report-select-all input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.report-empty {
  margin: 0;
  padding: 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 13px;
}

.report-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.report-toolbar select {
  min-height: 34px;
  padding: 5px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.report-time {
  flex: none;
  color: var(--text-3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
}

.report-actions {
  justify-content: flex-end;
}

#load-more-reports {
  margin-right: auto;
}

/* ---------- 使用说明页 ---------- */

.help-topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px max(20px, env(safe-area-inset-left)) 12px max(20px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.help-back {
  color: var(--accent-bright);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

.help-back:hover {
  text-decoration: underline;
}

.help-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.help-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 22px 64px;
}

.help-lead {
  margin: 0 0 18px;
  color: var(--text-2);
  font-size: 13.5px;
}

.help-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 30px;
}

.help-toc a {
  padding: 6px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  text-decoration: none;
}

.help-toc a:hover {
  border-color: var(--accent-line);
  color: var(--accent-bright);
}

.help-section {
  margin-bottom: 38px;
  scroll-margin-top: 70px;
}

.help-section h2 {
  margin: 0 0 14px;
  color: var(--accent-bright);
  font-size: 20px;
}

.help-section h3 {
  margin: 24px 0 8px;
  color: var(--text);
  font-size: 16px;
}

.help-section p {
  margin: 0 0 10px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.8;
}

.help-section ul {
  margin: 0 0 12px;
  padding-left: 20px;
}

.help-section li {
  margin-bottom: 6px;
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.75;
}

.help-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 18px auto 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
}

.help-image.phone {
  width: 250px;
}

.help-image.desktop {
  width: 100%;
  max-width: 660px;
}

.help-caption {
  margin: 0 0 22px;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

.help-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  text-align: center;
}

.help-footer a {
  color: var(--accent-bright);
  font-size: 14px;
}

@media (max-width: 520px) {
  .help-main {
    padding: 20px 16px 48px;
  }

  .help-image.phone {
    width: 78%;
  }
}

/* ---------- 自助签到 ---------- */

.checkin-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-bright);
  font-size: 13px;
}

.checkin-bar.is-done {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--text-2);
}

.checkin-label {
  font-weight: 700;
  white-space: nowrap;
}

.checkin-bar input {
  width: 110px;
  min-height: 34px;
  padding: 4px 10px;
  text-align: center;
  letter-spacing: 0.3em;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
}

.checkin-bar .btn {
  flex: none;
}

.checkin-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.checkin-status {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.checkin-code {
  padding: 2px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.28em;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 520px) {
  .checkin-bar {
    flex-wrap: wrap;
  }

  .checkin-bar input {
    flex: 1;
    min-width: 0;
  }
}

/* ---------- 结束活动弹窗 ---------- */

.end-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.end-field label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-2);
}

.end-field input {
  width: 110px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.end-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.end-actions .btn {
  flex: 1;
}

.report-balls {
  flex: none;
  color: var(--text-2);
  font-size: 11.5px;
  white-space: nowrap;
}

/* ---------- 成员行：窄屏两行布局，避免昵称被压缩 ---------- */

@media (max-width: 560px) {
  .person-row {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }

  /* 第一行：头像 + 昵称（占据整行剩余宽度） */
  .person-row .person-name {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 14px;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-all;
  }

  /* 第二行：性别、等级、项目、签到状态整体换行，不受昵称字数影响 */
  .person-row .person-meta {
    display: flex;
    flex: 1 1 100%;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .person-row .gender-icon,
  .person-row .level-pill,
  .person-row .project-badge,
  .person-row .attendance-chip {
    flex: none;
  }

  /* 操作按钮整体换到第三行，右对齐 */
  .person-actions {
    flex: 1 1 100%;
    display: flex;
    justify-content: flex-end;
    gap: 6px;
  }
}

/* 备案号页脚（工信部要求网站底部展示） */
.site-footer {
  position: relative;
  z-index: 1;
  padding: 18px 16px 26px;
  text-align: center;
  font-size: 12px;
  color: var(--text-2);
}

.site-footer a {
  color: inherit;
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.auth-page .site-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(10px + env(safe-area-inset-bottom));
  padding: 0;
}

/* ---------- 历史活动修正 ---------- */

.report-edit {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px dashed var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-soft);
}

.report-edit-row,
.report-add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.report-add-row {
  margin-top: 10px;
}

.report-edit-row label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}

.report-edit input[type="number"] {
  width: 76px;
  min-height: 34px;
  text-align: center;
}

.report-edit input[type="text"] {
  flex: 1 1 140px;
  min-height: 34px;
}

.report-add-row select {
  min-height: 34px;
  padding: 4px 8px;
  font-size: 12.5px;
}

.report-add-row select:first-child {
  flex: 1 1 120px;
}

.report-add-row input[type="number"] {
  width: 62px;
  min-height: 34px;
  text-align: center;
}

@media (max-width: 520px) {
  .report-edit-row label:first-of-type {
    flex: 0 0 auto;
  }

  .report-edit input[type="text"] {
    flex: 1 1 100%;
    order: 3;
  }

  .report-add-row select:first-child {
    flex: 1 1 100%;
  }
}

/* 历史详情从管理面板里打开，需要盖在管理面板之上 */
#report-modal {
  z-index: 55;
}

#end-modal {
  z-index: 55;
}

/* 历史名单行：昵称优先，按钮允许换行 */
.report-person {
  flex-wrap: wrap;
}

.report-person .person-name {
  flex: 1 1 80px;
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
  word-break: break-all;
}

.report-person .person-actions {
  flex: none;
  margin-left: auto;
}

@media (max-width: 560px) {
  .report-person .person-actions {
    flex: 1 1 100%;
    justify-content: flex-end;
  }
}

/* 管理员强制设置场地项目 */
.court-project-control {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.court-project-label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.court-project-select {
  min-height: 32px;
  padding: 4px 8px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

/* 单打 / 双打 场地标签 */
.match-type-badge {
  display: inline-flex;
  align-items: center;
  flex: none;
  align-self: center;
  margin-left: 2px;
  padding: 1px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.9;
  letter-spacing: 0.02em;
}

.match-type-badge.is-singles {
  background: rgba(59, 130, 246, 0.16);
  color: #1d4ed8;
}

.match-type-badge.is-doubles {
  background: rgba(168, 85, 247, 0.16);
  color: #7c3aed;
}
