:root {
  --page: #f2f4f9;
  --panel: #ffffff;
  --panel-soft: #eef1f8;
  --text: #10151f;
  --muted: #9aa0ac;
  --label: #8a909c;
  --border: #e6e9f1;
  --brand: #c8342b;          /* HKEX 紅 */
  --btn-off: #eceef3;
  --btn-off-text: #b7bcc7;
  --btn-on: #123a63;
  --btn-on-2: #2f5fc4;
  --gold: #a9822f;
  --gold-soft: #f7eed7;
  --danger: #c8342b;
  --success: #16a34a;
  --field-bg: #ffffff;
}

[data-theme="dark"] {
  --page: #0a0f1c;
  --panel: #121a2c;
  --panel-soft: #1a2440;
  --text: #eef1f8;
  --muted: #8a94ab;
  --label: #8a94ab;
  --border: #243050;
  --brand: #ff7a70;
  --btn-off: #1a2440;
  --btn-off-text: #5b6577;
  --btn-on: #1c4b7c;
  --btn-on-2: #6fa0ff;
  --gold: #e8c877;
  --gold-soft: rgba(232, 200, 119, .14);
  --danger: #ff7a70;
  --success: #34d399;
  --field-bg: #121a2c;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "PingFang HK", "PingFang SC", "Microsoft JhengHei", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--page);
  transition: background-color .25s ease, color .25s ease;
}

.app {
  min-height: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px 40px 40px;
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.brand { display: flex; align-items: center; }

.brand__logo {
  height: 40px;
  width: auto;
  display: block;
}

.lang {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #4b5160;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.lang:hover { color: var(--text); }

/* 語言下拉選單 */
.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 140px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(20, 30, 60, .14);
  padding: 6px;
  z-index: 30;
}
.lang-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  font-size: 14px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.lang-menu__flag { width: 18px; height: 13px; flex: 0 0 auto; object-fit: cover; border-radius: 2px; }
.lang-menu__item:hover { background: var(--panel-soft); color: var(--gold); }

/* 主題切換按鈕 + 語言按鈕分組 */
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.theme-toggle {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--panel-soft);
  color: var(--gold);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color .15s, transform .2s;
}
.theme-toggle:hover { color: var(--gold); transform: rotate(14deg); }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: block; }
.theme-toggle svg { width: 17px; height: 17px; display: block; }
.theme-toggle__moon { display: none; }
[data-theme="dark"] .theme-toggle__sun { display: none; }
[data-theme="dark"] .theme-toggle__moon { display: block; }

/* ---------- 登录主体 ---------- */
.login { max-width: 460px; }

.login__title {
  font-size: 26px;
  font-weight: 800;
  margin: 4px 0 16px;
}

.online {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  color: var(--label);
  background: var(--panel-soft);
  padding: 5px 12px;
  border-radius: 999px;
  margin-bottom: 30px;
}
.online strong { color: #6a7180; font-weight: 700; }

.online__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.18);
}

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }

label {
  display: block;
  font-size: 13px;
  color: var(--label);
  margin-bottom: 9px;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 16px 18px;
  font-size: 16px;
  color: var(--text);
  background: var(--field-bg);
  border: 1px solid transparent;
  border-radius: 14px;
  outline: none;
  box-shadow: 0 1px 2px rgba(20,30,60,.04);
  transition: border-color .18s, box-shadow .18s;
}

input::placeholder { color: #b9bec9; }

input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft);
}

input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(226,35,26,.10);
}

.input-wrap { position: relative; }
.input-wrap input { padding-right: 50px; }

.toggle {
  position: absolute;
  top: 50%; right: 10px;
  transform: translateY(-50%);
  display: grid; place-items: center;
  width: 34px; height: 34px;
  padding: 0; border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.toggle:hover { background: var(--panel-soft); color: var(--text); }
.toggle .icon-eye-off { display: none; }
.toggle[aria-pressed="true"] .icon-eye { display: none; }
.toggle[aria-pressed="true"] .icon-eye-off { display: block; }

.error {
  min-height: 15px;
  margin: 6px 2px 0;
  font-size: 12px;
  color: var(--danger);
}

/* ---------- 按钮 ---------- */
.btn {
  position: relative;
  width: 100%;
  padding: 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--btn-off-text);
  background: var(--btn-off);
  border: 0;
  border-radius: 14px;
  cursor: not-allowed;
  margin-top: 8px;
  transition: background .18s, color .18s, transform .08s;
}

.btn.ready {
  color: #fff;
  background: linear-gradient(135deg, var(--btn-on), var(--btn-on-2));
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(18, 58, 99, .3);
}
.btn.ready:hover { filter: brightness(1.08); }
.btn.ready:active { transform: scale(.99); }

.btn:disabled { pointer-events: none; }

.spinner {
  display: none;
  position: absolute;
  top: 50%; left: 50%;
  width: 18px; height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn.loading .btn__text { visibility: hidden; }
.btn.loading .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }

.form-message {
  min-height: 18px;
  margin: 10px 2px 0;
  font-size: 13px;
}
.form-message.ok { color: var(--success); }
.form-message.bad { color: var(--danger); }

.login-links {
  display: flex;
  justify-content: flex-end;
  margin: -6px 2px 8px;
}
.login-links a {
  font-size: 13px;
  color: var(--gold);
  text-decoration: none;
}
.login-links a:hover { text-decoration: underline; }

/* ---------- 在线客服 ---------- */
.service {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 22px;
  padding: 18px 22px;
  background: linear-gradient(180deg, var(--panel), var(--panel-soft));
  border: 1px solid var(--border);
  border-radius: 16px;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 2px 10px rgba(20,30,60,.03);
  transition: transform .15s, box-shadow .15s;
}
.service:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(20,30,60,.08); }

.service__text { display: flex; flex-direction: column; gap: 4px; }
.service__title { font-size: 15px; font-weight: 700; }
.service__sub { font-size: 12.5px; color: var(--muted); }

.service__icon {
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, var(--btn-on), var(--btn-on-2));
  box-shadow: 0 6px 16px rgba(18,58,99,.35);
}

/* ---------- 底部 ---------- */
.foot {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
}
.foot__register {
  display: inline-block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gold);
  text-decoration: none;
  margin-bottom: 10px;
}
.foot__register:hover { text-decoration: underline; }

.foot__terms { margin: 0; font-size: 12px; color: var(--muted); }
.foot__terms a { color: var(--muted); text-decoration: none; }
.foot__terms a:hover { text-decoration: underline; }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .app { padding: 18px 20px 28px; }
  .login { max-width: 100%; }
  .login__title { font-size: 22px; }
}

/* ---------- Google 按钮 ---------- */
/* #gSignInBtn 由 Google 官方 SDK 渲染，容器需居中，否则默认贴左对齐 */
#gSignInBtn {
  display: flex;
  justify-content: center;
}
.btn.google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.btn.google img {
  width: 18px;
  height: 18px;
  display: inline-block;
}
.btn.google:hover { background: var(--panel-soft); border-color: var(--gold); }

/* ---------- 注册页专用 ---------- */
.reg-lead {
  margin: -8px 0 26px;
  font-size: 13.5px;
  color: var(--muted);
}

.code-btn {
  position: absolute;
  top: 50%; right: 8px;
  transform: translateY(-50%);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold);
  background: var(--gold-soft);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
}
.code-btn:hover { filter: brightness(.96); }
.code-btn:disabled { color: var(--btn-off-text); background: var(--btn-off); cursor: not-allowed; }

.input-wrap input[maxlength] { padding-right: 118px; }

.agree {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 4px 2px 18px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  cursor: pointer;
}
.agree input { margin-top: 2px; accent-color: var(--gold); width: 15px; height: 15px; flex: 0 0 auto; }
.agree a { color: var(--gold); text-decoration: none; }
.agree a:hover { text-decoration: underline; }

.reg-back {
  margin: 20px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
.reg-back a { color: var(--gold); font-weight: 600; text-decoration: none; }
.reg-back a:hover { text-decoration: underline; }
