/* ===== 全局变量 ===== */
:root {
    --primary: #4361ee;
    --primary-dark: #3a56d4;
    --success: #06d6a0;
    --warning: #ffb703;
    --danger: #ef476f;
    --dark: #073b4c;
    --light: #f8f9fa;
    --gray: #6c757d;
    --border: #e9ecef;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --radius-sm: 8px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --transition: all 0.3s ease;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--light);
    color: var(--dark);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background: white;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-md);
}

/* ===== 导航栏 ===== */
.navbar {
    background: var(--dark);
    padding: 12px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: rgba(7, 59, 76, 0.95);
    border-top: 3px solid rgba(255,255,255,0.2);
    border-bottom: 5px solid rgba(255,255,255,0.25);
    flex-wrap: nowrap;
    overflow-x: visible;
}

.navbar a {
    color: white;
    text-decoration: none;
    padding: 8px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: 400;
    transition: var(--transition);
    border: 1px solid transparent;
    white-space: nowrap;
    flex: 0 1 auto;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.navbar a i {
    font-size: 1.1em;
}

.navbar a:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

/* 当前页面高亮 */
.navbar a.active {
    background: var(--primary) !important;
    color: white !important;
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3) !important;
}

/* 语言切换按钮 */
.navbar a.lang-switch {
    background: var(--primary) !important;
    color: white !important;
}

.navbar a.lang-switch.active {
    background: var(--primary-dark) !important;
    box-shadow: 0 4px 8px rgba(67, 97, 238, 0.3) !important;
}

/* 退出模拟按钮 */
.navbar a[style*="background:#e74c3c"] {
    background: var(--danger) !important;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.navbar a[style*="background:#e74c3c"]:hover {
    background: #d64161 !important;
}

/* ===== 主内容 ===== */
main {
    flex: 1;
    padding: 24px 20px;
}

/* ===== 卡片通用 ===== */
.card {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--dark);
    border-left: 5px solid var(--primary);
    padding-left: 16px;
    line-height: 1.3;
}

.card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 24px 0 16px;
    color: var(--dark);
    position: relative;
    padding-bottom: 8px;
}

.card h3:after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

/* ===== 余额卡片 ===== */
.balance-box {
    background: linear-gradient(135deg, #f0f9ff, #e6f2ff);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(67, 97, 238, 0.2);
}

.balance-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 500;
    align-items: center;
}

.balance-value {
    font-weight: 700;
    color: var(--dark);
    background: white;
    padding: 4px 16px;
    border-radius: 30px;
    box-shadow: inset 0 1px 4px rgba(0,0,0,0.05);
    font-size: 1.2rem;
    white-space: nowrap;
    display: inline-block;
    text-align: right;
    line-height: 1.5;
    flex-shrink: 0;
}

/* ===== 按钮 ===== */
.btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 16px 32px;
    border: none;
    border-radius: 40px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
    border: 1px solid transparent;
    letter-spacing: 0.5px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(67, 97, 238, 0.3);
}

.btn-success {
    background: var(--success);
    box-shadow: 0 4px 12px rgba(6, 214, 160, 0.3);
}

.btn-success:hover {
    background: #05b588;
}

.btn-warning {
    background: var(--warning);
    color: var(--dark);
    box-shadow: 0 4px 12px rgba(255, 183, 3, 0.3);
}

.btn-warning:hover {
    background: #e6a502;
}

.btn-danger {
    background: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 71, 111, 0.3);
}

.btn-danger:hover {
    background: #d43f63;
}

.btn-sm {
    padding: 12px 24px;
    font-size: 16px;
    width: auto;
}

.btn:disabled, .btn[disabled] {
    background: var(--gray);
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.card .btn {
    width: auto;
    min-width: 160px;
    margin: 8px 0;
}

/* ===== 确保签到标签和奖励标签不换行 ===== */
span[style*="background:#27ae60"][style*="color:white"] {
    white-space: nowrap !important;
    display: inline-block !important;
    flex-shrink: 0 !important;
}

.reward-tag, 
span[style*="background:#27ae60"] {
    white-space: nowrap !important;
    display: inline-block !important;
}

.daily-signin,
.referral-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap !important;
    gap: 10px;
}

/* ===== 预购商品卡片 ===== */
.product-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.product-item:hover {
    box-shadow: var(--shadow-md);
}

/* 商品图片 - 放大到140x140并居中 */
.product-item img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto;
}

/* 无图片时的占位框也放大到140x140 */
.product-item .no-image-placeholder {
    width: 140px;
    height: 140px;
    background: #f0f0f0;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 14px;
    margin: 0 auto;
}

/* 商品信息 - 垂直居中，每项一行 */
.product-item .product-info {
    text-align:center;
    width:100%;
}

.product-item .product-info strong {
    font-size: 1.2rem;
    color: var(--dark);
    display: block;
    margin-bottom: 4px;
}

.product-item .product-info .price {
    color: var(--success);
    font-weight: 600;
    font-size: 1.1rem;
}

.product-item .product-info .expand-rate {
    color: var(--warning);
    font-weight: 600;
}

.product-item .product-info .meta {
    font-size: 0.9rem;
    color: var(--gray);
    margin-top: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.product-item .btn {
    width: auto;
    padding: 14px 28px;
    margin-left: auto;
    flex-shrink: 0;
}

.btn-secondary {
    background: var(--gray);
    cursor: not-allowed;
    opacity: 0.6;
}

/* ===== 兑换商品卡片 ===== */
.redeem-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.redeem-item:hover {
    box-shadow: var(--shadow-md);
}

.redeem-item img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto;
}

.redeem-item .redeem-info {
    width: 100%;
    text-align: center;
}

.redeem-item .redeem-info strong {
    font-size: 1.2rem;
    color: var(--dark);
    display: block;
    margin-bottom: 4px;
}

.redeem-item .redeem-info .redeem-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 8px 0;
    font-size: 0.95rem;
}

.redeem-item .button-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.redeem-item .btn {
    width: auto;
    padding: 12px 28px;
    min-width: 140px;
}

/* ===== 代卖商品卡片 ===== */
.resell-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.resell-item:hover {
    box-shadow: var(--shadow-md);
}

.resell-item img {
    width: 140px;
    height: 140px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto;
}

.resell-item .resell-info {
    width: 100%;
    text-align: center;
}

.resell-item .resell-info strong {
    font-size: 1.2rem;
    color: var(--dark);
    display: block;
    margin-bottom: 4px;
}

.resell-item .resell-info .resell-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    margin: 8px 0;
    font-size: 0.95rem;
}

.resell-item .resell-info .resell-meta span {
    white-space: nowrap;
}

.resell-item .button-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.resell-item .btn {
    width: auto;
    padding: 12px 28px;
    min-width: 140px;
}

/* ===== 订单卡片 ===== */
.order-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px;
    margin-bottom: 16px;
    transition: var(--transition);
}

.order-card .order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-weight: 600;
    font-size: 1.1rem;
}

.order-card .order-status {
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.status-pending { background: var(--warning); color: var(--dark); }
.status-assigned { background: var(--primary); color: white; }
.status-delivered { background: var(--success); color: white; }
.status-rejected { background: var(--danger); color: white; }
.status-active { background: #4caf50; color: white; }
.status-completed { background: #2196f3; color: white; }
.status-used { background: #9e9e9e; color: white; }
.status-cancelled { background: #f44336; color: white; }

.order-card .order-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
    font-size: 0.95rem;
    margin-top: 12px;
    background: var(--light);
    padding: 12px;
    border-radius: var(--radius-sm);
}

.order-card .order-body div {
    word-break: break-word;
    display: flex;
    align-items: baseline;
}

.order-card .order-body div strong {
    min-width: 70px;
    color: var(--gray);
    font-weight: 500;
}

.order-card .order-footer {
    margin-top: 12px;
    color: var(--gray);
    font-size: 0.85rem;
    text-align: right;
}

/* ===== 表格 ===== */
.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%;
}

th, td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: var(--dark);
    color: white;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    background: white;
}

tr:last-child td {
    border-bottom: none;
}

/* ===== 徽章 ===== */
.badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-warning { background: var(--warning); color: var(--dark); }
.badge-success { background: var(--success); }
.badge-danger { background: var(--danger); }
.badge-primary { background: var(--primary); }
.badge-secondary { background: var(--gray); }

/* ===== 表单 ===== */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--dark);
    font-size: 1rem;
}

.form-control {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: var(--transition);
    background: white;
    font-family: var(--font-family);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(67, 97, 238, 0.15);
}

/* ===== 提示框 ===== */
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 24px;
    font-weight: 500;
    border-left: 5px solid transparent;
    font-size: 0.95rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left-color: var(--success);
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left-color: var(--danger);
}

/* ===== 推荐链接卡片 ===== */
.referral-box {
    background: var(--light);
    padding: 16px 20px;
    border-radius: 40px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0;
    border: 2px dashed var(--primary);
}

.referral-box span {
    flex: 1;
    word-break: break-all;
    font-size: 0.9rem;
    color: var(--dark);
    font-weight: 500;
}

.referral-box .btn {
    width: auto;
    padding: 12px 24px;
    flex-shrink: 0;
}

/* ===== 进度条 ===== */
.progress-bar {
    background: var(--border);
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin: 12px 0;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--primary), var(--success));
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ===== 团队树状结构 ===== */
.team-tree ul {
    list-style: none;
    padding-left: 20px;
    margin-top: 8px;
}

.team-tree li {
    margin-bottom: 12px;
    padding: 10px 15px;
    background: var(--light);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
    position: relative;
}

.team-tree li:before {
    content: '';
    position: absolute;
    left: -20px;
    top: 20px;
    width: 20px;
    height: 2px;
    background: var(--border);
}

.team-tree .level-label {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    margin-right: 10px;
    text-transform: uppercase;
}

.level1-label { background: var(--primary); }
.level2-label { background: var(--success); }
.level3-label { background: var(--warning); color: var(--dark); }

/* ===== 页脚 ===== */
.footer {
    text-align: center;
    padding: 24px 20px;
    background: var(--light);
    font-size: 0.85rem;
    color: var(--gray);
    border-top: 1px solid var(--border);
}

.footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

/* ===== 加载动画 ===== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.loading {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===== 响应式调整 ===== */
@media (max-width: 480px) {
    .navbar {
        padding: 10px 6px;
        gap: 3px;
    }
    .navbar a {
        flex: 1;
        padding: 5px 3px;
        font-size: 1rem;
        gap: 2px;
    }
    .navbar a i {
        font-size: 0.9em;
    }
    .btn {
        padding: 14px 28px;
        font-size: 16px;
    }
    .card .btn {
        min-width: 140px;
    }
    .balance-value {
        font-size: 1rem;
        padding: 4px 12px;
    }
    span[style*="background:#27ae60"] {
        font-size: 0.85rem !important;
        padding: 6px 12px !important;
    }
    .product-item .product-meta,
    .redeem-item .redeem-meta,
    .resell-item .resell-meta {
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }
    .balance-item {
        font-size: 1rem;
    }
    .order-card .order-body {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .order-card .order-body div strong {
        min-width: 80px;
    }
}

/* 针对宽度在 421px 到 450px 的设备（如 iPhone 14 Pro Max）优化 */
@media (max-width: 450px) and (min-width: 421px) {
    .navbar a {
        padding: 5px 4px;
        font-size: 1.1rem;
        gap: 2px;
    }
    .navbar a i {
        font-size: 0.95em;
    }
}

/* 针对宽度在 376px 到 420px 的设备（如 iPhone 12 Pro）优化 */
@media (max-width: 420px) and (min-width: 376px) {
    .navbar a {
        padding: 5px 3px;
        font-size: 1rem;
        gap: 2px;
    }
    .navbar a i {
        font-size: 0.9em;
    }
}

/* 针对宽度 ≤ 375px 的进一步压缩 */
@media (max-width: 375px) {
    .navbar {
        padding: 8px 4px;
        gap: 2px;
    }
    .navbar a {
        padding: 4px 2px;
        font-size: 0.9rem;
        gap: 1px;
    }
    .navbar a i {
        font-size: 0.8em;
    }
}

/* 针对极窄屏幕（≤320px）的极限压缩 */
@media (max-width: 320px) {
    .navbar a {
        padding: 3px 2px;
        font-size: 0.8rem;
        gap: 0px;
    }
    .navbar a i {
        font-size: 0.7em;
    }
}

/* ===== 工具类 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.p-2 { padding: 8px; }
.p-4 { padding: 16px; }