/* ========== 天宝卡网 - 全局样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #eef2ff;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-lighter: #9ca3af;
    --bg: #f5f6fa;
    --card: #ffffff;
    --border: #e5e7eb;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --nav-h: 60px;
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
    min-height: 100vh;
    overscroll-behavior: none;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

/* ========== 顶部栏 ========== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.25);
}

.topbar .logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
}

.topbar .subtitle {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
}

.topbar .user-chip {
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    backdrop-filter: blur(4px);
}

/* ========== 内容区 ========== */
.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 14px calc(var(--nav-h) + 24px);
}

.page-title {
    font-size: 18px;
    font-weight: 700;
    margin: 8px 4px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.page-title::before {
    content: '';
    width: 4px;
    height: 18px;
    background: var(--primary);
    border-radius: 2px;
}

/* ========== 分类标签 ========== */
.category-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 2px 12px;
    scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
    flex-shrink: 0;
    padding: 8px 16px;
    background: var(--card);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-light);
    border: 1px solid var(--border);
    transition: all 0.2s;
}
.cat-tab.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* ========== 商品卡片 ========== */
.product-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.product-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 12px;
    align-items: center;
    transition: transform 0.15s, box-shadow 0.15s;
}
.product-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.product-thumb {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
}

.product-info {
    flex: 1;
    min-width: 0;
}

.product-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-desc {
    font-size: 12px;
    color: var(--text-lighter);
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-price {
    color: var(--danger);
    font-size: 18px;
    font-weight: 700;
}
.product-price .unit {
    font-size: 12px;
    font-weight: 400;
}

.buy-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    flex-shrink: 0;
}
.buy-btn:active {
    transform: scale(0.93);
    opacity: 0.9;
}
.buy-btn.out {
    background: #d1d5db;
    pointer-events: none;
}

/* ========== 底部导航 ========== */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-h);
    background: var(--card);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
    padding-bottom: env(safe-area-inset-bottom);
}

.tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-lighter);
    font-size: 11px;
    transition: color 0.2s, transform 0.15s;
}
.tab-item:active { transform: scale(0.9); }
.tab-item.active { color: var(--primary); }

.tab-item svg {
    width: 22px;
    height: 22px;
}

/* ========== 弹窗 ========== */
.mask {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 200;
    display: none;
    align-items: flex-end;
    justify-content: center;
    animation: fadeIn 0.2s;
}
.mask.show { display: flex; }

.modal {
    background: #fff;
    width: 100%;
    max-width: 480px;
    border-radius: 16px 16px 0 0;
    padding: 20px;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 85vh;
    overflow-y: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.modal h3 {
    font-size: 17px;
    margin-bottom: 16px;
    text-align: center;
}

.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg);
    transition: border-color 0.2s, background 0.2s;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

.btn-primary {
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.15s;
}
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { opacity: 0.5; }

.btn-ghost {
    width: 100%;
    padding: 12px;
    background: var(--bg);
    color: var(--text-light);
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-top: 8px;
    transition: background 0.15s;
}
.btn-ghost:active { background: var(--border); }

/* 支付方式选择 */
.pay-methods {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}
.pay-method {
    flex: 1;
    padding: 14px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
    transition: all 0.15s;
    cursor: pointer;
}
.pay-method.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 600;
}
.pay-method .ico {
    font-size: 22px;
    display: block;
    margin-bottom: 4px;
}

/* 价格行 */
.price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}
.price-row .label { color: var(--text-light); font-size: 13px; }
.price-row .value { color: var(--danger); font-size: 20px; font-weight: 700; }
.price-row .discount-tag {
    background: var(--warning);
    color: #fff;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}

/* ========== Toast ========== */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.78);
    color: #fff;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 999;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
    max-width: 80%;
    text-align: center;
}
.toast.show { opacity: 1; }

/* ========== 订单列表 ========== */
.order-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}
.order-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}
.order-no {
    font-size: 12px;
    color: var(--text-lighter);
    font-family: monospace;
}
.order-status {
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}
.status-0 { background: #fef3c7; color: #92400e; }
.status-1 { background: #dbeafe; color: #1e40af; }
.status-2 { background: #d1fae5; color: #065f46; }
.status-3 { background: #f3f4f6; color: #6b7280; }

.order-product {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}
.order-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-light);
}

/* 订单详情 */
.detail-section {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-light); }
.detail-row .v { color: var(--text); font-weight: 500; }

.card-box {
    background: #1f2937;
    color: #fbbf24;
    padding: 14px;
    border-radius: var(--radius-sm);
    font-family: monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
    margin-top: 8px;
    user-select: all;
}

/* ========== 我的页 ========== */
.profile-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 24px 16px 40px;
    margin: -16px -14px 0;
    border-radius: 0 0 20px 20px;
}
.profile-user {
    display: flex;
    align-items: center;
    gap: 12px;
}
.avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
}
.profile-name { font-size: 18px; font-weight: 700; }
.profile-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }

.balance-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    margin: -24px 0 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.balance-amount { font-size: 26px; font-weight: 700; color: var(--danger); }
.balance-label { font-size: 12px; color: var(--text-light); margin-top: 4px; }

.menu-list {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:active { background: var(--bg); }
.menu-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    flex-shrink: 0;
}
.menu-text { flex: 1; font-size: 14px; }
.menu-arrow { color: var(--text-lighter); font-size: 18px; }

/* 等级卡片 */
.level-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.level-current {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.level-badge {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}
.level-progress {
    height: 8px;
    background: var(--bg);
    border-radius: 4px;
    overflow: hidden;
    margin: 8px 0;
}
.level-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--warning));
    border-radius: 4px;
    transition: width 0.5s;
}
.level-tip { font-size: 12px; color: var(--text-light); }

.level-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.level-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: 8px;
    background: var(--bg);
    font-size: 13px;
}
.level-item.current {
    background: var(--primary-light);
    border: 1px solid var(--primary);
}
.level-item .lv-name { font-weight: 600; }
.level-item .lv-discount { color: var(--danger); font-weight: 600; }

/* ========== 登录页 ========== */
.auth-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.auth-header {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 50px 24px 60px;
    text-align: center;
    border-radius: 0 0 30px 30px;
}
.auth-header h1 { font-size: 26px; margin-bottom: 6px; }
.auth-header p { opacity: 0.85; font-size: 13px; }

.auth-box {
    background: #fff;
    margin: -30px 16px 16px;
    border-radius: var(--radius);
    padding: 24px 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.auth-tabs {
    display: flex;
    margin-bottom: 20px;
    background: var(--bg);
    border-radius: 10px;
    padding: 4px;
}
.auth-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-light);
    font-weight: 500;
    transition: all 0.2s;
}
.auth-tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 16px;
}
.checkbox-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.auth-footer {
    text-align: center;
    font-size: 12px;
    color: var(--text-lighter);
    padding: 16px;
}

/* ========== 后台 ========== */
.admin-layout {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}
.admin-nav {
    display: flex;
    gap: 8px;
    background: var(--card);
    padding: 8px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow-x: auto;
}
.admin-nav a {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    color: var(--text-light);
}
.admin-nav a.active {
    background: var(--primary);
    color: #fff;
}
.admin-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 16px;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.admin-table th, .admin-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.admin-table th { color: var(--text-light); font-weight: 600; background: var(--bg); }
.admin-table tr:hover td { background: #fafafa; }

/* 通用工具 */
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap-8 { gap: 8px; }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-muted { color: var(--text-lighter); }
.text-center { text-align: center; }

.empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-lighter);
    font-size: 14px;
}
.empty .ico { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
