:root {
    --bg: #f6f7fb;
    --card: rgba(255, 255, 255, 0.9);
    --text: #18202f;
    --muted: #6b7280;
    --primary: #5b6cff;
    --primary-dark: #3c49d9;
    --green: #17b978;
    --red: #ef4444;
    --shadow: 0 18px 50px rgba(27, 37, 89, .11);
    --radius: 24px;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(91,108,255,.18), transparent 30%),
        radial-gradient(circle at top right, rgba(23,185,120,.16), transparent 24%),
        var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}
a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px min(6vw, 72px);
    background: rgba(255,255,255,.76);
    backdrop-filter: blur(18px);
    border-bottom: 1px solid rgba(255,255,255,.55);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; }
.brand-logo {
    width: 38px; height: 38px;
    display: inline-grid; place-items: center;
    color: white; background: linear-gradient(135deg, var(--primary), var(--green));
    border-radius: 14px;
}
.nav { display: flex; gap: 18px; align-items: center; color: #374151; }
.nav a { padding: 8px 10px; border-radius: 12px; }
.nav a:hover { background: rgba(91,108,255,.09); color: var(--primary-dark); }
.badge { background: var(--primary); color: white; border-radius: 999px; padding: 2px 7px; font-size: 12px; }
.page { width: min(1180px, 92vw); margin: 34px auto 70px; }
.hero, .admin-hero {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: center;
    padding: 46px;
    border-radius: 34px;
    background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,255,255,.72));
    box-shadow: var(--shadow);
    overflow: hidden;
}
.hero h1, .admin-hero h1 { margin: 6px 0 12px; font-size: clamp(34px, 5vw, 58px); letter-spacing: -1.5px; }
.hero p, .admin-hero p { color: var(--muted); line-height: 1.8; }
.eyebrow { color: var(--primary) !important; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; font-size: 13px; }
.search { display: flex; max-width: 620px; margin-top: 24px; background: white; padding: 8px; border-radius: 18px; box-shadow: 0 12px 34px rgba(91,108,255,.12); }
.search input { flex: 1; border: 0; outline: 0; padding: 0 16px; }
.search button, .btn {
    border: 0;
    color: white;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    padding: 13px 20px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(91,108,255,.25);
}
button:disabled { opacity: .45; cursor: not-allowed; }
.btn:hover { transform: translateY(-1px); }
.btn.small { padding: 9px 12px; font-size: 14px; }
.btn.full { width: 100%; margin-top: 14px; }
.btn.secondary { background: #111827; box-shadow: none; }
.hero-card, .stat {
    min-height: 170px;
    border-radius: 28px;
    padding: 24px;
    background: linear-gradient(135deg, #111827, #2d3659);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
}
.hero-card span, .stat span { color: rgba(255,255,255,.74); line-height: 1.7; }
.section-head { margin: 38px 0 18px; display: flex; justify-content: space-between; align-items: end; }
.section-head h2 { font-size: 28px; margin: 0; }
.section-head span { color: var(--muted); }
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 22px;
}
.product-card {
    background: var(--card);
    border: 1px solid rgba(255,255,255,.7);
    border-radius: var(--radius);
    box-shadow: 0 12px 35px rgba(31,41,55,.08);
    overflow: hidden;
    transition: .2s;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.product-img { display: block; height: 210px; background: #eef2ff; overflow: hidden; }
.product-img img, .detail-img img, .cart-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.placeholder { height: 100%; display: grid; place-items: center; color: var(--primary); font-weight: 800; background: linear-gradient(135deg, #eef2ff, #e6fff5); }
.placeholder.big { min-height: 420px; border-radius: 30px; }
.placeholder.mini { width: 68px; height: 68px; border-radius: 16px; }
.product-body { padding: 18px; }
.product-title-row { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.product-title-row h3 { margin: 0; font-size: 18px; }
.price { color: var(--red); font-weight: 900; white-space: nowrap; }
.product-body p { color: var(--muted); line-height: 1.6; height: 52px; overflow: hidden; }
.card-actions { display: flex; justify-content: space-between; align-items: center; }
.stock, .pill { color: var(--green); background: rgba(23,185,120,.12); padding: 6px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.flash-wrap { margin-bottom: 18px; }
.flash { padding: 13px 16px; border-radius: 16px; margin-bottom: 10px; background: white; box-shadow: 0 10px 25px rgba(0,0,0,.06); }
.flash.success { border-left: 5px solid var(--green); }
.flash.danger { border-left: 5px solid var(--red); }
.flash.warning { border-left: 5px solid #f59e0b; }
.flash.info { border-left: 5px solid var(--primary); }
.detail { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; align-items: start; }
.detail-img, .detail-info, .auth-card, .form-card, .table-card, .cart-box, .summary, .empty {
    background: var(--card);
    border-radius: 30px;
    box-shadow: var(--shadow);
    padding: 28px;
}
.detail-img { min-height: 420px; overflow: hidden; padding: 0; }
.detail-info h1 { font-size: 42px; margin: 18px 0 8px; }
.detail-price { color: var(--red); font-weight: 900; font-size: 36px; margin-bottom: 20px; }
.detail-info p { color: var(--muted); line-height: 1.9; }
.buy-box { display: grid; grid-template-columns: 80px 110px 1fr; gap: 12px; align-items: center; margin-top: 26px; }
.buy-box input, .product-form input, .product-form textarea, .auth-card input, .qty-input {
    border: 1px solid #e5e7eb;
    background: white;
    border-radius: 14px;
    padding: 13px 14px;
    outline: none;
}
.buy-box input:focus, .product-form input:focus, .product-form textarea:focus, .auth-card input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(91,108,255,.12); }
.auth-card, .form-card { width: min(560px, 100%); margin: 0 auto; }
.auth-card p { color: var(--muted); }
.auth-card form, .product-form { display: grid; gap: 13px; }
.product-form label { font-weight: 800; margin-top: 5px; }
.hint { color: var(--muted); font-size: 13px; }
.admin-hero { grid-template-columns: 1fr 170px 170px; }
.stat { min-height: 125px; text-align: center; align-items: center; }
.stat b { font-size: 42px; }
.admin-actions { display: flex; gap: 14px; margin: 24px 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 12px; border-bottom: 1px solid #eef0f4; text-align: left; }
th { color: var(--muted); font-size: 14px; }
.ops { display: flex; gap: 12px; align-items: center; }
.ops a { color: var(--primary-dark); font-weight: 700; }
.link-danger, .ghost.danger { border: 0; background: transparent; color: var(--red); cursor: pointer; font-weight: 700; }
.cart-box { display: grid; grid-template-columns: 1fr 310px; gap: 24px; align-items: start; padding: 0; background: transparent; box-shadow: none; }
.cart-list { display: grid; gap: 14px; }
.cart-item {
    display: grid;
    grid-template-columns: 76px 1fr 96px 100px 60px;
    gap: 16px;
    align-items: center;
    background: var(--card);
    padding: 16px;
    border-radius: 22px;
    box-shadow: 0 12px 30px rgba(31,41,55,.07);
}
.cart-thumb { width: 76px; height: 76px; border-radius: 18px; overflow: hidden; background: #eef2ff; }
.cart-info h3 { margin: 0 0 6px; }
.cart-info p { margin: 0; color: var(--muted); }
.summary { position: sticky; top: 94px; }
.summary h3 { margin-top: 0; }
.summary-row { display: flex; justify-content: space-between; padding: 14px 0; border-top: 1px solid #eef0f4; border-bottom: 1px solid #eef0f4; }
.checkout-form { display: flex; justify-content: flex-end; margin-top: 16px; }
.checkout { min-width: 230px; background: linear-gradient(135deg, var(--green), #0f9f70); box-shadow: 0 12px 30px rgba(23,185,120,.22); }
.empty { text-align: center; color: var(--muted); }
.footer { width: min(1180px, 92vw); margin: 0 auto 40px; color: var(--muted); display: flex; justify-content: space-between; gap: 18px; font-size: 14px; }
@media (max-width: 820px) {
    .topbar { flex-direction: column; gap: 14px; }
    .nav { flex-wrap: wrap; justify-content: center; }
    .hero, .admin-hero, .detail, .cart-box { grid-template-columns: 1fr; }
    .cart-item { grid-template-columns: 68px 1fr; }
    .cart-item .qty-input, .cart-item strong, .cart-item button { grid-column: 2; }
    .footer { flex-direction: column; }
}

/* 多图与图片压缩版新增样式 */
.product-img { position: relative; }
.image-count {
    position: absolute;
    right: 12px;
    top: 12px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(17, 24, 39, .78);
    color: white;
    font-size: 12px;
    font-weight: 800;
    backdrop-filter: blur(10px);
}
.detail-gallery { display: grid; gap: 14px; }
.thumb-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 10px;
}
.thumb-btn {
    border: 2px solid transparent;
    padding: 0;
    height: 74px;
    border-radius: 16px;
    overflow: hidden;
    background: white;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(31,41,55,.08);
}
.thumb-btn.active { border-color: var(--primary); }
.thumb-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pill.soft { color: var(--primary-dark); background: rgba(91,108,255,.12); margin-left: 8px; }
.wide-form { width: min(760px, 100%); }
.image-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}
.image-preview img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    border-radius: 16px;
    box-shadow: 0 8px 18px rgba(31,41,55,.08);
}
.image-manager { margin-top: 24px; }
.image-manager h2 { margin-top: 0; }
.manage-image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 14px;
}
.manage-image-card {
    background: #f8fafc;
    border: 1px solid #eef0f4;
    border-radius: 18px;
    padding: 10px;
    display: grid;
    gap: 8px;
}
.manage-image-card img {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 14px;
    display: block;
}
.manage-image-card .ghost.danger {
    width: 100%;
    background: rgba(239,68,68,.08);
    padding: 9px 10px;
    border-radius: 12px;
}
.admin-hero { grid-template-columns: 1fr 150px 150px 150px; }
.admin-thumb {
    width: 58px;
    height: 58px;
    border-radius: 14px;
    overflow: hidden;
    background: #eef2ff;
    display: grid;
    place-items: center;
    color: var(--muted);
    font-size: 12px;
}
.admin-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (max-width: 820px) {
    .admin-hero { grid-template-columns: 1fr; }
    .table-card { overflow-x: auto; }
    table { min-width: 780px; }
}
