:root {
    --accent: #2f7a3e;
    --accent-deep: #1f5c2d;
    --accent-soft: #eaf3e8;
    --clay: #c2563a;
    --ink: #1c2320;
    --ink-2: #4a5751;
    --muted: #7b8a83;
    --line: #e3e8e4;
    --bg: #f4f6f3;
    --card: #ffffff;
    --shadow: 0 1px 2px rgba(28, 35, 32, .05), 0 8px 24px rgba(28, 35, 32, .06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- 启动态 ---------- */
.boot {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--muted);
}

.boot-dot {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 3px solid var(--accent-soft);
    border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 登录 ---------- */
.login {
    min-height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 12% -10%, #dfeade 0%, rgba(223, 234, 222, 0) 62%),
        radial-gradient(760px 380px at 102% 108%, #f3e7dd 0%, rgba(243, 231, 221, 0) 60%),
        var(--bg);
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px 26px 24px;
    box-shadow: var(--shadow);
}

.login-foot { color: var(--muted); font-size: 12px; margin: 0; }

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    background: linear-gradient(145deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-size: 19px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}

.brand h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.brand.small .brand-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 16px; }
.brand.small h1 { font-size: 15px; }

.field { margin-bottom: 14px; }
.field label {
    display: block;
    font-size: 12px;
    color: var(--ink-2);
    margin-bottom: 6px;
    font-weight: 600;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(47, 122, 62, .12);
}

textarea { resize: vertical; min-height: 74px; }

.code-row { display: flex; gap: 10px; }
.code-row input { flex: 1; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
    white-space: nowrap;
}

.btn:hover { background: var(--accent-deep); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.block { width: 100%; }

.btn.ghost {
    background: #fff;
    border-color: var(--line);
    color: var(--ink-2);
}

.btn.ghost:hover { background: #f7f9f6; border-color: #cfd8d1; color: var(--ink); }
.btn.ghost.danger { color: var(--clay); border-color: #efd9d2; }
.btn.ghost.danger:hover { background: #fdf2ef; }
.btn.tiny { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

.icon-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    line-height: 1;
}

.icon-btn:hover { background: #f1f4f0; color: var(--ink); }

/* ---------- 骨架 ---------- */
.shell {
    display: grid;
    grid-template-columns: 216px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 20px 14px 16px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand { padding: 0 6px; margin-bottom: 18px; }

.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 11px;
    border: none;
    background: transparent;
    border-radius: 9px;
    color: var(--ink-2);
    font-size: 13.5px;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.nav-item span { font-size: 14px; }
.nav-item:hover { background: #f5f8f4; color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 600; }

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

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 26px;
    background: rgba(244, 246, 243, .86);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 5;
}

.topbar h2 { margin: 0; font-size: 17px; letter-spacing: .2px; }
.topbar .sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.who { font-size: 12px; color: var(--muted); }

.view { padding: 22px 26px 48px; }

/* ---------- 卡片 / 统计 ---------- */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 15px 16px;
    box-shadow: var(--shadow);
}

.stat .k { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 25px; font-weight: 700; letter-spacing: .5px; margin-top: 6px; }
.stat .v.clay { color: var(--clay); }
.stat .n { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 18px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    flex-wrap: wrap;
}

.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head .hint { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.panel-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.panel-tools input[type="search"] { width: 200px; }

.panel-body { padding: 16px; }

/* ---------- 表格 ---------- */
table.data { width: 100%; border-collapse: collapse; }
table.data th {
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    padding: 10px 16px;
    background: #fbfcfb;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
table.data td {
    padding: 11px 16px;
    border-bottom: 1px solid #f1f4f1;
    vertical-align: middle;
}
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fbfdfa; }

.cell-name { display: flex; align-items: center; gap: 11px; min-width: 220px; }
.thumb {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: linear-gradient(150deg, #eef4ea, #e2ece0);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    flex: 0 0 auto;
    overflow: hidden;
    border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cell-name .t { font-weight: 600; }
.cell-name .s { font-size: 12px; color: var(--muted); }

.price { font-weight: 700; color: var(--clay); white-space: nowrap; }
.price .o { font-weight: 400; color: var(--muted); text-decoration: line-through; font-size: 12px; margin-left: 5px; }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.pill {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.pill.ok { background: var(--accent-soft); color: var(--accent-deep); }
.pill.off { background: #f1f2f1; color: var(--muted); }
.pill.warn { background: #fdf2e7; color: #a4622a; }
.pill.info { background: #eaf0f7; color: #2b5786; }
.pill.muted { background: #f1f2f1; color: var(--muted); }
.pill.clay { background: #fbeae5; color: var(--clay); }

/* ---------- 空态 / 错误 ---------- */
.empty {
    padding: 44px 20px;
    text-align: center;
    color: var(--muted);
}
.empty .ico { font-size: 28px; display: block; margin-bottom: 8px; }
.empty p { margin: 0 0 12px; }

.error-box {
    background: #fdf2ef;
    border: 1px solid #efd9d2;
    color: #8f3a26;
    border-radius: 12px;
    padding: 14px 16px;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
}

.loading { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---------- 轮播图卡片 ---------- */
.grid-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.banner-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.banner-preview {
    height: 108px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 14px 16px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.banner-preview img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.banner-preview .bp-txt { position: relative; z-index: 1; text-shadow: 0 1px 6px rgba(0, 0, 0, .35); }
.banner-preview .bp-txt strong { font-size: 15px; display: block; }
.banner-preview .bp-txt span { font-size: 12px; opacity: .92; }

.banner-meta { padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.banner-meta .row-actions { flex: 1; justify-content: flex-end; }

/* ---------- 订单 ---------- */
.order-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 12px;
    background: #fff;
}

.order-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.order-no { font-weight: 700; letter-spacing: .4px; }
.order-time { font-size: 12px; color: var(--muted); margin-left: 8px; }

.order-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.order-item {
    display: grid;
    grid-template-columns: 34px 1fr auto auto;
    gap: 10px;
    align-items: center;
    font-size: 13px;
    color: var(--ink-2);
}
.order-item .oi-img {
    width: 34px; height: 34px; border-radius: 8px; overflow: hidden;
    background: #eef4ea; display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.order-item .oi-img img { width: 100%; height: 100%; object-fit: cover; }

.order-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    border-top: 1px dashed var(--line);
    padding-top: 10px;
}

.order-addr { font-size: 12.5px; color: var(--ink-2); }
.order-addr .muted { color: var(--muted); }
.order-total { font-size: 13px; }
.order-total strong { color: var(--clay); font-size: 15px; }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink-2);
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ---------- 弹窗 ---------- */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(22, 30, 26, .42);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
}

.modal-card {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: auto;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(22, 30, 26, .28);
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--line);
    position: sticky;
    bottom: 0;
    background: #fff;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 .field { margin-bottom: 0; }

.img-row { display: flex; gap: 14px; align-items: flex-start; }
.img-pick {
    width: 108px;
    height: 108px;
    border-radius: 12px;
    border: 1px dashed #cfd8d1;
    background: #fafcfa;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
    flex: 0 0 auto;
}
.img-pick:hover { border-color: var(--accent); color: var(--accent); }
.img-pick img { width: 100%; height: 100%; object-fit: cover; }
.img-actions { display: flex; flex-direction: column; gap: 8px; }
.img-actions .hint { margin: 0; font-size: 11.5px; color: var(--muted); max-width: 220px; }

.switch-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 0;
    border-top: 1px solid #f1f4f1;
    font-size: 13px;
}

.switch-row:first-child { border-top: none; }

.switch {
    position: relative;
    width: 42px;
    height: 24px;
    border-radius: 999px;
    background: #dfe4e0;
    border: none;
    cursor: pointer;
    transition: background .18s;
    flex: 0 0 auto;
}
.switch::after {
    content: "";
    position: absolute;
    top: 2px; left: 2px;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
    transition: transform .18s;
}
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    transform: translateX(-50%);
    background: #1c2320;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    z-index: 80;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
    max-width: 80vw;
}
.toast.err { background: var(--clay); }

.note {
    background: var(--accent-soft);
    border: 1px solid #d5e5d1;
    color: var(--accent-deep);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12.5px;
}

/* ---------------- 打印（A4 发货单 / 80mm 小票） ---------------- */

.print-root {
    display: none;
}

.sheet {
    color: #111827;
    font-size: 12.5px;
    line-height: 1.6;
}

.sheet + .sheet {
    margin-top: 24px;
}

.sheet-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    padding-bottom: 10px;
    border-bottom: 2px solid #111827;
}

.sheet-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sheet-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #2f7a3e;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sheet-brand h1 {
    margin: 0;
    font-size: 17px;
    letter-spacing: 0.5px;
}

.sheet-brand p {
    margin: 0;
    font-size: 11px;
    color: #6b7280;
    letter-spacing: 2px;
}

.sheet-meta {
    text-align: right;
    font-size: 11.5px;
    color: #374151;
}

.sheet-meta div {
    white-space: nowrap;
}

.sheet-meta span {
    color: #9ca3af;
    margin-right: 6px;
}

.sheet-meta strong {
    font-family: var(--mono, monospace);
    font-size: 12px;
    letter-spacing: 0.4px;
}

.sheet-recv {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 12px;
}

.sheet-recv-line {
    display: flex;
    gap: 10px;
}

.sheet-recv-line + .sheet-recv-line {
    margin-top: 4px;
}

.sheet-recv-line em {
    font-style: normal;
    color: #9ca3af;
    width: 52px;
    flex-shrink: 0;
}

.sheet-recv-line b {
    font-weight: 600;
}

.sheet-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 12px;
}

.sheet-table th,
.sheet-table td {
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    text-align: left;
}

.sheet-table th {
    background: #f3f4f6;
    font-weight: 600;
    color: #374151;
}

.sheet-table th:nth-child(1),
.sheet-table td:nth-child(1) {
    width: 34px;
    text-align: center;
    color: #9ca3af;
}

.sheet-table th:nth-child(3),
.sheet-table td:nth-child(3),
.sheet-table th:nth-child(4),
.sheet-table td:nth-child(4),
.sheet-table th:nth-child(5),
.sheet-table td:nth-child(5) {
    text-align: right;
    white-space: nowrap;
}

.sheet-foot {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-top: 12px;
}

.sheet-note {
    font-size: 11.5px;
    color: #4b5563;
    max-width: 62%;
}

.sheet-total {
    font-size: 13px;
    white-space: nowrap;
}

.sheet-total strong {
    font-size: 16px;
    margin-left: 4px;
}

.sheet-sign {
    display: flex;
    gap: 40px;
    margin-top: 22px;
    font-size: 12px;
    color: #374151;
}

.sheet-sign span {
    flex: 1;
    border-bottom: 1px solid #9ca3af;
    padding-bottom: 16px;
}

.sheet-printed {
    margin-top: 10px;
    font-size: 10.5px;
    color: #9ca3af;
    text-align: right;
}

/* 80mm 热敏小票：整体收窄、去掉大面积留白 */
.print-root.thermal .sheet {
    width: 72mm;
    font-size: 11px;
}

.print-root.thermal .sheet-head {
    flex-direction: column;
    gap: 4px;
    border-bottom: 1px dashed #111827;
    padding-bottom: 6px;
}

.print-root.thermal .sheet-logo {
    width: 26px;
    height: 26px;
    font-size: 14px;
    border-radius: 6px;
}

.print-root.thermal .sheet-brand h1 {
    font-size: 14px;
}

.print-root.thermal .sheet-meta {
    text-align: left;
    margin-top: 6px;
}

.print-root.thermal .sheet-recv {
    padding: 6px 8px;
    font-size: 10.5px;
}

.print-root.thermal .sheet-table {
    font-size: 10.5px;
    margin-top: 8px;
}

.print-root.thermal .sheet-table th,
.print-root.thermal .sheet-table td {
    padding: 3px 4px;
    border-left: none;
    border-right: none;
}

.print-root.thermal .sheet-table th:nth-child(1),
.print-root.thermal .sheet-table td:nth-child(1) {
    display: none;
}

.print-root.thermal .sheet-sign {
    display: none;
}

@media print {
    html,
    body {
        background: #fff !important;
        margin: 0;
        padding: 0;
    }

    #boot,
    #login,
    #shell,
    #modal,
    #toast {
        display: none !important;
    }

    .print-root {
        display: block !important;
    }

    .sheet {
        break-inside: avoid;
        page-break-inside: avoid;
        page-break-after: always;
    }

    .sheet:last-child {
        page-break-after: auto;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
