table {
    border-collapse: collapse;
    width: 100%;
    font-size: 8pt;
    table-layout: fixed;
}
th, td {
    border: 1px solid black;
    padding: 2px;
    text-align: center;
    overflow: hidden;
    text-overflow: clip; /* ...を非表示にする */
}
.item-name-header, .item-name {
    width: 25%;
    text-align: left;
    white-space: normal;
    word-break: break-all;
}
.unit-price-header, .unit-price {
    width: 8%;
}
.date-header {
    width: auto;
}
.date-cell {
    /* JavaScriptで幅を動的に設定 */
}
.total-qty-header, .total-amount-header {
    width: 8%;
}
.total-qty-header, .total-amount-header, .total-qty-cell, .total-amount-cell {
    font-size: 8pt;
}
.sub-client-group-header td {
    text-align: left;
    font-weight: bold;
    background-color: #f0f0f0;
}
.sub-client-summary td {
    font-weight: bold;
    background-color: #e9ecef;
}
.grand-total-section {
    margin-top: 20px;
}
.grand-total-section .grand-total-row td {
    background-color: #ddd;
    font-weight: bold;
}
/* 品目ごとの数量と金額の行を統合 */
.item-row td {
    padding: 2px;
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    vertical-align: middle;
}
.item-row td:first-child {
    text-align: left;
    white-space: normal;
    word-break: break-all;
}
.item-row td:nth-child(2) {
    text-align: right;
}
.date-cell-content {
    font-size: 8pt;
    white-space: normal;
    line-height: 1.2;
}
.total-col-content {
    font-size: 8pt;
}

/* ゼロの数字を非表示にする */
.date-cell-content > br + span:empty,
.date-cell-content > span:empty {
  display: none;
}
/* === PDF出力時の厳密なレイアウト制御 === */
@media print {
    body {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 9pt;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    @page {
        size: A4 landscape;
        margin: 5mm 10mm;
    }
    .statement-table {
        width: 100% !important;
        border-collapse: collapse !important;
        table-layout: fixed;
        font-size: 8pt;
        margin-bottom: 5mm;
    }
    .statement-table th, .statement-table td {
        border: 1px solid #000 !important;
        padding: 2px;
        text-align: center;
        vertical-align: middle;
        word-break: break-all;
        overflow: visible !important;
        text-overflow: clip !important;
    }
    .statement-table th {
        font-weight: bold;
        background-color: #f2f2f2;
    }
    
    /* 品目名 */
    .item-name-header, .item-name {
        width: 45mm !important; 
        white-space: normal !important;
        word-wrap: break-word;
        text-align: left !important;
    }
    /* 単価・合計数量・合計金額 */
    .unit-price-header, .unit-price {
        width: 15mm !important; 
        white-space: nowrap !important; 
    }
    .total-qty-header, .total-qty-cell {
        width: 15mm !important; 
        white-space: nowrap !important; 
    }
    .total-amount-header, .total-amount-cell {
        width: 20mm !important; 
        white-space: nowrap !important; 
    }
    
    /* 日付セル: 残り幅を自動で均等に割り当て */
    .date-header, .date-cell {
        width: auto !important;
        min-width: 8mm !important; 
        white-space: nowrap !important;
    }
    .date-cell-header-small {
        white-space: normal !important;
    }

    /* === ご要望の修正: 金額の数字を1pt小さくする === */
    .statement-table td.amount-cell, 
    .statement-table td.total-amount-cell,
    .statement-table .sub-client-summary-amount td,
    .statement-table .grand-total-amount-row td {
        font-size: 7pt !important; /* 8ptから1pt縮小 */
        white-space: nowrap !important; /* 金額の改行は禁止 */
    }
    
    /* ¥記号の制御は前回のロジックを維持 */
    .amount-cell:empty::before,
    .daily-total-amount:empty::before,
    .total-amount-cell:empty::before {
        content: "" !important;
    }
    .amount-cell:not(:empty)::before,
    .daily-total-amount:not(:empty)::before,
    .total-amount-cell:not(:empty)::before {
        content: "¥";
    }

    /* 全体合計のセルの幅調整 */
    .grand-total-container .item-name-header,
    .grand-total-container .item-name {
        width: 40mm !important;
    }
    .grand-total-container .total-quantity-header,
    .grand-total-container .total-amount-header,
    .grand-total-container .grand-total-quantity-row td:last-child,
    .grand-total-container .grand-total-amount-row td:last-child {
        width: 30mm !important;
    }
}