/* ===================== 顾客端 - 仿小程序风格 ===================== */
:root {
  --c-bg: #f5f5f7;
  --c-card: #ffffff;
  --c-line: #e5e5ea;
  --c-text-1: #1c1c1e;
  --c-text-2: #6e6e73;
  --c-text-3: #aeaeb2;
  --c-primary: #07c160;       /* 微信绿 */
  --c-primary-dark: #06ad56;
  --c-secondary: #1989fa;
  --c-warning: #ff976a;
  --c-danger: #ee0a24;
  --c-vip: #c9a36a;
  --c-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
  --c-radius: 10px;
  --c-radius-lg: 14px;
}

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

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: #000;  /* 装饰背景：手机外面 */
  color: var(--c-text-1);
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  justify-content: center;
}

/* 手机外壳容器 */
.phone-frame {
  width: 100%;
  max-width: 414px;
  min-height: 100vh;
  background: var(--c-bg);
  position: relative;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.4);
}

/* 桌面端显示装饰 */
@media (min-width: 768px) {
  body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    align-items: center;
    padding: 20px 0;
  }
  .phone-frame {
    border-radius: 24px;
    overflow: hidden;
    height: 90vh;
    max-height: 900px;
    min-height: auto;
  }
}

/* ===================== 状态栏（仿手机顶部） ===================== */
.statusbar {
  height: 32px;
  background: var(--c-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-text-1);
  flex-shrink: 0;
}

.statusbar .icons { display: inline-flex; gap: 4px; align-items: center; font-size: 12px; }

/* ===================== 顶部导航条 ===================== */
.navbar {
  height: 48px;
  background: var(--c-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid var(--c-line);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}

.navbar .nav-back {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: var(--c-text-1);
}
.navbar .nav-back:hover { background: var(--c-bg); }

.navbar .nav-title {
  font-size: 16px;
  font-weight: 600;
  flex: 1;
  text-align: center;
  margin: 0 8px;
}

.navbar .nav-right { width: 32px; text-align: right; }
.navbar .nav-right.placeholder { visibility: hidden; }

/* ===================== 主体内容区 ===================== */
.view-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 12px;
}

.view-container::-webkit-scrollbar { width: 4px; }
.view-container::-webkit-scrollbar-thumb { background: var(--c-text-3); border-radius: 2px; }

/* ===================== 底部 Tab 栏 ===================== */
.tabbar {
  height: 56px;
  background: var(--c-card);
  display: flex;
  border-top: 1px solid var(--c-line);
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.tabbar.hidden { display: none; }

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  color: var(--c-text-2);
  font-size: 11px;
  user-select: none;
  transition: color .15s;
}
.tab-item.active { color: var(--c-primary); }
.tab-item .icon { font-size: 22px; line-height: 1; }

/* ===================== 通用卡片 ===================== */
.card {
  background: var(--c-card);
  border-radius: var(--c-radius);
  margin: 12px;
  padding: 16px;
  box-shadow: var(--c-shadow);
}

.card-flat {
  background: var(--c-card);
  margin: 12px 0;
  padding: 16px;
}

.card h3 {
  margin: 0 0 12px;
  font-size: 15px;
  font-weight: 600;
}

/* ===================== 列表 ===================== */
.cell-group {
  background: var(--c-card);
  margin: 12px 0;
  border-radius: var(--c-radius);
  overflow: hidden;
  box-shadow: var(--c-shadow);
  margin-left: 12px;
  margin-right: 12px;
}

.cell {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-line);
  cursor: pointer;
  transition: background .15s;
}
.cell:last-child { border-bottom: none; }
.cell:active { background: var(--c-bg); }

.cell .icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.cell .label { flex: 1; font-size: 14px; color: var(--c-text-1); }

.cell .value {
  font-size: 13px;
  color: var(--c-text-2);
  margin-right: 6px;
}

.cell .arrow { color: var(--c-text-3); font-size: 14px; }

/* ===================== 按钮 ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: 24px;
  font-size: 15px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all .15s;
  user-select: none;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}
.btn-primary:active { background: var(--c-primary-dark); }

.btn-secondary {
  background: var(--c-card);
  color: var(--c-primary);
  border-color: var(--c-primary);
}

.btn-ghost {
  background: var(--c-bg);
  color: var(--c-text-1);
  border-color: var(--c-line);
}

.btn-block { display: flex; width: 100%; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ===================== 表单 ===================== */
.form-field {
  margin: 12px 0;
}

.form-field label {
  display: block;
  font-size: 13px;
  color: var(--c-text-2);
  margin-bottom: 6px;
}

.form-field input,
.form-field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--c-radius);
  background: var(--c-card);
  font-size: 15px;
  color: var(--c-text-1);
  outline: none;
  transition: border-color .15s;
}
.form-field input:focus { border-color: var(--c-primary); }

/* ===================== 用户头部（首页/我的） ===================== */
.user-header {
  background: linear-gradient(135deg, #1989fa 0%, #07c160 100%);
  padding: 28px 20px 40px;
  color: #fff;
  position: relative;
}

.user-header .row {
  display: flex;
  align-items: center;
  gap: 12px;
}

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

.user-header .info { flex: 1; }
.user-header .name { font-size: 18px; font-weight: 600; }
.user-header .level {
  display: inline-block;
  margin-top: 4px;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  font-size: 12px;
}

/* 余额卡（叠在 header 上） */
.balance-card {
  margin: -28px 12px 12px;
  background: var(--c-card);
  border-radius: var(--c-radius-lg);
  padding: 20px;
  box-shadow: var(--c-shadow);
  position: relative;
  z-index: 2;
}

.balance-card .label {
  font-size: 13px;
  color: var(--c-text-2);
}

.balance-card .amount {
  font-size: 32px;
  font-weight: 700;
  margin: 4px 0 14px;
  color: var(--c-text-1);
  font-family: -apple-system, "Helvetica Neue", sans-serif;
}

.balance-card .actions {
  display: flex;
  gap: 8px;
}

.balance-card .actions .btn { flex: 1; padding: 10px; font-size: 13px; }

/* ===================== 球台卡片（首页用） ===================== */
.table-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 12px;
}

.table-card {
  background: var(--c-card);
  border-radius: var(--c-radius);
  padding: 16px 12px;
  box-shadow: var(--c-shadow);
  cursor: pointer;
  transition: transform .15s;
  position: relative;
}
.table-card:active { transform: scale(0.97); }

.table-card .name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.table-card .price {
  font-size: 12px;
  color: var(--c-text-2);
}

.table-card .badge {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* busy/maintain 球台禁用视觉 */
.table-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f0f0f3;
}
.table-card.disabled:active { transform: none; }

/* 当前用户自己开的台高亮 */
.table-card.mine {
  border: 2px solid var(--c-primary);
  background: linear-gradient(135deg, #fff 0%, #f0fff4 100%);
}
.table-card.mine::before {
  content: '我的';
  position: absolute;
  top: -6px;
  left: 12px;
  background: var(--c-primary);
  color: #fff;
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 8px;
}

.badge-idle    { background: rgba(7, 193, 96, 0.12);  color: var(--c-primary); }
.badge-busy    { background: rgba(255, 151, 106, 0.15); color: var(--c-warning); }
.badge-maintain{ background: rgba(174, 174, 178, 0.2); color: var(--c-text-2); }

/* ===================== 套餐卡片 ===================== */
.package-card {
  background: linear-gradient(135deg, #fff 0%, #fafafa 100%);
  border: 1px solid var(--c-line);
  border-radius: var(--c-radius);
  padding: 16px;
  margin: 12px;
  box-shadow: var(--c-shadow);
  display: flex;
  align-items: center;
  gap: 14px;
}

.package-card .icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, #ffd194 0%, #d1913c 100%);
  color: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}

.package-card .info { flex: 1; min-width: 0; }
.package-card .name { font-size: 15px; font-weight: 600; }
.package-card .desc { font-size: 12px; color: var(--c-text-2); margin-top: 4px; }
.package-card .price {
  font-size: 18px;
  color: var(--c-danger);
  font-weight: 700;
  margin-top: 6px;
}
.package-card .price small { font-size: 12px; color: var(--c-text-2); font-weight: normal; }

/* ===================== 空状态 ===================== */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--c-text-3);
}
.empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty .text { font-size: 13px; }

/* ===================== 进行中浮动条 ===================== */
.active-bar {
  background: linear-gradient(135deg, #07c160 0%, #1989fa 100%);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.active-bar[hidden] { display: none; }
.active-bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 50%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shine 2.5s infinite;
}
@keyframes shine {
  to { left: 200%; }
}
.active-bar .pulse {
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
  animation: pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
.active-bar .info { flex: 1; line-height: 1.3; min-width: 0; }
.active-bar .name { font-weight: 600; font-size: 14px; }
.active-bar .time { font-family: Menlo, monospace; opacity: 0.95; font-size: 12px; }
.active-bar .arrow { font-size: 16px; opacity: 0.9; }

/* ===================== 模态遮罩 ===================== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 999;
  animation: mask-fade-in .2s;
}
@keyframes mask-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal-sheet {
  background: var(--c-card);
  width: 100%;
  max-width: 414px;
  margin: 0 auto;
  border-radius: 14px 14px 0 0;
  padding: 16px 0 calc(16px + env(safe-area-inset-bottom, 0));
  max-height: 70vh;
  overflow-y: auto;
  animation: sheet-up .25s ease-out;
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.modal-header {
  padding: 0 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--c-line);
}
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-header .close { background: none; border: none; font-size: 20px; color: var(--c-text-3); cursor: pointer; line-height: 1; }
.modal-list .cell { cursor: pointer; }
.modal-list .cell.disabled { opacity: 0.5; cursor: not-allowed; }

/* ===================== Toast ===================== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  pointer-events: none;
  animation: toast-show .25s;
}

@keyframes toast-show {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* ===================== 加载 ===================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--c-text-3);
  font-size: 13px;
}

/* ===================== 调试条（顶部）===================== */
.dev-bar {
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  padding: 6px 12px;
  font-size: 11px;
  color: #6d4c41;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dev-bar .dev-actions { display: flex; gap: 6px; }

.dev-bar button {
  background: none;
  border: 1px solid #ffd54f;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  color: #5d4037;
  cursor: pointer;
}
.dev-bar button:hover { background: #fff3c4; }

/* ===================== 标签页（订单/流水切换） ===================== */
.tab-strip {
  display: flex;
  background: var(--c-card);
  padding: 0 12px;
  border-bottom: 1px solid var(--c-line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.tab-strip-item {
  flex: 1;
  padding: 12px 0;
  text-align: center;
  font-size: 14px;
  color: var(--c-text-2);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .15s;
}
.tab-strip-item.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
  font-weight: 500;
}

/* ===================== 流水/订单条目 ===================== */
.tx-item {
  background: var(--c-card);
  padding: 14px 16px;
  border-bottom: 1px solid var(--c-line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.tx-item .left .title { font-size: 14px; font-weight: 500; }
.tx-item .left .meta { font-size: 12px; color: var(--c-text-3); margin-top: 4px; }
.tx-item .amount { font-size: 16px; font-weight: 600; }
.tx-item .amount.plus { color: var(--c-primary); }
.tx-item .amount.minus { color: var(--c-danger); }
