/* =========================================================
   WALLET custom styles (FiMobile template 확장)
   ========================================================= */
body, .form-control, .btn { font-family: "Nunito", "Noto Sans KR", "Open Sans", sans-serif; }
html:lang(ja) body { font-family: "Nunito", "Hiragino Sans", "Meiryo", sans-serif; }
html:lang(zh) body { font-family: "Nunito", "PingFang SC", "Microsoft YaHei", sans-serif; }

/* ---------- header language switch ---------- */
.header .col-auto > .btn + .lang-switch { margin-left: 6px; }
.lang-switch .btn-44 { position: relative; }
.lang-switch .lang-code {
    position: absolute; right: 2px; bottom: 2px;
    font-size: 9px; line-height: 1; font-weight: 700;
    padding: 2px 3px; border-radius: 4px;
    background: var(--fimobile-theme-color); color: #fff;
}
.lang-switch .dropdown-menu { min-width: 140px; border-radius: 12px; }
.lang-switch .dropdown-item.active,
.lang-switch .dropdown-item:active { background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); font-weight: 700; }

/* ---------- avatar initial ---------- */
.user-initial {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--fimobile-theme-color-grad-1), var(--fimobile-theme-color-grad-3));
    color: #fff; font-weight: 700; font-size: 20px; margin: 0;
}
.user-initial.sm { font-size: 16px; }

/* ---------- soft colored icon boxes ---------- */
.avatar[class*="-soft"] { display: inline-flex; align-items: center; justify-content: center; font-size: 20px; }
.bg-theme-soft   { background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); }
.bg-success-soft { background: rgba(58, 199, 155, .15); color: #23a07a; }
.bg-warning-soft { background: rgba(255, 189, 23, .18); color: #c78e00; }
.bg-info-soft    { background: rgba(97, 125, 234, .15); color: #4a62c9; }
.rounded-20 { border-radius: 20px; }

/* ---------- balance card ---------- */
.balance-card .card-footer { border-radius: 0 0 var(--fimobile-rounded) var(--fimobile-rounded); }
.bg-opac-10 { background: rgba(255, 255, 255, .12); }
.balance-card .quick-btn { color: var(--fimobile-theme-color); }
.balance-card .card-footer p { color: #fff; }
.opacity-75 { opacity: .75; }

/* ---------- filter chips ---------- */
.filter-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.filter-chip {
    flex: 0 0 auto; border-radius: 30px; padding: 6px 14px;
    background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); border: 0;
}
.filter-chip.active { background: var(--fimobile-theme-color); color: #fff; }

/* ---------- inputs ---------- */
.input-group-check { flex-wrap: nowrap; }
.input-group-check .form-control { border-top-right-radius: 0 !important; border-bottom-right-radius: 0 !important; }
.input-group-check .btn-check-id {
    border-radius: 0 var(--fimobile-input-rounded) var(--fimobile-input-rounded) 0;
    white-space: nowrap; padding: 0 16px; border: 1px solid var(--fimobile-theme-bordercolor); border-left: 0;
}
.check-msg.ok { color: #23a07a; }
.check-msg.err { color: #f73563; }
.otp-input { letter-spacing: 6px; font-weight: 700; }
.amount-group .btn-max { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); z-index: 5; }
.amount-group .form-control { padding-right: 70px; }
.form-group.is-invalid .form-control, .form-control.is-invalid { border-color: #f73563; }
.form-group.is-invalid .invalid-feedback { display: block; }
.mt-n2 { margin-top: -.5rem !important; }

.search-group .input-group-text { background: transparent; border-right: 0; border-radius: var(--fimobile-input-rounded) 0 0 var(--fimobile-input-rounded); }
.search-group .form-control { border-left: 0; height: 48px; }

/* ---------- copy box / qr ---------- */
.copy-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--fimobile-theme-color-light); border-radius: 12px; padding: 8px 8px 8px 12px;
}
.copy-box code { flex: 1; color: var(--fimobile-theme-color); word-break: break-all; font-size: 13px; text-align: left; }
.qr-box { width: 180px; height: 180px; padding: 8px; background: #fff; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,.08); }
.qr-box img { width: 100%; height: 100%; }
.notice-box { border-radius: var(--fimobile-rounded); font-size: 13px; border: 0; }

/* ---------- OTP steps ---------- */
.otp-steps { list-style: none; padding: 0; margin: 0; }
.otp-step { display: flex; gap: 14px; position: relative; padding-bottom: 24px; }
.otp-step:not(:last-child)::before {
    content: ""; position: absolute; left: 15px; top: 34px; bottom: 4px;
    border-left: 2px dashed var(--fimobile-theme-bordercolor);
}
.otp-step-num {
    flex: 0 0 32px; height: 32px; border-radius: 50%;
    background: var(--fimobile-theme-color); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.otp-step-body { flex: 1; min-width: 0; padding-top: 4px; }
.btn-danger-outline { background: transparent !important; color: #f73563 !important; border: 1px solid #f73563 !important; }

/* ---------- package cards ---------- */
.pkg-card { cursor: pointer; border: 2px solid transparent; transition: border-color .15s; }
.btn-check:checked + .pkg-card { border-color: var(--fimobile-theme-color); background: var(--fimobile-theme-color-light); }
.btn-check:focus-visible + .pkg-card { outline: 2px solid var(--fimobile-theme-color-grad-2); }
.pkg-name { font-weight: 700; color: var(--fimobile-theme-color); }

.bonus-split strong { font-size: 14px; }

/* ---------- referral tree (unilevel) ---------- */
.ref-tree-wrap { overflow-x: auto; }
.ref-tree, .ref-tree ul { list-style: none; margin: 0; padding: 0; }
.ref-tree ul { padding-left: 22px; margin-left: 12px; border-left: 1px dashed var(--fimobile-theme-bordercolor); }
.ref-tree li { position: relative; padding: 4px 0; }
.ref-tree ul > li::before {
    content: ""; position: absolute; left: -22px; top: 24px; width: 18px;
    border-top: 1px dashed var(--fimobile-theme-bordercolor);
}
.ref-tree li.collapsed > ul { display: none; }
.tree-node {
    display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
    padding: 8px 12px; border-radius: 12px; background: var(--fimobile-theme-color-light);
}
.tree-node.root { background: var(--fimobile-theme-color); color: #fff; }
.tree-node.root .tree-inv, .tree-node.root .tree-lv { color: rgba(255,255,255,.8); }
.tree-node.match { outline: 2px solid #ffbd17; }
.tree-toggle {
    width: 20px; height: 20px; border-radius: 6px; border: 0; padding: 0; line-height: 1;
    background: #fff; color: var(--fimobile-theme-color); display: inline-flex; align-items: center; justify-content: center;
}
.tree-toggle.empty { background: transparent; }
.tree-lv { font-size: 11px; color: var(--fimobile-theme-color); opacity: .8; min-width: 24px; }
.tree-id { font-weight: 700; }
.tree-inv { font-size: 12px; color: #6c757d; }
.tree-cnt { font-size: 11px; background: #fff; color: var(--fimobile-theme-color); border-radius: 10px; padding: 1px 6px; }

/* ---------- binary tree ---------- */
.bt-scroll { overflow-x: auto; padding: 16px 4px; }
.bt-tree { display: inline-block; min-width: 100%; text-align: center; }
.bt-tree ul { display: flex; justify-content: center; padding: 18px 0 0; margin: 0; position: relative; list-style: none; }
.bt-tree > ul { padding-top: 0; }
.bt-tree li { flex: 1 1 0; position: relative; padding: 18px 4px 0; text-align: center; }
.bt-tree > ul > li { padding-top: 0; }
.bt-tree li::before, .bt-tree li::after {
    content: ""; position: absolute; top: 0; right: 50%; width: 50%; height: 18px;
    border-top: 1px solid var(--fimobile-theme-bordercolor);
}
.bt-tree li::after { right: auto; left: 50%; border-left: 1px solid var(--fimobile-theme-bordercolor); }
.bt-tree li:first-child::before, .bt-tree li:last-child::after { border: 0 none; }
.bt-tree li:last-child::before { border-right: 1px solid var(--fimobile-theme-bordercolor); border-radius: 0 6px 0 0; }
.bt-tree li:first-child::after { border-radius: 6px 0 0 0; }
.bt-tree li:only-child::before, .bt-tree li:only-child::after { display: none; }
.bt-tree > ul > li::before, .bt-tree > ul > li::after { display: none; }
.bt-tree ul ul::before {
    content: ""; position: absolute; top: 0; left: 50%; height: 18px;
    border-left: 1px solid var(--fimobile-theme-bordercolor);
}
.bt-node {
    display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
    min-width: 84px; padding: 8px 4px; border-radius: 12px; text-decoration: none;
    background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); font-size: 12px;
}
.bt-node strong { font-size: 13px; }
.bt-node.root { background: var(--fimobile-theme-color); color: #fff; }
.bt-node.root .text-muted, .bt-node.root .bt-vol { color: rgba(255,255,255,.8) !important; }
.bt-node.empty { background: transparent; border: 1px dashed var(--fimobile-theme-bordercolor); color: #9aa3c0; min-height: 70px; justify-content: center; }
.bt-node.empty i { font-size: 18px; }
.bt-avatar {
    width: 30px; height: 30px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--fimobile-theme-color-grad-1), var(--fimobile-theme-color-grad-3)); color: #fff; font-weight: 700;
}
.bt-vol { font-size: 10px; color: #6c757d; white-space: nowrap; }
.bt-vol em { font-style: normal; font-weight: 700; }

/* ---------- side (L/R) badge ---------- */
.side-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; padding: 0 6px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.side-l { background: rgba(97,125,234,.15); color: #4a62c9; }
.side-r { background: rgba(58,199,155,.15); color: #23a07a; }

/* ---------- lists / board ---------- */
.list-group-item.unread { background: rgba(97,125,234,.06); }
.list-group-item.unread p.mb-0::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #f73563; margin-right: 6px; vertical-align: middle; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notice-content { line-height: 1.75; }
.notice-nav .list-group-item { border-color: var(--fimobile-theme-bordercolor); }
.pagination .page-link { border-radius: 8px !important; margin: 0 3px; border: 0; color: var(--fimobile-theme-color); }
.pagination .page-item.active .page-link { background: var(--fimobile-theme-color); color: #fff; }
.accordion-item { border-color: var(--fimobile-theme-bordercolor); }
.accordion-button:not(.collapsed) { background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); }

/* ---------- toast ---------- */
#walletToast { background: var(--fimobile-theme-color); color: #fff; border-radius: 12px; }
#walletToast .btn-close { filter: invert(1); }

/* ---------- dark mode tweaks ---------- */
.dark-mode .tree-node, .dark-mode .bt-node:not(.root):not(.empty), .dark-mode .copy-box { background: rgba(255,255,255,.08); color: #fff; }
.dark-mode .tree-toggle, .dark-mode .tree-cnt { background: rgba(255,255,255,.15); color: #fff; }
.dark-mode .copy-box code { color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.toast-wrap { pointer-events: none; }
.toast-wrap .toast { pointer-events: auto; }

/* ---------- dark mode: 커스텀 요소 가독성 ---------- */
.dark-mode .pkg-name,
.dark-mode .tree-lv,
.dark-mode .filter-chip:not(.active),
.dark-mode .bg-theme-soft { color: #9db8ff; }
.dark-mode .btn-check:checked + .pkg-card { border-color: #6d8dff; background: rgba(109, 141, 255, .15); }
.dark-mode .filter-chip:not(.active) { background: rgba(255, 255, 255, .08); }
.dark-mode .tree-inv, .dark-mode .bt-vol { color: #a7b0cf; }
.dark-mode .bt-node.empty { border-color: rgba(255, 255, 255, .2); color: #8a93b5; }
.dark-mode .notice-box.alert-warning { background: rgba(255, 189, 23, .12); color: #ffd770; }
.dark-mode .list-group-item.unread { background: rgba(109, 141, 255, .1); }
.dark-mode .qr-box { background: #fff; }   /* QR 은 흰 배경 유지 (스캔 인식) */

/* ---------- Pay 버튼 아이콘 (하단 가운데 centerbutton.svg 를 테마 색으로) ---------- */
.sg-pay-icon {
    display: inline-block; width: 16px; height: 25px; vertical-align: middle;
    background-color: currentColor;
    -webkit-mask: url(../img/centerbutton.svg) no-repeat center / contain;
            mask: url(../img/centerbutton.svg) no-repeat center / contain;
}
.quick-btn .sg-pay-icon { color: var(--fimobile-theme-color); }
.avatar .sg-pay-icon { width: 16px; height: 24px; }

/* ---------- 후원조직도 (한줄) ---------- */
.sp-line-table { font-size: 14px; }
.sp-line-table th { font-size: 12px; font-weight: 600; color: #8a93b5; border-bottom-width: 1px; white-space: nowrap; }
.sp-line-table td { vertical-align: middle; white-space: nowrap; }
.sp-line-table th:first-child, .sp-line-table td:first-child { width: 56px; }
.sp-line-table .sp-me td { background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); font-weight: 700; }
.sp-lv { display: inline-block; min-width: 28px; padding: 2px 6px; border-radius: 8px; font-size: 12px;
         background: var(--fimobile-theme-color-light); color: var(--fimobile-theme-color); }
.dark-mode .sp-line-table { color: #e3e7f5; }
.dark-mode .sp-line-table td { border-color: rgba(255,255,255,.08); }
.dark-mode .sp-line-table .sp-me td, .dark-mode .sp-lv { background: rgba(109,141,255,.18); color: #b9cbff; }
.dark-mode .quick-btn .sg-pay-icon { color: #9db8ff; }
