:root {
  --primary: #5b5fc7;
  --primary-hover: #4a4eb8;
  --secondary: #0078d4;
  --success: #107c10;
  --warning: #ffb900;
  --danger: #d13438;
  --text: #242424;
  --text-secondary: #616161;
  --text-muted: #8a8a8a;
  --border: #e0e0e0;
  --bg: #f5f5f5;
  --bg-card: #ffffff;
  --radius: 8px;
  --shadow: 0 2px 4px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
}

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

/* 隐藏滚动条 */
::-webkit-scrollbar { display: none; }
html, body { scrollbar-width: none; -ms-overflow-style: none; }

body { 
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', sans-serif; 
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

.page { padding: 0 16px 20px; max-width: 480px; margin: 0 auto; }
.page-center { 
  min-height: 100vh; 
  display: flex; 
  align-items: center; 
  justify-content: center;
  padding: 20px;
}

.loading-box { text-align: center; }
.loading-spinner { 
  width: 32px; height: 32px; 
  border: 3px solid var(--border); 
  border-top-color: var(--primary); 
  border-radius: 50%; 
  animation: spin 0.8s linear infinite; 
  margin: 0 auto 12px; 
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box p { color: var(--text-muted); font-size: 13px; }

.auth-card { 
  background: var(--bg-card); 
  border-radius: 12px; 
  padding: 32px 24px; 
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
}
.auth-logo { 
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}
.auth-logo .ip { font-size: 28px; color: #fff; }
.auth-card h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.auth-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 24px; }
.form-group { margin-bottom: 16px; }
.form-group input, .auth-card input { 
  width: 100%; 
  padding: 12px 14px; 
  border: 1px solid var(--border); 
  border-radius: var(--radius); 
  font-size: 14px;
}
.form-group input:focus, .auth-card input:focus { 
  border-color: var(--primary); 
  outline: none; 
  box-shadow: 0 0 0 2px rgba(91,95,199,0.15);
}

.btn { 
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px; 
  border: none; 
  border-radius: var(--radius); 
  font-size: 14px; 
  font-weight: 500;
  cursor: pointer; 
  transition: all 0.15s;
}
.btn .ip { font-size: 16px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-lg { padding: 12px 24px; }
.btn-block { width: 100%; }

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
}
.header-left { display: flex; align-items: center; gap: 8px; }
.header-icon { font-size: 22px; color: var(--primary); }
.header-title { font-size: 17px; font-weight: 600; }
.header-right { font-size: 12px; color: var(--text-muted); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 14px 12px;
  box-shadow: var(--shadow);
}
.stat-header {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-header .ip { font-size: 14px; }
.stat-value { font-size: 18px; font-weight: 600; }
.stat-inline-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
  white-space: nowrap;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.card-title { 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  font-size: 14px; 
  font-weight: 600; 
}
.card-title .ip { font-size: 16px; color: var(--primary); }
.user-id-copy { 
  display: flex; 
  align-items: center; 
  gap: 6px; 
  font-size: 12px; 
  color: var(--text-muted); 
}
.user-id-copy .ip { cursor: pointer; font-size: 14px; }
.user-id-copy .ip:hover { color: var(--primary); }

.recharge-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.recharge-item {
  padding: 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.recharge-item:hover { border-color: var(--primary); }
.recharge-item.active { 
  border-color: var(--primary); 
  background: var(--primary); 
  color: #fff; 
}
.recharge-action {
  display: flex;
  gap: 8px;
}
.recharge-action input {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
}
.recharge-action input:focus { border-color: var(--primary); outline: none; }

.tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 2px;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 3px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.tab .ip { 
  font-size: 15px; 
  flex-shrink: 0;
  line-height: 1;
}
.tab span {
  font-size: 10px;
  line-height: 1.2;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  display: block;
}
.tab.active { background: var(--primary); color: #fff; }

.panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.sub-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 16px;
}
.sub-tab {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  border-radius: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.sub-tab.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow); }

.form-section { margin-bottom: 16px; }
.section-label { 
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px; 
  font-weight: 500; 
  color: var(--text-secondary); 
  margin-bottom: 10px; 
}
.section-label .ip { font-size: 14px; }

.options-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.option {
  padding: 12px 10px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.option:hover { border-color: var(--primary); }
.option.active { border-color: var(--primary); background: var(--primary); color: #fff; }
.option .name { font-size: 13px; font-weight: 500; }
.option .price { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.option.active .price { color: rgba(255,255,255,0.8); }

.custom-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  background: var(--bg);
  border-radius: 6px;
}
.custom-row input {
  width: 80px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 13px;
}
.custom-row input:focus { border-color: var(--primary); outline: none; }
.price-display { font-size: 14px; font-weight: 600; color: var(--primary); }

.result-box {
  background: var(--success);
  border-radius: 6px;
  padding: 14px;
  margin-bottom: 14px;
  color: #fff;
}
.result-header { 
  display: flex; 
  align-items: center; 
  gap: 5px; 
  font-size: 12px; 
  margin-bottom: 8px;
  opacity: 0.9;
}
.result-content { 
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  font-size: 15px;
  font-weight: 600;
}
.result-content button {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.2);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}
.result-content button:hover { background: rgba(255,255,255,0.3); }

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 14px;
}
.search-bar .ip { color: var(--text-muted); font-size: 16px; }
.search-bar input {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  font-size: 13px;
}
.search-bar input:focus { outline: none; }
.search-bar button {
  padding: 6px 12px;
  background: var(--primary);
  border: none;
  border-radius: 4px;
  color: #fff;
  font-size: 12px;
  cursor: pointer;
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  padding: 4px;
  background: var(--bg);
  border-radius: 6px;
}
.filter-bar.filter-bar-wrap {
  flex-wrap: wrap;
}
.filter-bar.filter-bar-wrap .filter-item {
  flex: 0 1 auto;
  min-width: 72px;
  white-space: nowrap;
}
.filter-item {
  flex: 1;
  padding: 8px 12px;
  text-align: center;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  color: var(--text-secondary);
  background: transparent;
}
.group-type-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  color: var(--primary);
  background: rgba(25, 118, 210, 0.1);
  vertical-align: middle;
}
.filter-item.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

.stats-row {
  display: flex;
  justify-content: center;
  gap: 40px;
  padding: 14px;
  background: var(--bg);
  border-radius: 6px;
  margin-bottom: 14px;
}
.stat-item { text-align: center; }
.stat-num { display: block; font-size: 22px; font-weight: 600; color: var(--primary); }
.stat-num.warn { color: var(--danger); }
.stat-label { font-size: 12px; color: var(--text-muted); }

.list { 
  margin-bottom: 14px; 
  min-height: 100px; 
  max-height: 60vh; 
  overflow-y: auto; 
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 24px; /* 底部留白，小屏滚动到底时最后一项按钮不被遮挡 */
}
.list::-webkit-scrollbar {
  width: 6px;
}
.list::-webkit-scrollbar-track {
  background: transparent;
  border-radius: 3px;
}
.list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 3px;
}
.list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
}
.list-item {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  position: relative;
  transition: all 0.15s;
}
.list-item.used { 
  opacity: 1;
  background: #f3f4f6 !important;
  border-color: #c5c7cb !important;
  border-left: 4px solid #9aa0a6 !important;
  position: relative;
}
#code-list .list-item:not(.used),
.agent-group-tree-groups .list-item:not(.used) {
  border-left: 4px solid #16a34a;
}
.list-item.used::before {
  content: none !important;
  display: none !important; /* 去掉中间横线，避免「半截显示」看不清 */
}
.list-item.used .code {
  text-decoration: none;
  color: #6b7280;
  position: relative;
  z-index: 2;
}
.list-item.used .code .card-key-text {
  text-decoration: line-through;
  text-decoration-color: #9aa0a6;
  opacity: 0.85;
}
.list-item.used .code .btn-copy {
  position: relative;
  z-index: 10;
  pointer-events: auto;
}
.list-item.used .info {
  color: #6b7280;
  position: relative;
  z-index: 2;
}
.code-status-filters {
  display: flex;
  gap: 8px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.code-status-filters .chip {
  border: 1px solid var(--border, #e5e7eb);
  background: #fff;
  color: #374151;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
}
.code-status-filters .chip.active {
  background: var(--primary, #2563eb);
  border-color: var(--primary, #2563eb);
  color: #fff;
}
.badge-used {
  display: inline-block;
  background: #6b7280;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 8px;
  vertical-align: middle;
}
.badge-unused {
  display: inline-block;
  background: #16a34a;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin-right: 8px;
  vertical-align: middle;
}
.list-item.expired {
  border-color: var(--danger);
  border-width: 2px;
  background: #fff5f5;
  box-shadow: 0 0 0 2px rgba(209, 52, 56, 0.1);
}
.list-item.expired .code {
  color: var(--danger);
}
.expired-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: var(--danger);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 2px 4px rgba(209, 52, 56, 0.3);
}
.expired-badge .ip {
  font-size: 12px;
}
.list-item .code {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}
.list-item .info { font-size: 12px; color: var(--text-muted); line-height: 1.7; }
.list-item .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.list-item .actions button {
  padding: 6px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.list-item .actions button:hover { border-color: var(--primary); color: var(--primary); }
/* 小屏下群列表操作区可换行、底部可滚动，避免「切换机器人」等按钮被遮挡 */
@media (max-width: 480px) {
  .list-item .actions button { padding: 6px 8px; font-size: 11px; }
  .list { padding-bottom: 32px; max-height: 65vh; }
  .pagination { margin-bottom: env(safe-area-inset-bottom, 16px); }
}
.btn-copy {
  padding: 4px 10px;
  background: #4caf50;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  color: #fff;
  cursor: pointer;
  position: relative;
  z-index: 10; /* 确保按钮始终在最上层 */
  pointer-events: auto; /* 确保按钮可以点击 */
  transition: all 0.2s;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.btn-copy:hover { 
  background: #45a049; 
  transform: scale(1.05);
  box-shadow: 0 2px 4px rgba(76, 175, 80, 0.3);
}
.btn-copy:active {
  transform: scale(0.98);
}

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}
.pagination button {
  width: 32px; height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}
.pagination button:hover { border-color: var(--primary); color: var(--primary); }
.pagination button .ip { font-size: 18px; }
.pagination span { font-size: 13px; color: var(--text-muted); }

/* 批量更换机器人弹窗内折叠区块 */
.batch-collapse-section {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fafafa;
}
.batch-collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.batch-collapse-header:hover { background: #f0f0f0; }
.batch-collapse-header .batch-collapse-arrow { color: var(--text-muted); flex-shrink: 0; }
.batch-collapse-open .batch-collapse-arrow { transform: rotate(0deg); }
.batch-collapse-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
}

.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-mask {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
}
.modal-box {
  position: relative;
  background: var(--bg-card);
  border-radius: 10px;
  width: 100%;
  max-width: 320px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 600;
}
.modal-header .ip { font-size: 20px; color: var(--text-muted); cursor: pointer; }
.modal-header .ip:hover { color: var(--text); }
.modal-body {
  padding: 16px;
  max-height: 70vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sub-price-modal {
  max-width: 400px !important;
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sub-price-modal .modal-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
}
.sub-price-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  line-height: 1.55;
}
.sub-price-search-wrap {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-card);
  padding-bottom: 10px;
  margin-bottom: 4px;
}
.sub-price-search {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px;
  background: #f7f8fa;
}
.sub-price-search:focus {
  border-color: var(--primary);
  outline: none;
  background: #fff;
}
.sub-price-search-meta {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.sub-price-list {
  padding-bottom: 8px;
}
.sub-ratio-row {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--bg-card);
}
.sub-ratio-row .sub-id {
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
  margin-bottom: 10px;
}
.sub-field {
  margin-bottom: 10px;
}
.sub-field:last-child { margin-bottom: 0; }
.sub-field-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.sub-field-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.sub-field-row input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 16px; /* 避免 iOS 聚焦放大 */
  box-sizing: border-box;
}
.sub-field-row .unit {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.sub-field-row .btn-save-field {
  flex-shrink: 0;
  padding: 0 14px;
  min-width: 64px;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.modal-body input {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}
.modal-body input:focus { border-color: var(--primary); outline: none; }

.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 13px;
  color: #fff;
  z-index: 2000;
  animation: fadeIn 0.2s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }
@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-8px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.empty { text-align: center; padding: 30px; color: var(--text-muted); font-size: 13px; }

.sales-hint { font-size: 12px; color: var(--text-muted); margin: 0 0 12px; line-height: 1.5; }
.sales-range-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 10px;
}
.sales-preset-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.sales-preset {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  border-radius: 16px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.sales-preset.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.sales-range-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sales-range-btn {
  flex: 1;
  min-width: 0;
  text-align: left;
  border: 1px solid var(--border);
  background: #fafafa;
  border-radius: var(--radius);
  padding: 8px 10px;
  cursor: pointer;
}
.sales-range-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.sales-range-value {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.sales-range-sep {
  color: var(--text-muted);
  font-size: 13px;
  flex: 0 0 auto;
}
.sales-query-btn {
  flex: 0 0 auto;
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.sales-range-tag {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.sales-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sales-table th, .sales-table td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--border); }
.sales-table th { color: var(--text-secondary); font-weight: 500; background: #fafafa; }
.sales-table td.ym { text-align: left; color: var(--text); font-weight: 500; }
.sales-table tfoot td { font-weight: 600; border-bottom: none; background: #fafafa; }

.sales-sheet {
  position: fixed;
  inset: 0;
  z-index: 3000;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sales-sheet-panel {
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 14px 14px 0 0;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
}
.sales-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.sales-sheet-close {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
}
.sales-sheet-list {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 20px;
}
.sales-sheet-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 14px 18px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid #f2f2f2;
}
.sales-sheet-item.active {
  color: var(--primary);
  font-weight: 600;
  background: #f5f6ff;
}

/* 代理设置样式 */
.agent-info {
  padding: 0;
}
.info-item {
  display: flex;
  align-items: center;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  transition: all 0.15s;
}
.info-item:last-child {
  border-bottom: none;
}
.info-item:hover {
  background: var(--bg);
  border-radius: 6px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}
.info-item .ip {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  color: #fff;
  font-size: 20px;
  margin-right: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91, 95, 199, 0.2);
}
.info-content {
  flex: 1;
  min-width: 0;
}
.info-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.info-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}
.btn-copy-small {
  padding: 8px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s;
  flex-shrink: 0;
}
.btn-copy-small:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(91, 95, 199, 0.3);
}
.btn-copy-small .ip {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  margin: 0;
  background: transparent !important;
  box-shadow: none !important;
  width: 1em !important;
  height: 1em !important;
  min-width: 1em;
  min-height: 1em;
  border-radius: 0 !important;
  color: inherit;
}

.setting-item {
  display: flex;
  align-items: center;
  padding: 16px 0;
  cursor: pointer;
  transition: all 0.15s;
  border-bottom: 1px solid var(--border);
}
.setting-item:last-child {
  border-bottom: none;
}
.setting-item:hover {
  background: var(--bg);
  border-radius: 6px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}
.setting-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 10px;
  color: #fff;
  font-size: 20px;
  margin-right: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(91, 95, 199, 0.2);
}
.setting-content {
  flex: 1;
  min-width: 0;
}
.setting-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
}
.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.setting-value {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  margin-right: 10px;
  flex-shrink: 0;
}
.setting-arrow {
  font-size: 20px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* 下级代理群 — 多级树状 */
.agent-group-tree-root {
  padding-bottom: 8px;
}
.agent-group-tree-node {
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}
.agent-group-tree-node > .agent-group-tree-summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: linear-gradient(135deg, rgba(91, 95, 199, 0.08), rgba(0, 120, 212, 0.06));
  display: flex;
  align-items: center;
  gap: 8px;
}
.agent-group-tree-node > .agent-group-tree-summary::-webkit-details-marker {
  display: none;
}
.agent-group-tree-node > .agent-group-tree-summary::before {
  content: '';
  width: 0;
  height: 0;
  border-left: 5px solid var(--text-muted);
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transform: rotate(0deg);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.agent-group-tree-node:not([open]) > .agent-group-tree-summary::before {
  transform: rotate(-90deg);
}
.agent-group-tree-body {
  padding: 0 0 10px;
  border-top: 1px solid var(--border);
}
.agent-group-tree-groups {
  padding: 10px 12px 0;
}
.agent-group-tree-groups .list-item {
  margin-bottom: 8px;
}
.agent-group-tree-children {
  padding: 4px 0 4px 12px;
  margin-left: 8px;
  border-left: 2px solid var(--border);
}
/* 下级代理块在上方时，与下方群/激活码列表分隔 */
.agent-group-tree-children-first {
  margin-bottom: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.agent-group-tree-children .agent-group-tree-node {
  background: #fafbff;
}
.agent-group-tree-meta {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}
