:root {
    --delivery-primary: #2f80ed;
    --delivery-primary-soft: rgba(47, 128, 237, 0.12);
    --delivery-text: #2f4056;
    --delivery-muted: #72849b;
    --delivery-border: rgba(118, 153, 207, 0.18);
    --delivery-surface: rgba(255, 255, 255, 0.74);
    --delivery-shadow: 0 18px 46px rgba(108, 145, 198, 0.16);
}

body.delivery-note-page {
    margin: 0;
    font-family: 'Noto Sans SC', sans-serif;
    color: var(--delivery-text);
    background: #f5f7fa;
}

.delivery-main {
    padding: 26px 0 72px;
}

.delivery-workspace {
    display: grid;
    grid-template-columns: 332px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.delivery-panel,
.delivery-preview {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.delivery-panel {
    position: sticky;
    top: 88px;
    padding: 26px;
}

.delivery-preview {
    padding: 28px;
}

.delivery-badge {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    border-radius: 999px;
    background: var(--delivery-primary-soft);
    color: var(--delivery-primary);
    font-size: 13px;
    font-weight: 700;
}

.panel-intro-card {
    padding: 4px 6px 24px;
    border-bottom: 1px solid rgba(118, 153, 207, 0.16);
    margin-bottom: 22px;
}

.panel-intro-card h1 {
    margin: 22px 0 18px;
    font-family: 'Outfit', 'Noto Sans SC', sans-serif;
    font-size: 56px;
    line-height: 0.95;
    letter-spacing: -0.05em;
    color: #34495e;
}

.panel-intro-card p {
    margin: 0;
    font-size: 18px;
    line-height: 1.75;
    color: var(--delivery-muted);
}

.panel-header h2 {
    margin: 0;
    font-size: 18px;
    color: #2f4056;
}

.delivery-form {
    display: grid;
    gap: 20px;
    margin-top: 18px;
}

.form-block {
    padding: 22px 20px;
    border-radius: 24px;
    background: rgba(252, 254, 255, 0.84);
    border: 1px solid rgba(118, 153, 207, 0.18);
}

.field-grid {
    display: grid;
    gap: 22px;
}

.field {
    display: grid;
    gap: 10px;
}

.field span {
    color: #1f2937;
    font-size: 16px;
    font-weight: 700;
}

.range-field {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: center;
}

.range-value {
    min-width: 20px;
    font-size: 18px;
    font-weight: 700;
    color: #1f5cc3;
}

.field input[type="range"] {
    width: 100%;
    height: 4px;
    margin: 0;
    appearance: none;
    border-radius: 999px;
    background: #d8e8ff;
    outline: none;
}

.field input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2f80ed;
    border: none;
    box-shadow: 0 2px 6px rgba(47, 128, 237, 0.25);
    cursor: pointer;
}

.field input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #2f80ed;
    border: none;
    box-shadow: 0 2px 6px rgba(47, 128, 237, 0.25);
    cursor: pointer;
}

.field select {
    width: 100%;
    border: 1px solid rgba(118, 153, 207, 0.34);
    border-radius: 18px;
    padding: 15px 16px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.98);
    color: var(--delivery-text);
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field select:focus {
    outline: none;
    border-color: rgba(47, 128, 237, 0.42);
    box-shadow: 0 0 0 4px rgba(47, 128, 237, 0.1);
}

.primary-btn {
    border: none;
    border-radius: 18px;
    padding: 16px 18px;
    background: linear-gradient(135deg, #2f80ed, #2388ff);
    color: #fff;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 16px 30px rgba(47, 128, 237, 0.28);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
}

.secondary-btn {
    border: 1px solid rgba(118, 153, 207, 0.28);
    border-radius: 18px;
    padding: 15px 18px;
    background: rgba(255, 255, 255, 0.94);
    color: #35506f;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 18px rgba(120, 154, 204, 0.12);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.secondary-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(47, 128, 237, 0.34);
}

.action-row {
    display: grid;
    gap: 12px;
}

.action-row .primary-btn,
.action-row .secondary-btn {
    width: 100%;
}

.paper-stage {
    padding: 0;
    background: transparent;
    overflow: auto;
}

.delivery-paper {
    --paper-font-size: 20px;
    --paper-margin: 5mm;
    width: 100%;
    min-height: 720px;
    margin: 0 auto;
    padding: var(--paper-margin);
    background: #fff;
    color: #111827;
    border-radius: 0;
    box-shadow: none;
    font-size: var(--paper-font-size);
    box-sizing: border-box;
}

.delivery-paper.landscape {
    min-height: 660px;
}

.paper-header {
    padding: 4px 6px 8px;
}

.paper-title-box {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2em;
    padding: 4px 0;
    border: 0;
    box-shadow: none;
    border-radius: 0;
    background: transparent;
}

.paper-company,
.paper-header h2,
.paper-header h3 {
    margin: 0;
    font-size: 1em;
    font-weight: 700;
    letter-spacing: 0;
}

.paper-company {
    padding: 0;
    border: 0;
    text-align: center;
}

.inline-title {
    min-width: 3em;
}

.paper-editable {
    position: relative;
    min-width: 1.5em;
    border-radius: 8px;
    outline: none;
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.paper-editable:hover {
    background: rgba(47, 128, 237, 0.05);
}

.paper-editable:focus {
    background: rgba(47, 128, 237, 0.08);
    box-shadow: 0 0 0 2px rgba(47, 128, 237, 0.14);
}

.paper-editable[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: #98a2b3;
}

.title-editable {
    padding: 2px 4px;
}

.inline-editable {
    display: inline-block;
    min-width: 6ch;
}

.large-editable {
    min-width: 170px;
}

.customer-info-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0 0 6px;
}

.customer-info-table th,
.customer-info-table td {
    padding: 4px 6px;
    vertical-align: middle;
    border: 0;
}

.customer-col-label,
.meta-label-cell {
    font-size: 1em;
    font-weight: 700;
    color: #2c3b4e;
    white-space: nowrap;
}

.customer-col-label {
    width: 8%;
    text-align: left;
    padding-left: 0;
}

.customer-col-input {
    width: 36%;
    text-align: left;
    vertical-align: stretch;
}

.customer-editable {
    display: block;
    width: 100%;
    height: 100%;
    line-height: 1.4;
    padding: 4px 10px;
    border: 1px solid #d6dee8;
    border-radius: 6px;
    background: #fff;
    box-sizing: border-box;
}

.customer-col-gap {
    width: 6%;
}

.meta-label-cell {
    width: 14%;
    text-align: left;
}

.meta-value-cell {
    width: auto;
    text-align: left;
}

.meta-value-cell .paper-editable {
    display: block;
    width: 100%;
    min-width: 8ch;
    box-sizing: border-box;
}

.meta-input-editable {
    min-height: 20px;
    padding: 3px 8px;
    border: 1px solid #d6dee8;
    border-radius: 6px;
    background: #fff;
}

.date-offset {
    padding-top: 0;
}

.nowrap {
    white-space: nowrap;
}

.signature-row div {
    display: flex;
    gap: 10px;
    align-items: baseline;
}

.signature-row span {
    color: #2c3b4e;
    white-space: nowrap;
    font-weight: 700;
}

.signature-row strong {
    font-weight: 600;
}

.signature-input-editable {
    min-width: 10ch;
    padding: 3px 8px;
    border: 1px solid #d6dee8;
    border-radius: 6px;
    background: #fff;
}

.paper-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    margin: 0 0 8px;
}

.paper-table th,
.paper-table td {
    border: 1px solid #202020;
    padding: 6px 8px;
    text-align: center;
    vertical-align: middle;
    word-break: break-word;
}

.paper-table th {
    font-weight: 700;
}

.paper-table td.editable-cell {
    cursor: text;
    background: rgba(255, 255, 255, 0.92);
}

.paper-table td.editable-cell:focus {
    outline: 0;
    background: rgba(47, 128, 237, 0.05);
    box-shadow: inset 0 0 0 2px rgba(47, 128, 237, 0.12);
}

.paper-table th:nth-child(1),
.paper-table td:nth-child(1) {
    width: 10%;
}

.paper-table th:nth-child(2),
.paper-table td:nth-child(2) {
    width: 17%;
}

.paper-table th:nth-child(3),
.paper-table td:nth-child(3) {
    width: 14%;
}

.paper-table th:nth-child(4),
.paper-table td:nth-child(4) {
    width: 13%;
}

.paper-table th:nth-child(5),
.paper-table td:nth-child(5),
.paper-table th:nth-child(6),
.paper-table td:nth-child(6),
.paper-table th:nth-child(7),
.paper-table td:nth-child(7) {
    width: 15.33%;
}

.paper-table td.text-left {
    text-align: left;
}

.paper-table td.amount-cell {
    background: rgba(15, 23, 42, 0.02);
}

.paper-table tfoot td {
    font-weight: 700;
}

.paper-table tfoot td.total-label {
    text-align: right;
    padding-right: 14px;
}

.paper-footer {
    padding: 8px 0 8px;
    background: transparent;
    color: inherit;
    /* 重置全局 footer 样式 */
    padding-top: 0;
    padding-bottom: 0;
}

.preview-status {
    margin: 10px 0 0;
    text-align: right;
    font-size: 13px;
    color: #98a2b3;
}

.signature-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding-top: 8px;
    border-top: 1px dashed #c9daf6;
}

@media (max-width: 1200px) {
    .delivery-workspace {
        grid-template-columns: 1fr;
    }

    .delivery-panel {
        position: static;
    }
}

@media (max-width: 860px) {
    .delivery-main {
        padding-top: 14px;
    }

    .delivery-panel,
    .delivery-preview {
        padding: 18px;
    }

    .panel-intro-card h1 {
        font-size: 42px;
    }

    .paper-title-box {
        flex-wrap: wrap;
        padding: 12px;
    }

    .signature-row {
        /* 始终保持两列，不折行 */
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding-left: 0;
        padding-right: 0;
    }

    .customer-info-table {
        table-layout: auto;
    }

    .customer-col-label {
        padding-left: 16px;
    }

    .delivery-paper,
    .delivery-paper.landscape {
        min-width: 680px;
    }
}

@media print {
    body.delivery-note-page {
        background: #fff;
    }

    /* 打印时隐藏所有 placeholder 提示文字 */
    body.delivery-note-page .paper-editable[data-placeholder]:empty::before,
    body.delivery-note-page .editable-cell[data-placeholder]:empty::before {
        content: none;
    }

    body.delivery-note-page header:not(.paper-header),
    body.delivery-note-page footer:not(.paper-footer),
    body.delivery-note-page .delivery-panel,
    body.delivery-note-page .preview-status {
        display: none !important;
    }

    body.delivery-note-page .delivery-main,
    body.delivery-note-page .container,
    body.delivery-note-page .delivery-workspace,
    body.delivery-note-page .delivery-preview,
    body.delivery-note-page .paper-stage {
        width: auto;
        max-width: none;
        margin: 0;
        padding: 0;
        background: transparent;
        border: 0;
        box-shadow: none;
    }

    body.delivery-note-page .delivery-paper {
        box-shadow: none;
        border-radius: 0;
    }
}