/* 浅色主题;色彩令牌取自已验证的参考调色板(diverging: 红盈/蓝亏,中性灰中点) */
:root {
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --line: #c3c2b7;
  --ring: rgba(11, 11, 11, .10);
  --accent: #2a78d6;
  --pos: #e34948;        /* 盈(填充) */
  --pos-text: #b42525;   /* 盈(文字,>4.5:1) */
  --neg: #2a78d6;        /* 亏(填充) */
  --neg-text: #1c5cab;   /* 亏(文字) */
  --good: #0ca30c;
  --good-text: #006300;
  --critical: #d03b3b;
  --neutral-mid: #f0efec;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 布局 */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 208px; flex: none; background: var(--surface);
  border-right: 1px solid var(--grid); padding: 16px 12px;
}
.side .brand { font-weight: 700; font-size: 15px; padding: 4px 10px 14px; }
.side nav a {
  display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink-2);
}
.side nav a:hover { background: var(--neutral-mid); text-decoration: none; }
.side nav a.on { background: var(--neutral-mid); color: var(--ink); font-weight: 600; }
.side .sec { margin: 14px 10px 4px; font-size: 12px; color: var(--muted); }
.main { flex: 1; min-width: 0; padding: 20px 24px 48px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar h1 { font-size: 18px; margin: 0; }
.topbar .who { color: var(--ink-2); font-size: 13px; display: flex; gap: 10px; align-items: center; }
.topbar form { display: inline; }

/* 卡片与 KPI */
.card {
  background: var(--surface); border: 1px solid var(--ring); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px;
}
.card h2 { font-size: 14px; margin: 0 0 10px; color: var(--ink-2); font-weight: 600; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--ring); border-radius: 12px; padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 2px; }
.tile .v .cur { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }

/* 表格 */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }
tr:hover td { background: #f6f5f2; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }
.empty { color: var(--muted); padding: 18px 0; text-align: center; }

/* 盈亏文字与双向条 */
.pnl.pos { color: var(--pos-text); }
.pnl.neg { color: var(--neg-text); }
.pnl.zero { color: var(--muted); }
.divbar { position: relative; height: 10px; min-width: 140px; background: var(--neutral-mid); border-radius: 5px; overflow: hidden; }
.divbar::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--line); }
.divbar i { position: absolute; top: 0; bottom: 0; display: block; }
.divbar i.bar-pos { background: var(--pos); border-radius: 0 5px 5px 0; }
.divbar i.bar-neg { background: var(--neg); border-radius: 5px 0 0 5px; }

/* 徽标(状态永远带文字,不只靠颜色) */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--ring); }
.badge.win { color: var(--good-text); background: #eaf6ea; }
.badge.lose { color: var(--ink-2); background: var(--neutral-mid); }
.badge.pending { color: var(--muted); }
.badge.role-admin { color: #6a4aa7; background: #f1edfb; }
.badge.role-banker { color: var(--neg-text); background: #e9f1fb; }
.badge.off { color: var(--critical); background: #fbecec; }

/* 表单 */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; }
.filters label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
input, select, button {
  font: inherit; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--ink);
}
input:focus, select:focus { outline: 2px solid #9ec5f4; border-color: var(--accent); }
button, .btn {
  cursor: pointer; background: var(--ink); color: #fff; border: none; border-radius: 8px; padding: 7px 14px;
  display: inline-block;
}
button:hover, .btn:hover { opacity: .88; text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.sm, button.sm { padding: 3px 10px; font-size: 12px; }
.quick a { margin-right: 8px; font-size: 13px; }
.quick a.on { color: var(--ink); font-weight: 600; }
.topbar .btn.ghost { color: var(--ink-2); }
/* 账号管理:每行多个操作表单排成一行,可换行不粘连 */
.rowacts { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.rowacts form { display: flex; gap: 4px; align-items: center; }
.rowacts input.sm { width: 110px; }
/* 窄表单卡(修改密码等) */
.form-narrow { max-width: 380px; }
.form-narrow label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.form-narrow input { width: 100%; }
/* 出错页 */
.errpage h1 { font-size: 22px; margin: 0 0 12px; color: var(--ink); }

/* 登录页 */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--page); }
.login-card { width: 340px; background: var(--surface); border: 1px solid var(--ring); border-radius: 14px; padding: 28px; }
.login-card h1 { font-size: 18px; margin: 0 0 18px; text-align: center; }
.login-card input { width: 100%; margin-bottom: 12px; }
.login-card button { width: 100%; }
.alert { padding: 8px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; }
.alert.err { background: #fbecec; color: var(--critical); }
.alert.ok { background: #eaf6ea; color: var(--good-text); }

/* 分页与工具行 */
.pager { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.pager .info { color: var(--muted); font-size: 12px; }
.toolrow { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.hint { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--grid); }
.tabs a { padding: 6px 14px; border-radius: 8px 8px 0 0; color: var(--ink-2); }
.tabs a.on { background: var(--surface); border: 1px solid var(--grid); border-bottom-color: var(--surface); font-weight: 600; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* 多币种按日盈亏:小型多组图(每币种独立标尺) */
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.panel { border: 1px solid var(--grid); border-radius: 12px; padding: 16px 16px 12px; background: var(--surface); }
.panel .phead { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel .cur { font-size: 12.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-2); background: var(--neutral-mid); padding: 3px 10px; border-radius: 999px; }
.panel .net, .panel .net .pnl { font-size: 24px; font-weight: 700; letter-spacing: -.01em; }
.panel .psub { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin: 5px 0 14px; }
.panel .psub .pnl { font-size: 13px; font-weight: 600; }
.spark { display: flex; align-items: stretch; gap: 6px; height: 152px; }
.spark .col { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; min-width: 0; }
.spark .plot { position: relative; width: 100%; height: 122px; }
.spark .zero { position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--line); }
.spark .bar { position: absolute; left: 16%; right: 16%; display: block; transition: filter .12s; }
.spark .bar.pos { bottom: 50%; background: var(--pos); border-radius: 4px 4px 0 0; }
.spark .bar.neg { top: 50%; background: var(--neg); border-radius: 0 0 4px 4px; }
.spark .col:hover .bar { filter: brightness(.9); }
.spark .col.now .plot { background: rgba(0,0,0,.035); border-radius: 6px; }
.spark .xlab { font-size: 12px; color: var(--muted); margin-top: 7px; font-variant-numeric: tabular-nums; }
.spark .col.now .xlab { color: var(--ink-2); font-weight: 600; }
/* 悬浮气泡:多行竖排(U 总额 + 各币种原值),深色圆角 */
.spark .col .tipbox { position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translate(-50%, 4px);
  display: flex; flex-direction: column; gap: 2px; text-align: left; background: var(--ink); color: #fff;
  font-variant-numeric: tabular-nums; padding: 7px 10px; border-radius: 8px; white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0,0,0,.24); opacity: 0; pointer-events: none; z-index: 20;
  transition: opacity .12s, transform .12s; }
.spark .col .tipbox b { font-size: 13px; font-weight: 700; }
.spark .col .tipbox span { font-size: 11.5px; color: #cbd5e1; }
.spark .col:hover .tipbox { opacity: 1; transform: translate(-50%, 0); }
.spark .col:first-child .tipbox { left: 0; transform: translate(0, 4px); }
.spark .col:first-child:hover .tipbox { transform: translate(0, 0); }
.spark .col:last-child .tipbox { left: auto; right: 0; transform: translate(0, 4px); }
.spark .col:last-child:hover .tipbox { transform: translate(0, 0); }
@media (prefers-reduced-motion: reduce) { .spark .col .tipbox { transition: opacity .12s; } }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .side { width: 100%; border-right: 0; border-bottom: 1px solid var(--grid); }
  .side nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .side .sec { flex-basis: 100%; width: 100%; margin: 8px 6px 2px; }
  .main { padding: 14px; }
}
