/* ============================================================
 * 家庭共享账单 —— 响应式布局样式
 * 策略：Mobile-First；断点
 *   < 520px     小型手机（最紧凑）
 *   520-767px   大号手机 / 小平板
 *   768-1023px  平板（iPad / Android pad）
 *   >= 1024px   桌面 / 笔记本
 * ============================================================ */

/* ---------- 1. 全局基础：clamp 字号 + 安全区 ---------- */
:root {
    --primary: #16a085;
    --primary-dark: #0f7f6a;
    --accent: #e67e22;
    --accent-dark: #c96a16;
    --danger: #e74c3c;
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #2c3e50;
    --text-light: #7f8c9b;
    --border: #e8ecf0;
    --plus: #16a085;
    --minus: #e67e22;
    --radius: clamp(12px, 1.6vw, 18px);
    --shadow: 0 2px 14px rgba(44, 62, 80, .08);
    /* 用 clamp 让根字号在 14px - 17px 之间连续缩放 */
    --fs-root: clamp(14px, 0.9vw + 11px, 17px);
    /* 主要按钮最小点击区 44px（符合 iOS 规范）；桌面略大到 48px */
    --btn-h: 44px;
    --btn-h-sm: 36px;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: var(--fs-root); }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 1rem;
    line-height: 1.6;
    min-height: 100vh;
    /* iOS 刘海屏 + 底部安全区 */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    overflow-x: hidden;
}

[hidden] { display: none !important; }

/* ---------- 2. 按钮 / 输入（统一最小点击高度 44px）---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 12px;
    min-height: var(--btn-h);
    padding: 0 clamp(14px, 1.6vw, 22px);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform .05s, background .2s, opacity .2s, box-shadow .2s;
    text-align: center;
    line-height: 1.1;
    white-space: nowrap;
}
.btn:hover { box-shadow: 0 4px 14px rgba(22, 160, 133, .2); }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-accent:hover { box-shadow: 0 4px 14px rgba(230, 126, 34, .25); }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-danger:hover { background: #f9d6d1; }
.btn-ghost {
    background: transparent; color: rgba(255,255,255,.95);
    border: 1.5px solid rgba(255,255,255,.5);
    backdrop-filter: blur(4px);
}
.btn-ghost:hover { background: rgba(255,255,255,.12); }
.btn-outline {
    background: #fff; color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover { background: #e8f6f3; }
.btn-block { width: 100%; margin-top: 12px; }
.btn-sm {
    min-height: var(--btn-h-sm);
    padding: 0 14px;
    font-size: 0.9rem;
    border-radius: 10px;
    font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.input, select.input {
    width: 100%;
    min-height: var(--btn-h);
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    font-size: 1rem;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .2s, box-shadow .2s;
    margin-top: 6px;
    -webkit-appearance: none;
}
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 160, 133, .12);
}
textarea.input { padding: 12px 14px; min-height: 96px; line-height: 1.5; }
.code-input {
    text-transform: uppercase;
    letter-spacing: clamp(6px, 1.2vw, 10px);
    text-align: center;
    font-size: clamp(20px, 3.4vw, 28px);
    font-weight: 700;
    padding: 0 !important;
    text-indent: clamp(6px, 1vw, 12px);
}
.file-input { padding: 8px 10px; font-size: 0.9rem; line-height: calc(var(--btn-h) - 16px); }

.field-label { display: block; margin-top: 14px; font-size: 0.85rem; color: var(--text-light); font-weight: 600; }
.optional { font-weight: 400; color: #aab4be; }

/* ============================================================
 * 3. 登录页（移动端居中；桌面端改为：左侧品牌+右侧表单，双栏）
 * ============================================================ */
.login-wrap {
    min-height: 100vh;
    min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #16a085 0%, #0f7f6a 45%, #f4f6f8 45.5%);
    /* 底部留出浮动下载卡的空间 */
    padding: 24px 20px 88px;
    position: relative; /* 供底部 .login-dl 绝对定位 */
}
.login-card {
    background: var(--card);
    border-radius: 20px;
    box-shadow: 0 14px 46px rgba(0,0,0,.16);
    padding: clamp(22px, 3vw, 34px) clamp(20px, 2.6vw, 30px);
    width: 100%;
    max-width: 440px;
    position: relative;
    overflow: hidden;
}
/* 为登录卡添加一个装饰圆形（不影响移动端） */
.login-card::after {
    content: ''; position: absolute;
    width: 260px; height: 260px; right: -120px; top: -120px;
    background: radial-gradient(circle at 30% 30%, rgba(22,160,133,.10), transparent 70%);
    pointer-events: none; border-radius: 50%;
}
.login-logo { font-size: clamp(42px, 6vw, 56px); text-align: center; position: relative; z-index: 1; }
.login-card h1 { text-align: center; font-size: clamp(20px, 2.4vw, 24px); margin-top: 6px; position: relative; z-index: 1; }
.login-sub { text-align: center; color: var(--text-light); font-size: 0.9rem; margin-bottom: 8px; }
.login-tip { text-align: center; font-size: 0.85rem; color: var(--text-light); margin-top: 14px; }
.login-tip a { color: var(--primary); text-decoration: none; font-weight: 600; }
.family-badge {
    background: #e8f6f3; color: var(--primary-dark);
    border-radius: 12px; padding: 10px 14px; margin-top: 16px;
    text-align: center; font-size: 0.9rem; font-weight: 500;
}
.qr-preview {
    display: block; margin: 12px auto 0;
    width: clamp(140px, 22vw, 180px);
    height: clamp(140px, 22vw, 180px);
    object-fit: contain;
    border-radius: 14px; border: 1px solid var(--border); background: #fff;
}

/* ---------- 登录页底部 APP 下载入口（毛玻璃卡片） ---------- */
.login-dl {
    position: absolute;
    left: 0; right: 0;
    bottom: calc(16px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    pointer-events: none; /* 仅卡片本体可点击 */
}
.login-dl a {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 10px;
    background: rgba(255,255,255,.78);
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 18px;
    box-shadow: 0 10px 30px rgba(15,127,106,.16);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    text-decoration: none;
    transition: transform .15s, box-shadow .2s;
}
.login-dl a:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(15,127,106,.22); }
.login-dl a:active { transform: scale(.97); }
.login-dl .dl-ico {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #1abc9c);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(22,160,133,.3);
    flex: 0 0 auto;
}
.login-dl .dl-txt { display: flex; flex-direction: column; line-height: 1.3; }
.login-dl .dl-txt b { font-size: 0.9rem; color: var(--text); font-weight: 700; }
.login-dl .dl-txt small { font-size: 0.75rem; color: var(--text-light); }
.login-dl .dl-go {
    margin-left: 6px;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: background .2s;
}
.login-dl a:hover .dl-go { background: var(--primary-dark); }

/* 桌面端登录：双栏（左边表单 1.05fr，右边品牌区 1fr）
   右侧品牌区由 JS 插入 .login-brand DOM 元素，样式见 .login-brand 块 */
@media (min-width: 1024px) {
    .login-wrap {
        background: linear-gradient(135deg, #eaf9f5 0%, #f4f6f8 55%, #eef2f6 100%);
        padding: 40px;
    }
    .login-card {
        display: grid;
        grid-template-columns: minmax(420px, 1.05fr) 1fr;
        max-width: 1080px;
        padding: 0;
        border-radius: 24px;
        overflow: hidden;
        box-shadow: 0 30px 80px rgba(15, 127, 106, .15);
        isolation: isolate;
    }
    .login-card::after { display: none; }
    .login-card::before { display: none; }

    /* 左侧表单区：统一样式 */
    .login-logo,
    .login-card > h1,
    .login-sub,
    .login-card > div[id^="login-step-"],
    .login-card > .login-tip,
    .login-card > .family-badge {
        grid-column: 1;
        padding-left: clamp(44px, 4vw, 64px);
        padding-right: clamp(44px, 4vw, 64px);
    }
    .login-card > div[id^="login-step-"] { padding-bottom: 8px; }
    .login-logo { padding-top: clamp(56px, 6vw, 80px); }
    .login-card > h1 { padding-top: 6px; }
    .login-sub { margin-bottom: 18px; }
    .login-tip:last-of-type { padding-bottom: clamp(56px, 6vw, 80px); }
    .family-badge { margin: 18px clamp(44px, 4vw, 64px); width: auto; }

    /* 右侧品牌区（由 JS 插入的 div） */
    .login-brand {
        grid-column: 2;
        grid-row: 1 / span 100;
        min-height: 620px;
        background:
            radial-gradient(circle at 20% 20%, rgba(255,255,255,.22), transparent 40%),
            radial-gradient(circle at 80% 90%, rgba(255,255,255,.14), transparent 45%),
            linear-gradient(145deg, #0f7f6a 0%, #16a085 50%, #1abc9c 100%);
        color: #fff;
        padding: clamp(48px, 5vw, 72px) clamp(36px, 4vw, 52px);
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        position: relative;
        overflow: hidden;
    }
    .login-brand::before {
        /* 装饰大圆 */
        content: '';
        position: absolute;
        width: 480px; height: 480px; right: -160px; top: -120px;
        background: radial-gradient(circle, rgba(255,255,255,.12), transparent 60%);
        border-radius: 50%;
    }
    .login-brand::after {
        content: '';
        position: absolute;
        width: 320px; height: 320px; left: -90px; bottom: -100px;
        background: radial-gradient(circle, rgba(255,255,255,.08), transparent 60%);
        border-radius: 50%;
    }
    .login-brand-head { position: relative; z-index: 1; }
    .login-brand-emoji {
        font-size: clamp(48px, 6vw, 72px);
        line-height: 1; margin-bottom: 18px;
        display: inline-block;
        filter: drop-shadow(0 10px 20px rgba(0,0,0,.18));
    }
    .login-brand-title {
        font-size: clamp(24px, 2.6vw, 32px);
        font-weight: 800;
        line-height: 1.3;
        margin-bottom: 10px;
    }
    .login-brand-sub {
        color: rgba(255,255,255,.82);
        font-size: clamp(14px, 1.05vw, 16px);
        line-height: 1.7;
        max-width: 380px;
    }
    .login-brand-foot { position: relative; z-index: 1; }
    .login-brand-tips {
        display: flex; flex-direction: column; gap: 12px;
        margin-bottom: 20px;
    }
    .login-brand-tip {
        display: flex; align-items: center; gap: 12px;
        font-size: 0.95rem;
        color: rgba(255,255,255,.9);
    }
    .login-brand-tip .icon {
        width: 32px; height: 32px; border-radius: 50%;
        background: rgba(255,255,255,.18);
        display: inline-flex; align-items: center; justify-content: center;
        font-size: 1rem; flex: 0 0 auto;
    }
    .login-brand-foot small {
        color: rgba(255,255,255,.6);
        font-size: 0.8rem;
    }

    /* 桌面端隐藏登录页底部浮动下载卡（右侧品牌区已有下载入口） */
    .login-dl { display: none; }

    /* 品牌区下载卡 */
    .login-brand-dl {
        display: flex;
        align-items: center;
        gap: 12px;
        background: rgba(255,255,255,.96);
        border-radius: 16px;
        padding: 12px 14px;
        margin-bottom: 22px;
        text-decoration: none;
        box-shadow: 0 10px 26px rgba(0,0,0,.22);
        transition: transform .15s, box-shadow .2s;
    }
    .login-brand-dl:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0,0,0,.28); }
    .login-brand-dl:active { transform: scale(.98); }
    .login-brand-dl .dl-ico {
        width: 42px; height: 42px;
        border-radius: 12px;
        background: linear-gradient(135deg, var(--primary), #1abc9c);
        display: flex; align-items: center; justify-content: center;
        font-size: 20px;
        flex: 0 0 auto;
    }
    .login-brand-dl .dl-txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
    .login-brand-dl .dl-txt b { font-size: 0.95rem; color: var(--text); font-weight: 800; }
    .login-brand-dl .dl-txt small { font-size: 0.78rem; color: var(--text-light); }
    .login-brand-dl .dl-go {
        margin-left: auto;
        background: var(--primary);
        color: #fff;
        border-radius: 999px;
        padding: 8px 16px;
        font-size: 0.85rem;
        font-weight: 700;
        white-space: nowrap;
        flex: 0 0 auto;
        transition: background .2s;
    }
    .login-brand-dl:hover .dl-go { background: var(--primary-dark); }
}

/* ============================================================
 * 4. 主应用
 *   Mobile: 顶部 header + Tab 切换的经典单栏（限宽 640px 居中）
 *   Desktop (>=1024px): 左侧固定侧边栏（家庭信息 + Tab + 登录人）
 *                      右侧主区域（限宽 920px 居中），卡片可以更舒展
 * ============================================================ */
.app-wrap {
    max-width: 640px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    background: var(--bg);
    position: relative;
}

.app-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 16px 16px 0;
    position: sticky; top: 0; z-index: 20;
    box-shadow: 0 2px 10px rgba(0,0,0,.1);
}
.header-main { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.header-family { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.family-name { font-size: clamp(17px, 2vw, 20px); font-weight: 700; }
.code-chip {
    align-self: flex-start;
    background: rgba(255,255,255,.18);
    border: 1.5px solid rgba(255,255,255,.35);
    color: #fff; border-radius: 999px;
    padding: 4px 14px; font-size: 0.82rem; cursor: pointer;
    min-height: 32px; display: inline-flex; align-items: center;
    transition: background .2s;
}
.code-chip:hover { background: rgba(255,255,255,.28); }
.code-chip b { font-weight: 800; letter-spacing: 1px; margin: 0 3px; }
.header-user { display: flex; align-items: center; gap: 10px; font-size: 0.95rem; white-space: nowrap; }

.tabs { display: flex; margin-top: 14px; gap: 4px; }
.tab {
    flex: 1; background: transparent; border: none; color: rgba(255,255,255,.75);
    padding: 12px 0; font-size: 1rem; cursor: pointer;
    border-bottom: 3px solid transparent; font-weight: 600;
    transition: color .2s, background .2s;
    min-height: var(--btn-h-sm);
    border-radius: 10px 10px 0 0;
}
.tab:hover { color: #fff; background: rgba(255,255,255,.06); }
.tab.active { color: #fff; border-bottom-color: #fff; background: rgba(255,255,255,.08); }

.app-main { padding: 18px 14px 100px; }

/* ---------- 主应用底部 APP 下载入口 ---------- */
#app-download {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 32px auto 0;
    padding: 14px 16px;
    max-width: 520px;
    background: linear-gradient(135deg, #ffffff 0%, #eefaf6 100%);
    border: 1.5px solid rgba(22,160,133,.25);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-decoration: none;
    transition: transform .15s, box-shadow .2s, border-color .2s;
}
#app-download:hover {
    transform: translateY(-2px);
    border-color: rgba(22,160,133,.55);
    box-shadow: 0 10px 28px rgba(22,160,133,.18);
}
#app-download:active { transform: scale(.98); }
#app-download .dl-ico {
    width: 46px; height: 46px;
    border-radius: 13px;
    background: linear-gradient(135deg, var(--primary), #1abc9c);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    box-shadow: 0 4px 10px rgba(22,160,133,.28);
    flex: 0 0 auto;
}
#app-download .dl-txt {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column;
    line-height: 1.35;
}
#app-download .dl-txt b { font-size: 0.95rem; color: var(--text); font-weight: 800; }
#app-download .dl-txt small { font-size: 0.78rem; color: var(--text-light); }
#app-download .dl-go {
    flex: 0 0 auto;
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    padding: 9px 18px;
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
    transition: background .2s;
}
#app-download:hover .dl-go { background: var(--primary-dark); }

.section-title { font-size: clamp(16px, 1.4vw, 18px); margin: 8px 2px 12px; font-weight: 700; }
.list-header {
    display: flex; justify-content: space-between; align-items: center;
    margin: 4px 2px 14px; gap: 8px; flex-wrap: wrap;
}
.list-header h2 { font-size: clamp(17px, 1.7vw, 19px); font-weight: 700; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 余额条 ---------- */
.balance-strip {
    display: flex; gap: 10px; overflow-x: auto; padding: 4px 2px 10px;
    scrollbar-width: none; margin-bottom: 6px;
}
.balance-strip::-webkit-scrollbar { display: none; }
.balance-chip {
    flex: 0 0 auto;
    background: var(--card); border-radius: 14px; padding: 10px 16px;
    box-shadow: var(--shadow); font-size: 0.9rem; display: flex; align-items: center; gap: 8px;
    min-height: 42px;
}
.balance-chip .b-name { font-weight: 700; }
.balance-chip .b-plus { color: var(--plus); font-weight: 700; }
.balance-chip .b-minus { color: var(--minus); font-weight: 700; }
.balance-chip .b-zero { color: var(--text-light); }

/* ---------- 卡片列表 ---------- */
.card-list { display: flex; flex-direction: column; gap: 14px; }

.bill-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 16px 18px;
    border-left: 4px solid var(--primary);
    transition: transform .1s;
}
.bill-card:hover { transform: translateY(-1px); }
.bill-card.is-settled { border-left-color: #bdc3c7; opacity: .75; }
.bill-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.bill-title { font-size: clamp(15px, 1.3vw, 17px); font-weight: 700; word-break: break-word; }
.bill-amount { font-size: clamp(18px, 2vw, 22px); font-weight: 800; color: var(--accent); white-space: nowrap; }
.bill-meta { font-size: 0.85rem; color: var(--text-light); margin-top: 6px; }
.bill-meta .payer-tag { color: var(--primary-dark); font-weight: 700; }
.bill-participants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.participant-tag {
    background: #eef2f5; border-radius: 999px; padding: 4px 12px;
    font-size: 0.82rem; color: #566573; font-weight: 500;
}
.bill-footer {
    display: flex; justify-content: space-between; align-items: center;
    margin-top: 14px; gap: 10px; flex-wrap: wrap;
}
.bill-share { font-size: 0.88rem; color: var(--text-light); }
.bill-share b { color: var(--text); font-weight: 700; }
.bill-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.settled-badge {
    background: #e8f6f3; color: var(--primary-dark);
    border-radius: 999px; padding: 5px 14px; font-size: 0.8rem; font-weight: 700;
}
.empty-tip {
    text-align: center; color: var(--text-light);
    padding: 50px 20px; font-size: 0.95rem;
}
.empty-tip .big { font-size: clamp(36px, 5vw, 52px); display: block; margin-bottom: 10px; }

/* ---------- 转账卡片 ---------- */
.transfer-card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px; display: flex; gap: 16px; align-items: center;
}
.transfer-info { flex: 1; min-width: 0; }
.transfer-flow { font-size: clamp(15px, 1.3vw, 17px); font-weight: 700; }
.transfer-flow .arrow { color: var(--accent); margin: 0 6px; }
.transfer-amount {
    font-size: clamp(22px, 2.4vw, 28px);
    font-weight: 800; color: var(--danger); margin-top: 4px;
}
.transfer-note { font-size: 0.82rem; color: var(--text-light); margin-top: 6px; }
.qr-thumb {
    width: clamp(76px, 10vw, 108px); height: clamp(76px, 10vw, 108px);
    border-radius: 12px; object-fit: cover;
    border: 1px solid var(--border); cursor: pointer; background: #fff;
    flex: 0 0 auto;
}
.qr-thumb.placeholder {
    display: flex; align-items: center; justify-content: center;
    background: #f0f2f5; color: #b2bcc6; font-size: 0.8rem; cursor: default;
    text-align: center; line-height: 1.4;
}
.settle-actions { margin-top: 18px; }

/* ---------- 历史 ---------- */
.history-card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 14px 18px; font-size: 0.95rem;
}
.history-flow { font-weight: 600; }
.history-flow .h-amount { color: var(--accent); font-weight: 800; margin-left: 6px; }
.history-meta { font-size: 0.8rem; color: var(--text-light); margin-top: 4px; }

/* ---------- 成员 ---------- */
.member-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.member-card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 12px; text-align: center;
}
.member-qr {
    width: clamp(88px, 12vw, 112px); height: clamp(88px, 12vw, 112px);
    border-radius: 14px; object-fit: cover;
    border: 1px solid var(--border); margin: 0 auto; cursor: pointer; background: #fff;
}
.member-qr.placeholder {
    display: flex; align-items: center; justify-content: center;
    background: #f0f2f5; color: #b2bcc6; font-size: 0.8rem;
}
.member-name {
    font-weight: 700; margin-top: 12px;
    font-size: clamp(15px, 1.2vw, 17px); word-break: break-word;
}
.member-qr-tip { font-size: 0.8rem; color: var(--text-light); margin-top: 2px; }
.member-card-actions { display: flex; justify-content: center; gap: 6px; margin-top: 12px; flex-wrap: wrap; }

/* ---------- 个人资料（我的资料） ---------- */
.profile-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 20px 14px;
    border-left: 4px solid var(--primary);
}
.profile-head {
    display: flex; align-items: center; gap: 16px;
    padding-bottom: 14px; border-bottom: 1px dashed var(--border);
}
.profile-avatar {
    width: clamp(48px, 5vw, 58px); height: clamp(48px, 5vw, 58px);
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: clamp(24px, 3vw, 30px); flex: 0 0 auto;
    box-shadow: 0 6px 14px rgba(22, 160, 133, .22);
}
.profile-title-wrap h2 { font-size: clamp(18px, 1.8vw, 20px); font-weight: 800; }
.profile-sub { font-size: 0.85rem; color: var(--text-light); margin-top: 2px; }

.profile-body { padding-top: 16px; }
.profile-row {
    display: grid;
    grid-template-columns: 1fr minmax(180px, 220px);
    gap: 22px;
    align-items: start;
}
.profile-col-main { min-width: 0; }
.profile-col-qr { text-align: center; }

.me-qr-box {
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 220px;
    margin: 4px auto 0;
    border-radius: 16px;
    border: 2px dashed #d5dce2;
    background: #fafbfc;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; position: relative;
}
.me-qr-box img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in; background: #fff; }
.me-qr-box .me-qr-empty {
    color: #b2bcc6; font-size: 0.9rem; text-align: center; line-height: 1.6; padding: 16px;
}
.profile-qr-tip { font-size: 0.8rem; color: var(--text-light); margin-top: 10px; text-align: center; }

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.5);
    display: flex; align-items: flex-end; justify-content: center;
    z-index: 100; padding: 0;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-box {
    background: #fff; width: 100%; max-width: 680px;
    border-radius: 20px 20px 0 0; max-height: 88vh; overflow-y: auto;
    animation: slideUp .22s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -10px 40px rgba(0,0,0,.18);
}
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    padding: 18px 22px 10px; position: sticky; top: 0; background: #fff; z-index: 2;
    border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.1rem; font-weight: 800; }
.modal-close {
    border: none; background: #f0f2f5; width: 34px; height: 34px;
    border-radius: 50%; cursor: pointer; color: var(--text-light); font-size: 1rem;
    transition: background .2s;
}
.modal-close:hover { background: #e3e8ee; }
.modal-body { padding: 12px 22px 28px; }

.checkbox-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.check-pill { position: relative; cursor: pointer; }
.check-pill input { position: absolute; opacity: 0; }
.check-pill span {
    display: inline-flex; align-items: center;
    padding: 9px 18px; border-radius: 999px;
    background: #f0f2f5; font-size: 0.95rem; border: 1.5px solid transparent;
    user-select: none; min-height: 38px;
    transition: background .15s, border-color .15s, color .15s;
}
.check-pill span:hover { background: #e6ebef; }
.check-pill input:checked + span {
    background: #e8f6f3; color: var(--primary-dark);
    border-color: var(--primary); font-weight: 700;
}
.check-pill input:disabled + span { opacity: .45; cursor: not-allowed; }

.modal-qr-preview { display: block; margin: 12px auto 0; max-width: 200px; border-radius: 14px; border: 1px solid var(--border); }

/* 结算弹窗 */
.settle-modal-item {
    display: flex; gap: 18px; align-items: center;
    padding: 16px 0; border-bottom: 1px dashed var(--border);
}
.settle-modal-item:last-of-type { border-bottom: none; }

/* ---------- 大图查看 ---------- */
.image-viewer {
    position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 200;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 30px; cursor: zoom-out;
    animation: fadeIn .15s ease;
}
.image-viewer img {
    max-width: 92%; max-height: 78vh;
    border-radius: 16px; background: #fff;
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.image-viewer-tip {
    color: rgba(255,255,255,.82); margin-top: 18px;
    font-size: 0.95rem; text-align: center; line-height: 1.5;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed; left: 50%;
    bottom: calc(40px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    background: rgba(44, 62, 80, .94); color: #fff;
    padding: 12px 24px; border-radius: 999px; font-size: 0.95rem;
    z-index: 300; max-width: 90vw; text-align: center;
    animation: toastIn .2s ease;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.toast.toast-error { background: rgba(231, 76, 60, .96); }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ============================================================
 * 5. 断点：平板 (>=768px)
 * ============================================================ */
@media (min-width: 768px) {
    .login-card { max-width: 520px; }
    .app-wrap { max-width: 760px; }
    .app-main { padding: 24px 20px 120px; }
    .member-grid { grid-template-columns: repeat(3, 1fr); }
    .tabs { gap: 6px; }
    .tab { font-size: 1.05rem; padding: 14px 0; }
    .modal-box { border-radius: 20px; }
    .modal-mask { align-items: center; padding: 20px; }
    .profile-row { grid-template-columns: 1fr 260px; gap: 28px; }
    .me-qr-box { max-width: 260px; }
    .settle-modal-item .qr-thumb { width: 112px !important; height: 112px !important; }
    .transfer-card { padding: 22px; gap: 22px; }
    .balance-chip { padding: 12px 18px; font-size: 1rem; gap: 10px; }
}

/* ============================================================
 * 6. 断点：桌面 / 笔记本 (>=1024px)
 *    主应用结构变成：左侧固定侧边栏（宽 280px），右侧主区域
 * ============================================================ */
@media (min-width: 1024px) {
    .app-wrap {
        max-width: none;
        margin: 0;
        display: grid;
        grid-template-columns: 300px 1fr;
        min-height: 100vh;
        background: var(--bg);
    }

    /* header 作为 sidebar 固定在左列 */
    .app-header {
        position: sticky; top: 0;
        height: 100vh;
        padding: 28px 22px;
        border-radius: 0;
        box-shadow: 2px 0 20px rgba(15,127,106,.10);
        display: flex;
        flex-direction: column;
        gap: 16px;
    }
    .header-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        order: 1;
    }
    .header-family { width: 100%; gap: 8px; }
    .family-name { font-size: 1.6rem; line-height: 1.25; }
    .code-chip { margin-top: 4px; font-size: 0.92rem; padding: 6px 16px; min-height: 36px; }

    /* 顶部用户区移到 sidebar 底部 */
    .header-user {
        margin-top: auto;
        order: 3;
        width: 100%;
        background: rgba(255,255,255,.08);
        border-radius: 14px;
        padding: 12px 14px;
        justify-content: space-between;
        border: 1.5px solid rgba(255,255,255,.2);
    }

    /* tabs 变成竖排 */
    .tabs {
        order: 2;
        margin-top: 24px;
        flex-direction: column;
        gap: 8px;
    }
    .tab {
        text-align: left;
        padding: 14px 16px;
        border-radius: 12px;
        border-bottom: none !important;
        border-left: 4px solid transparent;
        color: rgba(255,255,255,.75);
        transition: all .2s;
        justify-content: flex-start;
    }
    .tab:hover { background: rgba(255,255,255,.1); color: #fff; }
    .tab.active {
        background: rgba(255,255,255,.16);
        border-left: 4px solid #fff;
        color: #fff;
        font-weight: 700;
    }

    /* 主区域 */
    .app-main {
        padding: 36px 40px 120px;
        max-width: 1120px;
        width: 100%;
        margin: 0 auto;
    }

    /* 卡片更大 */
    .bill-card, .transfer-card, .profile-card, .history-card, .member-card {
        padding: 22px 24px;
    }
    .member-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }
    .profile-row { grid-template-columns: 1fr 320px; gap: 36px; }
    .me-qr-box { max-width: 300px; border-radius: 20px; }

    .modal-box { max-width: 760px; border-radius: 22px; }
    .modal-head { padding: 22px 28px 14px; }
    .modal-body { padding: 14px 28px 32px; }
    .section-title { font-size: 1.3rem; margin: 8px 2px 16px; }
    .toast { bottom: 60px; font-size: 1rem; padding: 14px 28px; }
}

/* 超宽屏 (>=1440px) 让主内容更松，成员 5 列，间距更大 */
@media (min-width: 1440px) {
    .app-wrap { grid-template-columns: 320px 1fr; }
    .app-main { max-width: 1240px; padding: 44px 50px 140px; }
    .member-grid { grid-template-columns: repeat(5, 1fr); }
    .login-card { max-width: 1080px; }
}

/* 超小屏 (<=360px) 让成员卡变单列，按钮更矮一点但仍保证 44px 点击区 */
@media (max-width: 360px) {
    .member-grid { grid-template-columns: 1fr; }
    .btn { font-size: 0.95rem; }
    .btn-sm { font-size: 0.85rem; }
    .code-chip { font-size: 0.75rem; padding: 4px 10px; }
}

/* 大平板横屏 (>=768 且 <1024)：成员 3 列，我的资料 QR 更大 */
@media (min-width: 768px) and (max-width: 1023px) {
    .member-grid { grid-template-columns: repeat(3, 1fr); }
}

/* 可访问性：减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
