/* 游戏中台运营后台：浅色为主，跟随系统暗色；窄屏菜单折叠。 */

:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --text: #1f2430;
  --text-2: #5b6372;
  --text-3: #8a92a0;
  --primary: #2f6bff;
  --primary-hover: #1f58e6;
  --primary-soft: #e8efff;
  --danger: #d9363e;
  --danger-soft: #fdecec;
  --ok: #1f9d55;
  --ok-soft: #e6f6ec;
  --warn: #c27a00;
  --warn-soft: #fff4dc;
  --heat-rgb: 47 107 255;
  --c1: #2f6bff;
  --c2: #17a673;
  --c3: #e5892a;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 18%);
  --radius: 8px;
  --top-h: 52px;
  --side-w: 200px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --panel: #1c1f26;
    --panel-2: #222630;
    --border: #2d323d;
    --border-strong: #3b4250;
    --text: #e6e8ec;
    --text-2: #a7aebb;
    --text-3: #7a8291;
    --primary: #5b8cff;
    --primary-hover: #7aa2ff;
    --primary-soft: #1f2b47;
    --danger: #f0616a;
    --danger-soft: #3a1f23;
    --ok: #3ccf7f;
    --ok-soft: #173326;
    --warn: #f0b23c;
    --warn-soft: #3a2f14;
    --heat-rgb: 91 140 255;
    --c1: #5b8cff;
    --c2: #3ccf9a;
    --c3: #f0a050;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-lg: 0 12px 32px rgb(0 0 0 / 50%);
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code,
.mono {
  font-family: var(--mono);
  font-size: 12.5px;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
}

[hidden] {
  display: none !important;
}

.muted {
  color: var(--text-2);
}
.small {
  font-size: 12px;
}
.ok-text {
  color: var(--ok);
}
.err-text {
  color: var(--danger);
}

/* ---------- 提示条 ---------- */

.flash {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  max-width: min(720px, calc(100vw - 24px));
  padding: 10px 12px 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid transparent;
  font-size: 13.5px;
}
.flash-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}
.flash-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 30%, transparent);
}
.flash-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}
.flash-text {
  flex: 1;
  word-break: break-word;
}
.flash-close {
  border: 0;
  background: none;
  color: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.7;
}

/* ---------- 登录 ---------- */

.login-page {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.login-card {
  width: min(360px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.login-card h1 {
  font-size: 18px;
}
.login-card p {
  margin: 0 0 8px;
}
.login-logo,
.brand-logo {
  display: inline-grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  border-radius: 10px;
}
.login-logo {
  width: 44px;
  height: 44px;
  font-size: 20px;
  margin: 0 auto 4px;
}
.login-err {
  color: var(--danger);
  font-size: 13px;
  text-align: left;
}

/* ---------- 外框 ---------- */

#app {
  height: 100%;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--top-h);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  width: calc(var(--side-w) - 32px);
}
.brand-logo {
  width: 28px;
  height: 28px;
  font-size: 14px;
  border-radius: 7px;
}
.topbar-game {
  display: flex;
  align-items: center;
  gap: 8px;
}
.game-select {
  min-width: 140px;
  font-weight: 500;
}
.topbar-right {
  margin-left: auto;
}
.menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 6px;
  cursor: pointer;
}
.menu-toggle span {
  display: block;
  height: 2px;
  background: var(--text);
  border-radius: 1px;
}

.layout {
  padding-top: var(--top-h);
  height: 100%;
}
.sidebar {
  position: fixed;
  top: var(--top-h);
  bottom: 0;
  left: 0;
  width: var(--side-w);
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px 8px 24px;
  z-index: 40;
}
.nav-group + .nav-group {
  margin-top: 12px;
}
.nav-group-title {
  font-size: 12px;
  color: var(--text-3);
  padding: 4px 12px;
}
.nav-item {
  display: block;
  padding: 7px 12px;
  border-radius: 6px;
  color: var(--text);
}
.nav-item:hover {
  background: var(--panel-2);
  text-decoration: none;
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.main {
  margin-left: var(--side-w);
  min-height: 100%;
}
.page {
  padding: 20px 24px 48px;
  max-width: 1400px;
}
.scrim {
  display: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.page-head h2 {
  font-size: 20px;
}
.page-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.page-actions .field {
  flex-direction: row;
  align-items: center;
}
.page-note {
  margin: -8px 0 12px;
}

/* ---------- 卡片 ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  min-width: 0;
}
.card-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 {
  font-size: 14.5px;
}
.card-body {
  padding: 16px;
}
.card-body > * + * {
  margin-top: 12px;
}
.card-body > .table-wrap:only-child {
  margin: -16px;
  border: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}
.card:not(:has(.card-head)) .card-body > .table-wrap:only-child {
  border-radius: var(--radius);
}
.sub-title {
  font-size: 13.5px;
  margin-top: 20px !important;
}

/* ---------- 总览 ---------- */

.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.game-card {
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.game-card:hover {
  border-color: var(--border-strong);
}
.game-card.current {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}
.game-card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
}
.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px 8px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-2);
}
.stat-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.chart-grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.chart-grid-3 .card {
  margin-bottom: 0;
}

/* ---------- 图表 ---------- */

.chart-wrap {
  position: relative;
}
.chart {
  width: 100%;
  height: auto;
  display: block;
}
.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}
.chart-tick {
  fill: var(--text-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
}
.chart-area {
  opacity: 0.12;
}
.chart-dot {
  fill: var(--panel);
  stroke-width: 2;
}
.chart-bar {
  opacity: 0.85;
}
.chart-bar:hover {
  opacity: 1;
}
.chart-hit {
  fill: transparent;
}
.chart-tip {
  position: absolute;
  pointer-events: none;
  background: var(--text);
  color: var(--panel);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ---------- 表格 ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.table th,
.table td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: var(--panel-2);
  color: var(--text-2);
  font-weight: 500;
  font-size: 12.5px;
  white-space: nowrap;
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr:hover td {
  background: var(--panel-2);
}
.table tr.clickable {
  cursor: pointer;
}
.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table .actions-col {
  white-space: nowrap;
}
.empty-cell {
  text-align: center !important;
  color: var(--text-3);
  padding: 28px 12px !important;
}
.bar-col {
  width: 30%;
  min-width: 120px;
}
.bar-track {
  height: 8px;
  background: var(--panel-2);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar-fill {
  height: 100%;
  background: var(--primary);
}
.heat {
  display: inline-block;
  min-width: 64px;
  padding: 2px 8px;
  border-radius: 4px;
  text-align: right;
  background: rgb(var(--heat-rgb) / calc(0.08 + var(--heat) * 0.8));
}
.heat.heat-strong {
  color: #fff;
}
.props-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 480px;
}
.props-cell code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-text {
  word-break: break-word;
}

/* ---------- 表单 ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.toolbar .field {
  min-width: 180px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}
.field-label {
  font-size: 12.5px;
  color: var(--text-2);
  font-weight: 500;
}
.field-hint {
  font-size: 12px;
  color: var(--text-3);
}
.input {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 7px 10px;
  min-height: 34px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus,
.code-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 20%, transparent);
}
.input:disabled {
  background: var(--panel-2);
  color: var(--text-3);
}
textarea.input {
  resize: vertical;
  line-height: 1.5;
}
select.input {
  padding-right: 28px;
}
.radio-row {
  display: flex;
  gap: 20px;
}
.radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.reward-editor {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}
.reward-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.reward-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.reward-row .reward-kind {
  flex: 1 1 200px;
  min-width: 0;
}
.reward-row .reward-num {
  width: 110px;
  flex: 0 0 110px;
}

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font: inherit;
  font-weight: 500;
  min-height: 34px;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none !important;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover {
  background: var(--panel-2);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-danger {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.btn-danger:hover {
  background: var(--danger-soft);
}
.modal-foot .btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
}
.btn-ghost:hover {
  background: var(--primary-soft);
}
.btn-sm {
  min-height: 28px;
  padding: 3px 10px;
  font-size: 12.5px;
}
.btn-block {
  width: 100%;
}
.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- 徽标 ---------- */

.badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--panel-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.badge-primary {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: transparent;
}
.badge-ok {
  background: var(--ok-soft);
  color: var(--ok);
  border-color: transparent;
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: transparent;
}
.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

/* ---------- 键值列表 ---------- */

.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  margin: 0;
}
.kv dt {
  color: var(--text-2);
}
.kv dd {
  margin: 0;
  word-break: break-all;
}
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 32px;
}

/* ---------- 空状态 ---------- */

.loading,
.empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-3);
}
.empty {
  background: var(--panel);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.empty-title {
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}
.empty.notimpl {
  border-color: color-mix(in srgb, var(--warn) 50%, var(--border));
  background: color-mix(in srgb, var(--warn-soft) 50%, var(--panel));
}
.empty.notimpl .empty-title {
  color: var(--warn);
}
.empty.error .empty-title {
  color: var(--danger);
}

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin: -4px 0 16px;
}
.pager:empty {
  display: none;
}

/* ---------- JSON ---------- */

.json-view {
  margin: 0;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow: auto;
  max-height: 420px;
  white-space: pre;
}
.code-editor {
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  overflow: hidden;
  background: var(--panel);
}
.code-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.code-status {
  margin-left: 4px;
  word-break: break-word;
}
.code-area {
  display: flex;
  position: relative;
}
.code-gutter {
  flex: 0 0 auto;
  min-width: 44px;
  padding: 10px 8px 10px 0;
  text-align: right;
  color: var(--text-3);
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  overflow: hidden;
  user-select: none;
}
.code-gutter > div {
  padding-left: 8px;
}
.code-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  resize: vertical;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--text);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
}

/* ---------- 弹窗 ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgb(10 14 22 / 45%);
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
}
.modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.modal-wide {
  width: min(820px, 100%);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  font-size: 15px;
}
.modal-x {
  border: 0;
  background: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-2);
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
}
.modal-body p {
  margin: 0;
}
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.modal-body > .form > .btn-row:last-child:has(button[type='submit']) {
  justify-content: flex-end;
}

/* ---------- 窄屏 ---------- */

@media (max-width: 860px) {
  .menu-toggle {
    display: flex;
  }
  .brand {
    width: auto;
  }
  .hide-sm,
  .brand-text {
    display: none;
  }
  .topbar {
    gap: 10px;
    padding: 0 12px;
  }
  .game-select {
    min-width: 0;
    max-width: 46vw;
  }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
    width: 240px;
  }
  body.menu-open .sidebar {
    transform: none;
  }
  body.menu-open .scrim {
    display: block;
    position: fixed;
    inset: var(--top-h) 0 0 0;
    background: rgb(10 14 22 / 35%);
    z-index: 30;
  }
  .main {
    margin-left: 0;
  }
  .page {
    padding: 16px 16px 40px;
  }
  .two-col {
    grid-template-columns: 1fr;
  }
  .toolbar .field {
    min-width: 0;
    flex: 1 1 100%;
  }
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chart-grid-3 {
    grid-template-columns: 1fr;
  }
  .modal-foot .btn {
    flex: 1;
  }
}
