:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --bg: #f4f6fa;
  --card: #ffffff;
  --border: #e5e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --green: #16a34a;
  --red: #dc2626;
  --orange: #ea580c;
  --purple: #7c3aed;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }

/* 按钮 */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 14px;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #c7d2e5; background: #f8fafc; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: #fff; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }

/* 登录 */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.login-card {
  background: #fff; border-radius: 12px; padding: 40px 34px; width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}
.login-logo { font-size: 22px; font-weight: 700; text-align: center; }
.login-sub { color: var(--muted); text-align: center; margin: 8px 0 26px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 6px; margin-bottom: 14px; font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--primary); }
.login-err { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

/* 主布局 */
.app-wrap { max-width: 1400px; margin: 0 auto; padding: 0 22px 40px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-name { font-size: 19px; font-weight: 700; }
.badge-test, .badge-game {
  font-size: 12px; padding: 3px 9px; border-radius: 20px; font-weight: 600;
}
.badge-test { background: #fef3c7; color: #b45309; }
.badge-game { background: #dbeafe; color: #1d4ed8; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.write-flag { font-size: 12px; color: var(--orange); background: #fff7ed; padding: 5px 10px; border-radius: 6px; }

/* 统计卡片 */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 22px; font-weight: 700; }
.stat-card.total .stat-value { color: var(--primary); }

/* 工具栏 */
.toolbar {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar-left, .toolbar-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-box input {
  width: 380px; max-width: 60vw; padding: 9px 14px; border: 1px solid var(--border);
  border-radius: 6px; font-size: 14px;
}
.search-box input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
.search-box { display: flex; flex-direction: column; gap: 4px; }
.search-hint { font-size: 12px; color: var(--muted); }
select {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; font-size: 14px; cursor: pointer;
}

/* 表格 */
.table-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; box-shadow: var(--shadow); min-height: 200px; position: relative;
}
table { width: 100%; border-collapse: collapse; }
thead th {
  background: #f8fafc; text-align: left; padding: 13px 14px; font-weight: 600;
  font-size: 13px; color: #475569; border-bottom: 1px solid var(--border);
}
tbody td { padding: 12px 14px; border-bottom: 1px solid #f1f4f9; font-size: 13.5px; }
tbody tr:hover { background: #f8faff; }
.num { text-align: right; }
td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.op-col { width: 150px; }

/* 状态标签 */
.status-tag { padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; display: inline-block; }
.s1 { background: #f1f5f9; color: #475569; }
.s2 { background: #fef9c3; color: #a16207; }
.s3 { background: #dcfce7; color: #15803d; }
.s4 { background: #ede9fe; color: #6d28d9; }
.s5 { background: #e0f2fe; color: #0369a1; }
.s6 { background: #ffedd5; color: #c2410c; }
.s7 { background: #fee2e2; color: #b91c1c; }
.s8 { background: #f3f4f6; color: #6b7280; }

/* 本地标记 */
.mark-tag { font-size: 12px; padding: 2px 8px; border-radius: 5px; }
.m-star { background: #fef3c7; color: #b45309; }
.m-flag { background: #e0e7ff; color: #4338ca; }
.m-green { background: #dcfce7; color: #15803d; }
.m-red { background: #fee2e2; color: #b91c1c; }
.note-dot { color: var(--primary); margin-left: 4px; cursor: help; }

.loading, .empty { text-align: center; padding: 50px; color: var(--muted); }

/* 分页 */
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; flex-wrap: wrap; gap: 10px; }
.page-info { color: var(--muted); font-size: 13px; }
.page-controls { display: flex; gap: 8px; align-items: center; }
.page-num { font-weight: 600; padding: 0 6px; }
button:disabled { opacity: .45; cursor: not-allowed; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 12px; width: 560px; max-width: 100%;
  max-height: 90vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-lg { width: 860px; }
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px;
}
.modal-close { border: none; background: none; font-size: 24px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-tabs { display: flex; gap: 4px; padding: 12px 22px 0; }
.modal-tab {
  border: none; background: none; padding: 8px 14px; cursor: pointer;
  border-bottom: 2px solid transparent; color: var(--muted); font-size: 14px;
}
.modal-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.detail-grid { display: grid; grid-template-columns: 130px 1fr; gap: 10px 14px; }
.detail-grid .k { color: var(--muted); }
.detail-grid .v { word-break: break-all; }
.detail-section { font-weight: 700; margin: 18px 0 10px; padding-left: 10px; border-left: 3px solid var(--primary); }
.detail-section:first-child { margin-top: 0; }
pre.raw-json { background: #f8fafc; padding: 14px; border-radius: 8px; font-size: 12px; overflow: auto; max-height: 55vh; }
pre.desc-text { white-space: pre-wrap; word-break: break-word; background: #f8fafc; padding: 14px; border-radius: 8px; font-size: 13px; line-height: 1.7; max-height: 45vh; overflow: auto; font-family: inherit; }
.empty-tip { color: var(--muted); padding: 30px 0; text-align: center; }
.raw-details { margin-top: 22px; }
.raw-details summary {
  cursor: pointer; color: var(--primary); font-size: 13px; padding: 8px 0;
  user-select: none;
}
.raw-details[open] summary { margin-bottom: 8px; }

.mark-tip { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.field-label { display: block; font-weight: 600; margin: 12px 0 6px; }
#mark-select, #mark-note { width: 100%; }
#mark-note { border: 1px solid var(--border); border-radius: 6px; padding: 10px; font-family: inherit; resize: vertical; }

/* Toast */
.toast {
  position: fixed; top: 26px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 20px; border-radius: 8px;
  z-index: 200; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

/* 账号图片网格 */
.img-gallery {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.img-thumb {
  position: relative; aspect-ratio: 16 / 10; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--border); background: #f8fafc; cursor: zoom-in;
}
.img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s; }
.img-thumb:hover img { transform: scale(1.05); }
.img-thumb.img-broken::after {
  content: "图片加载失败"; position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center; color: var(--muted); font-size: 12px;
}
@media (max-width: 720px) { .img-gallery { grid-template-columns: repeat(2, 1fr); } }

/* 灯箱 */
.lightbox {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .88); z-index: 300;
  display: flex; align-items: center; justify-content: center;
}
.lightbox img {
  max-width: 88vw; max-height: 86vh; object-fit: contain; border-radius: 6px;
  box-shadow: 0 12px 48px rgba(0,0,0,.5);
}
.lb-close {
  position: absolute; top: 18px; right: 28px; border: none; background: none;
  color: #fff; font-size: 40px; cursor: pointer; line-height: 1;
}
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%); border: none;
  background: rgba(255,255,255,.12); color: #fff; font-size: 46px; cursor: pointer;
  width: 60px; height: 80px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.lb-nav:hover { background: rgba(255,255,255,.25); }
.lb-prev { left: 24px; }
.lb-next { right: 24px; }
.lb-count {
  position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
  color: #fff; font-size: 14px; background: rgba(255,255,255,.12); padding: 6px 16px; border-radius: 20px;
}

/* 账号编辑表单 */
.modal-sm { width: 480px; }
.edit-num-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
}
.edit-num label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.edit-num input {
  width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px;
  font-size: 14px;
}
.edit-num input:focus { outline: none; border-color: var(--primary); }
.edit-descs {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: inherit; font-size: 13px; line-height: 1.7; resize: vertical;
}
.edit-note {
  margin-top: 14px; background: #f1f5f9; color: var(--muted); font-size: 12.5px;
  padding: 10px 12px; border-radius: 8px; line-height: 1.6;
}
.edit-warn:empty { display: none; }
.edit-warn {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px;
}

/* 确认写回 */
.change-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  border-bottom: 1px solid #f1f4f9; font-size: 13.5px;
}
.change-label { font-weight: 600; min-width: 90px; }
.change-from { color: var(--muted); }
.change-to { color: #15803d; font-weight: 700; }
.confirm-tip {
  margin-top: 14px; background: #fffbeb; border: 1px solid #fde68a; color: #92400e;
  padding: 10px 12px; border-radius: 8px; font-size: 12.5px; line-height: 1.6;
}

/* ===== 新增数据按钮 ===== */
.btn-add { background: #0ea5e9; border-color: #0ea5e9; color: #fff; font-weight: 600; }
.btn-add:hover { background: #0284c7; border-color: #0284c7; }

/* ===== 动态表单 ===== */
.edit-form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ef-item label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.ef-item input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 9px 10px; font-size: 14px; }
.ef-item input:focus { outline: none; border-color: var(--primary); }

.ef-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; padding: 9px 0; border-bottom: 1px solid #f1f4f9; }
.ef-label { color: var(--muted); font-size: 13px; padding-top: 8px; }
.ef-ctl select, .ef-ctl input[type=text], .ef-ctl input[type=number] { width: 100%; }
.ef-ctl input[type=number], .ef-ctl input[type=text] { border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; font-size: 14px; }
.ef-ctl input:focus, .ef-ctl select:focus { outline: none; border-color: var(--primary); }

/* 复选框组 */
.cb-box { display: flex; flex-wrap: wrap; gap: 8px 16px; border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; max-height: 150px; overflow-y: auto; background: #fcfdff; }
.cb-item { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.cb-item input { cursor: pointer; }

/* ===== 上传块 ===== */
.up-block { border: 1px solid var(--border); border-radius: 8px; padding: 12px; margin-bottom: 14px; background: #fcfdff; }
.up-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.up-head b { font-size: 13.5px; }
.up-list { display: flex; flex-wrap: wrap; gap: 10px; }
.up-item { position: relative; width: 110px; height: 82px; border-radius: 6px; overflow: hidden; border: 1px solid var(--border); background: #f1f5f9; }
.up-item img, .up-item video { width: 100%; height: 100%; object-fit: cover; }
.up-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: none; border-radius: 50%; background: rgba(220,38,38,.92); color: #fff; font-size: 14px; line-height: 1; cursor: pointer; }

/* ===== 流水 ===== */
.flow-tip { font-size: 12.5px; color: var(--muted); background: #f1f5f9; padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; }
.flow-row { display: flex; gap: 10px; align-items: flex-end; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.flow-row label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 110px; }
.flow-row input { border: 1px solid var(--border); border-radius: 6px; padding: 7px 9px; font-size: 13px; }
.flow-row input:focus { outline: none; border-color: var(--primary); }

@media (max-width: 720px) {
  .edit-form-grid { grid-template-columns: 1fr; }
  .ef-row { grid-template-columns: 1fr; gap: 6px; }
}
