/* ============================================================
   用户中心（会员端）member.php
   依赖 ui.css / front.css 的变量与基础组件
   ============================================================ */

.mb-hero {
    padding: 54px 0 30px;
    background:
        radial-gradient(760px 340px at 12% -20%, rgba(99, 102, 241, .16), transparent 70%),
        radial-gradient(560px 300px at 92% 0%, rgba(56, 189, 248, .14), transparent 68%);
}
.mb-hero .eyebrow { letter-spacing: .16em; }
.mb-hero h1 {
    margin: 10px 0 10px;
    font-size: 34px;
    letter-spacing: -.035em;
    line-height: 1.15;
}
.mb-hero p { margin: 0; max-width: 640px; color: var(--text-2); font-size: 13.5px; line-height: 1.9; }

.mb-wrap { padding-bottom: 70px; }
.mb-wrap [hidden] { display: none !important; }

/* ---------- 标题 / 说明 ---------- */
.mb-title { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.01em; }
.mb-sub { margin: 6px 0 16px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }
.mb-tip { margin: 14px 0 0; font-size: 12px; color: var(--muted); line-height: 1.8; }
.mb-hint { margin: 10px 0 0; font-size: 11.5px; color: var(--muted); }
.mb-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mb-hr { height: 1px; background: var(--line); margin: 18px 0; }

.mb-err {
    margin: 0 0 12px;
    padding: 9px 12px;
    border-radius: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 12.5px;
    line-height: 1.7;
}

.mb-global-err {
    margin-bottom: 16px;
    padding: 11px 14px;
    border-radius: 12px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 12.5px;
    word-break: break-all;
}

/* ---------- 未登录 ---------- */
.mb-auth-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.mb-auth-grid .card { height: fit-content; }

/* ---------- 已登录：资料卡 ---------- */
.mb-profile {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 20px;
}
.mb-avatar {
    width: 52px; height: 52px; flex: none;
    display: grid; place-items: center;
    border-radius: 16px;
    background: var(--grad);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .02em;
    box-shadow: 0 12px 26px -14px rgba(99, 102, 241, .9);
}
.mb-profile-main { flex: 1; min-width: 0; }
.mb-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-name b { font-size: 17px; letter-spacing: -.02em; }
.mb-meta { margin-top: 5px; font-size: 12px; color: var(--muted); }
.mb-profile-actions { display: flex; gap: 8px; flex: none; }

/* ---------- 数据卡 ---------- */
.mb-stat-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}
.mb-stat { padding: 15px 16px; }
.mb-stat span { display: block; font-size: 11.5px; color: var(--muted); }
.mb-stat b { display: block; margin: 6px 0 4px; font-size: 21px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.mb-stat em { display: block; font-style: normal; font-size: 11px; color: var(--muted); }

/* ---------- Tab ---------- */
.mb-tabs {
    display: flex;
    gap: 4px;
    margin: 18px 0 14px;
    padding: 4px;
    border-radius: 14px;
    background: var(--surface-2, #f5f7fc);
    border: 1px solid var(--line);
    overflow-x: auto;
    scrollbar-width: none;
}
.mb-tabs::-webkit-scrollbar { display: none; }
.mb-tab {
    flex: 1;
    min-width: max-content;
    padding: 9px 14px;
    border-radius: 10px;
    text-align: center;
    font-size: 13px;
    font-weight: 550;
    color: var(--text-2);
    cursor: pointer;
    white-space: nowrap;
    transition: all .16s;
}
.mb-tab:hover { color: var(--brand-600); }
.mb-tab.active {
    background: var(--surface, #fff);
    color: var(--brand-600);
    box-shadow: 0 6px 18px -12px rgba(15, 23, 42, .45);
}

/* ---------- 授权卡 ---------- */
.mb-lic-list { display: grid; gap: 12px; }
.mb-lic {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 16px;
    background: var(--surface, #fff);
}
.mb-lic-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mb-lic-name { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mb-lic-name b { font-size: 14.5px; }
.mb-lic-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 18px;
    margin-top: 12px;
}
.mb-lic-grid > div { min-width: 0; }
.mb-lic-grid span { display: block; font-size: 11px; color: var(--muted); }
.mb-lic-grid b {
    display: block;
    margin-top: 3px;
    font-size: 12.5px;
    color: var(--text);
    font-weight: 550;
    word-break: break-all;
}

/* ---------- 套餐 / 等级 ---------- */
.mb-group + .mb-group { margin-top: 18px; }
.mb-group-title {
    font-size: 12px;
    font-weight: 650;
    color: var(--brand-600);
    margin: 0 0 10px;
    letter-spacing: .02em;
}
.mb-pkg-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.mb-pkg {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 14px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: var(--surface, #fff);
    transition: all .18s;
}
.mb-pkg:hover { border-color: var(--brand); box-shadow: 0 16px 34px -26px rgba(99, 102, 241, .9); transform: translateY(-1px); }
.mb-pkg-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mb-pkg-top b { font-size: 14px; }
.mb-price { font-size: 16px; font-weight: 700; color: var(--brand-600); letter-spacing: -.02em; }
.mb-pkg p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.7; min-height: 34px; }
.mb-pkg .btn { align-self: flex-start; }

/* ---------- 余额 ---------- */
.mb-balance-grid,
.mb-account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}
.mb-amounts { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.mb-amounts button {
    height: 32px;
    padding: 0 14px;
    border-radius: 9px;
    border: 1px solid var(--line-strong, var(--line));
    background: var(--surface, #fff);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all .16s;
}
.mb-amounts button:hover { border-color: var(--brand); color: var(--brand-600); }
.mb-amounts button.on { background: var(--brand-soft, #eef0ff); border-color: var(--brand); color: var(--brand-600); }

.mb-log-list { max-height: 420px; overflow: auto; }
.mb-logs { display: flex; flex-direction: column; }
.mb-log {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line);
}
.mb-log:last-child { border-bottom: 0; }
.mb-log > div:first-child { min-width: 0; }
.mb-log b { display: block; font-size: 12.5px; font-weight: 550; color: var(--text); word-break: break-all; }
.mb-log span { display: block; margin-top: 2px; font-size: 11px; color: var(--muted); }
.mb-log-amt { flex: none; text-align: right; font-size: 13px; font-weight: 650; font-variant-numeric: tabular-nums; }
.mb-log-amt.in { color: #16a34a; }
.mb-log-amt.out { color: #dc2626; }
.mb-log-amt em { display: block; font-style: normal; font-size: 10.5px; color: var(--muted); font-weight: 400; margin-top: 2px; }

/* ---------- 订单 ---------- */
.mb-orders { display: flex; flex-direction: column; }
.mb-order {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}
.mb-order:last-child { border-bottom: 0; }
.mb-order-main { min-width: 0; }
.mb-order-main b { display: block; font-size: 13px; font-weight: 600; }
.mb-order-main span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.mb-order-side { flex: none; text-align: right; display: flex; align-items: center; gap: 10px; }
.mb-order-side b { font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* ---------- 空态 / 加载 ---------- */
.mb-empty {
    padding: 34px 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.9;
    border: 1px dashed var(--line-strong, var(--line));
    border-radius: 14px;
}
.mb-empty span { display: inline-block; margin-top: 4px; font-size: 12px; color: var(--muted); }

.mb-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    font-size: 12.5px;
    color: var(--muted);
}
.mb-loading span {
    width: 15px; height: 15px;
    border-radius: 50%;
    border: 2px solid var(--line);
    border-top-color: var(--brand);
    animation: mbspin .7s linear infinite;
}
@keyframes mbspin { to { transform: rotate(360deg); } }

/* ---------- 提示条 ---------- */
.mb-toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    transform: translate(-50%, 14px);
    z-index: 200;
    max-width: min(90vw, 420px);
    padding: 11px 18px;
    border-radius: 12px;
    background: rgba(15, 23, 42, .92);
    color: #fff;
    font-size: 13px;
    line-height: 1.6;
    text-align: center;
    opacity: 0;
    transition: all .22s;
    box-shadow: 0 18px 40px -22px rgba(15, 23, 42, .8);
}
.mb-toast.show { opacity: 1; transform: translate(-50%, 0); }
.mb-toast.err { background: rgba(185, 28, 28, .95); }

/* ---------- 弹窗（复用抽奖弹窗视觉） ---------- */
.lot-modal {
    position: fixed; inset: 0; z-index: 130;
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    background: rgba(8, 12, 24, .62);
    opacity: 0; visibility: hidden;
    transition: opacity .2s, visibility .2s;
}
.lot-modal.show { opacity: 1; visibility: visible; }
.lot-panel {
    width: min(420px, 100%);
    max-height: 88vh;
    overflow: auto;
    background: var(--surface, #fff);
    border-radius: 20px;
    padding: 24px 22px;
    text-align: center;
    box-shadow: 0 40px 80px -40px rgba(8, 12, 24, .7);
    transform: translateY(10px) scale(.98);
    transition: transform .22s;
}
.lot-modal.show .lot-panel { transform: none; }
.btn-text {
    display: block;
    width: 100%;
    margin-top: 10px;
    padding: 8px;
    border: 0;
    background: none;
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
}
.btn-text:hover { color: var(--brand-600); }

/* ---------- 响应式 ---------- */
@media (max-width: 980px) {
    .mb-stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .mb-balance-grid,
    .mb-account-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
    .mb-hero { padding: 38px 0 22px; }
    .mb-hero h1 { font-size: 25px; }
    .mb-hero p { font-size: 12.5px; }
    .mb-auth-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    .mb-profile { flex-wrap: wrap; padding: 16px; }
    .mb-profile-actions { width: 100%; }
    .mb-profile-actions .btn { flex: 1; }
    .mb-lic-grid { grid-template-columns: minmax(0, 1fr); }
    .mb-tabs { border-radius: 12px; }
    .mb-tab { flex: none; padding: 8px 12px; font-size: 12.5px; }
    .mb-pkg-grid { grid-template-columns: minmax(0, 1fr); }
    .mb-pkg { padding: 13px 14px; }
    .mb-pkg .btn { width: 100%; }
    .lot-panel { padding: 20px 16px; }
    .mb-order { flex-wrap: wrap; }
    .mb-order-side { width: 100%; justify-content: space-between; }
}

@media (max-width: 380px) {
    .mb-hero h1 { font-size: 22px; }
    .mb-stat b { font-size: 18px; }
}

/* ---------- 用户端内嵌抽奖 ---------- */
.mb-lot-frame {
    display: block;
    width: 100%;
    height: 900px;
    border: 0;
    border-radius: 14px;
    background: var(--surface-2);
}
@media (max-width: 760px) {
    .mb-lot-frame { height: 1180px; }
}

@media (max-width: 760px) {
    .mb-tabs { flex-wrap: wrap; overflow: visible; }
    .mb-tab { flex: 1 1 21%; padding: 9px 4px; font-size: 12px; }
    #panel-lottery > .card { padding: 12px; }
    #panel-lottery .mb-sub { margin-bottom: 10px; }
}

/* ---------- 代理中心入口 ---------- */
.mb-stat.is-link { cursor: pointer; transition: border-color .16s, box-shadow .16s; }
.mb-stat.is-link:hover { border-color: var(--brand-400); box-shadow: 0 14px 30px -24px rgba(99, 102, 241, .9); }
.mb-stat.is-link em { color: var(--brand-600); font-weight: 550; }

.mb-agent-list { display: flex; flex-direction: column; gap: 10px; }
.mb-agent {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
    background: var(--surface-2);
}
.mb-agent-main { min-width: 0; }
.mb-agent-main b { display: block; font-size: 14px; color: var(--text); word-break: break-all; }
.mb-agent-main span { display: block; margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.mb-agent-side { display: flex; align-items: center; gap: 8px; flex: none; }

.mb-panel .card + .card { margin-top: 14px; }

@media (max-width: 480px) {
    .mb-agent { flex-wrap: wrap; }
    .mb-agent-side { width: 100%; justify-content: flex-end; }
}

/* ---------- 工单 ---------- */
.badge.blue { background: #eff6ff; color: #1d4ed8; }

.mb-tab { position: relative; }
.mb-tab-dot {
    position: absolute; top: 2px; right: 4px;
    min-width: 16px; height: 16px; padding: 0 4px;
    border-radius: 8px; background: #ef4444; color: #fff;
    font-size: 10px; font-style: normal; line-height: 16px; font-weight: 600;
    box-shadow: 0 0 0 2px var(--surface, #fff);
}

.mb-tk-filter { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.mb-tk-pill {
    padding: 6px 13px; border-radius: 9px; border: 1px solid var(--line);
    background: var(--surface); color: var(--text-2); font-size: 12.5px;
    font-family: inherit; cursor: pointer; transition: all .16s;
}
.mb-tk-pill:hover { border-color: var(--brand-400); color: var(--brand-600); }
.mb-tk-pill.active { background: var(--brand-soft); border-color: rgba(99, 102, 241, .3); color: var(--brand-600); font-weight: 600; }

.mb-tk-list { display: flex; flex-direction: column; gap: 10px; }
.mb-tk-item {
    position: relative; display: block; width: 100%; text-align: left;
    padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px;
    background: var(--surface); font-family: inherit; cursor: pointer;
    transition: border-color .16s, box-shadow .16s, transform .16s;
}
.mb-tk-item:hover { border-color: var(--brand-400); box-shadow: 0 14px 30px -26px rgba(99, 102, 241, .9); }
.mb-tk-item-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.mb-tk-cat {
    font-size: 11px; color: var(--text-2);
    padding: 2px 8px; border-radius: 6px; background: var(--bg-soft);
}
.mb-tk-unread { width: 7px; height: 7px; border-radius: 50%; background: #ef4444; margin-left: auto; }
.mb-tk-item > b { display: block; font-size: 13.5px; font-weight: 650; color: var(--text); line-height: 1.5; }
.mb-tk-item > p {
    margin: 5px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mb-tk-time { display: block; margin-top: 7px; font-size: 11px; color: var(--muted); }

.mb-tk-empty {
    display: flex; flex-direction: column; align-items: center; gap: 5px;
    padding: 34px 14px; text-align: center; color: var(--muted);
}
.mb-tk-empty b { font-size: 13.5px; color: var(--text-2); }
.mb-tk-empty span { font-size: 12px; }

.mb-tk-pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 14px; }
.mb-tk-pager span { font-size: 12px; color: var(--muted); }

.mb-tk-modal {
    position: fixed; inset: 0; z-index: 150;
    display: flex; align-items: center; justify-content: center;
    padding: 20px; background: rgba(8, 12, 24, .62);
    opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s;
}
.mb-tk-modal.show { opacity: 1; visibility: visible; }
.mb-tk-panel {
    width: min(560px, 100%); max-height: calc(100vh - 40px);
    display: flex; flex-direction: column;
    background: var(--surface, #fff); border-radius: 18px;
    box-shadow: 0 40px 80px -40px rgba(8, 12, 24, .7);
    transform: translateY(10px) scale(.98); transition: transform .22s;
    overflow: hidden;
}
.mb-tk-modal.show .mb-tk-panel { transform: none; }
.mb-tk-head {
    flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
    padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.mb-tk-head h3 { margin: 0; font-size: 15.5px; font-weight: 680; line-height: 1.45; word-break: break-word; }
.mb-tk-head p { margin: 4px 0 0; font-size: 11.5px; color: var(--muted); }
.mb-tk-x {
    flex: none; width: 30px; height: 30px; border: 0; border-radius: 9px;
    background: var(--bg-soft); color: var(--text-2); font-size: 18px; line-height: 1;
    cursor: pointer;
}
.mb-tk-x:hover { background: var(--line); color: var(--text); }
.mb-tk-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 16px; -webkit-overflow-scrolling: touch; }
.mb-tk-foot { flex: none; padding: 10px 16px 12px; border-top: 1px solid var(--line); background: var(--surface, #fff); }
.mb-tk-foot textarea {
    width: 100%; min-height: 62px; padding: 9px 11px; border: 1px solid var(--line-strong);
    border-radius: 10px; font-family: inherit; font-size: 13px; line-height: 1.6;
    color: var(--text); background: var(--surface); resize: vertical; outline: 0;
}
.mb-tk-foot textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(99, 102, 241, .12); }
.mb-tk-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 9px; }
.mb-tk-actions .btn { min-width: 88px; }
.mb-tk-err {
    margin-top: 10px; padding: 9px 11px; border-radius: 9px;
    background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; font-size: 12.5px;
}

.mb-tk-thread { display: flex; flex-direction: column; gap: 14px; }
.mb-tk-msg { display: flex; gap: 8px; align-items: flex-start; }
.mb-tk-avatar {
    flex: none; width: 28px; height: 28px; border-radius: 9px;
    display: grid; place-items: center; font-size: 11.5px;
    background: var(--bg-soft); color: var(--text-2);
}
.mb-tk-msg.is-admin .mb-tk-avatar { background: var(--brand-soft); color: var(--brand-600); }
.mb-tk-main { max-width: 78%; min-width: 0; }
.mb-tk-bubble {
    padding: 9px 12px; border-radius: 12px; font-size: 13px; line-height: 1.7;
    background: var(--surface-2, #f6f7fb); color: var(--text); word-break: break-word;
}
.mb-tk-msg.is-user { flex-direction: row-reverse; }
.mb-tk-msg.is-user .mb-tk-main { text-align: right; }
.mb-tk-msg.is-user .mb-tk-bubble { background: var(--brand-soft); color: var(--brand-700, #4338ca); text-align: left; }
.mb-tk-time { display: block; margin-top: 4px; font-size: 10.5px; color: var(--muted); }

@media (max-width: 640px) {
    .mb-tk-modal { align-items: flex-end; padding: 0; }
    .mb-tk-panel {
        width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0;
        max-height: 92dvh;
    }
    .mb-tk-head { padding: 14px 14px 10px; }
    .mb-tk-body { padding: 12px 14px; }
    .mb-tk-foot { padding: 9px 14px calc(10px + env(safe-area-inset-bottom)); }
    .mb-tk-actions .btn { flex: 1; }
    .mb-tk-main { max-width: 84%; }
}
