.invoice-shell {
    max-width: 1120px;
    margin: 24px auto;
    padding: 22px;
}

.glass-panel,
.glass-card,
.invoice-paper {
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(255,255,255,.42);
    box-shadow: 0 12px 34px rgba(0,0,0,.12);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: 18px;
}

.glass-card,
.invoice-paper {
    padding: 18px;
    margin: 16px 0;
}

.invoice-shell h1 {
    text-align: center;
    margin: 0 0 18px;
}

.search-row,
.two-col,
.bill-ship-grid,
.notice-total-grid,
.invoice-header,
.meta-grid {
    display: grid;
    gap: 12px;
}

.search-row {
    grid-template-columns: 90px 1fr auto auto;
    align-items: center;
}

.two-col,
.bill-ship-grid {
    grid-template-columns: 1fr 1fr;
}

.two-col .wide { grid-column: span 2; }

.invoice-header {
    grid-template-columns: 1fr auto;
    align-items: start;
    border-bottom: 1px solid #aaa;
    padding-bottom: 12px;
}

.company-block {
    display: flex;
    gap: 18px;
    align-items: center;
}

.logo {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.invoice-title-block {
    text-align: right;
}

.invoice-title {
    font-size: 30px;
    font-weight: 700;
}

.meta-grid {
    grid-template-columns: repeat(6, 1fr);
    margin: 16px 0;
}

label {
    display: block;
    font-weight: 700;
    margin: 5px 0 3px;
}

input, textarea, select {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 7px 8px;
    background: rgba(255,255,255,.84);
}

textarea { min-height: 70px; }

.items-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.items-table th,
.items-table td {
    border: 1px solid #aaa;
    padding: 6px;
    vertical-align: top;
}

.items-table th {
    background: rgba(240,240,240,.86);
    text-align: left;
}

.items-table th:nth-child(1) { width: 28%; }
.items-table th:nth-child(2) { width: 9%; }
.items-table th:nth-child(3) { width: 13%; }
.items-table th:nth-child(4) { width: 11%; }
.items-table th:nth-child(5),
.items-table th:nth-child(6),
.items-table th:nth-child(7) { width: 12%; }
.items-table th:nth-child(8) { width: 8%; }

.notice-total-grid {
    grid-template-columns: 1fr 340px;
    margin-top: 16px;
}

.totals {
    display: grid;
    grid-template-columns: 1fr 130px;
    gap: 6px 10px;
    align-items: center;
}

.totals input { text-align: right; }
.totals .grand { font-size: 18px; }

.btn-primary,
.btn-secondary,
.btn-small {
    border: 0;
    border-radius: 10px;
    padding: 9px 15px;
    cursor: pointer;
    font-weight: 700;
}

.btn-primary { background: #1769e0; color: white; }
.btn-secondary { background: #e8eef8; color: #123; }
.btn-small { background: #ececec; color: #111; padding: 5px 8px; }

.action-bar { text-align: right; margin-top: 14px; }
.status-message { margin-top: 8px; color: #114c9c; font-weight: 700; }
.text-danger { color: #a40000; }

.confirm-dialog {
    border: 0;
    border-radius: 16px;
    width: min(980px, 92vw);
    max-height: 86vh;
    overflow: auto;
    padding: 20px;
}

.confirm-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 14px;
}

.confirm-table-wrap th,
.confirm-table-wrap td {
    border: 1px solid #aaa;
    padding: 6px;
}

.dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@media (max-width: 760px) {
    .invoice-shell { padding: 12px; margin: 8px; }
    .search-row,
    .two-col,
    .bill-ship-grid,
    .notice-total-grid,
    .invoice-header,
    .meta-grid { grid-template-columns: 1fr; }
    .two-col .wide { grid-column: auto; }
    .invoice-title-block { text-align: left; }
    .items-table { min-width: 920px; }
    .invoice-paper { overflow-x: auto; }
}

@media print {
    body { background: white !important; }
    .no-print,
    .action-bar,
    .glass-card,
    .invoice-shell > h1 { display: none !important; }
    .invoice-shell,
    .invoice-paper {
        max-width: none;
        margin: 0;
        padding: 0;
        box-shadow: none;
        border: 0;
        background: white;
        border-radius: 0;
    }
    input, textarea, select {
        border: 0;
        background: transparent;
        padding: 0;
    }
}


/* InvoicePrint fixes: readable dark-blue headers and visible total labels */
.invoice-shell,
.invoice-paper,
.invoice-paper label,
.invoice-paper h1,
.invoice-paper h2,
.invoice-paper h3,
.invoice-paper th,
.invoice-paper td,
.invoice-paper p,
.confirm-dialog,
.confirm-dialog h2,
.confirm-dialog h3,
.confirm-dialog th,
.confirm-dialog td {
    color: #0b2d5c !important;
}

.items-table thead th,
.confirm-table-wrap thead th {
    color: #0b2d5c !important;
    background: rgba(232, 238, 248, .96) !important;
    font-weight: 800;
}

.totals label {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 34px;
    margin: 0;
    padding-right: 8px;
    color: #0b2d5c !important;
    font-weight: 800;
    text-align: right;
}

.totals input {
    color: #111827 !important;
    background: rgba(255,255,255,.92) !important;
}

.totals .grand,
#grandTotal {
    color: #0b2d5c !important;
    font-weight: 900;
}

.visually-hidden-submit {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

@media print {
    .items-table thead th,
    .confirm-table-wrap thead th,
    .totals label {
        color: #000 !important;
    }
}

/* =========================================================
   ✅ InvoicePrint 最终强制版：所有白卡/输入框透明毛玻璃 + 深蓝字体
   说明：
   - 只作用在 .invoice-shell 内，不影响其它页面；
   - 普通页面显示透明毛玻璃；
   - 打印时恢复白底黑字，保证发票打印/PDF正常。
   ========================================================= */
@media screen {
    html body .invoice-shell,
    html body .invoice-shell *,
    html body dialog.confirm-dialog,
    html body dialog.confirm-dialog * {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        text-shadow: none !important;
    }

    html body .invoice-shell.glass-panel {
        max-width: 1120px;
        margin: 24px auto !important;
        padding: 22px !important;
        position: relative !important;
        isolation: isolate !important;
        overflow: hidden !important;
        border-radius: 22px !important;
        background: rgba(255, 255, 255, 0.055) !important;
        background-color: rgba(255, 255, 255, 0.055) !important;
        background-image:
            radial-gradient(circle at 16% 0%, rgba(255, 255, 255, 0.13), transparent 36%),
            radial-gradient(circle at 88% 7%, rgba(0, 194, 255, 0.10), transparent 34%),
            linear-gradient(135deg, rgba(255,255,255,.075), rgba(255,255,255,.028)) !important;
        border: 1px solid rgba(255, 255, 255, 0.26) !important;
        box-shadow:
            0 26px 72px rgba(3, 18, 43, 0.30),
            inset 0 1px 0 rgba(255, 255, 255, 0.20) !important;
        -webkit-backdrop-filter: blur(30px) saturate(175%) !important;
        backdrop-filter: blur(30px) saturate(175%) !important;
    }

    html body .invoice-shell.glass-panel::before {
        content: "";
        position: absolute;
        inset: 0;
        z-index: -1;
        border-radius: inherit;
        pointer-events: none;
        background:
            linear-gradient(135deg, rgba(255,255,255,.10), rgba(255,255,255,.02)),
            radial-gradient(circle at 50% 0%, rgba(255,255,255,.16), transparent 42%) !important;
    }

    html body .invoice-shell .glass-panel,
    html body .invoice-shell .glass-card,
    html body .invoice-shell .invoice-paper,
    html body .invoice-shell .customer-search,
    html body .invoice-shell .customer-editor,
    html body .invoice-shell .invoice-header,
    html body .invoice-shell .company-block,
    html body .invoice-shell .invoice-title-block,
    html body .invoice-shell .bill-ship-grid > div,
    html body .invoice-shell .meta-grid > div,
    html body .invoice-shell .notice-box,
    html body .invoice-shell .totals,
    html body .invoice-shell .action-bar,
    html body .invoice-shell .status-message,
    html body .invoice-shell .confirm-table-wrap,
    html body dialog.confirm-dialog {
        background: rgba(255, 255, 255, 0.075) !important;
        background-color: rgba(255, 255, 255, 0.075) !important;
        background-image:
            linear-gradient(135deg, rgba(255,255,255,.11), rgba(255,255,255,.025)) !important;
        border: 1px solid rgba(255, 255, 255, 0.24) !important;
        border-radius: 18px !important;
        box-shadow:
            0 16px 42px rgba(3, 18, 43, 0.20),
            inset 0 1px 0 rgba(255, 255, 255, 0.18) !important;
        -webkit-backdrop-filter: blur(24px) saturate(165%) !important;
        backdrop-filter: blur(24px) saturate(165%) !important;
    }

    html body .invoice-shell .invoice-paper {
        background: rgba(255, 255, 255, 0.065) !important;
        background-color: rgba(255, 255, 255, 0.065) !important;
    }

    html body .invoice-shell .invoice-header {
        border-bottom: 1px solid rgba(7, 58, 103, 0.20) !important;
    }

    html body .invoice-shell input,
    html body .invoice-shell textarea,
    html body .invoice-shell select,
    html body .invoice-shell .form-control,
    html body .invoice-shell .form-select,
    html body dialog.confirm-dialog input,
    html body dialog.confirm-dialog textarea,
    html body dialog.confirm-dialog select {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        caret-color: #073A67 !important;
        background: rgba(255, 255, 255, 0.105) !important;
        background-color: rgba(255, 255, 255, 0.105) !important;
        border: 1px solid rgba(7, 58, 103, 0.26) !important;
        border-radius: 14px !important;
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.25),
            0 8px 20px rgba(3, 18, 43, 0.09) !important;
        -webkit-backdrop-filter: blur(18px) saturate(155%) !important;
        backdrop-filter: blur(18px) saturate(155%) !important;
        outline: none !important;
    }

    html body .invoice-shell textarea {
        min-height: 70px;
    }

    html body .invoice-shell input::placeholder,
    html body .invoice-shell textarea::placeholder,
    html body dialog.confirm-dialog input::placeholder,
    html body dialog.confirm-dialog textarea::placeholder {
        color: rgba(7, 58, 103, 0.72) !important;
        -webkit-text-fill-color: rgba(7, 58, 103, 0.72) !important;
        opacity: 1 !important;
    }

    html body .invoice-shell input:focus,
    html body .invoice-shell textarea:focus,
    html body .invoice-shell select:focus {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        background: rgba(255, 255, 255, 0.16) !important;
        background-color: rgba(255, 255, 255, 0.16) !important;
        border-color: rgba(7, 58, 103, 0.58) !important;
        box-shadow:
            0 0 0 4px rgba(0, 194, 255, 0.16),
            0 0 26px rgba(0, 194, 255, 0.18),
            inset 0 1px 0 rgba(255, 255, 255, 0.32) !important;
    }

    html body .invoice-shell input[readonly],
    html body .invoice-shell textarea[readonly],
    html body .invoice-shell input:disabled,
    html body .invoice-shell textarea:disabled,
    html body .invoice-shell select:disabled {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        opacity: 1 !important;
        background: rgba(255, 255, 255, 0.08) !important;
        background-color: rgba(255, 255, 255, 0.08) !important;
    }

    html body .invoice-shell input:-webkit-autofill,
    html body .invoice-shell input:-webkit-autofill:hover,
    html body .invoice-shell input:-webkit-autofill:focus,
    html body .invoice-shell textarea:-webkit-autofill,
    html body .invoice-shell textarea:-webkit-autofill:hover,
    html body .invoice-shell textarea:-webkit-autofill:focus,
    html body .invoice-shell select:-webkit-autofill,
    html body .invoice-shell select:-webkit-autofill:hover,
    html body .invoice-shell select:-webkit-autofill:focus {
        -webkit-text-fill-color: #073A67 !important;
        caret-color: #073A67 !important;
        box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.10) inset !important;
        transition: background-color 9999s ease-in-out 0s !important;
    }

    html body .invoice-shell select option {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        background: #dff3ff !important;
    }

    html body .invoice-shell .items-table,
    html body dialog.confirm-dialog table {
        width: 100%;
        overflow: hidden;
        border-collapse: separate !important;
        border-spacing: 0 !important;
        border-radius: 18px !important;
        background: rgba(255, 255, 255, 0.055) !important;
        background-color: rgba(255, 255, 255, 0.055) !important;
        border: 1px solid rgba(255, 255, 255, 0.24) !important;
        box-shadow:
            0 14px 38px rgba(3, 18, 43, 0.16),
            inset 0 1px 0 rgba(255, 255, 255, 0.16) !important;
        -webkit-backdrop-filter: blur(22px) saturate(160%) !important;
        backdrop-filter: blur(22px) saturate(160%) !important;
    }

    html body .invoice-shell .items-table th,
    html body .invoice-shell .items-table td,
    html body dialog.confirm-dialog th,
    html body dialog.confirm-dialog td {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        border-color: rgba(7, 58, 103, 0.14) !important;
        background: rgba(255, 255, 255, 0.055) !important;
        background-color: rgba(255, 255, 255, 0.055) !important;
    }

    html body .invoice-shell .items-table th,
    html body dialog.confirm-dialog th {
        font-weight: 900 !important;
        background: rgba(255, 255, 255, 0.095) !important;
        background-color: rgba(255, 255, 255, 0.095) !important;
    }

    html body .invoice-shell .btn-primary,
    html body .invoice-shell .btn-secondary,
    html body .invoice-shell .btn-small,
    html body .invoice-shell button,
    html body dialog.confirm-dialog button {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        font-weight: 900 !important;
        border: 1px solid rgba(7, 58, 103, 0.28) !important;
        border-radius: 999px !important;
        background: rgba(255, 255, 255, 0.12) !important;
        background-color: rgba(255, 255, 255, 0.12) !important;
        background-image: linear-gradient(135deg, rgba(255,255,255,.18), rgba(255,255,255,.05)) !important;
        box-shadow:
            0 10px 24px rgba(3, 18, 43, 0.16),
            inset 0 1px 0 rgba(255, 255, 255, 0.26) !important;
        -webkit-backdrop-filter: blur(18px) saturate(155%) !important;
        backdrop-filter: blur(18px) saturate(155%) !important;
    }

    html body .invoice-shell .btn-primary:hover,
    html body .invoice-shell .btn-secondary:hover,
    html body .invoice-shell .btn-small:hover,
    html body .invoice-shell button:hover,
    html body dialog.confirm-dialog button:hover {
        background: rgba(255, 255, 255, 0.18) !important;
        background-color: rgba(255, 255, 255, 0.18) !important;
        transform: translateY(-1px);
    }

    html body .invoice-shell label,
    html body .invoice-shell h1,
    html body .invoice-shell h2,
    html body .invoice-shell h3,
    html body .invoice-shell p,
    html body .invoice-shell span,
    html body .invoice-shell div,
    html body .invoice-shell b,
    html body .invoice-shell strong,
    html body .invoice-shell .status-message,
    html body .invoice-shell .text-danger,
    html body .invoice-shell .totals .grand,
    html body .invoice-shell #grandTotal {
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
    }

    html body .invoice-shell .text-danger {
        font-weight: 900 !important;
    }

    html body dialog.confirm-dialog::backdrop {
        background: rgba(7, 21, 47, 0.42) !important;
        -webkit-backdrop-filter: blur(10px) !important;
        backdrop-filter: blur(10px) !important;
    }
}

/* 打印时不要毛玻璃，避免发票/PDF变灰 */
@media print {
    body {
        background: #ffffff !important;
    }

    .invoice-shell,
    .invoice-shell *,
    dialog.confirm-dialog,
    dialog.confirm-dialog * {
        color: #111827 !important;
        -webkit-text-fill-color: #111827 !important;
        text-shadow: none !important;
        box-shadow: none !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    .invoice-shell.glass-panel,
    .invoice-shell .glass-card,
    .invoice-shell .invoice-paper,
    .invoice-shell .invoice-header,
    .invoice-shell .company-block,
    .invoice-shell .invoice-title-block,
    .invoice-shell .bill-ship-grid > div,
    .invoice-shell .meta-grid > div,
    .invoice-shell .notice-box,
    .invoice-shell .totals,
    .invoice-shell .action-bar {
        background: #ffffff !important;
        border-color: #cccccc !important;
    }

    .invoice-shell input,
    .invoice-shell textarea,
    .invoice-shell select {
        background: transparent !important;
        border: 0 !important;
    }
}


/* =========================================================
   ✅ v4 发票打印手机端：白卡透明毛玻璃 + 输入框居中不越界
   ========================================================= */
@media screen and (max-width: 760px) {
    html body .invoice-shell.glass-panel,
    html body .invoice-shell {
        width: min(100%, calc(100vw - 18px)) !important;
        max-width: calc(100vw - 18px) !important;
        min-width: 0 !important;
        margin: 10px auto 18px auto !important;
        padding: 10px !important;
        overflow-x: hidden !important;
        border-radius: 24px !important;
        background: rgba(20, 34, 67, 0.20) !important;
        border: 1px solid rgba(255,255,255,.28) !important;
        -webkit-backdrop-filter: blur(24px) saturate(165%) !important;
        backdrop-filter: blur(24px) saturate(165%) !important;
    }

    html body .invoice-shell .glass-panel,
    html body .invoice-shell .glass-card,
    html body .invoice-shell .invoice-paper,
    html body .invoice-shell .search-row,
    html body .invoice-shell .customer-search,
    html body .invoice-shell .customer-editor,
    html body .invoice-shell .bill-ship-grid > div,
    html body .invoice-shell .meta-grid > div,
    html body .invoice-shell .notice-box,
    html body .invoice-shell .totals,
    html body .invoice-shell .action-bar {
        width: min(100%, 720px) !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        padding: 12px !important;
        border-radius: 22px !important;
        background: rgba(255,255,255,.105) !important;
        background-image: linear-gradient(135deg, rgba(255,255,255,.14), rgba(255,255,255,.035)) !important;
        border: 1px solid rgba(255,255,255,.30) !important;
        box-shadow: 0 16px 40px rgba(3,18,43,.20), inset 0 1px 0 rgba(255,255,255,.24) !important;
        -webkit-backdrop-filter: blur(24px) saturate(165%) !important;
        backdrop-filter: blur(24px) saturate(165%) !important;
    }

    html body .invoice-shell .search-row,
    html body .invoice-shell .two-col,
    html body .invoice-shell .bill-ship-grid,
    html body .invoice-shell .notice-total-grid,
    html body .invoice-shell .invoice-header,
    html body .invoice-shell .meta-grid,
    html body .invoice-shell .totals {
        grid-template-columns: 1fr !important;
        justify-items: center !important;
        align-items: stretch !important;
    }

    html body .invoice-shell label,
    html body .invoice-shell input,
    html body .invoice-shell textarea,
    html body .invoice-shell select,
    html body .invoice-shell .form-control,
    html body .invoice-shell .form-select {
        width: min(100%, 640px) !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin-left: auto !important;
        margin-right: auto !important;
        box-sizing: border-box !important;
    }

    html body .invoice-shell input,
    html body .invoice-shell textarea,
    html body .invoice-shell select,
    html body .invoice-shell .form-control,
    html body .invoice-shell .form-select {
        background: rgba(255,255,255,.105) !important;
        border: 1px solid rgba(7,58,103,.24) !important;
        border-radius: 16px !important;
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        -webkit-backdrop-filter: blur(18px) saturate(160%) !important;
        backdrop-filter: blur(18px) saturate(160%) !important;
    }

    html body .invoice-shell .items-table {
        min-width: 760px !important;
        width: 760px !important;
        max-width: none !important;
    }

    html body .invoice-shell .invoice-paper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    html body .invoice-shell .action-bar {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 10px !important;
        text-align: center !important;
    }

    html body .invoice-shell .btn-primary,
    html body .invoice-shell .btn-secondary,
    html body .invoice-shell .btn-small,
    html body .invoice-shell button {
        width: min(100%, 640px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
}


/* =========================================================
   ✅ 2026-06-26 fix3：发票打印手机端改为“一条记录一个卡片”
   - 不再横向滚动宽表，避免 iPhone/微信 WebView 里表格被拉伸、变形；
   - 每个项目行变成一个毛玻璃卡片；
   - 打印/PDF 仍然保持原来的表格格式。
   ========================================================= */
@media screen and (max-width: 760px) {
    html body .invoice-shell .invoice-paper {
        overflow-x: visible !important;
    }

    html body .invoice-shell .items-table {
        min-width: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        table-layout: auto !important;
        border: 0 !important;
        border-radius: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
        box-shadow: none !important;
        -webkit-backdrop-filter: none !important;
        backdrop-filter: none !important;
    }

    html body .invoice-shell .items-table thead {
        display: none !important;
    }

    html body .invoice-shell .items-table tbody {
        display: grid !important;
        grid-template-columns: 1fr !important;
        gap: 14px !important;
        width: 100% !important;
    }

    html body .invoice-shell .items-table tr {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 12px !important;
        border-radius: 22px !important;
        background: rgba(255, 255, 255, 0.105) !important;
        background-image: linear-gradient(135deg, rgba(255,255,255,.15), rgba(255,255,255,.035)) !important;
        border: 1px solid rgba(255,255,255,.30) !important;
        box-shadow: 0 14px 34px rgba(3,18,43,.18), inset 0 1px 0 rgba(255,255,255,.22) !important;
        -webkit-backdrop-filter: blur(22px) saturate(160%) !important;
        backdrop-filter: blur(22px) saturate(160%) !important;
        box-sizing: border-box !important;
    }

    html body .invoice-shell .items-table td {
        display: grid !important;
        grid-template-columns: minmax(90px, 34%) minmax(0, 1fr) !important;
        gap: 8px !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
        padding: 7px 0 !important;
        border: 0 !important;
        background: transparent !important;
        background-color: transparent !important;
        box-shadow: none !important;
        box-sizing: border-box !important;
    }

    html body .invoice-shell .items-table td::before {
        content: attr(data-label);
        color: #073A67 !important;
        -webkit-text-fill-color: #073A67 !important;
        font-weight: 900 !important;
        line-height: 1.25 !important;
        text-align: left !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
    }

    html body .invoice-shell .items-table td input,
    html body .invoice-shell .items-table td select,
    html body .invoice-shell .items-table td textarea {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        margin: 0 !important;
        box-sizing: border-box !important;
    }

    html body .invoice-shell .items-table td.no-print {
        grid-template-columns: 1fr !important;
        padding-top: 12px !important;
    }

    html body .invoice-shell .items-table td.no-print::before {
        display: none !important;
        content: "" !important;
    }

    html body .invoice-shell .items-table td.no-print button {
        width: 100% !important;
        max-width: 100% !important;
    }
}


/* ✅ fix3：确认弹窗表格手机端也改卡片，避免横向变形 */
@media screen and (max-width: 760px) {
    html body dialog.confirm-dialog .confirm-table-wrap table,
    html body dialog.confirm-dialog .confirm-table-wrap thead,
    html body dialog.confirm-dialog .confirm-table-wrap tbody,
    html body dialog.confirm-dialog .confirm-table-wrap tr,
    html body dialog.confirm-dialog .confirm-table-wrap td {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
    html body dialog.confirm-dialog .confirm-table-wrap thead { display: none !important; }
    html body dialog.confirm-dialog .confirm-table-wrap tr {
        margin: 0 0 12px !important;
        padding: 10px !important;
        border-radius: 18px !important;
        background: rgba(255,255,255,.11) !important;
        border: 1px solid rgba(255,255,255,.28) !important;
    }
    html body dialog.confirm-dialog .confirm-table-wrap td {
        display: grid !important;
        grid-template-columns: minmax(96px, 36%) minmax(0,1fr) !important;
        gap: 8px !important;
        border: 0 !important;
        padding: 7px 0 !important;
        background: transparent !important;
    }
    html body dialog.confirm-dialog .confirm-table-wrap td::before {
        content: attr(data-label);
        font-weight: 900 !important;
    }
}

/* =========================================================
   Invoice print NOTICE / TOTAL alignment fix
   1) NOTICE width matches the Description column.
   2) Totals area keeps a two-character gap from NOTICE.
   ========================================================= */
@media screen, print {
    .invoice-paper {
        --invoice-description-col-width: 52%;
        --invoice-notice-total-gap: 2ch;
    }

    .invoice-paper .items-table {
        table-layout: fixed !important;
    }

    .invoice-paper .items-table th:nth-child(1),
    .invoice-paper .items-table td:nth-child(1) {
        width: var(--invoice-description-col-width) !important;
    }

    .invoice-paper .notice-total-grid {
        display: grid !important;
        grid-template-columns: var(--invoice-description-col-width) minmax(0, 1fr) !important;
        column-gap: var(--invoice-notice-total-gap) !important;
        row-gap: 0 !important;
        align-items: start !important;
    }

    .invoice-paper .notice-box,
    .invoice-paper .totals {
        min-width: 0 !important;
        box-sizing: border-box !important;
    }
}


/* =========================================================
   ✅ Invoice print final alignment fix v2
   原因：上一版 Description=56%，但其它列合计 52%，总计 108%，
   浏览器会按比例缩放表格列，导致 Description 实际宽度不是 56%。
   本版把所有 col 宽度固定为合计 100%，NOTICE 与 Description 永远等宽。
   ========================================================= */
@media screen, print {
    .invoice-paper,
    .page {
        --invoice-description-col-width: 52% !important;
        --invoice-notice-total-gap: 2ch !important;
        --description-col-width: 52% !important;
        --notice-total-gap: 2ch !important;
    }

    .invoice-paper .items-table,
    .page table {
        table-layout: fixed !important;
        width: 100% !important;
    }

    .invoice-paper .items-table col.desc-col,
    .invoice-paper .items-table th:nth-child(1),
    .invoice-paper .items-table td:nth-child(1),
    .page table col.desc-col,
    .page table th:nth-child(1),
    .page table td:nth-child(1) {
        width: 52% !important;
    }

    .invoice-paper .items-table col.qty-col,
    .page table col.qty-col { width: 6% !important; }

    .invoice-paper .items-table col.price-col,
    .page table col.price-col { width: 9% !important; }

    .invoice-paper .items-table col.taxp-col,
    .page table col.taxp-col { width: 7% !important; }

    .invoice-paper .items-table col.taxamt-col,
    .page table col.taxamt-col { width: 8% !important; }

    .invoice-paper .items-table col.inctax-col,
    .page table col.inctax-col { width: 8% !important; }

    .invoice-paper .items-table col.linetotal-col,
    .page table col.linetotal-col { width: 10% !important; }

    .invoice-paper .notice-total-grid,
    .invoice-paper .notice-total,
    .page .notice-total {
        display: grid !important;
        grid-template-columns: 52% minmax(0, 1fr) !important;
        column-gap: 2ch !important;
        align-items: start !important;
    }

    .invoice-paper .notice-box,
    .invoice-paper .notice,
    .page .notice {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}
