:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --bg: #f5f5f7;
    --card-bg: #ffffff;
    --border: #e8e8ed;
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #e53e3e;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.06);
    --max-width: 1160px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===== Container ===== */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

/* ===== Header ===== */
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}
.site-header .header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}
.site-header .logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    letter-spacing: -0.3px;
}
.site-header nav { display: flex; gap: 24px; align-items: center; }
.site-header nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.6;
    transition: color 0.15s;
}
.site-header nav a:hover { color: var(--primary); }
.site-header nav a.admin-link {
    color: var(--primary);
    font-weight: 600;
    line-height: 1.6;
    padding: 0 12px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--primary);
    border-radius: 14px;
}
.site-header nav a.admin-link:hover {
    background: var(--primary);
    color: #fff;
}

/* ===== Footer ===== */
.site-footer {
    text-align: center;
    padding: 28px 0;
    color: var(--text-muted);
    font-size: 13px;
    border-top: 1px solid var(--border);
    margin-top: 56px;
}
.footer-qr {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}
.footer-qr img {
    width: 120px;
    height: 120px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    object-fit: cover;
}
.footer-qr p {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ===== Hero ===== */
.hero {
    text-align: center;
    padding: 28px 0 12px;
}
.hero h1 {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
    letter-spacing: -0.5px;
}
.hero .hero-subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    margin-bottom: 8px;
}
.hero .hero-tip {
    color: var(--text-muted);
    font-size: 13px;
}

/* ===== Category Nav ===== */
.category-nav {
    display: flex;
    gap: 6px;
    padding: 10px 0 18px;
    flex-wrap: wrap;
}
.category-nav a {
    padding: 5px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.15s;
}
.category-nav a.active,
.category-nav a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== Product Grid ===== */
.products-section {
    padding: 8px 0 24px;
}
.products-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}
.products-section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}
.products-count {
    font-size: 13px;
    color: var(--text-muted);
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    align-items: stretch;
}

/* ===== Product Card ===== */
.product-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
}
.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: #d0d0d8;
}
.product-card a {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    flex: 1;
    height: 100%;
    width: 100%;
}

/* Cover */
.product-cover {
    width: 100%;
    height: 180px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
.product-cover .cover-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}
/* 有背景图时隐藏默认图标 */
.product-cover[style*="background-image"] .cover-icon {
    display: none;
}
/* Cover color variants */
.cover-violet { background: linear-gradient(135deg, #eef2ff 0%, #e0e7ff 100%); }
.cover-violet .cover-icon { background: rgba(79,70,229,0.12); }
.cover-blue { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%); }
.cover-blue .cover-icon { background: rgba(37,99,235,0.12); }
.cover-emerald { background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%); }
.cover-emerald .cover-icon { background: rgba(16,185,129,0.12); }
.cover-amber { background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%); }
.cover-amber .cover-icon { background: rgba(245,158,11,0.12); }
.cover-rose { background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%); }
.cover-rose .cover-icon { background: rgba(244,63,94,0.12); }
.cover-slate { background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%); }
.cover-slate .cover-icon { background: rgba(100,116,139,0.12); }

/* Card body */
.product-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.product-card-body .product-name {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card-body .product-desc {
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.5;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 36px;
}

/* Tags */
.product-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.product-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.6;
}
.tag-auto { background: #d1fae5; color: #065f46; }
.tag-source { background: #dbeafe; color: #1e40af; }
.tag-download { background: #fef3c7; color: #92400e; }
.tag-key { background: #ede9fe; color: #5b21b6; }
.tag-unlimited { background: #e0f2fe; color: #0369a1; }

/* Card footer: price + button */
.product-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}
.product-price {
    font-size: 20px;
    color: var(--danger);
    font-weight: 700;
}
.product-price .unit { font-size: 13px; font-weight: 500; }

.btn-card {
    display: inline-block;
    padding: 6px 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}
.btn-card:hover { background: var(--primary-hover); }

/* Stock badge on card */
.product-stock-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(4px);
}
.badge-sold-out { color: #991b1b; }

/* ===== Empty State ===== */
.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 56px 0;
    font-size: 14px;
    grid-column: 1 / -1;
}

/* ===== Trust Section ===== */
.trust-section {
    display: flex;
    justify-content: center;
    gap: 40px;
    padding: 28px 0 8px;
    flex-wrap: wrap;
}
.trust-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}
.trust-icon {
    font-size: 18px;
    line-height: 1;
}

/* ===== Product Detail ===== */
.product-detail {
    background: var(--card-bg);
    padding: 28px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 700px;
    margin: 16px auto 0;
}
.product-detail .detail-header {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
    align-items: flex-start;
}
.product-detail .detail-cover {
    width: 100px;
    height: 100px;
    border-radius: var(--radius);
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
/* 有背景图时隐藏默认图标 */
.product-detail .detail-cover[style*="background-image"] .cover-icon {
    display: none;
}
.product-detail .detail-info { flex: 1; }
.product-detail h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
    line-height: 1.4;
}
.price-tag {
    font-size: 28px;
    color: var(--danger);
    font-weight: 700;
    margin-bottom: 12px;
}
.product-detail .product-meta {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.product-detail .meta-item {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}
.product-detail .desc {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: 24px;
}
.product-detail .desc p,
.delivery-content p { margin: 0 0 12px; }
.product-detail .desc p:last-child,
.delivery-content p:last-child { margin-bottom: 0; }
.product-detail .desc ul,
.delivery-content ul { margin: 0 0 12px; padding-left: 20px; }
.product-detail .desc a,
.delivery-content a {
    color: var(--primary, #6c5ce7);
    text-decoration: underline;
    word-break: break-all;
}
.product-detail .desc a:hover,
.delivery-content a:hover { opacity: .8; }

.order-form .form-group { margin-bottom: 16px; }
.order-form label { display: block; margin-bottom: 6px; font-weight: 500; font-size: 14px; }
.order-form input[type=text],
.order-form select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--card-bg);
    transition: border-color 0.15s;
}
.order-form input[type=text]:focus,
.order-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.pay-methods { display: flex; gap: 12px; }
.pay-option {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.15s;
}
.pay-option:hover { border-color: var(--primary); }

/* ===== Service QR ===== */
.service-qr {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 28px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-align: center;
}
.service-qr img {
    width: 160px;
    height: 160px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    object-fit: cover;
}
.service-qr p {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s;
    gap: 6px;
}
.btn:hover { background: var(--bg); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { padding: 5px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin: 12px 0;
    font-size: 14px;
}
.alert-out { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-info { background: #eef2ff; color: #3730a3; }

/* ===== Pay Page ===== */
.pay-page { display: flex; justify-content: center; padding: 32px 0; }
.pay-box {
    background: var(--card-bg);
    padding: 32px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    text-align: center;
    max-width: 420px;
    width: 100%;
}
.pay-box h2 { margin-bottom: 20px; font-size: 18px; font-weight: 700; }
.order-info { text-align: left; margin-bottom: 24px; }
.order-info .row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.order-info .row:last-child { border-bottom: none; }
.order-info .amount { color: var(--danger); font-weight: 700; font-size: 18px; }
.qrcode { margin: 16px auto; }
.qrcode img, .qrcode canvas { width: 220px !important; height: 220px !important; border-radius: 8px; }
.pay-tip { color: var(--text-muted); font-size: 13px; margin: 12px 0; line-height: 1.6; }
.pay-status { color: var(--warning); font-weight: 500; font-size: 14px; }
.pay-box .btn { margin: 8px 0; }

/* ===== Order Query Page ===== */
.order-query-page { max-width: 640px; margin: 16px auto 0; }
.order-query-page h1 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.order-query-form { display: flex; gap: 8px; margin-bottom: 24px; }
.order-query-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--card-bg);
    transition: border-color 0.15s;
}
.order-query-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    transition: box-shadow 0.15s;
}
.order-item:hover { box-shadow: var(--shadow-sm); }
.order-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.order-no { font-weight: 600; font-size: 14px; color: var(--text); }
.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.status-pending { background: #fef3c7; color: #92400e; }
.status-paid { background: #d1fae5; color: #065f46; }
.status-expired { background: #fee2e2; color: #991b1b; }
.status-closed { background: #f3f4f6; color: #6b7280; }
.order-body { display: flex; justify-content: space-between; align-items: center; font-size: 14px; color: var(--text-secondary); flex-wrap: wrap; gap: 8px; }
.order-body .amount { color: var(--danger); font-weight: 600; }
.order-item .btn-small { margin-top: 10px; }

/* ===== Order Result Page ===== */
.order-result-page { max-width: 640px; margin: 16px auto 0; }
.order-result-page h1 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.order-detail-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.order-detail-card .row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.order-detail-card .row:last-child { border-bottom: none; }
.order-detail-card .amount { color: var(--danger); font-weight: 700; }
.delivery-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.delivery-box h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; }
.delivery-content {
    background: #f8f9fb;
    padding: 14px;
    border-radius: var(--radius-sm);
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 13px;
    line-height: 1.7;
    border: 1px solid var(--border);
}
.tip {
    color: var(--text-muted);
    font-size: 13px;
    margin-top: 10px;
    line-height: 1.6;
}
/* ===== Responsive ===== */

/* Tablet: 2-3 columns */
@media (max-width: 1024px) {
    .product-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .hero { padding: 20px 0 8px; }
    .hero h1 { font-size: 22px; }
    .hero .hero-subtitle { font-size: 14px; }
    .hero .hero-tip { font-size: 12px; }
    .trust-section { gap: 20px; padding: 20px 0 4px; }
    .trust-item { font-size: 12px; }

    .product-detail { padding: 20px; }
    .product-detail .detail-header { flex-direction: column; align-items: flex-start; }
    .product-detail .detail-cover { width: 72px; height: 72px; }

    .product-card-body { padding: 12px; }
    .product-cover { height: 140px; }

    .site-header nav { gap: 16px; }
    .site-header nav a { font-size: 13px; }
}

/* Mobile: 1-2 columns */
@media (max-width: 480px) {
    .container { padding: 0 14px; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .hero h1 { font-size: 20px; }
    .hero .hero-subtitle { font-size: 13px; }
    .hero .hero-tip { font-size: 12px; }

    .product-card-body { padding: 10px; }
    .product-cover { height: 110px; }
    .product-card-body .product-name { font-size: 13px; }
    .product-card-body .product-desc { font-size: 11px; min-height: 30px; }
    .product-cover .cover-icon { width: 44px; height: 44px; font-size: 20px; border-radius: 10px; }
    .product-price { font-size: 17px; }
    .btn-card { padding: 5px 12px; font-size: 12px; }
    .product-tag { font-size: 10px; padding: 1px 6px; }

    .product-detail { padding: 16px; }

    .trust-section { gap: 16px; }
    .trust-item { font-size: 11px; }
    .trust-icon { font-size: 16px; }

    .order-query-form { flex-direction: column; }
    .order-body { flex-direction: column; align-items: flex-start; }

    .pay-box { padding: 20px; }
    .site-header .logo { font-size: 16px; }
    .site-footer { margin-top: 36px; padding: 20px 0; }
    .footer-qr img { width: 100px; height: 100px; }
    .service-qr { margin-top: 20px; padding: 16px; }
    .service-qr img { width: 130px; height: 130px; }
}
