:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e3e6ea;
  --border-strong: #d0d5db;
  --text: #1c1f23;
  --text-2: #5b6472;
  --text-3: #8b95a3;
  --brand: #2f6fed;
  --brand-dark: #2559c9;
  --brand-soft: #eaf1fe;
  --up: #d93025;      /* 中式：红涨 */
  --down: #12875a;    /* 中式：绿跌 */
  --warn: #d98200;
  --warn-soft: #fff5e6;
  --danger: #d93025;
  --danger-soft: #fdecea;
  --ok: #12875a;
  --ok-soft: #e7f6ef;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; }

/* ---------- 登录 ---------- */
.login-screen {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #e8f0ff 0%, var(--bg) 60%);
}
.login-card {
  width: 360px; padding: 32px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); text-align: center;
}
.login-logo {
  width: 52px; height: 52px; margin: 0 auto 14px; border-radius: 14px;
  background: linear-gradient(140deg, #3b7bff, #1a4fd6); color: #fff;
  display: grid; place-items: center; font-size: 24px; font-weight: 700;
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card p { margin: 0 0 22px; font-size: 13px; }
.login-card label { display: block; text-align: left; margin-bottom: 14px; }
.login-card label span { display: block; margin-bottom: 6px; font-size: 12.5px; color: var(--text-2); }
.login-card input { width: 100%; }
.error-text { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 10px; }

/* ---------- 布局 ---------- */
.app { display: grid; grid-template-columns: 224px 1fr; height: 100vh; }

.sidebar {
  background: var(--panel); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 12px;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; padding: 6px 8px 18px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(140deg, #3b7bff, #1a4fd6);
  color: #fff; display: grid; place-items: center; font-size: 14px; font-weight: 700;
}
#nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
#nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 8px;
  color: var(--text-2); text-decoration: none; font-size: 13.5px; transition: .14s;
}
#nav a i { font-style: normal; width: 16px; text-align: center; opacity: .75; }
#nav a:hover { background: var(--panel-2); color: var(--text); }
#nav a.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
#nav a.active i { opacity: 1; }
.sidebar-footer { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 8px; }

.content { display: flex; flex-direction: column; overflow: hidden; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.topbar h2 { margin: 0; font-size: 17px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.view { padding: 20px 24px 40px; overflow: auto; }

/* ---------- 组件 ---------- */
.btn {
  border: 1px solid var(--border-strong); background: var(--panel); color: var(--text);
  padding: 7px 13px; border-radius: 8px; cursor: pointer; font-size: 13px; transition: .14s;
  font-family: inherit;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn.secondary { background: var(--panel-2); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f0c4c0; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn.block { width: 100%; justify-content: center; padding: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.link { border: none; background: none; color: var(--brand); padding: 2px 4px; }

input, select, textarea {
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px;
  font: inherit; color: var(--text); background: #fff; outline: none; width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47,111,237,.12); }
textarea { min-height: 90px; resize: vertical; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; }
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--text-2); }
label.field > span.field-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

button.reveal {
  border: none; background: none; color: var(--brand); cursor: pointer;
  font-size: 12px; padding: 0 2px; font-family: inherit;
}
button.reveal:hover { text-decoration: underline; }
.hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); margin-bottom: 16px;
}
.card h3 { margin: 0 0 4px; font-size: 14.5px; }
.card .card-sub { margin: 0 0 14px; font-size: 12.5px; color: var(--text-2); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

.stat { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .stat-label { font-size: 12.5px; color: var(--text-2); }
.stat .stat-value { font-size: 24px; font-weight: 650; margin-top: 4px; letter-spacing: -.5px; }
.stat .stat-foot { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); font-size: 12px; color: var(--text-2);
}
.badge.ok { background: var(--ok-soft); border-color: #bfe6d5; color: #0d6b48; }
.badge.warn { background: var(--warn-soft); border-color: #f3ddb3; color: #9a5c00; }
.badge.danger { background: var(--danger-soft); border-color: #f2c6c1; color: #a52019; }
.badge.brand { background: var(--brand-soft); border-color: #c9dcff; color: var(--brand-dark); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-weight: 600; color: var(--text-2); font-size: 12.5px; background: var(--panel-2); white-space: nowrap; }
tbody tr:hover { background: var(--panel-2); }
td.actions { white-space: nowrap; text-align: right; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); }
.table-wrap table { min-width: 720px; }

.empty { padding: 34px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.account-side-stack { display: grid; gap: 14px; align-content: start; }
.account-detail-grid { align-items: stretch; }
.account-detail-grid > .card { margin-bottom: 0; }
.account-side-stack .card:last-child { margin-bottom: 0; }
.account-picker-card { padding: 11px 14px; margin-bottom: 12px; }
.account-picker-head { margin-bottom: 8px; }
.account-picker-card .card-sub { margin-bottom: 0; }
.account-picker-card .avatar-strip { padding: 0 2px 2px; gap: 8px; }
.account-picker-card .avatar-item { width: 78px; padding: 7px 5px 6px; gap: 3px; border-radius: 9px; }
.account-picker-card .avatar-face,
.account-picker-card .avatar-face img,
.account-picker-card .avatar-ph { width: 40px; height: 40px; }
.account-picker-card .avatar-ph { font-size: 16px; }
.account-picker-card .avatar-name { font-size: 11.5px; }
.account-picker-card .avatar-sub { font-size: 10px; }
.permission-compact-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.permission-compact-row:last-child { border-bottom: 0; padding-bottom: 0; }
.permission-compact-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.auth-code-value { font: 700 30px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: 5px; color: var(--text); padding: 12px 0 8px; }
.auth-code-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wmpvp-match-panel { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.wmpvp-match-summary .stat { box-shadow: none; }
.wmpvp-match-mount { min-height: 80px; }
.platform-account-section,
.platform-stats-section { margin-bottom: 16px; }
.platform-account-grid,
.platform-stats-platform-grid { align-items: stretch; }
.platform-account-card {
  min-width: 0; padding: 14px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--panel-2);
}
.platform-account-card-head,
.platform-stat-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.platform-account-card h4,
.platform-stat-card h4,
.platform-stats-platform-card h4 { margin: 0; font-size: 14px; }
.platform-account-card .card-sub,
.platform-stat-card .card-sub,
.platform-stats-platform-card .card-sub { margin: 3px 0 0; }
.platform-account-id { margin-top: 12px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--panel); overflow-wrap: anywhere; }
.platform-account-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 9px; color: var(--text-2); font-size: 12px; }
.platform-stats-grid { align-items: start; }
.platform-stat-card { min-width: 0; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel-2); }
.platform-stat-content { margin-top: 12px; }
.platform-stat-foot { margin-top: 10px; color: var(--text-2); font-size: 12px; }
.platform-metric-grid { margin-top: 4px; gap: 8px; }
.platform-metric-grid .stat { padding: 10px 12px; }
.platform-metric-grid .stat .stat-value { font-size: 20px; }
.platform-subheading { margin: 16px 0 6px; font-size: 13.5px; }
.platform-history-table { max-height: 360px; overflow: auto; }
.platform-match-list { margin-top: 14px; }
.platform-stats-page { display: grid; gap: 16px; }
.platform-stats-intro { margin-bottom: 0; }
.platform-stats-group { display: grid; gap: 10px; }
.platform-stats-group-head { padding: 2px 2px 0; }
.platform-stats-group-head h3 { margin: 0; font-size: 15px; }
.platform-stats-group-head .card-sub { margin: 3px 0 0; }
.platform-stats-platform-card { margin-bottom: 0; }
.platform-stats-platform-card .platform-stats-content { min-height: 86px; }
@media (max-width: 900px) {
  .platform-metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.pill-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: #fff; cursor: pointer; font-size: 12.5px;
}
.chip.on { background: var(--brand-soft); border-color: #c9dcff; color: var(--brand-dark); font-weight: 600; }

.switch { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.switch input { width: auto; }

.callout {
  border-radius: 8px; padding: 10px 12px; font-size: 12.5px; border: 1px solid;
  margin-bottom: 12px;
}
.callout.info { background: var(--brand-soft); border-color: #c9dcff; color: #1c3f8f; }
.callout.warn { background: var(--warn-soft); border-color: #f3ddb3; color: #8a5200; }
.callout.danger { background: var(--danger-soft); border-color: #f2c6c1; color: #98211a; }

pre.log {
  background: #1e2126; color: #d6dae1; border-radius: 8px; padding: 12px; font-size: 12px;
  max-height: 420px; overflow: auto; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
pre.log .l-error { color: #ff8f87; }
pre.log .l-warn { color: #ffc46b; }
pre.log .l-success { color: #7ee2b8; }
pre.log .l-info { color: #a9b4c2; }

/* modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(18, 22, 28, .38); display: grid; place-items: center;
  padding: 24px; z-index: 50; overflow: auto;
}
.modal {
  background: var(--panel); border-radius: 12px; box-shadow: 0 18px 50px rgba(16,24,40,.22);
  width: 560px; max-width: 100%; padding: 20px 22px; max-height: 90vh; overflow: auto;
}
.modal.wide { width: 820px; }
.modal.xwide { width: 1080px; }
.modal h3 { margin: 0 0 4px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* toast */
.toast-root { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 200; }
.toast {
  background: #1e2126; color: #fff; padding: 10px 14px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.24); max-width: 380px; animation: slideIn .18s ease-out;
}
.toast.ok { background: #14724e; }
.toast.err { background: #a52019; }
@keyframes slideIn { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(47,111,237,.25); border-top-color: var(--brand);
  border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spark { width: 100%; height: 64px; display: block; }
.num-up { color: var(--up); }
.num-down { color: var(--down); }

/* ---------- 库存卡片网格 ---------- */
/* 弹窗内左右两栏：左侧分类与筛选，右侧物品。
   这样物品不会被上方的内容挤出可视区（之前一栏布局就有这个问题）。 */
.inv-layout { display: grid; grid-template-columns: 268px minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .inv-layout { grid-template-columns: 1fr; } }
.inv-side .card { margin-bottom: 0; }
.inv-side .pill-row { display: grid; grid-template-columns: 1fr; gap: 6px; }
.inv-side .chip { width: 100%; justify-content: space-between; }
.inv-main { min-width: 0; }

.inv-grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  max-height: 62vh; overflow: auto; padding: 2px;
}
.inv-card {
  border: 1px solid var(--border); border-radius: 9px; background: var(--panel);
  padding: 9px; display: flex; flex-direction: column; gap: 5px;
  text-align: center; transition: .14s;
}
.inv-card:hover { border-color: var(--brand); box-shadow: 0 2px 10px rgba(47,111,237,.12); }
.inv-card.locked { opacity: .62; }
.inv-card img { width: 100%; height: 70px; object-fit: contain; }
.inv-noimg { width: 100%; height: 70px; border-radius: 6px; background: var(--panel-2); }
.inv-name {
  font-size: 12px; line-height: 1.35; color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.inv-meta {
  font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.inv-foot { display: flex; justify-content: center; gap: 4px; flex-wrap: wrap; margin-top: auto; }
.inv-foot .badge { font-size: 11px; padding: 2px 7px; }

/* ---------- 账号头像条 ---------- */
.avatar-strip {
  display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 8px;
  scrollbar-width: thin;
}
.avatar-item {
  flex: 0 0 auto; width: 92px; padding: 10px 6px 8px; cursor: pointer;
  border: 1px solid var(--border); border-radius: 11px; background: var(--panel);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-family: inherit; transition: .15s;
}
.avatar-item:hover { border-color: var(--brand); transform: translateY(-1px); }
.avatar-item.on {
  border-color: var(--brand); background: var(--brand-soft);
  box-shadow: 0 0 0 2px rgba(47,111,237,.16);
}
.avatar-face { position: relative; width: 48px; height: 48px; display: block; }
.avatar-face img {
  width: 48px; height: 48px; border-radius: 10px; object-fit: cover; display: block;
}
.avatar-ph {
  width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(140deg, #3b7bff, #1a4fd6); color: #fff;
  font-size: 20px; font-weight: 700;
}
.avatar-crown, .avatar-lock {
  position: absolute; top: -5px; right: -6px; font-size: 10px; line-height: 1;
  padding: 2px 4px; border-radius: 5px; color: #fff; font-weight: 600;
}
.avatar-crown { background: var(--brand); }
.avatar-lock { background: var(--danger); }
.avatar-name {
  font-size: 12px; font-weight: 600; color: var(--text); max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.avatar-sub {
  font-size: 10.5px; color: var(--text-3); max-width: 100%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.avatar-marks { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.avatar-marks .badge { font-size: 10px; padding: 1px 5px; }
