/* ===================== 全局 ===================== */
:root {
  --primary: #667eea;
  --primary-dark: #5568d3;
  --green: #4CAF50;
  --red: #f44336;
  --orange: #ff9800;
  --blue: #2196F3;
  --bg: #f0f2f5;
  --card: #fff;
  --text: #333;
  --text2: #666;
  --text3: #999;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  min-height: 100vh;
  color: var(--text);
}

/* ===================== 顶栏 ===================== */
.topbar {
  background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
  color: #fff;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(102,126,234,0.3);
}

.topbar h1 {
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar h1 span { font-size: 28px; }

.indicators { display: flex; gap: 18px; align-items: center; }

.debug-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all .15s;
}
.debug-link:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
}

.indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.9);
}

.dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transition: all 0.3s;
}

.dot.live {
  background: #69f0ae;
  box-shadow: 0 0 10px rgba(105,240,174,0.8);
  animation: pulse 1.5s infinite;
}

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ===================== 统计栏 ===================== */
.stats-bar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  overflow-x: auto;
}

.stat-card {
  flex: 1;
  min-width: 120px;
  background: var(--card);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-card .label { font-size: 12px; color: var(--text3); margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 700; color: var(--primary); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.orange { color: var(--orange); }

/* ===================== 球台网格 ===================== */
.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  padding: 0 24px 24px;
}

.table-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  border-left: 5px solid #e0e0e0;
}

.table-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}

.table-card.active { border-left-color: var(--green); }
.table-card.paused { border-left-color: var(--orange); }
.table-card.idle { border-left-color: #e0e0e0; }

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.table-name {
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.table-name .icon { font-size: 28px; }

.table-badge {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.table-badge.idle { background: #f5f5f5; color: var(--text3); }
.table-badge.active { background: #e8f5e9; color: #2e7d32; }
.table-badge.paused { background: #fff3e0; color: #e65100; }

/* ===================== 灯状态 ===================== */
.light-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 12px;
}

.light-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #ddd;
}

.light-dot.on { background: #ffc107; box-shadow: 0 0 8px rgba(255,193,7,0.6); }

/* ===================== 计时区域 ===================== */
.timer-area {
  text-align: center;
  padding: 16px 0;
}

.timer-label {
  font-size: 12px;
  color: var(--text3);
  margin-bottom: 4px;
}

.timer-display {
  font-size: 42px;
  font-weight: 700;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  color: var(--text);
  letter-spacing: 2px;
}

.timer-display.idle { color: #ccc; }
.timer-display.warning { color: var(--orange); }
.timer-display.overtime { color: var(--red); }

.timer-cost {
  font-size: 22px;
  font-weight: 600;
  color: var(--orange);
  margin-top: 6px;
}

.timer-cost.idle { color: #ddd; }

.timer-start-time {
  font-size: 12px;
  color: var(--text3);
  margin-top: 4px;
}

/* ===================== 按钮 ===================== */
.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.btn {
  flex: 1;
  min-width: 60px;
  padding: 12px 8px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #fff;
  text-align: center;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-start { background: linear-gradient(135deg, var(--green), #66bb6a); }
.btn-start:hover:not(:disabled) { background: linear-gradient(135deg, #43a047, #4CAF50); }

.btn-stop { background: linear-gradient(135deg, var(--red), #ef5350); }
.btn-stop:hover:not(:disabled) { background: linear-gradient(135deg, #d32f2f, #f44336); }

.btn-pause { background: linear-gradient(135deg, var(--orange), #ffb74d); }
.btn-pause:hover:not(:disabled) { background: linear-gradient(135deg, #f57c00, #ff9800); }

.btn-switch { background: linear-gradient(135deg, var(--blue), #64b5f6); }
.btn-switch:hover:not(:disabled) { background: linear-gradient(135deg, #1976d2, #2196F3); }

.btn-topup { background: linear-gradient(135deg, #9c27b0, #ba68c8); }
.btn-topup:hover:not(:disabled) { background: linear-gradient(135deg, #7b1fa2, #9c27b0); }

.btn-cancel { background: #e0e0e0; color: var(--text2); }
.btn-cancel:hover { background: #d5d5d5; }

/* ===================== 弹窗 ===================== */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--card);
  border-radius: 20px;
  padding: 28px;
  width: 90%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.25s;
}

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

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

.modal-body { margin-bottom: 20px; }

.modal-label {
  font-size: 14px;
  color: var(--text2);
  margin-bottom: 10px;
  display: block;
}

.modal-section { margin-bottom: 16px; }

.modal-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.modal-buttons .btn { flex: none; padding: 14px; }

/* 模式选择 */
.mode-select {
  display: flex;
  gap: 10px;
}

.mode-btn {
  flex: 1;
  padding: 16px 10px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text2);
  transition: all 0.2s;
  text-align: center;
}

.mode-btn:hover { border-color: var(--primary); color: var(--primary); }
.mode-btn.selected { border-color: var(--primary); background: #f0f3ff; color: var(--primary); }

/* 预付输入 */
.prepay-input {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.prepay-quick {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
  color: var(--text2);
  transition: all 0.2s;
}

.prepay-quick:hover { border-color: var(--primary); color: var(--primary); }

.prepay-cost {
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--orange);
}

/* 关台信息 */
.close-info {
  background: #f8f9fa;
  border-radius: 12px;
  padding: 16px;
  font-size: 15px;
  line-height: 2;
}

/* 换台目标选择 */
.switch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.switch-target {
  padding: 16px;
  border: 2px solid #e0e0e0;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s;
  text-align: center;
}

.switch-target:hover { border-color: var(--blue); color: var(--blue); background: #e3f2fd; }

/* ===================== 设置面板 ===================== */
.settings-panel {
  margin: 0 24px 24px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}

.settings-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setting-item label {
  font-size: 14px;
  color: var(--text2);
  white-space: nowrap;
}

.setting-item input {
  width: 90px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  text-align: center;
}

.setting-item input:focus { border-color: var(--primary); }

.setting-item .unit { font-size: 13px; color: var(--text3); }

/* ===================== 日志 ===================== */
.log-panel {
  margin: 0 24px 24px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
}

.log-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
  color: var(--text2);
  cursor: pointer;
  user-select: none;
}

.log-content {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text2);
  max-height: 150px;
  overflow-y: auto;
  background: #fafafa;
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.8;
}

/* ===================== 响应式 ===================== */
@media (max-width: 600px) {
  .topbar { padding: 16px; }
  .topbar h1 { font-size: 18px; }
  .table-grid { grid-template-columns: 1fr; padding: 0 16px 16px; }
  .stats-bar { padding: 12px 16px; }
  .settings-panel, .log-panel { margin: 0 16px 16px; }
  .timer-display { font-size: 36px; }
  .table-actions { flex-wrap: wrap; }
}
