:root {
  color-scheme: dark;
  --bg: #080c12;
  --panel: #111821;
  --panel-strong: #16212c;
  --line: #25313d;
  --text: #f4f7f9;
  --muted: #8d9aa7;
  --cyan: #61e7d4;
  --cyan-dim: rgba(97, 231, 212, 0.12);
  --green: #73e39b;
  --red: #ff7a83;
  --amber: #f2c66d;
  font-family: Inter, "Noto Sans TC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: radial-gradient(circle at 85% -10%, #183744 0, transparent 30%), var(--bg); color: var(--text); }
.hidden { display: none !important; }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 60px; }
.topbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 22px; }
.eyebrow, .section-kicker { margin: 0 0 8px; color: var(--cyan); font: 700 11px/1.2 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .16em; }
h1, h2 { margin: 0; letter-spacing: -.035em; }
h1 { font-size: clamp(28px, 4vw, 46px); }
h2 { font-size: 22px; }
.status-cluster { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; background: var(--green); border-radius: 50%; box-shadow: 0 0 15px var(--green); }
.user-cluster { display: flex; align-items: center; gap: 14px; }
.user-cluster > div { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.user-cluster strong { font-size: 13px; }
.user-cluster span { color: var(--muted); font-size: 11px; }
.notice { display: flex; gap: 18px; align-items: center; padding: 13px 16px; margin-bottom: 18px; border: 1px solid rgba(242,198,109,.3); background: rgba(242,198,109,.07); color: #d9d0bc; font-size: 13px; }
.notice strong { color: var(--amber); white-space: nowrap; }
.metrics { display: grid; grid-template-columns: 1.35fr repeat(3, 1fr); gap: 12px; margin-bottom: 12px; }
.metric { min-height: 122px; padding: 21px; display: flex; flex-direction: column; justify-content: space-between; border: 1px solid var(--line); background: rgba(17,24,33,.92); }
.metric-primary { border-color: rgba(97,231,212,.42); background: linear-gradient(140deg, rgba(97,231,212,.13), rgba(17,24,33,.95) 60%); }
.metric span { color: var(--muted); font-size: 13px; }
.metric strong { font: 650 clamp(23px, 3vw, 34px)/1.1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: -.06em; }
.metric small { color: var(--muted); }
.workspace-grid { display: grid; grid-template-columns: minmax(330px, .72fr) minmax(580px, 1.45fr); gap: 12px; margin-bottom: 12px; }
.panel { border: 1px solid var(--line); background: rgba(17,24,33,.94); }
.order-panel { padding: 23px; }
.positions-panel, .trades-panel { overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 22px 23px 18px; }
.order-panel .panel-heading { padding: 0 0 21px; }
.mode-badge, .count-badge { color: var(--muted); border: 1px solid var(--line); padding: 6px 9px; font-size: 11px; }
label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; font-weight: 650; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
input { width: 100%; border: 1px solid #34424f; outline: none; background: #0c1219; color: var(--text); padding: 13px 14px; }
input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); }
.button { border: 1px solid transparent; padding: 12px 17px; font-weight: 750; }
.button.secondary { background: #1b2631; border-color: #34424f; color: var(--text); }
.button.primary { width: 100%; background: var(--cyan); color: #05110f; }
.button.primary:disabled { opacity: .35; cursor: not-allowed; }
.quote-card { display: flex; justify-content: space-between; align-items: center; min-height: 110px; margin: 16px 0; padding: 18px; border: 1px solid var(--line); background: var(--panel-strong); }
.quote-card > div { display: flex; flex-direction: column; gap: 7px; }
.quote-card span, .quote-card small { color: var(--muted); font-size: 12px; }
.quote-card strong { font-size: 20px; }
.quote-price { text-align: right; }
.quote-price strong { font: 700 27px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.side-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border: 0; padding: 0; margin: 0 0 17px; }
.side-switch label { margin: 0; }
.side-switch input { position: absolute; opacity: 0; pointer-events: none; }
.side-switch span { display: block; padding: 11px; text-align: center; border: 1px solid var(--line); color: var(--muted); }
.side-switch input:checked + span { border-color: var(--cyan); background: var(--cyan-dim); color: var(--cyan); }
.estimate { display: flex; justify-content: space-between; margin: 15px 0; padding-top: 15px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.estimate strong { color: var(--text); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.form-hint { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 10px 0 0; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 16px; text-align: right; border-top: 1px solid var(--line); font-size: 12px; }
th { color: var(--muted); font-weight: 600; background: rgba(8,12,18,.35); }
th:first-child, td:first-child { text-align: left; padding-left: 23px; }
th:last-child, td:last-child { padding-right: 23px; }
.stock-cell { display: flex; flex-direction: column; gap: 3px; }
.stock-cell strong { font-size: 13px; }
.stock-cell small { color: var(--muted); }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.empty-row { text-align: center !important; padding: 48px !important; color: var(--muted); }
.side-tag { padding: 4px 7px; font-weight: 750; }
.side-buy { color: var(--green); background: rgba(115,227,155,.1); }
.side-sell { color: var(--red); background: rgba(255,122,131,.1); }
.text-button { border: 0; background: transparent; color: var(--cyan); }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 360px; padding: 13px 16px; background: #e9fff9; color: #0b2a22; box-shadow: 0 18px 45px rgba(0,0,0,.35); transform: translateY(120px); opacity: 0; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast.error { background: #ffe8ea; color: #4a1116; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.app-footer { padding: 20px 0 28px; color: var(--muted); font-size: 12px; letter-spacing: .08em; text-align: center; }

.auth-shell { width: min(980px, calc(100% - 32px)); min-height: 100vh; margin: 0 auto; display: grid; grid-template-columns: 1.15fr .85fr; align-items: center; gap: clamp(40px, 8vw, 110px); }
.auth-brand h1 { font-size: clamp(38px, 6vw, 68px); line-height: 1; max-width: 520px; }
.auth-brand > p:not(.eyebrow) { max-width: 500px; color: var(--muted); font-size: 16px; line-height: 1.8; }
.auth-points { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.auth-points span { border: 1px solid var(--line); color: var(--cyan); padding: 8px 10px; font: 650 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.auth-card { border: 1px solid #31414e; background: rgba(17,24,33,.96); padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,.34); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 24px; }
.auth-tabs button { border: 1px solid var(--line); background: #0c1219; color: var(--muted); padding: 11px; }
.auth-tabs button.active { border-color: var(--cyan); background: var(--cyan-dim); color: var(--cyan); }
.auth-card input { margin-bottom: 16px; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0; color: var(--muted); font-size: 11px; }
.auth-divider::before, .auth-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.google-button { min-height: 46px; display: flex; justify-content: center; align-items: center; gap: 10px; border: 1px solid #3c4a56; background: #f6f8fa; color: #18212a; text-decoration: none; font-weight: 700; }
.google-button.disabled { opacity: .4; pointer-events: none; }
.google-mark { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1px solid #ccd4db; border-radius: 50%; color: #4285f4; font: 800 14px Arial, sans-serif; }
.auth-message { min-height: 20px; color: var(--red); font-size: 12px; }
.auth-footnote { margin: 14px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; text-align: center; }

@media (max-width: 980px) {
  .metrics { grid-template-columns: 1fr 1fr; }
  .workspace-grid { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .app-shell { width: min(100% - 22px, 1440px); padding-top: 22px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .user-cluster { width: 100%; justify-content: space-between; }
  .user-cluster > div { align-items: flex-start; }
  .notice { align-items: flex-start; flex-direction: column; gap: 6px; }
  .metrics { grid-template-columns: 1fr; }
  .metric { min-height: 102px; }
  .panel-heading { align-items: flex-start; }
}

@media (max-width: 760px) {
  .auth-shell { grid-template-columns: 1fr; align-content: center; gap: 30px; padding: 28px 0; }
  .auth-brand h1 { font-size: 42px; }
  .auth-brand > p:not(.eyebrow) { font-size: 14px; }
  .auth-card { padding: 20px; }
}
