/* ==========================================================================
   一路狂飙 · 极速起号管理中枢 (Speedway Console) - 赛车机能仪表盘设计系统
   规范遵循: ui-ux-pro-max (纯矢量SVG、Tabular等宽数字、触觉微交互、高对比度黑金赛车配色)
   ========================================================================== */

:root {
  /* 基础黑金底色 */
  --bg-app: #090a0f;
  --bg-surface: #12141c;
  --bg-surface-card: #181b26;
  --bg-surface-elevated: #202433;
  --bg-input: #0e1017;

  /* 边框与刻线 */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: #f59e0b;

  /* 赛车主题强调色 */
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.25);
  --accent-amber-hover: #fbbf24;
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.25);
  --accent-cyan: #06b6d4;
  --accent-rose: #f43f5e;

  /* 文本梯度 */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;

  /* 几何半径 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* 基础重置 */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-app);
  background-image: 
    radial-gradient(ellipse at 50% 0%, rgba(245, 158, 11, 0.08) 0%, transparent 60%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 32px 32px, 32px 32px;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 20px 14px 40px;
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* 顶部机能标题栏 */
.header-panel {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
}

.header-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-amber);
}

.brand-block {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-title .tag-ver {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 4px;
  letter-spacing: 0;
}

.brand-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.system-status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-emerald);
  background: rgba(16, 185, 129, 0.1);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.system-status-indicator.offline {
  color: var(--accent-rose);
  background: rgba(244, 63, 94, 0.1);
  border-color: rgba(244, 63, 94, 0.25);
}

.system-status-indicator.offline .pulse-dot {
  background: var(--accent-rose);
  box-shadow: none;
  animation: none;
}

@media (max-width: 480px) {
  .header-panel {
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand-block {
    width: 100%;
  }

  .system-status-indicator {
    margin-left: auto;
  }
}

#gen-coupons-text {
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.receipt-panel {
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

.receipt-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: var(--text-secondary);
  font-size: 12px;
}

.receipt-heading button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}

#receipt-token {
  display: block;
  color: var(--text-primary);
  font-size: 12px;
  overflow-wrap: anywhere;
  user-select: all;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
  animation: pulse-ring 2s infinite ease-in-out;
}

@keyframes pulse-ring {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.4); opacity: 1; }
}

/* 导航选项卡 (Segmented Switch) */
.tab-switch {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
}

.tab-switch-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab-switch-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.tab-switch-btn.active {
  color: #000;
  background: var(--accent-amber);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

.tab-switch-btn:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

/* 主面板卡片 */
.console-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

/* 步骤指示条 */
.step-guide-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-tertiary);
}

.step-pill .num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
}

.step-pill.active {
  color: var(--accent-amber);
}

.step-pill.active .num {
  background: var(--accent-amber);
  color: #000;
  border-color: var(--accent-amber);
  font-weight: 800;
}

.step-arrow-divider {
  width: 24px;
  height: 1px;
  background: var(--border-subtle);
}

/* 表单字段 */
.field-block {
  margin-bottom: 16px;
}

.field-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.field-label .required-dot {
  color: var(--accent-amber);
  margin-right: 4px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-box {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus {
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 3px var(--accent-amber-glow);
}

.input-box::placeholder {
  color: var(--text-tertiary);
  font-size: 13px;
}

.input-box.mono {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.5px;
}

.input-box:read-only {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  border-color: rgba(16, 185, 129, 0.3);
  cursor: not-allowed;
}

.field-hint {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.4;
}

/* 按钮规范 (带物理轻微微光) */
.btn-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-action svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2.2;
  fill: none;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(180deg, var(--accent-amber-hover) 0%, var(--accent-amber) 100%);
  color: #000;
  box-shadow: 0 4px 14px var(--accent-amber-glow), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-amber-hover);
  box-shadow: 0 6px 18px rgba(245, 158, 11, 0.4);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 2px 6px var(--accent-amber-glow);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-secondary {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  padding: 10px 16px;
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
}

.btn-secondary:active:not(:disabled) {
  transform: translateY(1px);
}

/* 信息提示栏 (Alert) */
.alert-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-notice svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-notice.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.alert-notice.success svg {
  stroke: #10b981;
}

.alert-notice.error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

.alert-notice.error svg {
  stroke: var(--accent-rose);
}

/* 当前订单概况横幅 (HUD Metadata Banner) */
.hud-meta-card {
  background: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.hud-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hud-meta-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

.hud-meta-val {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
}

.hud-meta-val.cyan {
  color: var(--accent-cyan);
}

.hud-meta-val.emerald {
  color: var(--accent-emerald);
}

/* 账号卡片阵列 */
.accounts-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.acc-card {
  background: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  position: relative;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.acc-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

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

.slot-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
}

.slot-tag {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 2px 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-secondary);
}

.acc-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
}

/* 状态药丸 (Status Badge) */
.badge-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-state.running {
  background: rgba(16, 185, 129, 0.12);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-state.sleeping {
  background: rgba(245, 158, 11, 0.12);
  color: var(--accent-amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-state.completed {
  background: rgba(6, 182, 212, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.badge-state .state-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* 等级进度与里程碑刻度 */
.progress-section {
  margin-bottom: 14px;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 12px;
  margin-bottom: 6px;
}

.progress-title {
  color: var(--text-secondary);
  font-weight: 600;
}

.progress-title b {
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.progress-pct {
  font-weight: 700;
  color: var(--accent-amber);
  font-variant-numeric: tabular-nums;
}

.meter-track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface-elevated);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.meter-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-amber) 0%, #f97316 100%);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.meter-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* 战力、关卡、体力、钻石 仪表盘数据矩阵 */
.metric-matrix {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 8px;
  margin-bottom: 12px;
}

.metric-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
}

.metric-col:not(:last-child)::after {
  content: "";
  position: absolute;
  right: -4px;
  top: 15%;
  height: 70%;
  width: 1px;
  background: var(--border-subtle);
}

.metric-icon-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.metric-icon-label svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.metric-number {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, monospace;
}

.metric-number.amber { color: var(--accent-amber); }
.metric-number.cyan { color: var(--accent-cyan); }
.metric-number.emerald { color: var(--accent-emerald); }

/* 控制台实时流水终端 (Console Terminal) */
.console-feed {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.console-feed svg {
  width: 13px;
  height: 13px;
  stroke: var(--accent-cyan);
  stroke-width: 2;
  fill: none;
  flex-shrink: 0;
}

.console-feed span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 响应式调整 */
@media (max-width: 400px) {
  .metric-matrix {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .metric-col:not(:last-child)::after {
    display: none;
  }
}

/* ==========================================================================
   管理员控制台 (Admin Console) 专属组件
   ========================================================================== */

.card.admin-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

#admin-key {
  min-width: 0;
}

#admin-key + button {
  flex-shrink: 0;
  white-space: nowrap;
}

@media (max-width: 480px) {
  #coupons-table-container table,
  #coupons-table-container tbody,
  #coupons-table-container td {
    display: block;
  }

  #coupons-table-container thead {
    display: none;
  }

  #coupons-table-container tr {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) 68px;
    gap: 2px;
    padding: 7px 0;
  }

  #coupons-table-container td:nth-child(1) { grid-column: 1; grid-row: 1; }
  #coupons-table-container td:nth-child(2) { grid-column: 2; grid-row: 1; overflow-wrap: anywhere; }
  #coupons-table-container td:nth-child(3) { grid-column: 3; grid-row: 1; white-space: nowrap; }
  #coupons-table-container td:nth-child(4) { grid-column: 2; grid-row: 2; overflow-wrap: anywhere; }
  #coupons-table-container td:nth-child(5) { grid-column: 3; grid-row: 2; }

  #coupons-table-container td:nth-child(4)::before {
    content: "邀请 ";
    color: var(--text-tertiary);
  }
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.admin-stat-card {
  background: var(--bg-surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-bottom: 4px;
}

.admin-stat-num {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  font-family: ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
}

.coupon-table-box {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-input);
}

.coupon-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.coupon-table th, .coupon-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.coupon-table th {
  background: var(--bg-surface-elevated);
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}

.coupon-table td {
  color: var(--text-primary);
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

.badge-unused {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-used {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
  border: 1px solid rgba(148, 163, 184, 0.25);
}
