:root {
  --bg: #f7f7fb;
  --card: #ffffff;
  --line: #e4e7ee;
  --text: #1f2937;
  --muted: #6b7280;
  --brand: #2563eb;
  --danger: #dc2626;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff, var(--bg));
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
.app {
  max-width: 1280px;
  margin: 0 auto;
  min-height: 100%;
  padding: 12px 12px 84px;
}
.top { padding: 4px 2px 10px; }
.title { font-size: 20px; font-weight: 800; }
.sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(17,24,39,0.06);
  padding: 12px;
  margin-bottom: 10px;
}
.cardTitle { font-weight: 800; margin-bottom: 10px; }
.row {
  display: flex; gap: 8px; align-items: center;
  margin-bottom: 8px; flex-wrap: wrap;
}
input, textarea {
  border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 14px; background: #fff;
}
input:not([type="checkbox"]):not([type="radio"]):not([style*="width"]) { width: 100%; }
textarea { width: 100%; }
label { font-size: 13px; color: var(--muted); white-space: nowrap; }
button {
  border: 1px solid #c7d2fe; background: #e0e7ff; color: #1e3a8a;
  border-radius: 8px; padding: 8px 12px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
button.secondary { border-color: #d1d5db; background: #f3f4f6; color: #374151; }
button.danger { border-color: #fecaca; background: #fee2e2; color: var(--danger); }
button:disabled, button.disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.result {
  margin: 0; margin-top: 6px; padding: 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: #f9fafb; min-height: 36px; max-height: 320px;
  overflow: auto; font-size: 12px; line-height: 1.45;
}
.bottomNav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255,255,255,0.96); border-top: 1px solid var(--line); padding: 8px;
}
.bottomNav .inner {
  max-width: 820px; margin: 0 auto;
  display: flex; gap: 6px; overflow-x: auto;
}
.featureBtn {
  border: 1px solid #dbeafe; background: #eff6ff; color: #1d4ed8;
  border-radius: 999px; padding: 8px 12px; white-space: nowrap; font-size: 12px;
}
.featureBtn.active { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.featureBtn.danger { border-color: #fecaca; background: #fee2e2; color: var(--danger); }

.issueMeta {
  border: 1px dashed var(--line); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; color: var(--muted); margin-bottom: 10px;
}

/* 资料分区样式 */
.materialSection {
  margin-bottom: 16px;
}

.materialSection .sectionTitle {
  font-weight: 700;
  font-size: 15px;
  padding: 10px 12px;
  background: #f3f4f6;
  border-radius: 8px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none;
}

.materialSection .sectionTitle:hover {
  background: #e5e7eb;
}

#imageRuleCards {
  opacity: 1;
}

#imageRuleCards.collapsed {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
}

#imageToggleIcon {
  transition: transform 0.3s ease;
}

#imageRuleCards.collapsed + .sectionTitle #imageToggleIcon,
#imageToggleIcon.collapsed {
  transform: rotate(-90deg);
}
.ruleHintLine {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
  line-height: 1.3;
}

/* 文字资料渲染视图样式 */
.ruleRenderView {
  padding: 12px;
  background: #f9fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 60px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 文字资料编辑视图样式 */
.ruleEditView {
  margin-bottom: 10px;
}

/* 渲染视图中的分段样式（匹配首页） */
.ruleRenderView .matContent {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: baseline;
}

.ruleRenderView .matSeg {
  display: inline;
  white-space: pre-wrap;
}
.btnSm {
  border: 1px solid #d1d5db; background: #f3f4f6; color: #374151;
  border-radius: 6px; padding: 4px 8px; font-size: 12px;
  font-weight: 700; cursor: pointer; white-space: nowrap;
}
.btnSm.primary {
  border-color: #c7d2fe; background: #e0e7ff; color: #1e3a8a;
}

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 10px; font-size: 14px; font-weight: 700;
  z-index: 9999; pointer-events: none;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 1.9s;
}
.toastOk { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.toastErr { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%,-12px); } to { opacity: 1; transform: translate(-50%,0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

.modalOverlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 8000;
  display: flex; align-items: center; justify-content: center;
}
.modalBox {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  width: 96%; max-width: 920px;
  max-height: 80vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modalHead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.modalHead b { font-size: 15px; }
.modalBody {
  flex: 1; overflow-y: auto;
  padding: 10px 14px;
  font-size: 13px;
}
.modalFoot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px 14px 14px;
  border-top: 1px solid var(--line);
}

/* ===== 共享表单样式（平台配置、运维等页面通用） ===== */
.platformForm {
  padding: 16px 0;
}

.platformFormRow {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}

.platformFormRow label {
  width: 100px;
  flex-shrink: 0;
  font-weight: 500;
  color: #333;
}

.platformFormRow input[type="text"],
.platformFormRow input[type="number"] {
  flex: 1;
  max-width: 400px;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
}

.platformFormRow input[type="text"]:focus,
.platformFormRow input[type="number"]:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.platformFormRow .hint {
  color: #999;
  font-size: 12px;
}

.platformFormSection {
  margin: 20px 0;
  padding: 16px;
  background: #f8f9fa;
  border-radius: 8px;
}

.sectionTitle {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 12px;
}

/* ===== 共享开关样式 ===== */
.switchLabel {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  cursor: pointer;
}

.switchLabel input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switchSlider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}

.switchSlider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.switchLabel input:checked + .switchSlider {
  background-color: #667eea;
}

.switchLabel input:checked + .switchSlider:before {
  transform: translateX(22px);
}

/* ===== 共享弹窗样式（platformForm 系列弹窗，区别于 modalOverlay/modalBox） ===== */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal.show {
  display: flex;
}

.modalContent {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modalHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e9ecef;
}

.modalTitle {
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.modalClose {
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.modalClose:hover {
  color: #333;
}

.modalContent .modalBody {
  padding: 20px;
}

.modalFooter {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid #e9ecef;
}

.modalFooter button {
  flex: 1;
  padding: 12px 20px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modalFooter button.primary {
  background: #667eea;
  color: white;
}

.modalFooter button.primary:hover {
  background: #5a6fd6;
}

.modalFooter button.secondary {
  background: #f8f9fa;
  color: #333;
  border: 1px solid #ddd;
}

.modalFooter button.secondary:hover {
  background: #e9ecef;
}

.imgMatAssetsPathLabel {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.imgMatAssetsHint {
  font-size: 12px;
  color: var(--muted);
}
.imgMatAssetsTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.imgMatAssetsTable th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-weight: 500;
}
.imgMatAssetsTable td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f0f0;
}
.imgMatAssetsTable tr.imgMatAssetsRow {
  cursor: pointer;
}
.imgMatAssetsTable tr.imgMatAssetsRow:hover {
  background: #f5f5f5;
}
.imgMatAssetsTable tr.imgMatAssetsSel {
  background: #e0e7ff;
}
.imgMatAssetsTable tr.imgMatAssetsSel td {
  font-weight: 500;
}

.siteSelectorWrap {
  margin-right: 8px;
  flex-shrink: 0;
}
.siteSelector {
  border: 1px solid #c7d2fe;
  background: #e0e7ff;
  color: #1e3a8a;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  max-width: 200px;
}
.siteSelector:focus {
  border-color: #1d4ed8;
}
.siteSelector:hover {
  background: #c7d2fe;
}

/* ===== 移动端适配（手机/平板，所有后台页面共享） ===== */
@media (max-width: 768px) {
  /* 禁止页面级水平滚动条（底部导航栏内部可独立滚动） */
  html, body { overflow-x: hidden; }

  /* 整体布局：减少内边距 */
  .app { padding: 8px 8px 84px; max-width: 100%; }
  .card { padding: 10px; }
  .cardTitle { font-size: 15px; }

  /* 弹窗：覆盖所有弹窗类的固定/最大宽度，确保不超出屏幕 */
  .modalBox { width: 96% !important; max-width: 96% !important; max-height: 88vh; }
  .paymentModalContent { width: 96% !important; max-width: 96% !important; }
  .modal-content { max-width: 95% !important; width: 95% !important; }
  .edit-modal-content { max-width: 95% !important; width: 95% !important; }
  .modalContent { max-width: 95% !important; width: 95% !important; }
  /* 内联样式弹窗：通过属性选择器覆盖固定宽度 */
  div[style*="max-width:600px"],
  div[style*="max-width:700px"],
  div[style*="max-width:720px"],
  div[style*="max-width:800px"],
  div[style*="max-width:900px"],
  div[style*="max-width:920px"],
  div[style*="max-width:960px"],
  div[style*="max-width:1100px"] { max-width: 95% !important; }
  div[style*="width:480px"] { width: 95% !important; max-width: 95% !important; }
  /* 内联固定宽度输入框：移动端不超过屏幕 */
  input[style*="width:300px"],
  input[style*="width:200px"] { width: 100% !important; max-width: 100%; }

  /* 表格：所有表格在移动端支持水平滚动 */
  .playerTableWrapper,
  .tableWrapper,
  .imgMatAssetsTable {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* 无包裹容器的表格：自身变为可滚动块（!important 覆盖内联 display:table） */
  .playerTable,
  .recordTable,
  .audit-table,
  .agentTable,
  .detailTable,
  .stats-table,
  .ms-tier-table,
  .ms-logs-table {
    display: block !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* flex 行：确保所有 flex 容器在移动端允许换行 */
  .paymentFormRowInline { flex-wrap: wrap; }
  .paymentChannelActions { flex-wrap: wrap; }
  .detailHeader { flex-wrap: wrap; gap: 8px; }
  .tabNav { flex-wrap: wrap; }
  .tabBar { flex-wrap: wrap; }
  .admin-header { flex-wrap: wrap; gap: 8px; }
  .admin-actions { flex-wrap: wrap; }
  .freezeRow { flex-wrap: wrap; gap: 12px; }

  /* 网格布局：移动端单列 */
  .infoGrid { grid-template-columns: 1fr !important; }
  .bindingList { grid-template-columns: 1fr !important; }
  .paymentTipsGrid { grid-template-columns: 1fr; }

  /* 触控友好：输入框和按钮 */
  input, textarea, select { font-size: 16px; }
  button { min-height: 40px; padding: 8px 12px; }
  .btnSm { min-height: 32px; }
  .featureBtn { min-height: 36px; }

  /* 标签页：紧凑排列 */
  .tabBtn { padding: 8px 12px; font-size: 13px; }

  /* 分页：紧凑 */
  .pagination { flex-wrap: wrap; gap: 4px; }
  .pagination button { padding: 8px 10px; min-height: 36px; }

  /* 底部导航：保持滚动，禁止页面级横向溢出 */
  .bottomNav { overflow: hidden; }
  .bottomNav .inner { gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .featureBtn { padding: 6px 10px; font-size: 11px; }
}

@media (max-width: 480px) {
  /* 手机：进一步紧凑 */
  .app { padding: 6px 6px 80px; }
  .card { padding: 8px; }
  .title { font-size: 18px; }

  /* 标签页：文字缩小 */
  .tabBtn { padding: 6px 10px; font-size: 12px; }

  /* 按钮：等宽排列 */
  .row > button { flex: 1 1 auto; }

  /* 底部导航按钮：更紧凑 */
  .featureBtn { padding: 5px 8px; font-size: 10px; }
}

/* ===== 客服悬浮按钮（所有后台页面共享，仅对有客服权限的管理员显示） ===== */
.csAdminFab {
  position: fixed;
  right: 20px;
  bottom: 80px; /* 高于 bottomNav */
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #1d4ed8;
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(29, 78, 216, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  z-index: 900;
  transition: transform 0.2s;
}
.csAdminFab:hover {
  transform: scale(1.08);
}
.csAdminFabBadge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  line-height: 20px;
  border-radius: 10px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  text-align: center;
  padding: 0 5px;
  border: 2px solid #fff;
  box-sizing: content-box;
}
.csAdminFabBadge:empty { display: none; }

@media (max-width: 768px) {
  .csAdminFab { right: 12px; bottom: 72px; width: 48px; height: 48px; font-size: 13px; }
}
@media (max-width: 480px) {
  .csAdminFab { right: 10px; bottom: 70px; width: 44px; height: 44px; font-size: 12px; }
}
