/* ================================
 * a51.css — Referral (推薦人 / 返傭) 置中版（X 在框右上）
 * ================================ */

/* 遮罩：背景模糊 */
#a51-ref-modal{
  position: fixed; inset: 0;
  display: none;                          /* JS 會設為 flex */
  align-items: center; justify-content: center;
  background: rgba(0,0,0,.6);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
  z-index: 10000;
  padding-left:  calc(env(safe-area-inset-left) + 12px);
  padding-right: calc(env(safe-area-inset-right) + 12px);
}
#a51-ref-modal[style*="display: flex"]{ display:flex !important; }

/* 卡片本體：::after 霓虹外框 */
#a51-ref-modal .a51-card{
  position: relative;
  width: min(420px, calc(100vw - 24px));
  max-width: 100%;
  margin: 0 auto;
  padding: 18px 16px 16px;
  background: rgba(20,20,40,.95);
  border-radius: 12px;
  border: 2px solid transparent;          /* 讓 ::after 的 content-box 有間距 */
  box-shadow:
    0 0 12px rgba(0,255,255,.45),
    0 0 24px rgba(255,0,255,.25),
    inset 0 0 8px rgba(0,255,255,.18);
  overflow: hidden;
}
#a51-ref-modal .a51-card::after{
  content:""; position:absolute; inset:0; border-radius:inherit; padding:2px;
  background: linear-gradient(135deg,#00ffff,#ff00ff,#00ffff);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  pointer-events:none;
}
#a51-ref-modal .a51-card::before{
  content:"";
  position:absolute; inset:0; pointer-events:none;
  background:
    linear-gradient(rgba(255,255,255,.05) 1px, transparent 1px) 0 0,
    linear-gradient(90deg, rgba(255,255,255,.05) 1px, transparent 1px) 0 0;
  background-size:20px 20px;
  mix-blend-mode: overlay;
}

/* Header */
#a51-ref-modal .a51-header{
  display:flex; align-items:center; justify-content:center;
  gap: 0;
  padding-bottom: 14px;
  position: relative;
  margin-bottom: 10px;
}
#a51-ref-modal .a51-header::after{
  content:"";
  position:absolute; left:0; right:0; bottom:0; height:1px;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,.18) 20%, rgba(255,255,255,.18) 80%, transparent 100%);
}

/* 關閉鍵 */
#a51-ref-modal .a51-close{
  position:absolute; right: 8px; top: 8px;
  z-index: 5; appearance: none;
  border: 0; background: transparent; color: #fff;
  width: 28px; height: 28px; line-height: 28px; text-align: center;
  font-size: 18px; border-radius: 6px; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
#a51-ref-modal .a51-close:hover{ background: rgba(255,255,255,.08); transform: translateY(-1px); }

/* Tabs */
#a51-ref-modal .a51-tabs{ display:flex; gap:40px; justify-content:center; align-items:baseline; flex: 0 0 auto; }
#a51-ref-modal .a51-tab-btn{
  background: transparent; border: 0;
  padding: 8px 4px 14px;
  color: rgba(255,255,255,.82);
  font-weight: 800; letter-spacing: .2px;
  cursor: pointer; position: relative; white-space: nowrap;
  transition: color .15s ease, transform .08s ease;
}
#a51-ref-modal .a51-tab-btn:hover{ color:#bff5ff; transform: translateY(-1px); }
#a51-ref-modal .a51-tab-btn::after{
  content:""; position:absolute; bottom:-3px; height:3px;
  width:56px; left:50%; transform: translateX(-50%);
  border-radius:999px; background: transparent; box-shadow:none; transition: all .2s ease;
}
#a51-ref-modal .a51-tab-btn.active{
  color:#00ffff;
  text-shadow: 0 0 6px rgba(0,255,255,.6), 0 0 10px rgba(255,0,255,.35);
}
#a51-ref-modal .a51-tab-btn.active::after{
  background: linear-gradient(90deg, #00ffff, #ff00ff, #00ffff);
  box-shadow: 0 0 10px rgba(0,255,255,.6), 0 0 14px rgba(255,255,255,.45);
}

#a51-ref-modal .a51-tab-content{ margin-top: 6px; }

/* 推薦人（輸入列） */
#a51-ref-modal .a51-ref-block{ margin-bottom:10px; max-width: 360px; margin-left:auto; margin-right:auto; }
#a51-ref-modal .a51-label{ display:block; margin:0 0 8px; font-size:.95rem; color:#9aeaff; text-shadow:0 0 4px rgba(0,0,0,.6); text-align:center; }
#a51-ref-modal .a51-link-row{ display:flex; gap:8px; align-items:stretch; }
#a51-ref-modal #a51-upline-input{
  flex:1; padding:10px 12px; border-radius:8px; border:1px solid rgba(255,255,255,.22);
  background:rgba(0,0,0,.28); color:#fff; outline:none; box-shadow: inset 0 0 6px rgba(0,0,0,.35);
}
#a51-ref-modal #a51-upline-input::placeholder{ color: rgba(255,255,255,.45); }
#a51-ref-modal #a51-upline-input:disabled{ opacity:.7; cursor:not-allowed; }
#a51-ref-modal #a51-bind-btn:disabled{ opacity:.6; cursor:not-allowed; }

#a51-ref-modal .a51-tip{ font-size:.86rem; opacity:.9; margin-top:6px; color:#c8f7ff; }

/* 綁定狀態 */
#a51-bound-status{ text-align:center; margin-top:8px; font-size:.95rem; opacity:.9; }

/* KPI（返傭） */
#a51-ref-modal .a51-kpis{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:8px; }
#a51-ref-modal .a51-kpi{
  background: rgba(255,255,255,.06);
  border:1px solid rgba(255,255,255,.12);
  border-radius:10px; padding:10px 12px; text-align:center;
  box-shadow: inset 0 0 6px rgba(0,0,0,.25);
}
#a51-ref-modal .a51-kpi-label{ font-size:.82rem; opacity:.85; margin-bottom:4px; }
#a51-ref-modal .a51-kpi-value{
  font-weight:800; font-size:1.06rem;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* 表格（返傭） */
#a51-ref-modal .a51-table-wrap{ max-height:320px; overflow-y:auto; overflow-x:hidden; }
#a51-ref-modal .a51-table{
  width:100%; border-collapse:separate; border-spacing:0; table-layout: fixed;
}
#a51-ref-modal .a51-table thead th{
  position:sticky; top:0;
  background:rgba(0,0,0,.45);
  backdrop-filter: blur(4px);
  text-align:left; padding:8px; font-weight:800;
  border-bottom:1px solid rgba(255,255,255,.15);
  white-space: nowrap; overflow:hidden; text-overflow: ellipsis;
}
/* NEW: 桌機—讓第 1 欄表頭可換行（支持 Downline<br>Wallet 或空白斷行） */
#a51-ref-modal .a51-table thead th:nth-child(1){
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.15;
}
/* 既有：桌機—讓第 2 欄表頭可換行、不使用省略號 */
#a51-ref-modal .a51-table thead th:nth-child(2){
  white-space: normal;    /* 取消 nowrap */
  overflow: visible;
  text-overflow: clip;
  line-height: 1.15;
  /* overflow-wrap: anywhere;  若不用 <wbr> 也能硬折行（可選） */
}

#a51-ref-modal .a51-table tbody td{
  padding:8px; border-bottom:1px dashed rgba(255,255,255,.1); white-space: nowrap;
}
#a51-ref-modal .a51-table tbody tr:hover{ background:rgba(255,255,255,.06); }
#a51-ref-modal .a51-addr{ font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
#a51-ref-modal .a51-table tbody td:nth-child(2),
#a51-ref-modal .a51-table tbody td:nth-child(3){
  text-align:right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* 欄寬比例：地址 56% / 存款 22% / 返傭 22%（桌機） */
#a51-ref-modal .a51-table th:nth-child(1),
#a51-ref-modal .a51-table td:nth-child(1) { width: 56%; }
#a51-ref-modal .a51-table th:nth-child(2),
#a51-ref-modal .a51-table td:nth-child(2) { width: 22%; }
#a51-ref-modal .a51-table th:nth-child(3),
#a51-ref-modal .a51-table td:nth-child(3) { width: 22%; }

/* 地址過長以省略號顯示 */
#a51-ref-modal .a51-addr { display:block; overflow:hidden; text-overflow:ellipsis; }

/* 動作列 */
#a51-ref-modal .a51-actions{ display:flex; gap:8px; justify-content:flex-end; margin-top:14px; }

/* 無障礙 */
@media (prefers-reduced-motion: reduce){
  #a51-ref-modal *{ animation:none!important; transition:none!important; }
}

/* ── RWD：縮小字體 & 手機調整欄位比例 ───────────────── */

/* ≤420px：縮字、表頭換行、且讓第2欄更靠左（56/24/20） */
@media (max-width: 420px){
  #a51-ref-modal .a51-card { font-size: 0.90rem; }

  #a51-ref-modal .a51-tabs { gap: 24px; }
  #a51-ref-modal .a51-tab-btn{ font-size: .93rem; padding: 6px 2px 10px; }
  #a51-ref-modal .a51-tab-btn::after{ width: 46px; }

  #a51-ref-modal .a51-kpis{ grid-template-columns: 1fr 1fr; gap:6px; }
  #a51-ref-modal .a51-kpi{ padding: 8px 10px; }
  #a51-ref-modal .a51-kpi-label{ font-size: .74rem; }
  #a51-ref-modal .a51-kpi-value{ font-size: .96rem; }

  /* 表頭允許換行顯示完整字 */
  #a51-ref-modal .a51-table thead th{
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-size: .82rem;
    line-height: 1.15;
    padding: 4px 6px;
  }

  /* 只把第2欄（Deposit）改為靠左，數字更靠近欄左邊 */
  #a51-ref-modal .a51-table thead th:nth-child(2){ text-align: left !important; }
  #a51-ref-modal .a51-table tbody td:nth-child(2){
    text-align: left !important;
    padding-left: 2px;  /* 原 6px → 更貼左 */
    padding-right: 0;
  }
  /* 第3欄維持靠右 */
  #a51-ref-modal .a51-table thead th:nth-child(3){ text-align: right; }
  #a51-ref-modal .a51-table tbody td:nth-child(3){ text-align: right; }

  /* 欄位比例：地址 56% / 存款 24% / 返傭 20% */
  #a51-ref-modal .a51-table th:nth-child(1),
  #a51-ref-modal .a51-table td:nth-child(1) { width: 56%; }
  #a51-ref-modal .a51-table th:nth-child(2),
  #a51-ref-modal .a51-table td:nth-child(2) { width: 24%; }
  #a51-ref-modal .a51-table th:nth-child(3),
  #a51-ref-modal .a51-table td:nth-child(3) { width: 20%; }

  /* 表身更緊湊 */
  #a51-ref-modal .a51-table tbody td{ padding: 5px 6px; }
  #a51-ref-modal .a51-table tbody td:nth-child(3){ padding-right: 2px; }
}

/* ≤360px：再多給第2欄空間（55/25/20） */
@media (max-width: 360px){
  #a51-ref-modal .a51-card { font-size: 0.84rem; }
  #a51-ref-modal .a51-table thead th{ font-size: .76rem; line-height: 1.12; }

  #a51-ref-modal .a51-table thead th:nth-child(2){ text-align: left !important; }
  #a51-ref-modal .a51-table tbody td:nth-child(2){
    text-align: left !important;
    padding-left: 2px;  /* 原 4px → 更貼左 */
    padding-right: 0;
  }
  #a51-ref-modal .a51-table tbody td:nth-child(3){ padding-right: 1px; }

  #a51-ref-modal .a51-table th:nth-child(1),
  #a51-ref-modal .a51-table td:nth-child(1) { width: 55%; }
  #a51-ref-modal .a51-table th:nth-child(2),
  #a51-ref-modal .a51-table td:nth-child(2) { width: 25%; }
  #a51-ref-modal .a51-table th:nth-child(3),
  #a51-ref-modal .a51-table td:nth-child(3) { width: 20%; }
}

/* 基準字色／表格顏色 */
#a51-ref-modal .a51-card{ color: rgba(255,255,255,.92); }
#a51-ref-modal .a51-kpi-label{ color: rgba(255,255,255,.72); }
#a51-ref-modal .a51-kpi-value{ color: #eafcff; }
#a51-ref-modal .a51-table thead th{ color: rgba(255,255,255,.95); }
#a51-ref-modal .a51-table tbody td{ color: rgba(255,255,255,.88); }
#a51-ref-modal .a51-addr{ color: rgba(255,255,255,.92); }
