:root {
    --primary: #4e73df;
    --primary-hover: #2e59d9;
    --bg: #F5F7FA;
    --card: #FFFFFF;
    --text: #333333;
    --text-light: #777777;
    --border: #E0E6ED;
    --radius: 5px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* ========== 头部 ========== */
.header {
    background: var(--card);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 16px;
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
    gap: 10px;
    flex-wrap: nowrap;
}

.logo {
    font-size: 1.2em;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-form {
    display: flex;
    gap: 6px;
    flex: 1;
    max-width: 500px;
    min-width: 140px;
}

.search-input {
    flex: 1;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    font-size: 0.85em;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(78, 115, 223, 0.15);
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 500;
    transition: 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    min-height: 38px;
    background-color: var(--primary);
    color: #fff;
}

.btn:hover {
    background-color: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.78em;
    min-height: 34px;
}
.sales-login .btn-sm {
    padding: 5px 10px;
    font-size: 0.75em;
    min-height: 30px;
    white-space: nowrap;
}
/* 销售登录区域 */
.sales-login {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}

.sales-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(78, 115, 223, 0.1);
    color: var(--primary);
    padding: 5px 12px;
    border-radius: 5px;
    font-size: 0.82em;
    font-weight: 500;
}

.login-icon,
.sales-icon {
    font-size: 1em;
}

.sales-logout-btn {
    font-size: 0.82em;
    text-decoration: none;
}

/* ========== 内容容器 ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ========== 分类栏 ========== */
.categories-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.cat-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 90px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.85em;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    transition: 0.2s;
    user-select: none;
    white-space: nowrap;
    text-align: center;
    flex-shrink: 0;
}

.cat-tag:hover,
.cat-tag.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ========== 商品网格 ========== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.product-card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
    transform: translateY(-2px);
}

.product-img-wrap {
    width: 100%;
    aspect-ratio: 4/3;
    overflow: hidden;
    background: #f8f8f8;
    cursor: pointer;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: 0.3s;
}

.product-img:hover {
    transform: scale(1.03);
}

.product-body {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-title {
    font-weight: 600;
    font-size: 1em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-sku {
    font-size: 0.75em;
    color: var(--text-light);
}

.product-desc {
    font-size: 0.82em;
    color: var(--text-light);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    cursor: pointer;
    transition: 0.2s;
}

.product-desc.expanded {
    -webkit-line-clamp: unset;
    display: block;
}

.product-desc::after {
    display: block;
    text-align: right;
    color: var(--primary);
    font-size: 0.9em;
}

.product-desc:not(.expanded)::after {
    content: '[展开]';
}

.product-desc.expanded::after {
    content: '[收起]';
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 8px;
}

.product-price {
    font-size: 1.15em;
    font-weight: 700;
    color: #e74c3c;
}

.product-stock {
    font-size: 0.8em;
    color: var(--text-light);
}

.product-cat {
    font-size: 0.75em;
    background: #eef3f9;
    color: var(--primary);
    padding: 3px 8px;
    border-radius: 5px;
    align-self: flex-start;
}

/* 销售专属成本利润 */
.product-cost-profit {
    display: flex;
    justify-content: space-between;
    font-size: 0.8em;
    color: var(--text-light);
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #eee;
}

.product-cost-profit .profit.positive {
    color: #1cc88a;
}

.product-cost-profit .profit.negative {
    color: #e74a3b;
}

/* ========== 分页 ========== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.page-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    cursor: pointer;
    transition: 0.2s;
    color: var(--text);
}

.page-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.no-results {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
}

.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    margin-top: 40px;
}

/* ========== 图片灯箱 ========== */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: var(--radius);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #fff;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
    transition: 0.2s;
}

.lightbox-close:hover {
    color: var(--primary);
}

/* ========== 销售登录弹窗 ========== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    width: 90%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 1.5em;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

.modal-close-btn:hover {
    color: var(--text);
}

.modal-header {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 16px;
    text-align: center;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9em;
    outline: none;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.alert {
    padding: 10px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.9em;
}

.alert-error {
    background: #fbe9e7;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    .header-inner {
        flex-wrap: wrap;
        height: auto;
        padding: 8px 0;
        gap: 8px;
    }

    .logo {
        width: 100%;
        text-align: left;
        font-size: 1.1em;
        padding: 4px 0;
    }

    .search-form {
        flex: 1;
        max-width: none;
        min-width: 120px;
        order: 2;
    }

    .sales-login {
        order: 3;
        margin-left: 0;
    }

    .search-input {
        padding: 6px 8px;
        font-size: 0.8em;
    }

    .btn {
        padding: 6px 12px;
        font-size: 0.8em;
        min-height: 36px;
    }

    .products-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .product-img-wrap {
        aspect-ratio: 1/1;
    }

    .modal {
        padding: 20px;
    }

    .categories-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
        gap: 6px;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .categories-bar::-webkit-scrollbar {
        display: none;
    }

    .cat-tag {
        min-width: 80px;
        padding: 7px 12px;
        font-size: 0.8em;
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 1em;
    }

    .sales-badge {
        padding: 4px 8px;
        font-size: 0.75em;
    }

    .cat-tag {
        min-width: 70px;
        padding: 6px 10px;
        font-size: 0.75em;
    }
}
/* 付款二维码按钮容器 - 手机端独占一行 */
.qrcode-btn-wrap {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}
.qrcode-btn-wrap .btn-sm {
    font-size: 0.78em;
}

/* 二维码弹窗专用样式 */
.qrcode-modal {
    max-width: 360px;
    text-align: center;
}
.qrcode-modal img {
    display: block;
    margin: 0 auto;
}

/* 响应式：手机端让二维码按钮独占一行，位于销售按钮下方 */
@media (max-width: 768px) {
    .qrcode-btn-wrap {
        width: 100%;
        order: 4;          /* 保证在最后一行 */
        margin-top: 4px;
    }
    .qrcode-btn-wrap .btn {
        width: 100%;
        justify-content: center;
    }
}
/* 下架商品卡片淡化 */
.product-card.product-offline {
    opacity: 0.75;
    background: #fafafa;
}

/* 下架标识标签 */
.product-offline-badge {
    display: inline-block;
    background: #e74a3b;
    color: #fff;
    font-size: 0.72em;
    padding: 2px 8px;
    border-radius: var(--radius);
    margin-left: 6px;
    vertical-align: middle;
    font-weight: 500;
}

/* 标签容器（分类和下架标识排列） */
.product-tags {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
/* 已下架商品价格变为灰色 */
.product-card.product-offline .product-price {
    color: #999 !important;
}