:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --text: #17211d;
  --muted: #65716c;
  --line: #dfe7e3;
  --green: #087e55;
  --green-dark: #066b49;
  --green-soft: #e9f6f0;
  --red: #bd342e;
  --red-dark: #a52a25;
  --red-soft: #fff0ef;
  --amber: #916211;
  --amber-soft: #fff6dc;
  --blue: #2e62a1;
  --blue-soft: #edf4fc;
  --shadow: 0 18px 48px rgba(25, 52, 41, .08);
  --radius: 18px;
  --sans: "Microsoft YaHei UI", "PingFang SC", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 2%, rgba(8, 126, 85, .08), transparent 28rem),
    var(--bg);
  font-family: var(--sans);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
[hidden] { display: none !important; }

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: .55rem; font-size: clamp(1.65rem, 3vw, 2.3rem); line-height: 1.2; letter-spacing: -.035em; }
h2 { margin-bottom: .25rem; font-size: 1.18rem; line-height: 1.3; }
.muted { color: var(--muted); }
.break-all { word-break: break-all; }

.boot-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .65rem;
  color: var(--muted);
}

.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #cbd7d1;
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.panel {
  background: var(--panel);
  border: 1px solid rgba(210, 222, 216, .9);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 1rem;
}

.login-card { width: min(100%, 410px); padding: 2.4rem; text-align: center; }
.login-card .stack { text-align: left; }
.login-intro { margin-bottom: 1.7rem; }

.brand, .dialog-icon, .claim-brand {
  display: grid;
  place-items: center;
  margin: 0 auto 1.2rem;
  width: 3.2rem;
  height: 3.2rem;
  color: #fff;
  background: linear-gradient(145deg, #10a875, #087e55);
  border-radius: 15px;
  box-shadow: 0 10px 22px rgba(8, 126, 85, .2);
  font-weight: 800;
  font-size: 1.45rem;
}

.eyebrow, .step-label, .claim-overline {
  margin-bottom: .45rem;
  color: var(--green);
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.stack { display: grid; gap: 1rem; }

.field { display: grid; gap: .42rem; color: #36413c; font-size: .86rem; font-weight: 700; }
.field b { color: var(--red); }
.field small { justify-self: end; margin-top: -.22rem; color: #85918b; font-size: .7rem; font-weight: 500; }

.field input, .field textarea {
  width: 100%;
  border: 1px solid #ccd8d2;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #fff;
  font-weight: 500;
  transition: border-color .15s, box-shadow .15s;
}

.field input { height: 44px; padding: 0 .8rem; }
.field textarea { min-height: 82px; padding: .68rem .8rem; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: #9aa49f; font-weight: 400; }
.field input:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(8, 126, 85, .11); }

.money-input { position: relative; display: block; }
.money-input i { position: absolute; z-index: 1; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; }
.money-input input { padding-left: 1.8rem; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.form-error { margin: 0; color: var(--red); font-size: .82rem; font-weight: 600; }

.button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  padding: .55rem .9rem;
  border: 1px solid transparent;
  border-radius: 9px;
  text-decoration: none;
  font-size: .84rem;
  font-weight: 700;
  line-height: 1.2;
  transition: background .15s, border-color .15s, transform .08s, opacity .15s;
}
.button:active:not(:disabled) { transform: translateY(1px); }
.button:focus-visible { outline: 3px solid rgba(8, 126, 85, .2); outline-offset: 2px; }
.button:disabled { cursor: not-allowed; opacity: .58; }
.button-primary { color: #fff; background: var(--green); }
.button-primary:hover:not(:disabled) { background: var(--green-dark); }
.button-secondary { color: #34433c; background: #fff; border-color: #cdd9d3; }
.button-secondary:hover:not(:disabled), .button-quiet:hover:not(:disabled) { background: #f1f5f3; }
.button-quiet { min-height: 36px; color: #405049; background: transparent; }
.button-danger { color: #fff; background: var(--red); }
.button-danger:hover:not(:disabled) { background: var(--red-dark); }
.button-wechat { min-height: 49px; color: #fff; background: #07c160; font-size: .95rem; }
.button-wechat:hover:not(:disabled) { background: #06ad56; }
.button-wide { width: 100%; }

.topbar { position: sticky; z-index: 10; top: 0; border-bottom: 1px solid rgba(211, 222, 216, .9); background: rgba(255,255,255,.9); backdrop-filter: blur(15px); }
.topbar-inner { width: min(1440px, calc(100% - 2rem)); height: 64px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; }
.wordmark { display: inline-flex; align-items: center; gap: .65rem; color: var(--text); text-decoration: none; font-weight: 800; }
.wordmark-mark { display: grid; place-items: center; width: 1.9rem; height: 1.9rem; color: #fff; background: var(--green); border-radius: 8px; }
.topbar-actions { display: flex; align-items: center; gap: .25rem; }

.page-shell { width: min(1440px, calc(100% - 2rem)); margin: 0 auto; padding: 2.1rem 0 3rem; }
.page-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 1.45rem; }
.page-heading p:last-child { margin-bottom: 0; }
.dashboard-grid { display: grid; grid-template-columns: minmax(330px, 390px) minmax(0, 1fr); align-items: start; gap: 1.2rem; }
.transfer-panel { padding: 1.45rem; }
.orders-panel { min-height: 400px; overflow: hidden; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; }
.orders-heading { margin: 0; padding: 1.4rem 1.5rem 1rem; }
.security-note { margin: -.25rem 0 0; color: var(--muted); text-align: center; font-size: .74rem; }
.security-note span { color: var(--green); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th { padding: .7rem 1rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); color: #748079; background: #f7f9f8; text-align: left; font-size: .7rem; white-space: nowrap; }
td { padding: 1rem; border-bottom: 1px solid #e8eeeb; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfc; }
.cell-primary { display: block; color: var(--text); font-weight: 750; }
.cell-secondary { display: block; margin-top: .18rem; color: var(--muted); font-size: .7rem; }
.openid-text { max-width: 205px; word-break: break-all; }
.amount-text { white-space: nowrap; font-size: .94rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.actions-column { text-align: right; }
.table-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .35rem; min-width: 150px; }
.action-button { min-height: 30px; padding: .35rem .58rem; border: 1px solid #d3ded8; border-radius: 7px; color: #385048; background: #fff; font-size: .7rem; font-weight: 700; }
.action-button:hover:not(:disabled) { border-color: #aebfb6; background: #f5f8f6; }
.action-button.danger { color: var(--red); }

.status-pill { display: inline-flex; align-items: center; min-height: 25px; padding: .2rem .55rem; border-radius: 999px; color: var(--blue); background: var(--blue-soft); font-size: .7rem; font-weight: 750; white-space: nowrap; }
.status-pill.waiting { color: var(--amber); background: var(--amber-soft); }
.status-pill.success { color: var(--green); background: var(--green-soft); }
.status-pill.failed { color: var(--red); background: var(--red-soft); }
.status-pill.cancelled { color: #606b66; background: #eef1ef; }

.empty-state { padding: 4.7rem 1rem; color: var(--muted); text-align: center; }
.empty-state span { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; margin: 0 auto .8rem; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 1.2rem; font-weight: 800; }
.empty-state strong { display: block; color: #46534d; }
.empty-state p { margin: .2rem 0 0; font-size: .78rem; }
.orders-loading { padding: 4rem 1rem; color: var(--muted); text-align: center; }

.confirm-dialog { width: min(94vw, 520px); max-height: 90vh; padding: 0; border: 0; border-radius: 20px; color: var(--text); background: #fff; box-shadow: 0 30px 90px rgba(19, 40, 31, .25); }
.confirm-dialog::backdrop { background: rgba(21, 33, 28, .48); backdrop-filter: blur(3px); }
.confirm-dialog form { padding: 1.8rem; }
.dialog-icon { width: 2.8rem; height: 2.8rem; margin-left: 0; margin-bottom: 1rem; border-radius: 12px; }
.confirm-list { margin: 1.35rem 0; border-top: 1px solid var(--line); }
.confirm-list div { display: grid; grid-template-columns: 88px 1fr; gap: 1rem; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.confirm-list dt { color: var(--muted); font-size: .78rem; }
.confirm-list dd { margin: 0; text-align: right; font-size: .82rem; font-weight: 700; }
.confirm-list .confirm-money { color: var(--red); font-size: 1.08rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.35fr; gap: .65rem; margin-top: 1.3rem; }

.toast-region { position: fixed; z-index: 100; right: 1rem; bottom: 1rem; display: grid; gap: .5rem; pointer-events: none; }
.toast { max-width: min(380px, calc(100vw - 2rem)); padding: .78rem 1rem; border: 1px solid #cfe0d8; border-radius: 10px; color: #fff; background: #253a31; box-shadow: 0 12px 34px rgba(23, 40, 32, .2); font-size: .8rem; font-weight: 650; animation: toast-in .2s ease-out; }
.toast.error { background: #772e2a; border-color: #8c3b36; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.claim-page { background: linear-gradient(160deg, #eaf8f1 0, #f6f8f7 42%, #eef3f0 100%); }
.claim-shell { width: min(100% - 2rem, 450px); min-height: 100vh; margin: 0 auto; padding: max(2rem, env(safe-area-inset-top)) 0 max(1.2rem, env(safe-area-inset-bottom)); display: flex; flex-direction: column; justify-content: center; }
.claim-card { padding: 2.1rem 1.45rem 1.5rem; border: 1px solid rgba(202, 220, 211, .8); border-radius: 24px; background: rgba(255,255,255,.96); box-shadow: 0 22px 64px rgba(30, 72, 54, .11); text-align: center; }
.claim-brand { width: 3rem; height: 3rem; border-radius: 50%; }
.claim-overline { margin-bottom: .35rem; }
.claim-card h1 { font-size: 1.6rem; }
.claim-state { min-height: 240px; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }
.claim-state .spinner { width: 1.45rem; height: 1.45rem; }
.claim-state p { margin: .8rem 0 0; }
.claim-amount { margin: 1.7rem 0; }
.claim-amount span { display: block; margin-bottom: .2rem; color: var(--muted); font-size: .78rem; }
.claim-amount strong { font-size: 2.25rem; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.claim-details { margin: 0 0 1.2rem; padding: .4rem 1rem; border-radius: 12px; background: #f6f8f7; text-align: left; }
.claim-details div { display: grid; grid-template-columns: 5rem 1fr; gap: .5rem; padding: .65rem 0; border-bottom: 1px solid #e3e9e6; }
.claim-details div:last-child { border-bottom: 0; }
.claim-details dt { color: var(--muted); font-size: .78rem; }
.claim-details dd { margin: 0; text-align: right; font-size: .8rem; font-weight: 700; word-break: break-word; }
.claim-message { margin: 0 0 1rem; padding: .7rem; border-radius: 9px; color: #6b551b; background: var(--amber-soft); font-size: .76rem; }
.claim-message.success { color: var(--green); background: var(--green-soft); }
.claim-message.error { color: var(--red); background: var(--red-soft); }
.claim-retry { margin-top: .65rem; }
.state-symbol { display: grid; place-items: center; width: 2.8rem; height: 2.8rem; border-radius: 50%; color: var(--red); background: var(--red-soft); font-size: 1.2rem; font-weight: 900; }
.claim-error h2 { margin-top: 1rem; }
.claim-error .button { margin-top: 1.2rem; }
.claim-footer { margin: 1rem .8rem 0; color: #748079; text-align: center; font-size: .7rem; }

@media (max-width: 930px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .transfer-panel { max-width: none; }
}

@media (max-width: 600px) {
  .topbar-inner, .page-shell { width: min(100% - 1rem, 1440px); }
  .topbar-inner { height: 58px; }
  .wordmark > span:last-child { display: none; }
  .topbar-actions { gap: 0; }
  .page-shell { padding-top: 1.2rem; }
  .page-heading { padding: 0 .35rem; }
  .page-heading .muted { font-size: .8rem; }
  .transfer-panel { padding: 1.15rem; }
  .form-row { grid-template-columns: 1fr; }
  .orders-heading { padding: 1.15rem; }
  th, td { padding: .8rem; }
  .login-card { padding: 2rem 1.35rem; }
  .confirm-dialog form { padding: 1.35rem; }
  .confirm-list div { grid-template-columns: 75px 1fr; }
  .dialog-actions { grid-template-columns: 1fr; }
  .toast-region { right: .5rem; bottom: .5rem; }
}

/* ============ 候选人管理 ============ */

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.candidate-manage-btn {
  min-height: 28px;
  padding: 0.2rem 0.6rem;
  font-size: 0.72rem;
  color: var(--green);
  border: 1px solid #cfe0d8;
  border-radius: 6px;
  background: var(--green-soft);
}

.candidate-manage-btn:hover:not(:disabled) {
  background: #d8ede4;
}

.candidate-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.candidate-select {
  flex: 1;
  height: 44px;
  padding: 0 0.8rem;
  border: 1px solid #ccd8d2;
  border-radius: 10px;
  outline: none;
  color: var(--text);
  background: #fff;
  font-weight: 500;
  font-size: 0.86rem;
  transition: border-color .15s, box-shadow .15s;
}

.candidate-select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 126, 85, .11);
}

.candidate-select:disabled {
  background: #f3f5f4;
  color: #999;
  cursor: not-allowed;
}

.or-divider {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.field-hint {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 400;
}

/* 候选人管理对话框 */
.candidate-dialog {
  width: min(94vw, 580px);
  max-height: 80vh;
  padding: 0;
  border: 0;
  border-radius: 20px;
  color: var(--text);
  background: #fff;
  box-shadow: 0 30px 90px rgba(19, 40, 31, .25);
}

.candidate-dialog::backdrop {
  background: rgba(21, 33, 28, .48);
  backdrop-filter: blur(3px);
}

.candidate-dialog > div {
  padding: 1.5rem;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.dialog-header h2 {
  margin: 0;
}

.dialog-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: background .15s;
}

.dialog-close:hover {
  background: #f1f5f3;
}

.candidate-add-form {
  display: grid;
  grid-template-columns: 1fr 1.5fr auto;
  gap: 0.6rem;
  margin-bottom: 1.2rem;
}

.candidate-add-form input {
  height: 40px;
  padding: 0 0.7rem;
  border: 1px solid #ccd8d2;
  border-radius: 8px;
  outline: none;
  font-size: 0.82rem;
  transition: border-color .15s;
}

.candidate-add-form input:focus {
  border-color: var(--green);
}

.candidate-add-form .button {
  min-height: 40px;
  white-space: nowrap;
}

.candidate-list {
  display: grid;
  gap: 0.5rem;
  max-height: 45vh;
  overflow-y: auto;
}

.candidate-empty {
  padding: 2rem 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.candidate-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid #e3eae6;
  border-radius: 10px;
  background: #fafcfb;
}

.candidate-info {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.candidate-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
}

.candidate-openid {
  font-size: 0.72rem;
  color: var(--muted);
  word-break: break-all;
}

.candidate-actions {
  display: flex;
  gap: 0.4rem;
  flex-shrink: 0;
}

.candidate-actions .button {
  min-height: 30px;
  padding: 0.25rem 0.6rem;
  font-size: 0.72rem;
}

.candidate-actions .danger {
  color: var(--red);
}

@media (max-width: 600px) {
  .candidate-add-form {
    grid-template-columns: 1fr;
  }
  
  .candidate-row {
    flex-direction: column;
    align-items: stretch;
  }
  
  .or-divider {
    text-align: center;
  }
}

.success-time {
  color: var(--green);
  font-weight: 600;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
