* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --bg: #efeff1;
    --bg-soft: #f4f4f6;
    --head-bg: #dedee2;
    --text: #111827;
    --soft: #374151;
    --line: rgba(88, 96, 110, 0.38);
    --vline: rgba(88, 96, 110, 0.48);

    --btn: #111827;
    --btn-text: #ffffff;

    --page-max-width: 1680px;
    --page-padding-x: 12px;
    --page-padding-top: 14px;
    --page-padding-bottom: 12px;
    --page-gap: 8px;

    --title-size: 28px;
    --title-weight: 900;

    --table-font-size: 13px;
    --table-cell-padding-y: 8px;
    --table-cell-padding-x: 8px;
    --table-row-height: 32px;

    --radius-btn: 8px;
}

html,
body {
    width: 100%;
    min-height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
        "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(180deg, #f3f3f5 0%, #eeeeef 52%, #e7e7e9 100%);
    color: var(--text);
    overflow: hidden;
}

body {
    min-height: 100vh;
}

/* 页面主容器 */
.page {
    width: 100%;
    height: 100vh;
    max-width: var(--page-max-width);
    margin: 0 auto;
    padding: var(--page-padding-top) var(--page-padding-x) var(--page-padding-bottom);
    display: flex;
    flex-direction: column;
    gap: var(--page-gap);
    background: transparent;
}

/* 顶部栏 */
.topbar {
    min-height: 34px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex: 0 0 auto;
}

.title-text {
    font-size: var(--title-size);
    font-weight: var(--title-weight);
    line-height: 1.1;
    letter-spacing: 0.1px;
    color: var(--text);
    text-align: left;
    word-break: break-word;
}

/* 表格区域 */
.table-wrap {
    flex: 1;
    min-height: 0;
    overflow: auto;
    background: var(--bg);
}

.table-wrap table {
    width: 100%;
    min-width: 1100px;
    border-collapse: collapse;
    table-layout: fixed;
    background: var(--bg);
}

/* 表头 */
.table-wrap thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--head-bg);
    color: var(--text);
    font-size: var(--table-font-size);
    font-weight: 900;
    text-align: center;
    padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
    border-bottom: 1px solid var(--line);
    border-right: none;
    white-space: nowrap;
}

.table-wrap thead th.no-head {
    color: transparent;
}

/* 单元格 */
.table-wrap tbody td {
    background: var(--bg);
    color: var(--soft);
    font-size: var(--table-font-size);
    font-weight: 400;
    line-height: 1.22;
    padding: var(--table-cell-padding-y) var(--table-cell-padding-x);
    border-right: 1px dashed var(--vline);
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
    overflow: visible;
    text-overflow: initial;
}

.table-wrap tbody td:last-child {
    border-right: none;
}

.table-wrap tbody tr {
    height: var(--table-row-height);
}

/* 常用单元格对齐 */
.no-cell,
.warehouse-cell,
.print-cell {
    text-align: center;
}

.name-cell,
.remark-cell,
.gift-cell,
.sn-cell {
    white-space: normal;
    word-break: break-word;
    line-height: 1.25;
}

.money-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
    padding-right: 10px;
}

/* 空状态 */
.empty-box {
    padding: 18px 12px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
    color: #4b5563;
    background: var(--bg);
    border-right: none !important;
}

/* 按钮 */
.btn,
.print-btn {
    height: 30px;
    padding: 0 14px;
    border: none;
    border-radius: var(--radius-btn);
    background: var(--btn);
    color: var(--btn-text);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.btn:active,
.print-btn:active {
    transform: scale(0.98);
}

/* 打印专用宿主 */
.print-host {
    position: fixed;
    left: -99999px;
    top: -99999px;
    width: 210mm;
    background: #fff;
    color: #111827;
}

.print-sheet {
    width: 100%;
    max-width: 182mm;
    min-height: 120mm;
    margin: 0 auto;
    padding: 5mm 14mm 10mm;
    background: #fff;
    color: #111827;
    page-break-after: auto;
}

.print-title {
    width: 100%;
    display: block;
    text-align: center;
    font-size: 24px;
    font-weight: 900;
    line-height: 1.2;
    letter-spacing: 2px;
    margin-top: 2mm;
    margin-bottom: 7mm;
    color: #111827;
}

.print-row {
    display: flex;
    align-items: flex-start;
    margin-bottom: 3.2mm;
    font-size: 15px;
    line-height: 1.42;
    color: #111827;
}

.print-label {
    width: 18mm;
    flex: 0 0 18mm;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.print-value {
    flex: 1;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
}

.print-gap {
    height: 4mm;
}

/* 移动端 */
@media (max-width: 900px) {
    .page {
        padding: 10px 8px 8px;
        gap: 6px;
    }

    .title-text {
        font-size: 22px;
    }

    .table-wrap table {
        min-width: 980px;
    }

    .table-wrap thead th,
    .table-wrap tbody td {
        font-size: 12px;
        padding: 6px 6px;
    }

    .table-wrap tbody tr {
        height: 28px;
    }
}

/* 打印 */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm 14mm 12mm;
    }

    body * {
        visibility: hidden !important;
    }

    #printHost,
    #printHost * {
        visibility: visible !important;
    }

    html,
    body {
        background: #fff !important;
        overflow: visible !important;
    }

    #printHost {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
    }

    .print-sheet {
        width: 100% !important;
        max-width: 182mm !important;
        min-height: 120mm !important;
        margin: 0 auto !important;
        padding: 12mm 14mm 10mm !important;
        box-shadow: none !important;
    }
}
