:root {
    --bg: #f3f6fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --text: #172033;
    --muted: #667085;
    --line: #e2e8f0;
    --line-dark: #cbd5e1;
    --primary: #1769e0;
    --primary-dark: #0f55ba;
    --success: #087443;
    --warning: #b54708;
    --danger: #b42318;
    --sidebar: #111827;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 24px; line-height: 1.25; margin-bottom: 8px; }
h2 { font-size: 18px; line-height: 1.3; margin-bottom: 14px; }
h3 { font-size: 15px; margin-bottom: 10px; }
p { color: var(--muted); margin-bottom: 14px; }

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    background: linear-gradient(180deg, #0f172a 0%, #111827 52%, #0b1120 100%);
    color: #fff;
    z-index: 30;
    box-shadow: 12px 0 30px rgba(15,23,42,.12);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 6px 10px 18px;
    color: #fff;
}

.sidebar-brand span {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--primary);
    font-weight: 800;
}

.sidebar-brand strong {
    font-size: 16px;
}

.sidebar-section {
    padding: 8px 12px;
    color: #94a3b8;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .08em;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
    margin-top: 4px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 14px;
    border-radius: 8px;
    color: #cbd5e1;
    font-weight: 700;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255,255,255,.11);
    box-shadow: inset 3px 0 0 var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding: 14px 12px;
    border-top: 1px solid rgba(255,255,255,.1);
    display: grid;
    gap: 8px;
}

.sidebar-footer span {
    color: #94a3b8;
    font-size: 13px;
    font-weight: 800;
}

.sidebar-footer a {
    color: #fff;
    font-weight: 900;
}

.app-main {
    min-width: 0;
    margin-left: 260px;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 78px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 28px;
    background: rgba(255,255,255,.86);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.eyebrow {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.page {
    width: min(1280px, calc(100% - 40px));
    margin: 24px auto 56px;
}

.app-page {
    width: auto;
    margin: 24px 28px 56px;
}

.public-topbar {
    height: 66px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 0 28px;
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.public-brand {
    color: var(--text);
    font-size: 18px;
    font-weight: 900;
}

.mini-query,
.query,
.filter-bar {
    display: flex;
    gap: 10px;
    align-items: center;
}

.mini-query {
    width: min(420px, 100%);
}

.mini-query input,
.query input {
    min-width: 0;
}

.notice {
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: 8px;
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #175cd3;
    font-weight: 700;
}

.notice.success { color: var(--success); background: #ecfdf3; border-color: #abefc6; }
.notice.error { color: var(--danger); background: #fef3f2; border-color: #fecdca; }

.auth-body {
    min-height: 100vh;
    background: radial-gradient(circle at 20% 20%, #dbeafe 0, transparent 32%), var(--bg);
}

.auth-box {
    width: min(440px, 100%);
    margin: 92px auto;
    padding: 30px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 20px 50px rgba(15,23,42,.08);
}

.heading,
.panel-main,
.panel-side,
.order-result {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    margin-bottom: 22px;
}

.admin-shell,
.split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 420px;
    gap: 22px;
    align-items: start;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 18px;
}

.section-title p { margin-bottom: 0; }

.metrics {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.metrics div {
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.metrics strong {
    display: block;
    font-size: 28px;
    line-height: 1.1;
}

.metrics span {
    color: var(--muted);
    font-weight: 700;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.compact-table th,
.compact-table td {
    padding: 10px 12px;
}

th, td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    color: #475467;
    background: #f8fafc;
    font-size: 13px;
    font-weight: 900;
}

tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }

.form {
    display: grid;
    gap: 14px;
}

label {
    display: grid;
    gap: 6px;
    color: #344054;
    font-weight: 800;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    padding: 10px 11px;
    color: var(--text);
    background: #fff;
    font: inherit;
    outline: none;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23,105,224,.12);
}

textarea { resize: vertical; }

button,
.button {
    min-height: 40px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 0 16px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    color: #fff;
}

.button.ghost {
    background: #fff;
    color: var(--text);
    border-color: var(--line-dark);
}

.button.ghost:hover {
    background: #f8fafc;
    color: var(--text);
}

.button.danger {
    background: #fff;
    color: var(--danger);
    border-color: #fecdca;
}

.link-button {
    min-height: auto;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--primary);
    font-weight: 800;
}

.link-button:hover {
    background: transparent;
    color: var(--primary-dark);
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    white-space: nowrap;
}

.table-actions form {
    display: inline;
}

button[disabled] {
    opacity: .55;
    cursor: not-allowed;
}

.filter-bar {
    padding: 14px;
    margin-bottom: 16px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    flex-wrap: wrap;
}

.filter-bar input { width: min(340px, 100%); }
.filter-bar select { width: 180px; }

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.wide-form { max-width: 820px; }
.actions { margin-top: 16px; }

.check-row {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
}

.check-row label,
.inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.check-row input,
.inline-check input {
    width: auto;
}

.rich-editor-wrap {
    display: grid;
    gap: 8px;
}

.rich-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.rich-toolbar button {
    min-height: 34px;
    padding: 0 10px;
    background: #fff;
    color: var(--text);
    border-color: var(--line-dark);
    font-size: 13px;
}

.rich-toolbar button:hover {
    background: #eef4ff;
    color: var(--primary);
    border-color: #b2ccff;
}

.rich-editor-box {
    min-height: 240px;
    padding: 14px;
    border: 1px solid var(--line-dark);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none;
    overflow: auto;
}

.rich-editor-box:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23,105,224,.12);
}

.rich-editor-box:empty::before {
    content: "请输入商品详情，可插入图片、列表和链接";
    color: var(--muted);
}

.rich-editor-box img,
.detail-box img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.rich-editor-box p,
.rich-editor-box ul,
.rich-editor-box ol {
    margin-top: 0;
    margin-bottom: 10px;
}

.upload-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
}

.cover-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.cover-preview img {
    width: 116px;
    height: 84px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eef2f7;
}

.cover-preview span {
    color: var(--muted);
    font-weight: 800;
}

.cover-preview-large {
    display: grid;
    align-items: start;
}

.cover-preview-large img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
}

.product-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 260px;
}

.product-cell img {
    width: 64px;
    height: 48px;
    flex: 0 0 auto;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #eef2f7;
}

.compact-product-cell {
    min-width: 300px;
}

.compact-product-cell img {
    width: 72px;
    height: 54px;
}

.product-table th,
.product-table td {
    white-space: nowrap;
}

.product-table .product-cell span {
    max-width: 360px;
}

.product-cell strong,
.product-cell span,
.product-cell em {
    display: block;
}

.product-cell span {
    max-width: 420px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-cell em,
.card-tags span,
.status-pill {
    width: fit-content;
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.product-cell em {
    margin-top: 4px;
    color: #8a4b00;
    background: #fff3d6;
    font-style: normal;
}

.status-pill { color: #344054; background: #eef2f7; }
.status-pending { color: #175cd3; background: #eff6ff; }
.status-paid_hold { color: var(--warning); background: #fff7e6; }
.status-delivered { color: var(--success); background: #ecfdf3; }
.status-closed { color: #667085; background: #f2f4f7; }

.brand-preview {
    display: grid;
    gap: 8px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 20px;
}

.brand-preview img {
    width: 84px;
    height: 84px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.brand-preview span,
.hint {
    color: var(--muted);
    font-size: 13px;
}

.thumb-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.thumb-list img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.pay-config {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.hidden { display: none !important; }

.detail-list {
    grid-template-columns: 112px 1fr;
    padding: 16px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 18px;
}

.detail-list dt { font-weight: 900; }
dd { margin: 0; }

pre {
    white-space: pre-wrap;
    word-break: break-word;
    padding: 16px;
    background: #111827;
    color: #e5e7eb;
    border-radius: 8px;
}

.amount-positive { color: var(--success); font-weight: 900; }
.amount-negative { color: var(--danger); font-weight: 900; }

.log-card {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    background: #f8fafc;
}

.log-card span {
    color: var(--muted);
    font-size: 12px;
}

.log-card pre {
    max-height: 220px;
    overflow: auto;
    margin: 0;
    font-size: 12px;
}

.store-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 24px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 18px;
}

.store-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.store-brand img {
    width: 68px;
    height: 68px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.ticker {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    background: #fff7e6;
    border: 1px solid #fedf89;
    border-radius: 8px;
    margin-bottom: 18px;
}

.ticker span {
    flex: 0 0 auto;
    color: #9a5700;
    font-weight: 900;
}

.banner-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 18px;
}

.banner-strip img {
    width: 100%;
    aspect-ratio: 16 / 7;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.category-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.tab {
    min-height: 36px;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--line);
}

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

.commerce-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
}

.commerce-card {
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: transform .18s ease, box-shadow .18s ease;
}

.commerce-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 28px rgba(15,23,42,.08);
}

.card-cover {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: #eef2f7;
}

.card-body {
    display: grid;
    gap: 10px;
    padding: 14px;
}

.card-body h2 {
    font-size: 17px;
    margin: 0;
}

.card-body p {
    min-height: 44px;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.card-tags span {
    color: #1849a9;
    background: #eef4ff;
}

.product-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.product-meta strong,
.price {
    color: var(--primary);
    font-size: 24px;
    font-weight: 900;
}

.empty-state {
    grid-column: 1 / -1;
    padding: 36px;
    text-align: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--muted);
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .58);
    z-index: 50;
}

.modal.show { display: flex; }

.modal-panel {
    position: relative;
    width: min(980px, 100%);
    max-height: min(760px, calc(100vh - 48px));
    overflow: auto;
    background: #fff;
    border-radius: 8px;
    padding: 22px;
}

.form-modal {
    width: min(860px, 100%);
}

.form-modal .rich-editor-box {
    min-height: 150px;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding-top: 8px;
}

.modal-close {
    position: absolute;
    right: 14px;
    top: 12px;
    width: 34px;
    min-height: 34px;
    padding: 0;
    border-radius: 50%;
    background: #eef2f7;
    color: #172033;
    border-color: #eef2f7;
    font-size: 22px;
}

.modal-product {
    display: grid;
    grid-template-columns: 360px minmax(0, 1fr);
    gap: 22px;
}

.modal-product > img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
}

.detail-box {
    max-height: 180px;
    overflow: auto;
    padding: 12px;
    margin: 10px 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.compact-form {
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.qrbox {
    display: inline-flex;
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 10px 0 18px;
}

.qrbox img {
    width: 220px;
    height: 220px;
    display: block;
}

@media (max-width: 1120px) {
    .sidebar {
        position: static;
        width: auto;
        height: auto;
        min-height: 0;
    }
    .sidebar-nav {
        display: flex;
        overflow-x: auto;
    }
    .sidebar-footer {
        display: none;
    }
    .app-main {
        margin-left: 0;
    }
    .admin-shell,
    .split,
    .modal-product {
        grid-template-columns: 1fr;
    }
    .commerce-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .page,
    .app-page {
        width: calc(100% - 24px);
        margin: 16px auto 40px;
    }
    .app-header,
    .public-topbar,
    .store-hero {
        align-items: stretch;
        flex-direction: column;
        height: auto;
        padding: 16px;
    }
    .metrics,
    .grid-2,
    .banner-strip,
    .commerce-grid {
        grid-template-columns: 1fr;
    }
    .filter-bar,
    .mini-query,
    .query {
        width: 100%;
        align-items: stretch;
        flex-direction: column;
    }
    .filter-bar input,
    .filter-bar select {
        width: 100%;
    }
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
