:root {
  color-scheme: light;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --ink: #172033;
  --muted: #68748a;
  --line: #dde4ef;
  --blue: #1d63d8;
  --blue-soft: #eaf2ff;
  --red: #d9363e;
  --green: #16845b;
  --orange: #b46908;
  --shadow: 0 12px 35px rgba(35, 57, 90, .09);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: Inter, "Microsoft YaHei", system-ui, sans-serif; }
button, input { font: inherit; }
button { cursor: pointer; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px clamp(16px, 4vw, 40px); background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(16px); }
.topbar h1 { margin: 2px 0 0; font-size: clamp(20px, 4vw, 28px); }
.eyebrow { margin: 0; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-pill { border-radius: 999px; padding: 7px 11px; background: var(--blue-soft); color: var(--blue); font-size: 12px; font-weight: 700; }
.status-pill.error { background: #ffeaec; color: var(--red); }
.status-pill.warn { background: #fff2dc; color: var(--orange); }
.ghost-button { border: 1px solid var(--line); border-radius: 10px; padding: 7px 12px; background: white; color: var(--ink); }

.app-shell { width: min(1400px, 100%); margin: 0 auto; padding: 22px clamp(14px, 3vw, 32px) 48px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 12px; }
.section-heading h2 { margin: 3px 0 0; font-size: 20px; }
.muted, .footer-note { color: var(--muted); font-size: 12px; }
.account-strip { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x mandatory; }
.account-card { flex: 0 0 min(310px, 82vw); scroll-snap-align: start; border: 1px solid var(--line); border-radius: 16px; padding: 15px; background: var(--surface); box-shadow: var(--shadow); text-align: left; color: inherit; }
.account-card.active { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,99,216,.12), var(--shadow); }
.account-title { display: flex; justify-content: space-between; gap: 8px; font-weight: 800; }
.account-id { color: var(--muted); font-size: 12px; }
.account-values { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 13px; }
.label { color: var(--muted); font-size: 11px; }
.value { display: block; margin-top: 2px; font-weight: 750; font-variant-numeric: tabular-nums; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; margin: 12px 0 20px; }
.metric { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.metric .value { font-size: clamp(18px, 3vw, 25px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.positive { color: var(--red) !important; }
.negative { color: var(--green) !important; }
.warning { color: var(--orange) !important; }

.tabs { display: flex; gap: 8px; overflow-x: auto; margin-bottom: 12px; }
.tab { flex: 0 0 auto; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; background: var(--surface); color: var(--muted); font-weight: 700; }
.tab.active { border-color: var(--blue); background: var(--blue); color: white; }
.panel { display: none; }
.panel.active { display: block; }

.position-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(285px, 1fr)); gap: 12px; }
.position-card { padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.position-head { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.position-head h3 { margin: 0; font-size: 16px; }
.direction { border-radius: 999px; padding: 4px 9px; background: var(--blue-soft); font-size: 11px; font-weight: 800; }
.position-data { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; margin-top: 14px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
th { position: sticky; top: 0; background: #f8faff; color: var(--muted); font-size: 11px; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; }
tr:last-child td { border-bottom: 0; }
.empty { padding: 32px 18px; border: 1px dashed #bcc7d8; border-radius: 15px; color: var(--muted); text-align: center; background: rgba(255,255,255,.5); }
.footer-note { text-align: center; margin-top: 18px; }

.login-page { min-height: 100vh; background: radial-gradient(circle at top left, #dfeaff, transparent 44%), linear-gradient(150deg,#f8fbff,#edf3fb); }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 22px; }
.login-card { width: min(430px,100%); padding: clamp(24px,6vw,38px); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; background: rgba(255,255,255,.92); box-shadow: 0 28px 70px rgba(35,63,105,.18); }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 20px; border-radius: 14px; background: var(--blue); color: white; font-weight: 900; }
.login-card h1 { margin: 5px 0 8px; }
.login-note, .security-tip { color: var(--muted); line-height: 1.6; }
.login-card label { display: block; margin: 22px 0 8px; font-weight: 700; }
.login-card input[type=password] { width: 100%; border: 1px solid #c9d3e2; border-radius: 12px; padding: 13px 14px; outline: none; background: white; }
.login-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(29,99,216,.12); }
.login-card button { width: 100%; margin-top: 14px; border: 0; border-radius: 12px; padding: 13px; background: var(--blue); color: white; font-weight: 800; }
.alert { margin-top: 16px; border-radius: 11px; padding: 11px 13px; background: #ffeaec; color: #a9252d; font-size: 13px; }
.security-tip { margin: 18px 0 0; font-size: 12px; }

@media (max-width: 760px) {
  .topbar { align-items: flex-start; }
  .top-actions { flex-direction: column; align-items: end; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metric { padding: 13px; }
  .position-grid { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  .status-pill { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .metric-grid { gap: 8px; }
  .account-card { flex-basis: 88vw; }
}
