:root {
  --bg-1: #eef2f9;
  --bg-2: #f7f4fb;
  --bg-3: #e9f0fb;
  --ink: #1c2333;
  --ink-2: #4a5468;
  --muted: #6b7488;
  --line: rgba(15, 26, 61, 0.08);
  --blue: #0a84ff;
  --indigo: #5e5ce6;
  --orange: #ff9f0a;
  --green: #30d158;
  --red: #ff453a;
  --glass: rgba(255, 255, 255, 0.82);
  --glass-strong: rgba(255, 255, 255, 0.92);
  --stroke: rgba(255, 255, 255, 0.75);
  --shadow: 0 12px 34px rgba(15, 26, 61, 0.1);
  --shadow-sm: 0 4px 14px rgba(15, 26, 61, 0.06);
  --radius: 22px;
  --radius-sm: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg-1);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.55;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(880px 620px at 8% -6%, rgba(94, 92, 230, 0.16), transparent 62%),
    radial-gradient(760px 540px at 98% 4%, rgba(10, 132, 255, 0.14), transparent 60%),
    radial-gradient(680px 620px at 46% 108%, rgba(255, 159, 10, 0.12), transparent 62%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 45%, var(--bg-3));
}

/* ------------------------------- 布局 ------------------------------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 228px;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(255, 255, 255, 0.5);
  backdrop-filter: blur(26px) saturate(1.6);
  -webkit-backdrop-filter: blur(26px) saturate(1.6);
  border-right: 1px solid var(--stroke);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; padding: 0 6px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 11px;
  background: linear-gradient(140deg, var(--blue), var(--indigo));
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 6px 16px rgba(10, 132, 255, 0.34);
}
.brand-text { line-height: 1.2; }
.brand-text strong { display: block; font-size: 15px; letter-spacing: 0.2px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink-2); cursor: pointer; user-select: none;
  transition: background 0.22s var(--ease), color 0.22s var(--ease), transform 0.22s var(--ease);
  font-size: 13.5px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.7); color: var(--ink); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.14), rgba(94, 92, 230, 0.14));
  color: var(--ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(10, 132, 255, 0.16);
}
.nav-item svg { width: 17px; height: 17px; flex: none; }

.sidebar-foot { margin-top: auto; font-size: 11px; color: var(--muted); padding: 0 8px; }
.sidebar-foot .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--green); margin-right: 6px; }
.sidebar-foot .dot.off { background: var(--red); }

.main { margin-left: 228px; flex: 1; padding: 30px 34px 60px; max-width: 1420px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 25px; letter-spacing: -0.3px; }
.page-head p { margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.page-head .actions { display: flex; gap: 10px; align-items: center; }

.view { display: none; animation: fade 0.32s var(--ease); }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

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

.card {
  background: var(--glass);
  backdrop-filter: blur(24px) saturate(1.6);
  -webkit-backdrop-filter: blur(24px) saturate(1.6);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
}
.card + .card { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.1px; }
.card-head .sub { font-size: 12px; color: var(--muted); }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.hero { grid-template-columns: 1.25fr 1fr; align-items: stretch; }

@media (max-width: 1180px) {
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.hero { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 22px 18px 50px; }
  .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
}

/* ------------------------------ 数据卡 ------------------------------ */

.stat { display: flex; flex-direction: column; gap: 5px; }
.stat .label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 27px; font-weight: 650; letter-spacing: -0.6px; font-variant-numeric: tabular-nums; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .hint { font-size: 11.5px; color: var(--muted); }
.stat .value.pos { color: var(--green); }
.stat .value.neg { color: var(--red); }

/* ------------------------------ 档位卡 ------------------------------ */

.tier-hero { display: flex; align-items: center; gap: 26px; }
.ring { position: relative; width: 148px; height: 148px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.ring .tier-num { font-size: 34px; font-weight: 700; letter-spacing: -1px; line-height: 1; }
.ring .tier-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.tier-meta { flex: 1; min-width: 0; }
.tier-meta .xp-line { font-size: 15px; margin-bottom: 12px; }
.tier-meta .xp-line b { font-size: 22px; font-variant-numeric: tabular-nums; }
.bar { height: 10px; border-radius: 999px; background: rgba(15, 26, 61, 0.08); overflow: hidden; }
.bar > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--blue), var(--indigo));
  transition: width 0.7s var(--ease);
  box-shadow: 0 2px 8px rgba(10, 132, 255, 0.4);
}
.tier-meta .under { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 8px; }
.reward-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 999px; font-size: 12.5px;
  background: linear-gradient(135deg, rgba(255, 159, 10, 0.16), rgba(255, 159, 10, 0.08));
  color: #a1620a; border: 1px solid rgba(255, 159, 10, 0.24);
}

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

.table-wrap { overflow-x: auto; margin: 0 -6px; padding: 0 6px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 10px; border-bottom: 1px solid rgba(15, 26, 61, 0.05); vertical-align: middle; }
tbody tr { transition: background 0.18s var(--ease); }
tbody tr:hover { background: rgba(255, 255, 255, 0.55); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }

/* ------------------------------ 控件 ------------------------------ */

button, .btn {
  font-family: inherit; font-size: 13px; cursor: pointer;
  border-radius: var(--radius-sm); border: 1px solid var(--stroke);
  background: var(--glass-strong); color: var(--ink);
  padding: 8px 14px; display: inline-flex; align-items: center; gap: 7px;
  transition: transform 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
  box-shadow: var(--shadow-sm);
}
button:hover, .btn:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(15, 26, 61, 0.1); }
button:active, .btn:active { transform: translateY(0); }
button svg, .btn svg { width: 15px; height: 15px; }
button.primary {
  background: linear-gradient(135deg, var(--blue), var(--indigo));
  color: #fff; border-color: transparent;
  box-shadow: 0 8px 20px rgba(10, 132, 255, 0.3);
}
button.ghost { background: rgba(255, 255, 255, 0.4); box-shadow: none; }
button.danger { color: var(--red); }
button.sm { padding: 5px 10px; font-size: 12px; border-radius: 10px; }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

input, select, textarea {
  font-family: inherit; font-size: 13px; color: var(--ink);
  padding: 8px 12px; border-radius: 12px;
  border: 1px solid rgba(15, 26, 61, 0.1);
  background: rgba(255, 255, 255, 0.8);
  outline: none; width: 100%;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(10, 132, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.13);
}
label.field { display: block; }
label.field > span { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 5px; }

.form-row { display: grid; gap: 12px; align-items: end; }
.form-row.c2 { grid-template-columns: 1fr 1fr; }
.form-row.c3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.c4 { grid-template-columns: repeat(4, 1fr); }
.form-row.c5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 980px) { .form-row.c4, .form-row.c5, .form-row.c3 { grid-template-columns: 1fr 1fr; } }

.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: rgba(15, 26, 61, 0.06); }
.seg button {
  border: none; background: transparent; box-shadow: none; padding: 6px 13px;
  border-radius: 10px; font-size: 12.5px; color: var(--ink-2);
}
.seg button:hover { transform: none; background: rgba(255, 255, 255, 0.6); }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; box-shadow: var(--shadow-sm); }

.tag {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px;
  padding: 3px 9px; border-radius: 999px; background: rgba(15, 26, 61, 0.06); color: var(--ink-2);
}
.tag.blue { background: rgba(10, 132, 255, 0.12); color: #0a5fbf; }
.tag.orange { background: rgba(255, 159, 10, 0.14); color: #9a6208; }
.tag.green { background: rgba(48, 209, 88, 0.15); color: #1c7a34; }
.tag.red { background: rgba(255, 69, 58, 0.12); color: #b52a22; }
.tag.indigo { background: rgba(94, 92, 230, 0.13); color: #43419f; }

.pos { color: var(--green); }
.neg { color: var(--red); }
.mono { font-variant-numeric: tabular-nums; }

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

.chart { width: 100%; height: 190px; }
.chart .grid-line { stroke: rgba(15, 26, 61, 0.07); stroke-width: 1; }
.chart .bar-xp { fill: url(#gradXp); }
.chart .bar-reward { fill: rgba(255, 159, 10, 0.75); }
.chart text { font-size: 10px; fill: var(--muted); }

/* ------------------------------ 浮层 ------------------------------ */

.toast-host { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 16px; font-size: 13px;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(20px) saturate(1.6);
  border: 1px solid var(--stroke); box-shadow: var(--shadow);
  animation: toastIn 0.28s var(--ease);
  max-width: 380px;
}
.toast.ok svg { color: var(--green); }
.toast.err svg { color: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: none; } }

.modal-host {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center;
  background: rgba(20, 28, 48, 0.28); backdrop-filter: blur(6px);
}
.modal-host.on { display: flex; }
.modal {
  width: min(520px, 92vw); max-height: 86vh; overflow: auto;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(30px) saturate(1.7);
  border: 1px solid var(--stroke); border-radius: 24px;
  box-shadow: 0 30px 70px rgba(15, 26, 61, 0.24);
  padding: 24px; animation: modalIn 0.26s var(--ease);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(16px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal h3 { margin: 0 0 4px; font-size: 17px; }
.modal .modal-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.stack { display: grid; gap: 12px; }

.levelup-overlay {
  position: fixed; inset: 0; z-index: 110; display: none;
  align-items: center; justify-content: center;
  background: rgba(16, 24, 46, 0.34); backdrop-filter: blur(8px);
}
.levelup-overlay.on { display: flex; }
.levelup-card {
  text-align: center; padding: 38px 46px; border-radius: 28px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--stroke);
  box-shadow: 0 30px 80px rgba(15, 26, 61, 0.3);
  animation: pop 0.42s var(--ease);
}
@keyframes pop { 0% { opacity: 0; transform: scale(0.86); } 60% { transform: scale(1.03); } 100% { opacity: 1; transform: scale(1); } }
.levelup-card .lc-tier { font-size: 13px; color: var(--muted); }
.levelup-card .lc-num { font-size: 46px; font-weight: 700; letter-spacing: -1.5px; margin: 6px 0 2px; }
.levelup-card .lc-reward {
  margin-top: 14px; font-size: 20px; font-weight: 600;
  background: linear-gradient(135deg, var(--orange), #ff6f3c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.list-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 4px;
  border-bottom: 1px solid rgba(15, 26, 61, 0.05);
}
.list-row:last-child { border-bottom: none; }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .meta { font-size: 11.5px; color: var(--muted); }
.xp-chip {
  font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px;
  padding: 4px 10px; border-radius: 999px;
  background: linear-gradient(135deg, rgba(10, 132, 255, 0.14), rgba(94, 92, 230, 0.14));
  color: #2a4bbd;
}

.token-gate {
  position: fixed; inset: 0; z-index: 200; display: none;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2));
}
.token-gate.on { display: flex; }

.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
