:root {
    --ios-spring: cubic-bezier(0.32, 0.72, 0, 1);
    --safe-area-top: env(safe-area-inset-top, 20px);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
    --container-max: 1120px;
}

/* ========== 通用 ========== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    color: #1D1D1F;
    -webkit-tap-highlight-color: transparent;
    margin: 0;
}

.glass-bar {
    background: rgba(245, 245, 247, 0.72);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.skeleton-pulse { animation: pulse 1.5s cubic-bezier(0.4, 0, 0.6, 1) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.site-container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 20px;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 900;
}
.overlay.is-active { opacity: 1; pointer-events: auto; }

.dialog-modal {
    position: fixed;
    z-index: 910;
    background: #F5F5F7;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s var(--ios-spring), opacity 0.3s ease;
}
.dialog-modal.is-active {
    opacity: 1;
    pointer-events: auto;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.dialog-header h2 { font-size: 18px; font-weight: 600; margin: 0; }
.dialog-close {
    width: 32px; height: 32px;
    background: #E5E5EA;
    border: none; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #86868B; cursor: pointer;
}
.dialog-body { padding: 20px 24px 24px; }
.dialog-input {
    width: 100%;
    padding: 14px 16px;
    background: white;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 14px;
    outline: none;
    font-size: 15px;
    margin-bottom: 12px;
    box-sizing: border-box;
}
.dialog-input:focus { box-shadow: 0 0 0 3px rgba(0,122,255,0.15); }
.dialog-btn-primary {
    width: 100%;
    height: 52px;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}
.dialog-btn-primary:hover { opacity: 0.9; }
.dialog-btn-black {
    width: 100%;
    height: 52px;
    background: black;
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
}
.query-result {
    margin-top: 16px;
    padding: 16px;
    background: white;
    border-radius: 14px;
    border: 1px solid rgba(0,0,0,0.08);
    font-size: 14px;
}
.query-meta { color: #86868B; font-size: 13px; margin-top: 4px; }
.query-card-item {
    margin-top: 8px;
    padding: 10px;
    background: #F5F5F7;
    border-radius: 10px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    word-break: break-all;
}

/* ========== 首页 ========== */
body.home-page {
    background: #F5F5F7;
    overflow-x: hidden;
}

.site-wrap { min-height: 100vh; display: flex; flex-direction: column; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}
.site-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 17px;
    color: #1D1D1F;
    text-decoration: none;
}
.logo-icon {
    width: 36px; height: 36px;
    background: white;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.header-nav { display: flex; align-items: center; gap: 8px; }
.nav-link {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 14px;
    color: #86868B;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
}
.nav-link.active { color: #1D1D1F; font-weight: 500; }
.nav-link:hover { background: rgba(0,0,0,0.04); }

.hero-section {
    padding: 48px 0 32px;
}
.hero-badge {
    display: inline-block;
    padding: 6px 12px;
    background: rgba(0,122,255,0.1);
    color: #007AFF;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
}
.hero-title {
    font-size: clamp(28px, 5vw, 40px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 12px;
}
.hero-desc {
    font-size: 16px;
    color: #86868B;
    max-width: 520px;
    line-height: 1.6;
    margin: 0;
}

.products-section { padding: 16px 0 64px; flex: 1; }
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 24px;
}
.section-title { font-size: 22px; font-weight: 600; margin: 0; }
.section-sub { font-size: 14px; color: #86868B; margin: 0; }

.products-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 640px) {
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; }
}
@media (min-width: 1024px) {
    .products-grid { grid-template-columns: repeat(3, 1fr); gap: 24px; }
}

.product-card {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 4px 20px rgba(0,0,0,0.04);
}
.product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
.product-card.sold-out { opacity: 0.65; }
.product-card-image {
    aspect-ratio: 16/10;
    background: #F5F5F7;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-card-body { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.product-card-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0 0 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card-desc {
    font-size: 13px;
    color: #86868B;
    line-height: 1.5;
    margin: 0 0 16px;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card-footer { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.product-card-price { font-size: 22px; font-weight: 700; }
.product-card-price .symbol { font-size: 14px; margin-right: 2px; }
.product-card-meta { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.product-tag {
    padding: 3px 8px;
    background: #F5F5F7;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
    color: #86868B;
    text-transform: uppercase;
}
.stock-badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 600;
}
.stock-badge.in-stock { background: rgba(52,199,89,0.12); color: #34C759; }
.stock-badge.out-stock { background: rgba(255,59,48,0.12); color: #FF3B30; }

.products-loading {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.skeleton-card {
    height: 280px;
    background: white;
    border-radius: 20px;
    border: 1px solid rgba(0,0,0,0.06);
}
.products-empty {
    text-align: center;
    padding: 64px 20px;
    color: #86868B;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.site-footer {
    padding: 24px 0;
    border-top: 1px solid rgba(0,0,0,0.06);
    text-align: center;
    font-size: 13px;
    color: #86868B;
}

/* 首页查单弹窗 - 桌面居中 */
body.home-page #query-modal {
    top: 50%; left: 50%;
    width: 420px; max-width: calc(100vw - 32px);
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15);
    transform: translate(-50%, -50%) scale(0.95);
}
body.home-page #query-modal.is-active {
    transform: translate(-50%, -50%) scale(1);
}

/* ========== 商品页 - 移动端 ========== */
body.product-page {
    background: #000;
    overflow: hidden;
}

.app-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.base-view {
    width: 100%;
    height: 100%;
    background: #F5F5F7;
    overflow-y: auto;
    transition: transform 0.5s var(--ios-spring), border-radius 0.5s var(--ios-spring), opacity 0.5s var(--ios-spring);
    transform-origin: center top;
    padding-bottom: 100px;
}
.base-view.is-stacked {
    transform: scale(0.93) translateY(12px);
    border-radius: 20px;
    opacity: 0.6;
    pointer-events: none;
    overflow: hidden;
}

.product-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    gap: 12px;
}
.back-link {
    display: flex;
    align-items: center;
    gap: 2px;
    color: #007AFF;
    text-decoration: none;
    font-size: 16px;
    flex-shrink: 0;
}
.product-header-title {
    font-size: 16px;
    text-align: center;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-image-box {
    width: 100%;
    aspect-ratio: 1;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.product-image-inner {
    width: 128px; height: 128px;
    background: #F5F5F7;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.04);
}

.product-info-card {
    padding: 24px 20px;
    background: white;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.product-title {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.35;
    margin: 0 0 12px;
}
.product-price-row {
    display: flex;
    align-items: flex-end;
    gap: 2px;
    margin-bottom: 16px;
}
.price-symbol { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.product-price { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.product-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tag-item {
    padding: 4px 10px;
    background: #F5F5F7;
    color: #86868B;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    text-transform: uppercase;
}
.product-desc { font-size: 14px; color: #86868B; line-height: 1.6; margin: 0 0 16px; }

.product-features-section { padding: 0 20px 24px; }
.features-label {
    font-size: 13px;
    font-weight: 600;
    color: #86868B;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 12px;
}
.features-card {
    background: white;
    border-radius: 20px;
    padding: 16px;
    border: 1px solid rgba(0,0,0,0.08);
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.features-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.features-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 15px;
    line-height: 1.5;
}

.mobile-buy-bar {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    padding: 16px 20px calc(var(--safe-area-bottom) + 16px);
    border-top: 1px solid rgba(0,0,0,0.08);
    z-index: 20;
}
.buy-btn-mobile {
    width: 100%;
    height: 52px;
    background: black;
    color: white;
    border: none;
    border-radius: 16px;
    font-size: 17px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
.buy-btn-mobile:disabled { opacity: 0.4; cursor: not-allowed; }

/* iOS 底部弹窗 - 移动端 */
.ios-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 910;
    transform: translateY(100%);
    transition: transform 0.5s var(--ios-spring), opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
}
.ios-modal.is-active { transform: translateY(0); }

.modal-grabber {
    width: 36px; height: 5px;
    background: #E5E5EA;
    border-radius: 3px;
    margin: 8px auto;
}

.pay-option {
    width: 100%;
    min-height: 68px;
    border-radius: 16px;
    border: 2px solid transparent;
    background: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.pay-radio.selected {
    border-color: #007AFF;
    background-color: #F0F8FF;
}
.pay-icon {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.checkout-dialog { height: 92vh; }
.checkout-card {
    background: white;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
.checkout-card-header {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: white;
}
.checkout-card-body { padding: 24px; text-align: center; }
.checkout-hint { font-size: 13px; color: #86868B; margin: 0 0 4px; }
.checkout-amount {
    display: flex;
    justify-content: center;
    align-items: baseline;
    margin-bottom: 24px;
    color: #1D1D1F;
}
.amount-int { font-size: 44px; font-weight: 700; }
.amount-cent { font-size: 44px; font-weight: 700; color: #007AFF; }
.qrcode-box {
    width: 200px; height: 200px;
    margin: 0 auto 16px;
    background: #F9F9F9;
    border-radius: 20px;
    border: 1px solid #F0F0F0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.qrcode-box img { width: 100%; height: 100%; object-fit: contain; }
.checkout-warning {
    font-size: 12px;
    font-weight: 500;
    color: #FF3B30;
    background: rgba(255,59,48,0.1);
    padding: 8px 12px;
    border-radius: 10px;
    display: inline-block;
    margin: 0;
}
.checkout-order-no { font-size: 11px; color: #86868B; margin-top: 12px; }
.checkout-actions { margin-top: 32px; }
.upload-btn { display: flex; align-items: center; justify-content: center; gap: 8px; height: 56px; border-radius: 18px; }
.checkout-upload-hint { text-align: center; font-size: 12px; color: #86868B; margin-top: 12px; }

.status-overlay {
    position: fixed;
    inset: 0;
    background: #F5F5F7;
    z-index: 950;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 24px;
    opacity: 0;
    transition: opacity 0.3s;
}
.status-overlay.is-visible { opacity: 1; }
.status-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 420px;
}
.status-icon-box {
    width: 80px; height: 80px;
    background: white;
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.status-success-icon {
    width: 80px; height: 80px;
    background: #34C759;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    transition: transform 0.5s;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
}
.status-pending-icon {
    width: 80px; height: 80px;
    background: #FF9500;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}
.status-back-link {
    margin-top: 40px;
    font-weight: 600;
    color: #007AFF;
    font-size: 17px;
    text-decoration: none;
}
.cards-result {
    width: 100%;
    background: white;
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
}
.card-block-label {
    font-size: 12px;
    font-weight: 600;
    color: #86868B;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    display: block;
    margin-bottom: 8px;
}
.card-block-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F5F5F7;
    padding: 14px;
    border-radius: 14px;
    gap: 12px;
}
.card-block-text { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.card-copy-btn {
    background: none; border: none;
    color: #007AFF;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
}
.card-block-divider { margin-top: 20px; padding-top: 20px; border-top: 1px solid rgba(0,0,0,0.08); }
.card-extra-row { display: flex; gap: 12px; margin-top: 12px; }
.card-extra-col { flex: 1; }
.card-extra-col label {
    font-size: 12px;
    font-weight: 600;
    color: #86868B;
    display: block;
    margin-bottom: 6px;
}
.card-extra-item {
    background: #F5F5F7;
    padding: 12px;
    border-radius: 14px;
    text-align: center;
    font-family: ui-monospace, monospace;
    font-weight: 700;
}

/* ========== 商品页 - 桌面端 ========== */
@media (min-width: 768px) {
    body.product-page {
        background: #F5F5F7;
        overflow: auto;
    }

    .app-container {
        width: 100%;
        height: auto;
        min-height: 100vh;
        overflow: visible;
        max-width: var(--container-max);
        margin: 0 auto;
    }

    .base-view {
        height: auto;
        min-height: 100vh;
        padding-bottom: 48px;
        overflow: visible;
    }
    .base-view.is-stacked {
        transform: none;
        border-radius: 0;
        opacity: 1;
        pointer-events: auto;
    }

    .product-header-inner {
        max-width: var(--container-max);
        margin: 0 auto;
        padding: 16px 24px;
    }
    .product-header-title { text-align: left; font-size: 15px; color: #86868B; font-weight: 400; }
    .back-link .back-text { display: inline; }

    .product-layout {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 32px;
        max-width: var(--container-max);
        margin: 0 auto;
        padding: 24px;
        align-items: start;
    }

    .product-image-box {
        aspect-ratio: 4/3;
        border-radius: 24px;
        border: 1px solid rgba(0,0,0,0.06);
        overflow: hidden;
    }
    .product-image-inner {
        width: 160px; height: 160px;
        border-radius: 28px;
    }

    .product-info-card {
        border-radius: 24px;
        border: 1px solid rgba(0,0,0,0.06);
        box-shadow: 0 4px 20px rgba(0,0,0,0.05);
        position: sticky;
        top: 80px;
    }
    .product-title { font-size: 26px; }
    .product-price { font-size: 36px; }

    .buy-btn-desktop {
        width: 100%;
        height: 52px;
        background: black;
        color: white;
        border: none;
        border-radius: 16px;
        font-size: 17px;
        font-weight: 600;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        margin-top: 8px;
        transition: opacity 0.2s;
    }
    .buy-btn-desktop:hover { opacity: 0.85; }
    .buy-btn-desktop:disabled { opacity: 0.4; cursor: not-allowed; }

    .product-features-section { padding: 0; margin-top: 24px; }

    /* 桌面弹窗：居中对话框 */
    .ios-modal, .dialog-modal.checkout-dialog, .dialog-modal.query-dialog {
        position: fixed;
        top: 50%;
        left: 50%;
        bottom: auto;
        width: 480px;
        max-width: calc(100vw - 48px);
        max-height: 90vh;
        border-radius: 20px;
        z-index: 910;
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        pointer-events: none;
        box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    }
    .ios-modal.is-active, .dialog-modal.is-active {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
        pointer-events: auto;
    }
    .checkout-dialog {
        height: auto;
        max-height: 90vh;
    }
    .checkout-body { max-height: calc(90vh - 80px); }
}

@media (min-width: 1024px) {
    .product-layout {
        grid-template-columns: 5fr 4fr;
        gap: 48px;
        padding: 32px 24px 64px;
    }
}

/* ========== 后台 ========== */
.admin-sidebar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(20px) saturate(180%);
    border-right: 1px solid rgba(0,0,0,0.06);
}
.admin-nav-item { transition: all 0.2s ease; }
.admin-nav-item.active { background: #007AFF; color: white; }
.admin-nav-item:not(.active):hover { background: rgba(0,0,0,0.04); }
.table-row:hover { background: rgba(0,0,0,0.02); }
.badge {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}
.badge-pending { background: rgba(255,149,0,0.15); color: #FF9500; }
.badge-paid { background: rgba(0,122,255,0.15); color: #007AFF; }
.badge-reviewing { background: rgba(255,149,0,0.15); color: #FF9500; }
.badge-completed { background: rgba(52,199,89,0.15); color: #34C759; }
.badge-rejected { background: rgba(255,59,48,0.15); color: #FF3B30; }

.qr-upload-card {
    background: #F5F5F7;
    border-radius: 16px;
    padding: 16px;
    border: 1px solid rgba(0,0,0,0.06);
}
.qr-preview {
    width: 100%;
    aspect-ratio: 1;
    max-width: 180px;
    margin: 0 auto 12px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}
.qr-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.qr-preview-empty {
    width: 100%;
    aspect-ratio: 1;
    max-width: 180px;
    margin: 0 auto 12px;
    background: white;
    border-radius: 12px;
    border: 1px dashed rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #86868B;
    font-size: 12px;
}
.qr-upload-btn {
    width: 100%;
    padding: 10px;
    background: #07C160;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s;
}
.qr-upload-btn:hover { opacity: 0.9; }
.qr-upload-btn.alipay { background: #1677FF; }
