:root {
  --bg: #f6f7fb;
  --bg-grad: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6b7280;
  --border: #e8e8f0;
  --primary: #6c5ce7;
  --primary-d: #5a4bd1;
  --gold: #f6b93b;
  --silver: #b2bec3;
  --bronze: #d68110;
  --danger: #e74c3c;
  --ok: #2ecc71;
  --shadow: 0 4px 24px rgba(80, 70, 160, 0.10);
  --shadow-lg: 0 12px 40px rgba(80, 70, 160, 0.18);
  --radius: 16px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 20px; }

/* ---------- Header ---------- */
.site-header {
  background: var(--bg-grad);
  color: #fff;
  padding: 28px 0;
  box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 40px; line-height: 1; }
.brand-text h1 { font-size: 26px; font-weight: 800; letter-spacing: .5px; }
.tagline { font-size: 13px; opacity: .85; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font-size: 15px; font-weight: 600;
  padding: 10px 22px; border-radius: 10px; transition: all .2s; text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: #fff; color: var(--primary); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,0,0,.18); }
.btn-lg { padding: 14px 30px; font-size: 16px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: 6px 14px; font-size: 13px; }

/* on dark header, primary button is white bg */
.site-header .btn-primary { background: #fff; color: var(--primary); }

/* ---------- Leaderboard ---------- */
.leaderboard { margin-top: 32px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; padding: 28px; }
.lb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.lb-head h2 { font-size: 22px; }
.lb-meta { display: flex; align-items: center; gap: 12px; }
.chip { font-size: 13px; color: var(--muted); background: var(--bg); padding: 5px 12px; border-radius: 20px; }
.live { font-size: 12px; color: var(--ok); display: flex; align-items: center; gap: 5px; font-weight: 600; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.7); } }

/* Podium */
.podium { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; align-items: end; margin-bottom: 28px; }
.podium-item {
  background: var(--card); border-radius: 14px; padding: 18px 10px; text-align: center;
  border: 2px solid transparent; position: relative; transition: transform .3s;
}
.podium-item:hover { transform: translateY(-4px); }
.podium-item .medal { font-size: 32px; line-height: 1; margin-bottom: 8px; }
.podium-item .pname { font-weight: 700; font-size: 15px; margin-bottom: 4px; word-break: break-all; }
.podium-item .pamt { font-weight: 800; font-size: 16px; }
.podium-1 { order: 2; padding-top: 28px; border-color: var(--gold); background: linear-gradient(180deg,#fffbe6,#fff); }
.podium-1 .pamt { color: var(--bronze); }
.podium-2 { order: 1; border-color: var(--silver); background: linear-gradient(180deg,#f7f7fa,#fff); }
.podium-3 { order: 3; border-color: #cd7f32; background: linear-gradient(180deg,#fdf0e6,#fff); }
@media (max-width: 560px) {
  .podium-item .medal { font-size: 26px; }
  .podium-item .pname { font-size: 13px; }
  .podium-item .pamt { font-size: 14px; }
  .podium-1 { padding-top: 18px; }
}

/* Rank list */
.rank-list { list-style: none; }
.rank-item {
  display: flex; align-items: center; gap: 16px; padding: 14px 16px;
  border-radius: 12px; transition: background .2s;
  border-bottom: 1px solid var(--border);
}
.rank-item:hover { background: var(--bg); }
.rank-item:last-child { border-bottom: none; }
.rank-item.is-me { background: linear-gradient(90deg, #f0f4ff, #fff); border-left: 4px solid var(--primary); }
.me-badge { display: inline-block; margin-left: 6px; font-size: 10px; font-weight: 800; color: #fff; background: var(--primary); padding: 2px 7px; border-radius: 10px; vertical-align: middle; }
.btn-boost { display: inline-flex; align-items: center; gap: 2px; margin-left: 8px; padding: 3px 10px; font-size: 11px; font-weight: 700; color: #fff; background: var(--primary); border: none; border-radius: 6px; cursor: pointer; transition: opacity .2s; white-space: nowrap; }
.btn-boost:hover { opacity: .85; }
.rank-no { font-size: 18px; font-weight: 800; color: var(--muted); min-width: 38px; text-align: center; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-sub { font-size: 12px; color: var(--muted); }
.rank-amount { font-weight: 800; font-size: 18px; color: var(--primary); white-space: nowrap; }
.rank-item.flash { animation: flashRow 1.2s ease; }
@keyframes flashRow { 0% { background: #eef0ff; } 100% { background: transparent; } }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 56px; margin-bottom: 12px; }
.empty-state h3 { font-size: 20px; margin-bottom: 8px; }
.empty-state p { color: var(--muted); margin-bottom: 20px; }

/* ---------- Find my rank ---------- */
.find-rank-bar { display: flex; gap: 10px; margin-bottom: 22px; }
.find-rank-bar input { flex: 1; border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 15px; font-family: inherit; }
.find-rank-bar input:focus { outline: none; border-color: var(--primary); }

.my-rank { background: linear-gradient(135deg, #f6f7fb, #fff); border: 1.5px solid var(--border); border-radius: 14px; padding: 18px 20px; margin-bottom: 24px; }
.my-rank-main { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.my-rank-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.my-rank-name { font-size: 18px; font-weight: 800; }
.my-rank-nums { display: flex; gap: 24px; text-align: center; }
.my-rank-nums div { display: flex; flex-direction: column; }
.my-rank-nums span { font-size: 22px; font-weight: 800; color: var(--primary); }
.my-rank-nums small { font-size: 12px; color: var(--muted); }
.my-rank-list { margin-top: 8px; }
.my-rank-list .rank-item { padding: 10px 12px; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20,15,50,.55); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; background: var(--card); border-radius: var(--radius);
  width: 100%; max-width: 440px; padding: 32px; box-shadow: var(--shadow-lg);
  animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-close { position: absolute; top: 14px; right: 16px; background: none; border: none; font-size: 26px; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-card h2 { font-size: 22px; margin-bottom: 6px; }
.modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.pay-form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text); }
.field small { color: var(--muted); font-weight: 400; }
.field input {
  border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px; font-size: 15px;
  font-family: inherit; transition: border-color .2s; background: #fff;
}
.field input:focus { outline: none; border-color: var(--primary); }
.amount-input { display: flex; align-items: center; border: 1.5px solid var(--border); border-radius: 10px; overflow: hidden; }
.amount-input:focus-within { border-color: var(--primary); }
.cur-symbol { padding: 0 12px; font-weight: 700; color: var(--muted); background: var(--bg); height: 100%; display: flex; align-items: center; align-self: stretch; }
.amount-input input { border: none; border-radius: 0; }
.amount-input input:focus { border: none; }
.quick-amounts { display: flex; gap: 8px; flex-wrap: wrap; }
.quick-amounts button {
  flex: 1; min-width: 70px; padding: 8px; border: 1.5px solid var(--border); background: #fff;
  border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all .15s; font-family: inherit;
}
.quick-amounts button:hover { border-color: var(--primary); color: var(--primary); }
.pay-note { font-size: 12px; color: var(--muted); min-height: 16px; }

.manual-box { background: var(--bg); border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.manual-instructions { font-size: 14px; line-height: 1.7; }
.manual-instructions .copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0; }
.manual-instructions code { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-family: ui-monospace, monospace; font-size: 12px; word-break: break-all; }
.btn-copy { padding: 4px 10px; font-size: 12px; border: 1px solid var(--primary); color: var(--primary); background: #fff; border-radius: 6px; cursor: pointer; font-weight: 600; }
.ins-note { margin-top: 8px; color: var(--muted); font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: #1a1a2e; color: #fff; padding: 14px 24px; border-radius: 10px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); z-index: 2000;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }

/* ---------- Footer ---------- */
.site-footer { margin-top: 48px; padding: 24px 0; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- Success page ---------- */
.success-card { margin-top: 80px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 48px 32px; text-align: center; max-width: 460px; margin-left: auto; margin-right: auto; }
.success-icon { font-size: 64px; margin-bottom: 12px; }
.success-info { background: var(--bg); border-radius: 10px; padding: 16px; margin: 16px 0; font-weight: 600; }

/* ---------- Admin ---------- */
.admin-login { max-width: 380px; margin: 80px auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 36px; text-align: center; }
.admin-login .lock-icon { font-size: 48px; margin-bottom: 12px; }
.admin-login h2 { margin-bottom: 6px; }
.admin-login p { color: var(--muted); margin-bottom: 24px; font-size: 14px; }

.admin-bar { background: #1a1a2e; color: #fff; padding: 14px 0; position: sticky; top: 0; z-index: 50; }
.admin-bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.admin-bar .brand-mini { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.admin-bar .brand-mini span { font-size: 22px; }
.admin-bar .btn-primary { background: var(--primary); color: #fff; }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 28px; }
.stat-card { background: var(--card); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.stat-card .value { font-size: 24px; font-weight: 800; }
.stat-card .value.ok { color: var(--ok); }
.stat-card .value.warn { color: var(--bronze); }
.stat-card .value.info { color: var(--primary); }

.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; margin-bottom: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.panel-head h3 { font-size: 18px; }
.panel-head .tools { display: flex; gap: 8px; flex-wrap: wrap; }
.panel-head select, .panel-head input { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14px; font-family: inherit; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
td .mono { font-family: ui-monospace, monospace; font-size: 12px; color: var(--muted); }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.status-paid { background: #e3fcef; color: var(--ok); }
.status-pending { background: #fff4e6; color: var(--bronze); }
.status-refunded { background: #fdecea; color: var(--danger); }
.provider-badge { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--border); }
.row-actions { display: flex; gap: 6px; }

.form-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.form-row .field { flex: 1; min-width: 120px; }

/* ---------- Provider Config Cards ---------- */
.providers-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.provider-card { background: var(--bg); border-radius: 14px; padding: 18px 20px; border: 1.5px solid var(--border); transition: border-color .2s; }
.provider-card:hover { border-color: var(--primary); }
.provider-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.provider-card-title { display: flex; align-items: center; gap: 10px; }
.provider-card-title .pc-name { font-weight: 800; font-size: 16px; }
.provider-card-title .pc-mode { font-size: 11px; padding: 2px 8px; border-radius: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.pc-mode.redirect { background: #e3fcef; color: var(--ok); }
.pc-mode.manual { background: #fff4e6; color: var(--bronze); }
.pc-mode.crypto { background: #f0f0ff; color: var(--primary); }
.pc-mode.bank { background: #fdf0e6; color: #cd7f32; }
.provider-card .env-badge { font-size: 11px; padding: 3px 10px; border-radius: 12px; font-weight: 700; }
.env-badge.ready { background: #e3fcef; color: var(--ok); }
.env-badge.not-ready { background: #fdecea; color: var(--danger); }
.provider-card .pc-fields { margin: 10px 0 12px; }
.pc-field { display: flex; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.pc-field:last-child { border-bottom: none; }
.pc-field-label { color: var(--muted); }
.pc-field-status { font-weight: 700; font-size: 12px; }
.pc-field-status.set { color: var(--ok); }
.pc-field-status.unset { color: var(--danger); }
.provider-card .pc-webhook { margin-bottom: 12px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.provider-card .pc-webhook code { background: var(--card); border: 1px solid var(--border); border-radius: 4px; padding: 3px 8px; font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; }
.provider-card .pc-actions { display: flex; gap: 8px; }
.pc-test-result { font-size: 12px; padding: 8px 12px; border-radius: 8px; margin-top: 10px; }
.pc-test-result.ok { background: #e3fcef; color: var(--ok); }
.pc-test-result.fail { background: #fdecea; color: var(--danger); }
.pc-test-result.testing { background: #fff4e6; color: var(--bronze); }

@media (max-width: 640px) {
  .brand-text h1 { font-size: 20px; }
  .header-inner { flex-direction: column; text-align: center; }
  .lb-head h2 { font-size: 18px; }
  .rank-no { min-width: 30px; font-size: 16px; }
  .rank-amount { font-size: 16px; }
  .modal-card { padding: 24px 20px; }
}
