:root {
  --green: #16a34a;
  --green-dark: #15803d;
  --green-light: #dcfce7;
  --bg: #f2f5f3;
  --card: #ffffff;
  --text: #1f2937;
  --text-sub: #6b7280;
  --border: #e5e7eb;
  --danger: #ef4444;
  --warn: #f59e0b;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 12px rgba(0, 0, 0, 0.04);
  --tabbar-h: 60px;
  --topbar-h: 56px;
}

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

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  font-size: inherit;
  color: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.06);
}

/* ===== 顶部栏 ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--green);
  color: #fff;
  height: var(--topbar-h);
  flex-shrink: 0;
}

.topbar-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 18px;
}

.logo-ball {
  font-size: 22px;
}

.logo.is-back {
  font-size: 18px;
}

.btn-back {
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  padding: 4px 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-login-top {
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
}

.avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* ===== 主内容 ===== */
.main {
  flex: 1;
  padding-bottom: calc(var(--tabbar-h) + 16px);
  padding-left: 12px;
  padding-right: 12px;
}

.view {
  padding-top: 12px;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== 底部导航 ===== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  height: var(--tabbar-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 30;
  padding-bottom: env(safe-area-inset-bottom);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-sub);
  font-size: 11px;
}

.tab.active {
  color: var(--green);
  font-weight: 600;
}

.tab-icon {
  font-size: 20px;
  line-height: 1;
}

.tab-icon-add {
  width: 26px;
  height: 26px;
  background: var(--green);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

/* ===== 通用组件 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 16px 4px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 600;
  font-size: 15px;
  transition: opacity 0.15s;
}

.btn:active {
  opacity: 0.85;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}

.btn-outline {
  background: #fff;
  color: var(--green);
  border: 1px solid var(--green);
}

.btn-ghost {
  background: var(--green-light);
  color: var(--green-dark);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 8px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--green-light);
  color: var(--green-dark);
}

.tag-gray {
  background: #f3f4f6;
  color: #6b7280;
}

.tag-red {
  background: #fee2e2;
  color: #dc2626;
}

.tag-amber {
  background: #fef3c7;
  color: #d97706;
}

.tag-blue {
  background: #dbeafe;
  color: #2563eb;
}

.empty {
  text-align: center;
  color: var(--text-sub);
  padding: 48px 20px;
}

.empty-icon {
  font-size: 44px;
  display: block;
  margin-bottom: 8px;
}

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding: 2px;
  -webkit-overflow-scrolling: touch;
}

.filter-bar select, .filter-bar input {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 0;
}

.filter-bar select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.filter-bar input[type="date"] {
  padding-right: 8px;
}

/* ===== 拼场卡片 ===== */
.event-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.1s;
}

.event-card:active {
  transform: scale(0.99);
}

.event-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.event-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  margin: 10px 0;
  color: var(--text-sub);
  font-size: 13px;
}

.event-meta span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.event-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.event-price {
  color: var(--danger);
  font-weight: 700;
  font-size: 16px;
}

.event-price small {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 400;
}

.organizer {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-sub);
}

.organizer .avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
}

.spots-bar {
  height: 6px;
  border-radius: 999px;
  background: #eef2ef;
  overflow: hidden;
  margin-top: 8px;
}

.spots-bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), #4ade80);
  border-radius: 999px;
}

.spots-text {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.form-row {
  display: flex;
  gap: 10px;
}

.form-row > .form-group {
  flex: 1;
}

/* ===== 球场卡片 ===== */
.field-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.field-banner {
  height: 110px;
  background: linear-gradient(135deg, #16a34a, #4ade80);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  position: relative;
}

.field-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 24px, rgba(255,255,255,0.12) 24px, rgba(255,255,255,0.12) 26px);
}

.field-body {
  padding: 12px 14px;
}

.field-name {
  font-size: 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.field-addr {
  font-size: 13px;
  color: var(--text-sub);
  margin: 6px 0;
}

.field-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.checkbox-item input {
  width: auto;
  margin: 0;
}

.checkbox-item:has(input:checked) {
  background: var(--green-light);
  border-color: var(--green);
  color: var(--green-dark);
}

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  max-height: 86vh;
  overflow-y: auto;
  padding: 20px;
  animation: popIn 0.2s ease;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 20px;
  color: var(--text-sub);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:active {
  background: #f3f4f6;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(17, 24, 39, 0.9);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 200;
  max-width: 80%;
  text-align: center;
  animation: fadeIn 0.2s ease;
}

/* ===== 详情页 ===== */
.detail-hero {
  background: linear-gradient(135deg, var(--green), #22c55e);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 12px;
}

.detail-hero h2 {
  font-size: 20px;
  margin-bottom: 8px;
}

.detail-hero .detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 13px;
  opacity: 0.95;
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.info-row:last-child {
  border-bottom: none;
}

.info-row .label {
  color: var(--text-sub);
}

.player-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.player-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #f3f4f6;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
}

.player-chip .avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-light);
  color: var(--green-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
}

/* ===== 个人中心 ===== */
.profile-head {
  background: linear-gradient(135deg, var(--green), #22c55e);
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.profile-name {
  font-size: 18px;
  font-weight: 700;
}

.profile-sub {
  font-size: 13px;
  opacity: 0.9;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.stat-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  text-align: center;
}

.stat-box .num {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
}

.stat-box .label {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
}

.menu-list {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  width: 100%;
  text-align: left;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:active {
  background: #f9fafb;
}

.menu-item .arrow {
  color: #d1d5db;
}

.menu-item.danger {
  color: var(--danger);
}

/* ===== 登录 ===== */
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.auth-tabs button {
  flex: 1;
  padding: 10px;
  border-radius: 10px;
  font-weight: 600;
  color: var(--text-sub);
  background: #f3f4f6;
}

.auth-tabs button.active {
  background: var(--green-light);
  color: var(--green-dark);
}

.error-text {
  color: var(--danger);
  font-size: 12px;
  margin-top: 4px;
  display: block;
}

/* 响应式 */
@media (min-width: 561px) {
  .tabbar {
    border-radius: 0;
  }
}
