/* สไตล์ร่วมของทุกหน้ารายงาน */

* { box-sizing: border-box; }
body { font-family: "Sarabun", Tahoma, sans-serif; margin: 10px; background: #eef1f4; }

/* ---------- แถบนำทาง ---------- */
.nav-bar { max-width: 1400px; margin: 0 auto 10px auto; }
.nav-bar a {
    display: inline-block; padding: 7px 14px; background: #fff; border-radius: 6px;
    text-decoration: none; color: #2980b9; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.nav-bar a:hover { background: #f4f8fb; }

/* ---------- กล่องตัวกรอง ---------- */
.filter-box { background: #fff; padding: 15px; border-radius: 8px; margin-bottom: 15px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); max-width: 1400px; margin-left: auto; margin-right: auto; }
.filter-box form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-box label { display: flex; flex-direction: column; font-size: 13px; flex: 1 1 150px; min-width: 150px; }
.filter-box input, .filter-box select {
    padding: 8px; margin-top: 4px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; width: 100%;
}
.filter-box button {
    padding: 10px 22px; background: #2980b9; color: #fff; border: none; border-radius: 4px;
    cursor: pointer; font-size: 14px; flex: 1 1 100%;
}
.filter-box button:hover { background: #1f6391; }

.empty-state {
    background: #fff; padding: 40px 20px; text-align: center; border-radius: 8px;
    color: #888; font-size: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    max-width: 1400px; margin: 0 auto;
}

.notice {
    background: #fff8e1; border: 1px solid #ffe082; color: #7a5c00; padding: 10px 14px;
    border-radius: 6px; font-size: 13px; margin: 0 auto 15px auto; max-width: 1400px;
}

/* ---------- ตัวรายงาน ---------- */
.report-sheet {
    background: #fff; padding: 15px; box-shadow: 0 1px 5px rgba(0,0,0,0.15);
    max-width: 1400px; margin: 0 auto; border-radius: 8px;
}
.report-header { text-align: center; margin-bottom: 5px; }
.report-header h2 { margin: 0; font-size: 17px; }
.report-header .sub { font-size: 13px; margin-top: 5px; }
.filter-line { margin: 10px 0 12px 0; font-size: 12px; color: #555; display: flex; flex-wrap: wrap; gap: 16px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.report-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.report-table th {
    border-bottom: 2px solid #333; padding: 6px 4px; text-align: center;
    white-space: nowrap; font-weight: 600;
}
table.report-table td { padding: 4px; border-bottom: 1px dotted #ddd; white-space: nowrap; }
table.report-table td.num { text-align: right; }
table.report-table td.center { text-align: center; }
table.report-table td.wrap { white-space: normal; min-width: 130px; }

.subtotal-row td { border-top: 1px solid #999; border-bottom: 1px solid #999; font-weight: bold; background: #fafafa; }
.grandtotal-row td { border-top: 2px solid #333; font-weight: bold; font-size: 13px; }

.summary-box { margin: 18px 0 0 auto; max-width: 460px; border: 1px solid #333; padding: 10px 14px; font-size: 13px; }
.summary-box .line { display: flex; justify-content: space-between; gap: 20px; padding: 3px 0; }
.summary-box .line span:last-child { font-weight: bold; }
.summary-box.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; }

.print-btn { text-align: center; margin: 15px 0 5px 0; }
.print-btn button {
    padding: 10px 25px; background: #27ae60; color: #fff; border: none; border-radius: 4px;
    cursor: pointer; font-size: 14px; width: 100%; max-width: 300px;
}

.print-footer { display: none; }

@media (min-width: 600px) {
    body { margin: 20px; }
    .filter-box label { flex: 1 1 170px; }
    .filter-box button { flex: 0 0 auto; }
    .report-sheet { padding: 25px 30px; }
    .report-header h2 { font-size: 20px; }
    .print-btn button { width: auto; }
}

/* ---------- ตอนพิมพ์ ---------- */
@media print {
    @page { size: A4 landscape; margin: 8mm; }
    .filter-box, .print-btn, .nav-bar { display: none; }
    body { background: #fff; margin: 0; }
    .report-sheet { box-shadow: none; padding: 0; max-width: none; border-radius: 0; }
    .table-wrap { overflow-x: visible; }
    table.report-table { font-size: 9.5px; min-width: 0; }

    /* หัวตารางซ้ำทุกหน้า และไม่ให้แถวถูกตัดครึ่ง */
    table.report-table thead { display: table-header-group; }
    table.report-table tfoot { display: table-footer-group; }
    table.report-table tr { page-break-inside: avoid; }
    .summary-box { page-break-inside: avoid; }

    .print-footer { display: block; margin-top: 10px; font-size: 10px; color: #333; border-top: 1px solid #333; padding-top: 4px; }
}
