/* ============================================================
   ระบบเบิกสินค้าและออกใบเสร็จ - Custom Stylesheet
   ============================================================ */

/* [1] CORE & VARIABLES
   ------------------------------------------------------------ */

/* ---------- Fonts & Root Variables ---------- */
:root {
    --primary: #4361ee;
    --primary-dark: #3a0ca3;
    --primary-light: #7b8ff7;
    --secondary: #3f37c9;
    --accent: #f72585;
    --accent-light: #ff6fb0;
    --success: #06d6a0;
    --warning: #fca311;
    --danger: #ef476f;
    --dark: #1a1a2e;
    --darker: #16213e;
    --light: #f8f9fa;
    --card-bg: #ffffff;
    --body-bg: #f0f2f5;
    --gradient-primary: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    --gradient-accent: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    --gradient-dark: linear-gradient(135deg, var(--dark) 0%, var(--darker) 100%);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.15);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Prompt', sans-serif;
    background-color: var(--body-bg);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* ---------- Gradient Backgrounds ---------- */
.bg-gradient-primary {
    background: var(--gradient-primary) !important;
}

.bg-gradient-accent {
    background: var(--gradient-accent) !important;
}

.bg-gradient-dark {
    background: var(--gradient-dark) !important;
}

/* [2] NAVIGATION & LAYOUT
   ------------------------------------------------------------ */
.navbar {
    padding: 0.75rem 0;
    backdrop-filter: blur(12px);
}

.navbar-brand {
    font-size: 1.15rem;
    letter-spacing: -0.3px;
}

.navbar .nav-link {
    font-size: 0.9rem;
    font-weight: 400;
    transition: var(--transition);
    border-radius: var(--border-radius-sm);
    padding: 0.4rem 0.75rem !important;
}

.navbar .nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* [3] COMPONENTS (CARDS, BUTTONS, FORMS)
   ------------------------------------------------------------ */
.card {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-weight: 600;
    padding: 1rem 1.25rem;
}

.card-header.bg-gradient-primary {
    border-bottom: none;
}

.card-body {
    padding: 1.5rem;
}

/* ---------- Profile Card ---------- */
.profile-card {
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--border-radius);
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.profile-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
}

.profile-card::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -30px;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
}

.profile-card .profile-icon {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.profile-card .profile-detail {
    position: relative;
    z-index: 1;
}

.profile-card .detail-item {
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-card .detail-item:last-child {
    border-bottom: none;
}

.profile-card .detail-label {
    font-size: 0.8rem;
    opacity: 0.7;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-card .detail-value {
    font-size: 1rem;
    font-weight: 500;
}

/* ---------- Form Styles ---------- */
.form-control,
.form-select {
    border-radius: var(--border-radius-sm);
    border: 1.5px solid #dee2e6;
    padding: 0.6rem 1rem;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.15);
}

.form-label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 0.4rem;
}

.form-floating>.form-control,
.form-floating>.form-select {
    border-radius: var(--border-radius-sm);
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    padding: 0.55rem 1.25rem;
    transition: var(--transition);
    font-size: 0.95rem;
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(67, 97, 238, 0.35);
    background: var(--primary-dark);
}

.btn-accent {
    background: var(--gradient-accent);
    border: none;
    color: white;
}

.btn-accent:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(247, 37, 133, 0.35);
    color: white;
}

.btn-success {
    background: var(--success);
    border: none;
}

.btn-success:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(6, 214, 160, 0.35);
}

.btn-lg {
    padding: 0.75rem 2rem;
    font-size: 1.05rem;
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

/* ---------- Tables ---------- */
.table {
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #fff;
    padding: 0.85rem 1rem;
    border: none;
}

.table td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    font-size: 0.93rem;
    border-bottom: 1px solid #eee;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background-color: rgba(67, 97, 238, 0.04);
}

.table-header-gradient {
    background: var(--gradient-primary);
}

/* ---------- Auth Pages ---------- */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--body-bg);
    padding: 2rem 1rem;
}

.auth-card {
    width: 100%;
    max-width: 480px;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    background: white;
}

.auth-header {
    background: var(--gradient-primary);
    padding: 2.5rem 2rem;
    text-align: center;
    color: white;
}

.auth-header .auth-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    margin: 0 auto 1rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.3);
    }

    50% {
        box-shadow: 0 0 0 10px rgba(255, 255, 255, 0);
    }
}

.auth-body {
    padding: 2rem;
}

/* ---------- Section Divider ---------- */
.section-divider {
    position: relative;
    text-align: center;
    margin: 2rem 0;
}

.section-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--primary-light), transparent);
}

.section-divider span {
    position: relative;
    background: white;
    padding: 0 1.25rem;
    color: var(--primary);
    font-weight: 600;
    font-size: 0.95rem;
}

/* ---------- Net Total Display ---------- */
.net-total-display {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    text-align: center;
}

.net-total-display .amount {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--success);
    text-shadow: 0 0 20px rgba(6, 214, 160, 0.3);
}

.net-total-display .thai-text {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.75);
    margin-top: 0.3rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--border-radius-sm);
}

/* ---------- Badge / Status ---------- */
.status-badge {
    padding: 0.35rem 0.85rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-pending {
    background-color: rgba(252, 163, 17, 0.12);
    color: #b87900;
}

.status-approved {
    background-color: rgba(6, 214, 160, 0.12);
    color: #05a87d;
}

.status-rejected {
    background-color: rgba(239, 71, 111, 0.12);
    color: #d32f2f;
}

/* ---------- Receipt (old - keep for compatibility) ---------- */
.receipt-container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.receipt-header {
    background: var(--gradient-primary);
    color: white;
    padding: 2.5rem 2rem;
    text-align: center;
    position: relative;
}

.receipt-header::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 25px solid transparent;
    border-right: 25px solid transparent;
    border-top: 20px solid var(--secondary);
}

.receipt-body {
    padding: 2.5rem 2rem;
}

.receipt-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.receipt-info-box {
    padding: 1.25rem;
    background: #f8f9fa;
    border-radius: var(--border-radius-sm);
    border-left: 4px solid var(--primary);
}

.receipt-info-box h6 {
    color: var(--primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

.receipt-total-section {
    background: linear-gradient(135deg, #f8f9fa, #eef2ff);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-top: 1.5rem;
    border: 2px solid rgba(67, 97, 238, 0.15);
}

/* [4] RECEIPT & PRINTING
   ------------------------------------------------------------ */
.formal-receipt {
    max-width: 850px;
    margin: 0 auto;
    background: white;
    padding: 30px 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    font-family: 'Prompt', sans-serif;
    font-size: 0.85rem;
    color: #333;
    line-height: 1.6;
}

/* --- ส่วนหัวบริษัท --- */
.receipt-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #000;
    padding-bottom: 15px;
    margin-bottom: 15px;
}

.receipt-company-header {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.company-logo-section {
    flex-shrink: 0;
}

.company-logo-img {
    max-height: 80px;
    max-width: 100px;
    object-fit: contain;
}

.company-logo-placeholder {
    width: 80px;
    height: 80px;
    background: #f0f2f5;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #aaa;
}

.company-info-section {
    flex: 1;
}

.company-name-th {
    font-size: 1.15rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 2px;
}

.company-detail {
    font-size: 0.78rem;
    color: #555;
    line-height: 1.5;
}

/* --- ชื่อเอกสาร --- */
.receipt-title-section {
    text-align: right;
    margin: 5px 0 0 0;
}

.receipt-title-box {
    display: inline-block;
    border: 2px solid #333;
    padding: 6px 30px;
    text-align: center;
}

.receipt-title-sub {
    font-size: 0.8rem;
    color: #666;
}

.receipt-title-main {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1a1a2e;
}

/* --- ข้อมูลลูกค้า + เลขที่ --- */
.receipt-customer-section {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 15px;
    padding-bottom: 0px;
}

.customer-info-left {
    flex: 1;
}

.receipt-number-right {
    flex-shrink: 0;
    text-align: right;
}

.info-table {
    border-collapse: collapse;
    font-size: 0.82rem;
}

.info-table td {
    padding: 2px 8px 2px 0;
    vertical-align: top;
}

.info-table .info-label {
    color: #555;
    white-space: nowrap;
    font-weight: 500;
}

.info-table .info-value {
    color: #1a1a2e;
    font-weight: 500;
}

/* --- ตารางรายการสินค้า --- */
.receipt-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    font-size: 0.85rem;
}

.receipt-items-table thead th {
    background: #f0f0f0 !important;
    border: 1px solid #000;
    padding: 8px 10px;
    text-align: center;
    font-weight: 600;
    color: #000;
    font-size: 0.82rem;
    line-height: 1.3;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.receipt-items-table thead th small {
    font-weight: 400;
    color: #777;
    display: block;
    font-size: 0.7rem;
}

.receipt-items-table tbody td {
    border: 1px solid #000;
    border-top: none;
    border-bottom: 1px solid #000;
    padding: 8px 10px;
    vertical-align: middle;
    color: #000;
    font-size: 0.85rem;
}

.receipt-items-table tbody tr:last-child td {
    border-bottom: 1px solid #000;
}

.receipt-items-table tbody tr:hover {
    background: #fafafa;
}

/* --- สรุปยอดเงิน + การชำระ --- */
.receipt-summary-section {
    display: flex;
    gap: 0px;
    border-top: none;
    margin-top: 0;
}

.payment-method-left {
    flex: 1;
    border: 1px solid #000;
    border-top: none;
    border-right: none;
    padding: 12px 15px;
    font-size: 0.85rem;
}

.payment-title {
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.payment-options {
    display: flex;
    gap: 18px;
    margin-bottom: 8px;
}

.payment-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: default;
    font-size: 0.8rem;
}

.checkbox-box {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 1.5px solid #666;
    background: white;
    position: relative;
    flex-shrink: 0;
}

.checkbox-box.checked::after {
    content: '✓';
    position: absolute;
    top: -3px;
    left: 1px;
    font-size: 13px;
    font-weight: bold;
    color: #333;
}

.payment-detail-row {
    display: flex;
    gap: 8px;
    margin-bottom: 3px;
    font-size: 0.78rem;
}

.payment-detail-label {
    color: #666;
    min-width: 100px;
}

.payment-detail-value {
    font-weight: 500;
    color: #333;
}

.totals-right {
    flex-shrink: 0;
    width: 260px;
}

.totals-table {
    width: 100%;
    border-collapse: collapse;
}

.totals-table td {
    border: 1px solid #000;
    border-top: none;
    padding: 8px 12px;
    font-size: 0.85rem;
}

.totals-table .totals-label {
    text-align: center;
    color: #000;
    font-weight: 500;
    line-height: 1.3;
    width: 140px;
}

.totals-table .totals-value {
    text-align: right;
    font-weight: 600;
    color: #1a1a2e;
    border-top: none;
}

.net-total-row .totals-label,
.net-total-row .totals-value {
    background: #f9f9f9;
}

.net-total-value {
    font-size: 0.95rem !important;
    color: var(--primary) !important;
}

/* --- ตัวอักษรไทย --- */
.receipt-thai-text {
    padding: 10px 15px;
    margin-top: 10px;
    font-size: 0.85rem;
}

.thai-text-label {
    font-weight: 600;
    color: #555;
    margin-right: 10px;
}

.thai-text-value {
    color: #1a1a2e;
    font-weight: 500;
}

/* --- Formal Receipt Professional Polishing --- */
.formal-receipt {
    background: #fff;
    padding: 30px;
    border-radius: 0;
    max-width: 900px;
    margin: 0 auto;
    font-family: 'Prompt', sans-serif;
    color: #000;
}

/* --- New Horizontal Header --- */
.receipt-header-new {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 3.5px solid #000;
    padding-bottom: 20px;
    margin-bottom: 25px;
}

.header-left-side {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    /* Reduce gap to pull them together */
    flex: 1;
}

.header-logo-container {
    flex-shrink: 0;
}

.company-logo-img {
    max-width: 90px;
    height: auto;
}

.header-info-container {
    text-align: left;
}

.company-name-th {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.1;
    margin-bottom: 2px;
    /* Pull address closer up */
}

.company-address-compact {
    font-size: 1rem; /* ขยายขนาดเพิ่มขึ้นนิดนึงจาก 0.9rem */
    line-height: 1.4;
    color: #000;
    font-weight: 500;
    max-width: 350px;
    /* บีบให้น้อยลงเพื่อบังคับขึ้นบรรทัดใหม่ ไม่ให้ล้นไปทางขวา */
    overflow-wrap: break-word;
    /* ตัดคำตามความเหมาะสมของภาษา */
}

.header-right-side {
    flex-shrink: 0;
    text-align: right;
}

.receipt-title-box {
    border: 3px solid #000;
    padding: 10px 15px;
    text-align: center;
    background: #fff;
    min-width: 180px;
    /* Reduce width to save space */
}

.receipt-title-sub {
    font-size: 0.85rem;
    font-weight: 700;
    color: #555;
    margin-bottom: 5px;
}

.receipt-title-main {
    font-size: 1.5rem;
    font-weight: 900;
    margin-bottom: 5px;
    color: #1a1a2e;
}

.receipt-title-en {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: #000;
}

.receipt-customer-section {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-label {
    color: #000;
    padding: 6px 0;
    font-weight: 700;
    font-size: 0.95rem;
}

.info-value {
    padding: 6px 10px;
    border-bottom: 1.5px solid #eee;
    font-weight: 700;
    color: #1a1a2e;
}

.receipt-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0;
    /* Connected to footer */
}

.receipt-items-table th {
    background: #f0f0f0 !important;
    border: 1.5px solid #000 !important;
    padding: 10px 8px;
    font-size: 0.85rem;
    text-align: center;
    font-weight: 700;
}

.receipt-items-table td {
    border: 1px solid #000;
    padding: 8px 10px;
    font-size: 0.9rem;
}

/* Footer / Summaries */
.summary-row td {
    border: 1.5px solid #000;
    padding: 8px 12px;
}

.thai-text-cell {
    vertical-align: top;
    background: #fff;
}

.thai-text-container {
    font-weight: 600;
    font-size: 0.85rem;
    margin-top: 5px;
}

.total-label {
    text-align: center;
    font-size: 0.8rem;
    line-height: 1.2;
    font-weight: 600;
    background: #f9f9f9;
}

.total-amount {
    text-align: right;
    font-weight: 700;
    font-size: 1rem;
}

.net-amount-row {
    background: #eee !important;
}

/* Payment Section */
.payment-section {
    padding: 15px !important;
    border: 1.5px solid #000 !important;
}

.payment-title {
    font-weight: 700;
    margin-bottom: 10px;
    text-decoration: underline;
}

.payment-methods {
    display: flex;
    gap: 20px;
    margin-bottom: 10px;
}

.payment-checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.85rem;
}

.checkbox-box {
    width: 14px;
    height: 14px;
    border: 1.5px solid #000;
    display: inline-block;
}

.checkbox-box.checked {
    background: #000;
}

.payment-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.payment-info-item .label {
    color: #555;
    font-size: 0.8rem;
}

.payment-info-item .val {
    font-weight: 700;
    font-size: 0.85rem;
    margin-left: 5px;
}

/* --- ลายเซ็น --- */
.receipt-signatures {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-top: 25px;
    padding-top: 10px;
}

.signature-box {
    text-align: center;
}

.signature-line {
    border-bottom: 2px solid #000;
    width: 90%;
    margin: 0 auto 8px;
    height: 30px;
}

.signature-label {
    font-size: 0.85rem;
    font-weight: 700;
    color: #000;
}

.signature-date {
    font-size: 0.8rem;
    margin-top: 4px;
    color: #333;
}

.receipt-footer-note {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 20px;
    border-top: 1px dotted #000;
    padding-top: 10px;
}

/* --- Logo Preview Box (Settings) --- */
.logo-preview-box {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: var(--border-radius-sm);
    border: 2px dashed #dee2e6;
    padding: 15px;
}

/* ---------- Footer ---------- */
.footer {
    margin-top: auto;
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeInUp 0.5s ease forwards;
}

.animate-fade-in:nth-child(2) {
    animation-delay: 0.1s;
}

.animate-fade-in:nth-child(3) {
    animation-delay: 0.2s;
}

.animate-fade-in:nth-child(4) {
    animation-delay: 0.3s;
}

/* ---------- Order Items in Form ---------- */
.order-item-row {
    background: #f8f9fa;
    border-radius: var(--border-radius-sm);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid #eee;
    transition: var(--transition);
    animation: fadeInUp 0.3s ease forwards;
}

.order-item-row:hover {
    border-color: var(--primary-light);
    background: #f0f2ff;
}

.btn-remove-item {
    width: 32px;
    height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(239, 71, 111, 0.1);
    color: var(--danger);
    border: none;
    transition: var(--transition);
}

.btn-remove-item:hover {
    background: var(--danger);
    color: white;
    transform: scale(1.1);
}

/* ---------- QR Code Payment Box ---------- */
.qr-payment-box {
    background: linear-gradient(135deg, #f0fdf4, #dcfce7);
    border: 2px solid #86efac;
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.qr-title {
    font-weight: 600;
    color: #166534;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.qr-image {
    max-width: 140px;
    max-height: 140px;
    object-fit: contain;
    width: 100%;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    border: 4px solid white;
    margin-bottom: 0.75rem;
    background-color: white;
}

.qr-note {
    font-size: 0.8rem;
    color: #15803d;
    background: rgba(255, 255, 255, 0.6);
    padding: 0.5rem;
    border-radius: 8px;
}

/* ---------- Slip Upload Box ---------- */
.slip-upload-box {
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.slip-title {
    font-weight: 600;
    color: var(--primary);
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.slip-dropzone {
    border: 2px dashed #cbd5e1;
    border-radius: var(--border-radius-sm);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.slip-dropzone:hover,
.slip-dropzone.dragover {
    border-color: var(--primary);
    background: #eef2ff;
    transform: scale(1.01);
}

.slip-preview-img {
    max-height: 220px;
    max-width: 100%;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    object-fit: contain;
}

.slip-note {
    font-size: 0.8rem;
    color: #666;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .receipt-info-grid {
        grid-template-columns: 1fr;
    }

    .profile-card {
        padding: 1.5rem;
    }

    .profile-card .profile-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    .card-body {
        padding: 1rem;
    }

    .net-total-display .amount {
        font-size: 1.8rem;
    }

    /* Fix table overflows */
    .table-responsive {
        border-radius: var(--border-radius-sm);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .order-item-row .row>div {
        margin-bottom: 0.5rem;
    }

    .order-item-row .row>div:last-child {
        margin-bottom: 0;
    }

    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }

    /* Formal receipt responsive */
    .formal-receipt {
        padding: 15px 15px;
        font-size: 0.75rem;
        overflow-x: auto;
    }

    .receipt-header-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .receipt-company-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 10px;
    }

    .receipt-title-section {
        width: 100%;
        text-align: center;
        margin-top: 15px;
    }

    .receipt-customer-section {
        flex-direction: column;
        gap: 10px;
    }

    .receipt-number-right {
        text-align: left;
    }

    .receipt-summary-section {
        flex-direction: column;
    }

    .totals-right {
        width: 100%;
    }

    .receipt-signatures {
        grid-template-columns: 1fr;
        gap: 25px;
    }

    .signature-box {
        text-align: center;
    }
}

/* Pack breakdown styling */
.pack-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.pack-item-index {
    background: var(--primary);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
}

.pack-status-badge {
    position: absolute;
    top: -8px;
    right: 15px;
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* ---------- Print Styles ---------- */
@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    .no-print,
    .navbar,
    .footer,
    .alert {
        display: none !important;
    }

    body {
        background: white !important;
        padding: 0;
        margin: 0;
        font-size: 9.5pt;
        color: #000 !important;
        line-height: 1.3;
    }

    main.container,
    main {
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
    }

    /* --- Formal Receipt Print --- */
    .formal-receipt {
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
        padding: 0;
        margin: 0;
        border: none;
        zoom: 0.85 !important;
    }

    .receipt-summary-section,
    .receipt-signatures {
        page-break-inside: avoid;
    }

    .receipt-signatures {
        margin-top: 15px !important;
    }

    .signature-box {
        margin-top: 5px !important;
    }

    .receipt-items-table th,
    .receipt-items-table td {
        padding: 5px 8px !important;
        border: 1pt solid #000 !important;
    }

    .totals-table td {
        padding: 6px 8px !important;
    }



    /* --- New Header Print Fix --- */
    .receipt-header-new {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: flex-start !important;
        border-bottom: 3.5px solid #000 !important;
        padding-bottom: 15px !important;
        margin-bottom: 20px !important;
    }

    .header-left-side {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-start !important;
        gap: 12px !important;
        /* Tighten for print */
        flex: 1 !important;
        text-align: left !important;
    }

    .header-logo-container {
        flex-shrink: 0 !important;
    }

    .company-name-th {
        font-size: 1.5rem !important;
        font-weight: 800 !important;
        display: block !important;
        margin-bottom: 3px !important;
        text-align: left !important;
    }

    .company-address-compact {
        font-size: 9.5pt !important; /* ขยายจาก 8.5pt เป็น 9.5pt */
        display: block !important;
        line-height: 1.3 !important;
        text-align: left !important;
        max-width: 320px !important;
        /* บีบให้แคบลงในหน้าปริ้น */
        overflow-wrap: break-word !important;
    }

    .header-right-side {
        flex-shrink: 0 !important;
    }

    .receipt-customer-section {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        gap: 20px !important;
        margin-bottom: 15px !important;
    }

    .customer-info-left {
        flex: 2 !important;
    }

    .receipt-number-right {
        flex: 1 !important;
        text-align: right !important;
    }

    .company-info-section {
        text-align: left !important;
    }

    .company-name-th {
        font-size: 1.4rem !important;
        font-weight: 800 !important;
        color: #000 !important;
        text-align: left !important;
    }

    .company-detail {
        font-size: 9pt !important;
        color: #000 !important;
        font-weight: 500 !important;
        text-align: left !important;
    }

    .receipt-title-box {
        border: 3px solid #000 !important;
        padding: 10px 20px !important;
    }

    .receipt-items-table thead th {
        background: #f0f0f0 !important;
        color: #000 !important;
        border: 1.5pt solid #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .receipt-items-table td,
    .summary-row td,
    .payment-section {
        border: 1pt solid #000 !important;
        color: #000 !important;
    }

    .receipt-signatures {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 10px !important;
        margin-top: 5px !important;
        page-break-inside: avoid !important;
    }

    .signature-box {
        margin-top: 0 !important;
        text-align: center !important;
    }

    .signature-line {
        border-bottom: 1.5pt solid #000 !important;
        width: 90% !important;
        margin: 0 auto !important;
        height: 25px !important;
    }

    .signature-label {
        font-size: 8pt !important;
        font-weight: 700 !important;
    }

    .signature-date {
        font-size: 7.5pt !important;
    }

    .receipt-footer-note {
        color: #000 !important;
        border-top: 1pt dotted #000 !important;
        margin-top: 10px !important;
    }

    /* Old receipt print */
    .receipt-container {
        box-shadow: none;
        border-radius: 0;
        max-width: 100%;
    }

    .receipt-header {
        background: white !important;
        color: black !important;
        padding: 1.5rem;
        border-bottom: 3px double #333;
    }

    .receipt-header h2,
    .receipt-header p {
        color: black !important;
    }

    .receipt-header::after {
        display: none;
    }

    .receipt-body {
        padding: 1.5rem;
    }

    .receipt-info-box {
        background: white !important;
        border: 1px solid #ddd;
    }

    .receipt-total-section {
        background: white !important;
        border: 2px solid #333;
    }

    .table th {
        background: #eee !important;
        color: black !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}