:root {
    --paper: #f4f1ea;
    --card: #fffefa;
    --ink: #1c1b18;
    --muted: #8b8479;
    --line: #e6e1d6;
    --accent: #2f4a3f;
    --accent-deep: #24392f;
    --gold: #b08a4f;
    --field: #fbf9f4;
    --gain: #2f6b4f;
    --loss: #b4553f;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    color: var(--ink);
    background-color: var(--paper);
    background-image: linear-gradient(180deg, #f7f4ee 0%, #f1ede5 100%);
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* 顶栏 */
.topbar {
    display: flex;
    align-items: center;
    gap: 26px;
    padding: 18px 32px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 254, 250, 0.86);
    backdrop-filter: blur(6px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    font-size: 12px;
    letter-spacing: 0.34em;
    color: var(--muted);
}

.topbar nav { display: flex; gap: 4px; margin-left: 6px; }

.topbar nav a {
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    color: #5d574d;
}

.topbar nav a:hover { background: #f1ece3; text-decoration: none; }

.topbar nav a.active {
    color: var(--accent);
    background: #eef1ec;
    font-weight: 600;
}

.logout { margin-left: auto; font-size: 12.5px; color: var(--muted); }

/* 主体 */
.wrap {
    max-width: 1120px;
    margin: 0 auto;
    padding: 34px 24px 60px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.page-head h1 {
    margin: 0 0 6px;
    font-size: 26px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

.head-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.seg {
    display: inline-flex;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card);
}

.seg a {
    padding: 7px 13px;
    font-size: 12.5px;
    color: #6b6459;
}

.seg a.on { background: var(--accent); color: #f7f5ee; }

.seg a:hover { text-decoration: none; }

.btn {
    height: 38px;
    padding: 0 18px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #f7f5ee;
    font-family: inherit;
    font-size: 13.5px;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn:hover { background: var(--accent-deep); }

.btn.ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid #cfd8cf;
}

.btn.ghost:hover { background: #f0f3ef; }

.btn:disabled { opacity: 0.55; cursor: default; }

/* 提示条 */
.notice {
    margin-bottom: 18px;
    padding: 12px 16px;
    border: 1px solid #dcd8ca;
    border-left: 3px solid var(--gold);
    border-radius: 6px;
    background: #fdfaf3;
    font-size: 13px;
    color: #4a443a;
}

.notice.is-err { border-left-color: var(--loss); background: #fdf6f4; color: #8a3f2f; }

/* 统计卡 */
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    margin-bottom: 26px;
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    background: var(--line);
}

.stat {
    background: var(--card);
    padding: 18px 20px 16px;
}

.stat span {
    display: block;
    font-size: 11.5px;
    letter-spacing: 0.14em;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat b {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 26px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.stat small { margin-left: 4px; color: var(--muted); font-size: 12px; }

.gain { color: var(--gain); }
.loss { color: var(--loss); }

/* 表格 */
.table-wrap {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow-x: auto;
}

.table-wrap.flat { border: 0; background: transparent; }

table.orders {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.orders thead th {
    text-align: left;
    padding: 13px 16px;
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: var(--muted);
    background: #faf7f1;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.orders tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid #f0ece3;
    vertical-align: top;
}

.orders tbody tr:last-child td { border-bottom: 0; }

.orders tbody tr:hover { background: #fdfbf6; }

.orders .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.orders .num { font-family: Georgia, "Times New Roman", serif; font-size: 14px; }

.orders .time { color: #6b6459; white-space: nowrap; font-size: 12.5px; }

.orders .oid {
    font-family: "SF Mono", Consolas, monospace;
    font-size: 12px;
    color: #6b6459;
    word-break: break-all;
}

.orders .goods span { display: block; line-height: 1.6; }

.orders .goods details { margin-top: 4px; }

.orders .goods summary {
    font-size: 11.5px;
    color: var(--muted);
    cursor: pointer;
    outline: none;
    list-style: none;
}

.orders .goods summary::-webkit-details-marker { display: none; }
.orders .goods summary::before { content: "＋ "; }

.orders .goods ul {
    margin: 8px 0 2px;
    padding: 0;
    list-style: none;
}

.orders .goods li {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 4px 0;
    font-size: 12px;
    color: #5d574d;
}

.orders .goods li i { font-style: normal; color: var(--muted); margin-left: 6px; }

.orders .goods li em {
    font-style: normal;
    color: var(--muted);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.orders .status { color: #5d574d; font-size: 12.5px; white-space: nowrap; }

.badge {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 5px;
    border: 1px solid #ddd6c6;
    border-radius: 3px;
    color: var(--gold);
    font-family: inherit;
    font-size: 10.5px;
    vertical-align: 1px;
}

.legend { margin: 0; padding: 12px 16px; font-size: 11.5px; color: var(--muted); border-top: 1px solid var(--line); }

/* 面板 */
.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 22px 24px 24px;
    margin-bottom: 18px;
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

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

.status-grid div { border-bottom: 1px solid #f0ece3; padding-bottom: 10px; }

.status-grid span {
    display: block;
    font-size: 11.5px;
    letter-spacing: 0.1em;
    color: var(--muted);
    margin-bottom: 5px;
}

.status-grid b { font-size: 13px; font-weight: 500; word-break: break-all; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

.stack { max-width: 520px; }
.stack.narrow { max-width: 360px; }
.stack > div { margin-bottom: 14px; }
.stack .btn { margin-top: 6px; }

.field-label {
    display: block;
    font-size: 12.5px;
    letter-spacing: 0.1em;
    color: #5d574d;
    margin-bottom: 7px;
}

.field {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0 12px;
    background: var(--field);
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field:focus-within {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 74, 63, 0.09);
}

.field.is-error { border-color: var(--loss); }

.field input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
    padding: 10px 0;
}

.field input::placeholder { color: #b6afa3; }

.hint { margin: 8px 2px 14px; font-size: 12px; color: var(--muted); min-height: 16px; }
.hint.is-error { color: var(--loss); }

.tip { font-size: 12.5px; color: var(--muted); line-height: 1.7; margin: 12px 0 0; }

.steps { margin: 0; padding-left: 20px; color: #5d574d; font-size: 13px; line-height: 2; }
.steps a { text-decoration: underline; }

.mini {
    width: 120px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--field);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
    text-align: right;
    outline: none;
}

.mini:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px rgba(47, 74, 63, 0.09); }

/* 导入页 */
.map-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px 18px;
    margin-bottom: 10px;
}

.map-grid select,
.field select {
    flex: 1;
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    font-family: inherit;
    font-size: 13px;
    color: var(--ink);
    padding: 10px 0;
    cursor: pointer;
}

.textarea-field { align-items: stretch; padding: 10px 12px; }

.textarea-field textarea {
    width: 100%;
    border: 0;
    outline: none;
    background: transparent;
    resize: vertical;
    font-family: "SF Mono", Consolas, "PingFang SC", monospace;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--ink);
}

.sub-title { margin: 24px 0 10px !important; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

table.preview th,
table.preview td {
    font-size: 12px;
    white-space: nowrap;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
}

table.preview td { padding: 9px 14px; color: #5d574d; }

.field input[type="file"] { font-size: 12.5px; padding: 9px 0; }

/* 连接抖店 */
.state-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--card);
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: 0.06em;
}

.state-chip::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #c9c2b4;
}

.state-chip.is-on {
    color: var(--accent);
    border-color: #cfd8cf;
    background: #f1f5f1;
}

.state-chip.is-on::before { background: var(--gain); }

.muted-time { margin-left: 10px; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.collect-grid {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 18px;
    align-items: start;
}

.qr-panel { text-align: center; }

.qr-panel h2 { text-align: left; }

.qr-frame {
    width: 258px;
    margin: 6px auto 0;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

.qr-frame img { display: block; width: 100%; height: auto; }

.qr-placeholder {
    margin: 6px auto 0;
    width: 278px;
    height: 278px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: 1px dashed #ddd6c6;
    border-radius: 10px;
    background: #faf7f1;
}

.qr-placeholder p { margin: 0; font-size: 13.5px; color: #4a443a; }
.qr-placeholder .sub { font-size: 12px; color: var(--muted); max-width: 190px; line-height: 1.7; }

.qr-actions { justify-content: center; margin-top: 18px; }

.qr-done { padding: 34px 10px 44px; }
.qr-done p { margin: 14px auto 0; max-width: 250px; font-size: 12.5px; color: var(--muted); line-height: 1.8; }

.collect-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    margin: 20px 0 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    background: var(--line);
}

.collect-stats div { background: var(--card); padding: 14px 10px 12px; }

.collect-stats span {
    display: block;
    font-size: 11px;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-bottom: 6px;
}

.collect-stats b {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 20px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.qr-seal {
    display: inline-block;
    padding: 10px 22px;
    border: 1px solid #cfd8cf;
    border-radius: 999px;
    background: #f1f5f1;
    color: var(--accent);
    font-size: 13px;
    letter-spacing: 0.18em;
}

.link-btn {
    border: 0;
    background: none;
    padding: 0;
    margin-top: 18px;
    color: var(--muted);
    font-family: inherit;
    font-size: 12.5px;
    cursor: pointer;
    text-decoration: underline;
}

.link-btn:hover { color: var(--loss); }

.qr-note {
    margin: 16px auto 0;
    max-width: 250px;
    font-size: 11.5px;
    line-height: 1.8;
    color: var(--muted);
}

.collect-back {
    margin: 22px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

.creds-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.creds-who { font-size: 12px; color: var(--muted); }


/* 空状态 */
.empty {
    padding: 60px 20px;
    text-align: center;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.empty p { margin: 0 0 8px; color: #4a443a; font-size: 14px; }
.empty .sub { color: var(--muted); font-size: 12.5px; }

/* 登录页 */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 38px 34px 30px;
    background: var(--card);
    border: 1px solid rgba(28, 27, 24, 0.06);
    border-radius: 14px;
    box-shadow: 0 1px 2px rgba(48, 41, 30, 0.04), 0 30px 70px -46px rgba(48, 41, 30, 0.32);
}

.brand {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 11px;
    letter-spacing: 0.38em;
    color: var(--muted);
}

.mark { width: 5px; height: 5px; background: var(--gold); transform: rotate(45deg); }

.login-card h1 { margin: 14px 0 8px; font-size: 24px; font-weight: 600; letter-spacing: 0.05em; }

.login-card .lede { margin: 0 0 24px; font-size: 13px; color: var(--muted); line-height: 1.7; }

.login-card .submit {
    width: 100%;
    height: 46px;
    border: 0;
    border-radius: 9px;
    background: var(--accent);
    color: #f7f5ee;
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 0.2em;
    text-indent: 0.2em;
    cursor: pointer;
    margin-top: 4px;
}

.login-card .submit:hover { background: var(--accent-deep); }

/* 响应式 */
@media (max-width: 860px) {
    .topbar { padding: 14px 18px; gap: 12px; }
    .topbar nav { margin-left: 0; }
    .wrap { padding: 24px 16px 48px; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .status-grid { grid-template-columns: 1fr 1fr; }
    .map-grid { grid-template-columns: 1fr 1fr; }
    .collect-grid { grid-template-columns: 1fr; }
    .qr-panel { order: -1; }
    .two-col { grid-template-columns: 1fr; }
    .table-wrap { overflow-x: auto; }
    table.orders { min-width: 720px; }
    .page-head { align-items: flex-start; }
}

/* ---- 状态分组 ---- */
.status-group { margin-top: 18px; }
.group-head h2 {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; margin: 0 0 10px; color: #1f2937;
}
.group-head h2 small { font-weight: 400; color: #6b7280; font-size: 12px; margin-left: 4px; }
.group-head .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ---- 复制商品名按钮 ---- */
.goods-name { display: inline; }
.copy-btn {
    display: inline-block; margin-left: 8px; padding: 1px 8px;
    font-size: 11px; line-height: 18px; color: #4b5563;
    background: #f3f4f6; border: 1px solid #d1d5db; border-radius: 4px;
    cursor: pointer; vertical-align: middle; user-select: none;
}
.copy-btn:hover { background: #e5e7eb; color: #111827; }
.copy-btn.is-done { background: #dcfce7; border-color: #86efac; color: #15803d; }

/* ---- 手机端：单行紧凑布局，所有列一屏看全 ---- */
@media (max-width: 640px) {
    .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
    .topbar .logo { font-size: 15px; }
    .topbar nav a { padding: 5px 9px; font-size: 13px; }
    .wrap { padding: 14px 8px 40px; }
    .page-head h1 { font-size: 19px; }
    .head-actions { width: 100%; justify-content: space-between; }
    .seg a { padding: 5px 9px; font-size: 12.5px; }
    .btn { padding: 6px 12px; font-size: 13px; }

    .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat { padding: 9px 11px; }
    .stat b { font-size: 19px; }

    .group-head h2 { font-size: 13.5px; flex-wrap: wrap; }

    /* 表格压成单行列表 */
    .table-wrap { overflow: visible; }
    table.orders { min-width: 0; }
    table.orders thead { display: none; }
    table.orders, table.orders tbody { display: block; }
    table.orders tr {
        display: flex;
        align-items: center;
        gap: 6px;
        background: var(--card);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 7px 8px;
        margin-bottom: 6px;
    }
    table.orders td {
        display: block;
        flex: 0 0 auto;
        padding: 0;
        border: 0;
        font-size: 11.5px;
        line-height: 1.35;
    }
    table.orders td::before { content: none; }
    table.orders td.time { color: var(--muted); }
    table.orders td.oid { display: flex; align-items: center; }
    .oid-text { font-size: 11px; }
    table.orders td.goods {
        flex: 1 1 auto;
        min-width: 0;
    }
    table.orders td.goods > span {
        display: block;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        font-size: 12px;
    }
    table.orders td.num { font-weight: 600; text-align: right; }
    .copy-btn.icon-only { padding: 4px 4px; margin-left: 2px; }

    .notice { font-size: 13px; }
    .empty { padding: 30px 14px; }
}

/* ---- 多店铺 ---- */
.shop-name{color:var(--muted,#888);font-size:13px;white-space:nowrap}
.shop-switch select{border:1px solid #ddd;border-radius:8px;padding:4px 8px;font-size:13px;background:#fff}
.shop-form-grid{display:grid;grid-template-columns:1fr 1fr;gap:12px 16px}
@media (max-width:640px){.shop-form-grid{grid-template-columns:1fr}}
.shop-card{border:1px solid #eee;border-radius:12px;padding:14px;margin:12px 0}
.shop-card-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin-bottom:10px}
.inline-form{display:flex;gap:6px;flex-wrap:wrap;align-items:center}
.inline-form input{border:1px solid #ddd;border-radius:8px;padding:6px 8px;font-size:13px;min-width:110px}
