/* ── Mercury 管理后台 · “水银账房” 视觉体系 ─────────────────────────
   深墨蓝底 + 液态金属银青 + Fraunces 衬线标题 + Plex Mono 表格数字 */

:root {
  --bg: #0b1014;
  --bg-raise: #10171d;
  --panel: #131c23;
  --panel-2: #182430;
  --line: rgba(164, 196, 210, 0.13);
  --line-strong: rgba(164, 196, 210, 0.28);
  --ink: #e8f0f2;
  --ink-dim: #93a8b3;
  --ink-faint: #5d707b;
  --hg: #8fd8cf;               /* mercury 液态银青 */
  --hg-deep: #47a89e;
  --pos: #7fd898;
  --neg: #f2917f;
  --warn: #e8c268;
  --danger: #e46e6e;
  --radius: 10px;
  --font-display: "Fraunces", "Songti SC", serif;
  --font-body: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 85% -10%, rgba(71, 168, 158, 0.10), transparent 60%),
    radial-gradient(900px 500px at -10% 100%, rgba(80, 110, 160, 0.08), transparent 55%),
    var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* 细腻噪点，压住大面积深色的“塑料感” */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: 0.05; z-index: 999;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

.mono, td.num, .amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

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

.sidebar {
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 28, 35, 0.9), rgba(11, 16, 20, 0.7));
  padding: 22px 14px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark {
  font-size: 26px; line-height: 1; color: var(--hg);
  width: 44px; height: 44px; display: grid; place-items: center;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: radial-gradient(circle at 30% 25%, rgba(143, 216, 207, 0.25), transparent 65%);
  text-shadow: 0 0 18px rgba(143, 216, 207, 0.6);
}
.brand-name { font-family: var(--font-display); font-size: 20px; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.35em; margin-top: 2px; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  color: var(--ink-dim); text-decoration: none; font-size: 13.5px;
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.nav a:hover { color: var(--ink); background: rgba(143, 216, 207, 0.06); }
.nav a.active {
  color: var(--hg); background: rgba(143, 216, 207, 0.09);
  border-color: rgba(143, 216, 207, 0.22);
}
.nav-ico { width: 18px; text-align: center; opacity: 0.85; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 8px; }
.mode-badge {
  font-size: 11px; padding: 5px 9px; border-radius: 999px; width: fit-content;
  border: 1px solid var(--line-strong); color: var(--ink-dim); letter-spacing: 0.05em;
}
.mode-badge.demo { color: var(--warn); border-color: rgba(232, 194, 104, 0.4); }
.mode-badge.live { color: var(--pos); border-color: rgba(127, 216, 152, 0.4); }
.org-name { font-size: 12px; color: var(--ink-faint); }

.main { padding: 0 34px 60px; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 24px 0 18px; margin-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.page-title { font-family: var(--font-display); font-size: 30px; font-weight: 600; letter-spacing: 0.01em; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.clock { font-size: 12px; color: var(--ink-faint); }

.view { animation: fadeup 0.35s ease both; }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── 通用组件 ── */
.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px;
}
.panel + .panel, .section + .section { margin-top: 18px; }
.panel-title {
  font-size: 12px; color: var(--ink-faint); text-transform: uppercase;
  letter-spacing: 0.18em; margin-bottom: 14px;
}

.grid { display: grid; gap: 16px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 800px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } .app { grid-template-columns: 64px 1fr; } }

.btn {
  font-family: var(--font-body); font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: rgba(143, 216, 207, 0.07); color: var(--ink);
  padding: 7px 14px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { background: rgba(143, 216, 207, 0.14); border-color: var(--hg-deep); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-dim); }
.btn-ghost:hover { color: var(--ink); }
.btn-danger { border-color: rgba(228, 110, 110, 0.45); background: rgba(228, 110, 110, 0.08); color: var(--neg); }
.btn-danger:hover { background: rgba(228, 110, 110, 0.16); border-color: var(--danger); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

input, select {
  font-family: var(--font-body); font-size: 13px;
  background: var(--bg-raise); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; outline: none;
}
input:focus, select:focus { border-color: var(--hg-deep); box-shadow: 0 0 0 3px rgba(71, 168, 158, 0.15); }
input::placeholder { color: var(--ink-faint); }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.filters label { font-size: 12px; color: var(--ink-faint); margin-right: -4px; }

/* ── 表格 ── */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; font-weight: 500; font-size: 11px;
  color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.12em;
  padding: 11px 14px; border-bottom: 1px solid var(--line-strong);
  background: rgba(16, 23, 29, 0.7); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background 0.12s; }
tbody tr:hover { background: rgba(143, 216, 207, 0.05); }
td.num { text-align: right; }

.amount.pos { color: var(--pos); }
.amount.neg { color: var(--neg); }

.tag {
  display: inline-block; font-size: 11px; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line-strong); color: var(--ink-dim); letter-spacing: 0.03em;
}
.tag.sent, .tag.active { color: var(--pos); border-color: rgba(127, 216, 152, 0.4); background: rgba(127, 216, 152, 0.07); }
.tag.pending { color: var(--warn); border-color: rgba(232, 194, 104, 0.4); background: rgba(232, 194, 104, 0.07); }
.tag.failed, .tag.cancelled, .tag.deleted, .tag.blocked { color: var(--neg); border-color: rgba(242, 145, 127, 0.4); background: rgba(242, 145, 127, 0.06); }
.tag.frozen { color: #9fc6e8; border-color: rgba(159, 198, 232, 0.4); background: rgba(159, 198, 232, 0.07); }

/* ── 总览 ── */
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--hg), transparent); opacity: 0.55;
}
.stat-label { font-size: 12px; color: var(--ink-dim); display: flex; justify-content: space-between; gap: 8px; }
.stat-value { font-family: var(--font-mono); font-size: 27px; font-weight: 600; margin: 10px 0 4px; letter-spacing: -0.01em; }
.stat-sub { font-size: 12px; color: var(--ink-faint); }
.stat-sub .mono { font-size: 11px; }

.hero-balance { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero-balance .figure { font-family: var(--font-display); font-size: 44px; font-weight: 700; letter-spacing: -0.01em; }
.hero-balance .cur { color: var(--ink-faint); font-size: 14px; letter-spacing: 0.2em; }

.chart-svg { width: 100%; height: 170px; display: block; }
.chart-legend { display: flex; gap: 18px; font-size: 12px; color: var(--ink-dim); margin-top: 8px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* ── 卡片管理 ── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.bank-card {
  position: relative; border-radius: 16px; padding: 20px;
  min-height: 190px; display: flex; flex-direction: column; justify-content: space-between;
  border: 1px solid var(--line-strong);
  background:
    radial-gradient(160% 120% at 100% 0%, rgba(143, 216, 207, 0.16), transparent 55%),
    linear-gradient(150deg, #1d2a35, #101820 70%);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.bank-card:hover { transform: translateY(-3px); box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45); }
.bank-card.frozen { filter: saturate(0.35) brightness(0.85); }
.bank-card.cancelled { opacity: 0.45; filter: grayscale(0.8); }
.bank-card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.bank-card .nick { font-size: 15px; font-weight: 600; }
.bank-card .meta { font-size: 12px; color: var(--ink-dim); margin-top: 3px; }
.bank-card .pan { font-family: var(--font-mono); font-size: 19px; letter-spacing: 0.14em; margin: 14px 0 4px; }
.bank-card-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; }
.bank-card .limit { font-size: 11.5px; color: var(--ink-faint); }
.card-actions { display: flex; gap: 8px; }

/* ── 抽屉详情 ── */
.drawer-mask { position: fixed; inset: 0; background: rgba(5, 8, 11, 0.6); backdrop-filter: blur(2px); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 92vw); z-index: 41;
  background: var(--bg-raise); border-left: 1px solid var(--line-strong);
  box-shadow: -30px 0 60px rgba(0, 0, 0, 0.45);
  display: flex; flex-direction: column;
  animation: slidein 0.25s ease both;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.drawer-body { padding: 20px 22px; overflow-y: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 9px 14px; font-size: 13px; }
.kv dt { color: var(--ink-faint); }
.kv dd { color: var(--ink); word-break: break-all; }

.empty { text-align: center; color: var(--ink-faint); padding: 48px 0; font-size: 13px; }
.error-box { border: 1px solid rgba(228, 110, 110, 0.4); background: rgba(228, 110, 110, 0.07); color: var(--neg); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; }
.loading { color: var(--ink-faint); padding: 40px 0; text-align: center; letter-spacing: 0.2em; animation: pulse 1.2s ease infinite; }
@keyframes pulse { 50% { opacity: 0.4; } }

.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--panel-2); border: 1px solid var(--hg-deep); color: var(--ink);
  padding: 10px 20px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  animation: fadeup 0.25s ease both;
}
.toast.err { border-color: var(--danger); color: var(--neg); }

.hint { font-size: 12px; color: var(--ink-faint); margin-top: 10px; line-height: 1.6; }
.hint code { font-family: var(--font-mono); color: var(--hg); background: rgba(143, 216, 207, 0.08); padding: 1px 5px; border-radius: 4px; }

/* ── 抽屉表单 & API 文档 ── */
.drawer-form { display: flex; flex-direction: column; gap: 9px; margin-top: 6px; }
.drawer-form label { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.drawer-form label b { color: var(--danger); }
.danger-zone { border-top: 1px dashed rgba(228, 110, 110, 0.35); margin-top: 20px; padding-top: 4px; }

.code-block {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.7;
  background: var(--bg-raise); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 16px; overflow-x: auto; white-space: pre; color: var(--ink);
}
.code-block .c { color: var(--ink-faint); }
.code-block .k { color: var(--hg); }
.api-table td:first-child { font-family: var(--font-mono); font-size: 12px; }
.copy-btn { float: right; margin-top: -4px; }

/* ── 登录页 ── */
.login-screen { position: fixed; inset: 0; display: grid; place-items: center; z-index: 50; }
.login-card {
  width: min(360px, 90vw); padding: 34px 30px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  display: flex; flex-direction: column; gap: 12px;
}
.login-card input { padding: 11px 12px; font-size: 14px; }
.login-card .btn { padding: 11px; font-size: 14px; }
.login-err { color: var(--neg); font-size: 12.5px; text-align: center; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(143, 216, 207, 0.15); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }
