/* 沛钊选品 — Design System */
:root {
    --navy: #1B2A4A;
    --navy-light: #2A3F6B;
    --coral: #FF6B4A;
    --coral-hover: #E85A3A;
    --green: #22C55E;
    --green-bg: #ECFDF3;
    --amber: #F59E0B;
    --amber-bg: #FFFBEB;
    --red: #EF4444;
    --red-bg: #FEF2F2;
    --bg: #F8F9FB;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --text: #1A1A2E;
    --text-secondary: #6B7280;
    --text-muted: #9CA3AF;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --font: 'Noto Sans SC', system-ui, sans-serif;
    --sidebar-width: 240px;
    --header-height: 64px;
    --transition: 150ms ease-out;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

body {
    font-family: var(--font);
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

::selection { background: rgba(255, 107, 74, 0.2); color: var(--text); }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-light); }
.btn-coral { background: var(--coral); color: #fff; }
.btn-coral:hover { background: var(--coral-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #DC2626; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: var(--green-bg); color: #15803D; }
.badge-danger { background: var(--red-bg); color: #B91C1C; }
.badge-warning { background: var(--amber-bg); color: #B45309; }
.badge-muted { background: #F3F4F6; color: var(--text-secondary); }

/* ── Live indicator ── */
.live-dot {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}
.live-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.85); }
}

/* ══════════════════════════════════════
   FRONTEND
   ══════════════════════════════════════ */

.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--navy);
    color: #fff;
    height: var(--header-height);
    box-shadow: var(--shadow-sm);
}
.header-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 24px;
}
.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    flex-shrink: 0;
}
.logo-icon { color: var(--coral); font-size: 14px; }

.main-nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    flex-shrink: 1;
}
.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: rgba(255,255,255,0.75);
    white-space: nowrap;
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.1); }
.nav-link.active { color: #fff; background: rgba(255,255,255,0.15); font-weight: 500; }

.search-form {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    padding: 0 4px 0 14px;
    flex: 1;
    max-width: 320px;
    margin-left: auto;
}
.search-form input {
    flex: 1;
    background: none;
    border: none;
    color: #fff;
    padding: 8px 0;
    outline: none;
    font-size: 14px;
}
.search-form input::placeholder { color: rgba(255,255,255,0.5); }
.search-form button {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    padding: 6px;
    display: flex;
}
.search-form button:hover { color: #fff; }

.site-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
    min-height: calc(100vh - var(--header-height) - 60px);
}

.catalog-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 24px;
}

/* Sidebar categories */
.category-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 24px);
    align-self: start;
}
.category-sidebar h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}
.category-list { list-style: none; }
.category-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    transition: background var(--transition);
}
.category-item a:hover { background: var(--surface); }
.category-item a.active {
    background: var(--surface);
    font-weight: 600;
    color: var(--navy);
    box-shadow: var(--shadow-sm);
}
.category-count {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    padding: 1px 8px;
    border-radius: 999px;
}

/* Filter bar */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.filter-bar select {
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}
.filter-bar .live-dot { margin-left: auto; }

/* Product grid */
.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}
.product-card {
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), transform var(--transition);
    display: flex;
    flex-direction: column;
}
.product-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}
.product-card-image {
    aspect-ratio: 1;
    overflow: hidden;
    background: #F3F4F6;
    position: relative;
}
.import-count-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: var(--amber);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    font-variant-numeric: tabular-nums;
}
.product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 300ms ease-out;
}
.product-card:hover .product-card-image img { transform: scale(1.04); }
.product-card-body {
    padding: 14px 16px 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.product-card-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.9em;
}
.product-card-price {
    font-size: 20px;
    font-weight: 700;
    color: var(--coral);
    font-variant-numeric: tabular-nums;
}
.product-card-cny {
    font-size: 12px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.product-card-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}
.product-card-rating { color: var(--amber); font-weight: 500; }
.product-card-reviews { color: var(--text-muted); font-size: 12px; }
.product-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
    padding-top: 4px;
}
.product-card-sync {
    font-size: 11px;
    color: var(--text-muted);
}
.product-card.updated-flash {
    animation: flashUpdate 600ms ease-out;
}
@keyframes flashUpdate {
    0% { background: rgba(255, 107, 74, 0.15); }
    100% { background: var(--surface); }
}

/* Product detail */
.product-detail {
    display: grid;
    grid-template-columns: 480px 1fr;
    gap: 40px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow-sm);
}
.product-detail-image {
    aspect-ratio: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: #F3F4F6;
}
.product-detail-image img { width: 100%; height: 100%; object-fit: cover; }
.product-detail-info h1 {
    font-size: 24px;
    font-weight: 600;
    line-height: 1.35;
    margin-bottom: 8px;
}
.product-detail-sku {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.product-detail-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--coral);
    font-variant-numeric: tabular-nums;
}
.product-detail-cny {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}
.product-detail-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin: 24px 0;
}
.stat-box {
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}
.stat-box .stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--navy);
    font-variant-numeric: tabular-nums;
}
.stat-box .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}
.breadcrumb {
    display: flex;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}
.breadcrumb a:hover { color: var(--coral); }
.breadcrumb span { color: var(--text-muted); }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 80px 24px;
    color: var(--text-secondary);
}
.empty-state svg { margin: 0 auto 16px; opacity: 0.4; }
.empty-state h3 { font-size: 18px; color: var(--text); margin-bottom: 8px; }

/* Skeleton */
.skeleton {
    background: linear-gradient(90deg, #F3F4F6 25%, #E5E7EB 50%, #F3F4F6 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 32px;
}
.pagination a, .pagination span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
}
.pagination a:hover { background: var(--surface); color: var(--text); }
.pagination .current {
    background: var(--navy);
    color: #fff;
    font-weight: 600;
}

.site-footer {
    text-align: center;
    padding: 24px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* ══════════════════════════════════════
   ADMIN
   ══════════════════════════════════════ */

.admin-body { background: var(--bg); }

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
}
.sidebar-brand {
    padding: 20px 20px 24px;
    font-weight: 700;
    font-size: 17px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: rgba(255,255,255,0.7);
    transition: background var(--transition), color var(--transition);
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active { background: rgba(255,255,255,0.12); color: #fff; font-weight: 500; }
.sidebar-link-muted { color: rgba(255,255,255,0.4); }
.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.admin-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}
.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 40;
}
.admin-page-title { font-size: 20px; font-weight: 600; }
.admin-user { font-size: 14px; color: var(--text-secondary); }
.admin-main { padding: 24px 32px 48px; flex: 1; }

/* Stats cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--navy);
    font-variant-numeric: tabular-nums;
}
.stat-card-value.text-coral { color: var(--coral); }
.stat-card-value.text-green { color: var(--green); }
.stat-card-value.text-red { color: var(--red); }

/* Panels */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.panel-header h2 { font-size: 16px; font-weight: 600; }
.panel-body { padding: 20px; }

/* Upload zone */
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--coral);
    background: rgba(255, 107, 74, 0.04);
}
.upload-zone-icon { font-size: 32px; margin-bottom: 8px; opacity: 0.5; }
.upload-zone p { color: var(--text-secondary); font-size: 14px; }
.upload-zone .hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(27, 42, 74, 0.1);
}
textarea.form-control { min-height: 120px; resize: vertical; font-family: monospace; font-size: 13px; }
.form-row { display: flex; gap: 12px; align-items: flex-end; }
.form-row .form-group { flex: 1; }

/* Data table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 10px 12px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:hover td { background: var(--bg); }
.table-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    background: #F3F4F6;
}
.table-actions { display: flex; gap: 6px; }

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin-bottom: 16px;
}
.alert-success { background: var(--green-bg); color: #15803D; }
.alert-error { background: var(--red-bg); color: #B91C1C; }

/* Login */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--navy);
}
.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
}
.login-card h1 {
    font-size: 22px;
    text-align: center;
    margin-bottom: 8px;
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 28px;
}

/* Progress bar */
.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0;
}
.progress-bar-fill {
    height: 100%;
    background: var(--coral);
    border-radius: 999px;
    transform-origin: left center;
    transition: transform 300ms ease-out;
}

/* Category drag list */
.category-drag-list { list-style: none; }
.category-drag-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}
.drag-handle { cursor: grab; color: var(--text-muted); }
.category-drag-item .cat-name { flex: 1; font-weight: 500; }
.category-drag-item .cat-slug { font-size: 12px; color: var(--text-muted); font-family: monospace; }
.category-drag-item .cat-count { font-size: 12px; color: var(--text-secondary); }

/* Demo banner */
.demo-banner {
    background: var(--amber-bg);
    color: #92400E;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */

@media (max-width: 1279px) {
    .product-grid { grid-template-columns: repeat(3, 1fr); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1023px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .category-sidebar { position: static; }
    .category-list { display: flex; flex-wrap: wrap; gap: 6px; }
    .category-item a { padding: 6px 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
    .product-detail { grid-template-columns: 1fr; }
    .main-nav { display: none; }
}

@media (max-width: 767px) {
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .header-inner { padding: 0 16px; gap: 12px; }
    .search-form { max-width: none; }
    .site-main { padding: 16px; }
    .admin-sidebar { transform: translateX(-100%); }
    .admin-content { margin-left: 0; }
    .admin-main { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .product-detail { padding: 20px; }
    .product-detail-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 479px) {
    .product-grid { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: 1fr; }
}
