: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); }
.floating-language { position: fixed; z-index: 20; top: 18px; right: 20px; }
.language-switch { display: inline-flex; padding: 3px; border: 1px solid var(--line); background: rgba(8,12,18,.9); backdrop-filter: blur(10px); }
.lang-button { border: 0; background: transparent; color: var(--muted); padding: 7px 10px; font: 700 11px/1 ui-monospace, SFMono-Regular, Consolas, monospace; }
.lang-button.active { background: var(--cyan-dim); color: var(--cyan); }
.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; width: 1px; height: 1px; 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; }
.rewards-panel { margin-bottom: 12px; overflow: hidden; }
.rewards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; padding: 0 22px 22px; }
.reward-card { position: relative; min-height: 150px; display: grid; grid-template-columns: 84px 1fr; gap: 14px; align-items: center; padding: 14px; border: 1px solid var(--line); background: var(--panel-strong); }
.reward-card.unread { border-color: rgba(97,231,212,.55); box-shadow: inset 3px 0 var(--cyan); }
.reward-media { width: 84px; height: 84px; display: grid; place-items: center; overflow: hidden; background: #081018; color: var(--cyan); font-size: 40px; }
.reward-media img, .reward-media video { width: 100%; height: 100%; object-fit: contain; }
.reward-copy { min-width: 0; }
.reward-copy strong { display: block; margin-bottom: 6px; }
.reward-copy p { margin: 0 0 8px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.reward-copy small { color: var(--green); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.reward-new { position: absolute; top: 8px; right: 8px; color: var(--cyan); font: 700 9px/1 ui-monospace, monospace; }

.reward-studio { margin-bottom: 14px; overflow: hidden; }
.reward-upload-form, .send-reward-form { display: grid; grid-template-columns: minmax(160px, .7fr) minmax(240px, 1fr) auto auto; gap: 12px; align-items: end; padding: 0 22px 20px; }
.reward-upload-form input[type="file"] { padding: 10px; }
.reward-checkbox { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; color: var(--text); }
.reward-checkbox input { width: auto; }
.reward-action { width: auto !important; white-space: nowrap; }
.asset-library { display: flex; flex-wrap: wrap; gap: 9px; padding: 0 22px 22px; }
.asset-chip { display: grid; grid-template-columns: 46px 1fr; gap: 9px; align-items: center; min-width: 190px; padding: 8px; border: 1px solid var(--line); background: rgba(8,12,18,.35); }
.asset-chip img, .asset-chip video { width: 46px; height: 46px; object-fit: contain; background: #080d12; }
.asset-chip small { display: block; color: var(--muted); }
.send-reward-form { grid-template-columns: minmax(160px,.7fr) minmax(180px,1fr) minmax(220px,1.2fr) auto; border-top: 1px solid var(--line); padding-top: 18px; }
.send-reward-form select { width: 100%; padding: 13px 14px; border: 1px solid #34424f; background: #0c1219; color: var(--text); }
.reward-history-title { margin: 0; padding: 0 22px 12px; font-size: 15px; }
.detail-rewards { padding-bottom: 18px; }
@media (max-width: 980px) {
  .reward-upload-form, .send-reward-form { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 620px) {
  .reward-upload-form, .send-reward-form { grid-template-columns: 1fr; }
}
.admin-body { background: var(--bg); }
.admin-shell { width: min(1540px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 70px; }
.admin-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 24px; }
.admin-subtitle { color: var(--muted); font-size: 12px; }
.admin-actions { display: flex; align-items: center; gap: 10px; }
.admin-back { display: inline-block; width: auto; text-decoration: none; }
.admin-metrics { grid-template-columns: repeat(4, 1fr); }
.admin-users-panel { overflow: hidden; }
.admin-search { width: min(320px, 42vw); }
.user-open { display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: transparent; color: var(--text); text-align: left; }
.user-open small, td small { display: block; margin-top: 3px; color: var(--muted); }
.admin-detail { margin-top: 14px; scroll-margin-top: 18px; }
.admin-detail-grid { display: grid; gap: 16px; padding: 0 22px 24px; }
.admin-detail-grid > div { min-width: 0; border: 1px solid var(--line); overflow: hidden; }
.admin-detail-grid h3 { margin: 0; padding: 16px 18px; font-size: 15px; }
.detail-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; padding: 0 22px 18px; }
.detail-metrics > div { display: flex; flex-direction: column; gap: 7px; padding: 14px; border: 1px solid var(--line); background: rgba(8,12,18,.3); }
.detail-metrics span { color: var(--muted); font-size: 11px; }
.detail-metrics strong { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
@media (max-width: 820px) {
  .admin-shell { width: min(100% - 22px, 1540px); padding-top: 22px; }
  .admin-header { align-items: flex-start; flex-direction: column; }
  .admin-actions { width: 100%; justify-content: space-between; }
  .admin-metrics, .detail-metrics { grid-template-columns: 1fr 1fr; }
  .admin-users-panel .panel-heading { flex-direction: column; }
  .admin-search { width: 100%; }
}
@media (max-width: 480px) {
  .admin-metrics, .detail-metrics { grid-template-columns: 1fr; }
}
.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) {
  .floating-language { top: 10px; right: 11px; }
  .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; flex-wrap: wrap; }
  .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; }
  .metric strong { font-size: 24px; letter-spacing: 0; overflow-wrap: anywhere; }
  .panel-heading { align-items: flex-start; flex-direction: column; }
  .input-row { grid-template-columns: 1fr; }
  .quote-card { align-items: flex-start; flex-direction: column; gap: 14px; }
  .quote-price { text-align: left; }
  .rewards-grid { grid-template-columns: 1fr; padding-inline: 14px; }
  .reward-card { grid-template-columns: 68px 1fr; }
  .reward-media { width: 68px; height: 68px; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
  tbody { display: grid; gap: 10px; padding: 0 12px 14px; }
  tr { border: 1px solid var(--line); background: rgba(8,12,18,.25); }
  td { display: flex; justify-content: space-between; gap: 16px; text-align: right; white-space: normal; border-top: 1px solid var(--line); padding: 11px 12px !important; font-size: 12px; }
  td:first-child { border-top: 0; }
  td::before { content: attr(data-label); color: var(--muted); text-align: left; }
  .empty-row { display: block; padding: 22px 12px !important; text-align: center !important; }
  .empty-row::before { content: ""; }
  .admin-header { padding-top: 34px; }
}

@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; }
}
