/* ==================== */
/* CSS Variables & Reset */
/* ==================== */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #16a34a;
    --success-hover: #15803d;
    --secondary-color: #6b7280;
    --secondary-hover: #4b5563;
    --danger-color: #dc2626;
    --warning-color: #f59e0b;
    --info-color: #0891b2;
    --background: #f3f4f6;
    --card-bg: #ffffff;
    --border-color: #e5e7eb;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    --radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== */
/* Layout */
/* ==================== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 25px;
    background: linear-gradient(135deg, var(--primary-color), #1e40af);
    color: white;
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-lg);
}

.header-left {
    text-align: left;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.header .subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 3px;
}

.user-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding-right: 15px;
    border-right: 1px solid rgba(255,255,255,0.3);
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-role {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: uppercase;
}

.header .btn {
    white-space: nowrap;
}

/* Header buttons — high contrast on dark background */
.header .btn-outline {
    border-color: rgba(255, 255, 255, 0.5);
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    font-weight: 500;
    transition: all 0.2s ease;
}

.header .btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.8);
}

.header .btn-outline-danger {
    border-color: rgba(255, 120, 120, 0.6);
    color: #fecaca;
    background-color: rgba(220, 38, 38, 0.2);
}

.header .btn-outline-danger:hover {
    background-color: rgba(220, 38, 38, 0.4);
    border-color: rgba(255, 120, 120, 0.9);
    color: white;
}

/* ==================== */
/* Modal */
/* ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    background: var(--background);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--danger-color);
}

.modal-body {
    padding: 25px;
    max-height: 60vh;
    overflow-y: auto;
}

/* User Management Table */
.user-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.user-table th,
.user-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.user-table th {
    background: var(--background);
    font-weight: 600;
    font-size: 0.85rem;
}

.user-table tr:hover {
    background: rgba(37, 99, 235, 0.02);
}

.role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.admin {
    background: #fee2e2;
    color: #dc2626;
}

.role-badge.manager {
    background: #fef3c7;
    color: #f59e0b;
}

.role-badge.staff {
    background: #dbeafe;
    color: #2563eb;
}

.user-form {
    display: grid;
    gap: 15px;
}

.user-form .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.user-form .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 10px;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* ==================== */
/* Panels */
/* ==================== */
.form-panel,
.preview-panel,
.data-panel,
.summary-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.form-panel h2,
.preview-panel h2,
.data-panel h2,
.summary-panel h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

/* Form Panel Header */
.form-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
}

.form-panel-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.form-mode-badge {
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 20px;
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.form-mode-badge.edit-mode {
    background-color: var(--warning-color);
}

/* ==================== */
/* Summary Panel */
/* ==================== */
.summary-panel {
    margin-bottom: 20px;
}

.summary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.summary-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.summary-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary-date-picker {
    display: flex;
    align-items: center;
    gap: 10px;
}

.summary-date-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
}

.summary-card {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.summary-card.printed {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: var(--success-color);
}

.summary-card.pending {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: var(--warning-color);
}

.summary-card.received {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: var(--primary-color);
}

.summary-card.waiting {
    background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
    border-color: #9333ea;
}

.summary-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

.summary-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.summary-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* ==================== */
/* Form Styles */
/* ==================== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group input::placeholder {
    color: var(--text-secondary);
}

/* Auto-generated field badge */
.auto-badge {
    display: inline-block;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 12px;
    margin-left: 6px;
    font-weight: 600;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

/* Readonly field styling */
.readonly-field {
    background-color: #f0fdf4 !important;
    border-color: #86efac !important;
    color: var(--text-primary) !important;
    cursor: not-allowed;
    font-weight: 500;
}

.readonly-field:focus {
    border-color: #86efac !important;
    box-shadow: none !important;
}

.divider {
    border: none;
    border-top: 1px dashed var(--border-color);
    margin: 20px 0;
}

/* ==================== */
/* Image Upload */
/* ==================== */
.image-upload-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.image-upload-single {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
    min-height: 200px;
    transition: border-color 0.2s, background-color 0.2s;
}

.image-upload-single:hover {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.02);
}

.image-upload-single.has-image {
    border-style: solid;
    border-color: var(--success-color);
}

.image-upload {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 4/3;
    transition: border-color 0.2s, background-color 0.2s;
}

.image-upload:hover {
    border-color: var(--primary-color);
    background-color: rgba(37, 99, 235, 0.02);
}

.image-upload.has-image {
    border-style: solid;
    border-color: var(--success-color);
}

.upload-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text-secondary);
}

.upload-icon {
    font-size: 2rem;
}

.upload-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none;
    padding: 5px;
}

.image-upload.has-image .upload-placeholder {
    display: none;
}

.image-upload.has-image .image-preview {
    display: block;
}

.image-upload-single .image-preview {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    display: none;
    padding: 10px;
}

.image-upload-single.has-image .upload-placeholder {
    display: none;
}

.image-upload-single.has-image .image-preview {
    display: block;
}

/* ==================== */
/* Buttons */
/* ==================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: var(--success-hover);
}

.btn-warning {
    background-color: #f59e0b;
    color: white;
    font-weight: 600;
}

.btn-warning:hover {
    background-color: #d97706;
}

/* v8.5.2 — Export dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.export-dropdown .dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    min-width: 120px;
    margin-top: 4px;
}

.export-dropdown.open .dropdown-menu {
    display: block;
}

.export-dropdown .dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    border: none;
    background: none;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: #374151;
}

.export-dropdown .dropdown-item:hover {
    background: #f3f4f6;
}

.export-dropdown .dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.export-dropdown .dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: var(--secondary-hover);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-outline-danger {
    background-color: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

.btn-outline-danger:hover {
    background-color: var(--danger-color);
    color: white;
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-outline:hover {
    background-color: var(--background);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.form-actions .btn {
    flex: 1;
}

.form-actions-secondary {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.form-actions-secondary .btn {
    flex: 1;
}

/* Image indicator in table */
.image-indicator {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    object-fit: cover;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.image-indicator:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.no-image {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* Action buttons in table */
.action-buttons {
    display: flex;
    gap: 5px;
    flex-wrap: nowrap;
}

.action-buttons .btn {
    padding: 4px 8px;
    min-width: auto;
}

/* ==================== */
/* Receipt Preview */
/* ==================== */
.receipt-preview {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    background: #fafafa;
    min-height: 500px;
}

.receipt-document {
    position: relative;
    background: white;
    padding: 30px;
    border: 1px solid #ddd;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Category Letter Badge */
.category-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    border: 3px solid #9ca3af;
    border-radius: 6px;
    background: #fff;
    color: #9ca3af;
    z-index: 1;
}

.receipt-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--primary-color);
}

.receipt-header h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.receipt-header p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Bottom Footer - Org Name & Doc No */
.receipt-bottom-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 10px;
    border-top: 2px solid #d1d5db;
}

.footer-org {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.footer-doc {
    font-size: 1rem;
    color: #111;
    font-weight: 700;
}

.receipt-body {
    margin-bottom: 25px;
}

.receipt-row {
    display: flex;
    padding: 8px 0;
    border-bottom: 1px dotted var(--border-color);
    align-items: flex-start;
}

.receipt-row .label {
    font-weight: 500;
    width: 150px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.receipt-row .label .label-th {
    color: var(--text-primary);
    font-weight: 600;
}

.receipt-row .label .label-en {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 400;
}

.receipt-row .value {
    color: var(--text-primary);
    padding-top: 2px;
}

.receipt-images {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.receipt-images-single {
    margin-bottom: 25px;
}

.receipt-image-box {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 10px;
    text-align: center;
    background: #fafafa;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.receipt-image-box-single {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 15px;
    text-align: center;
    background: #fafafa;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.receipt-image-box .image-label,
.receipt-image-box-single .image-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.receipt-image-box img {
    max-width: 100%;
    max-height: 120px;
    object-fit: contain;
    display: none;
}

.receipt-image-box-single img {
    max-width: 100%;
    max-height: 160px;
    object-fit: contain;
    display: none;
}

.receipt-image-box.has-image img,
.receipt-image-box-single.has-image img {
    display: block;
}

.receipt-image-box.has-image .image-label,
.receipt-image-box-single.has-image .image-label {
    display: none;
}

.receipt-confirmation {
    margin: 20px 0;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: var(--radius);
    border-left: 3px solid var(--primary-color);
}

.confirmation-text-th {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.confirmation-text-en {
    font-size: 0.8rem;
    line-height: 1.5;
    color: var(--text-secondary);
    font-style: italic;
    margin: 0;
}

.receipt-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 30px;
    padding-top: 20px;
}

.signature-box {
    text-align: center;
}

.signature-line {
    border-bottom: 1px solid var(--text-primary);
    width: 80%;
    margin: 0 auto 10px;
    height: 40px;
}

.signature-box p {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.signature-box .signer-name {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
    margin-top: 5px;
}


/* ==================== */
/* Data Table */
/* ==================== */
.data-panel {
    margin-top: 0;
}

.data-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.data-header h2 {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.data-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.search-box {
    position: relative;
}

.search-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    width: 250px;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Recent Receipts Dropdown */
.recent-receipts-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 100;
    max-height: 240px;
    overflow-y: auto;
}

.recent-receipts-dropdown .recent-header {
    padding: 6px 12px;
    font-size: 0.75rem;
    color: #6b7280;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.recent-receipts-dropdown .recent-header button {
    font-size: 0.7rem;
    color: #9ca3af;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
}

.recent-receipts-dropdown .recent-header button:hover {
    color: #ef4444;
}

.recent-receipts-dropdown .recent-item {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    border-bottom: 1px solid #f9fafb;
}

.recent-receipts-dropdown .recent-item:hover,
.recent-receipts-dropdown .recent-item.active {
    background: #eff6ff;
}

.recent-receipts-dropdown .recent-item .recent-name {
    color: #374151;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.recent-receipts-dropdown .recent-item .recent-no {
    color: #6b7280;
    font-size: 0.75rem;
    margin-left: 8px;
    flex-shrink: 0;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Date Filter */
.date-filter-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.date-filter-input {
    padding: 7px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.85rem;
    background: white;
    cursor: pointer;
    color: var(--text-primary);
}

.date-filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.btn-xs {
    padding: 5px 8px;
    font-size: 0.75rem;
    border-radius: var(--radius);
}

.date-filter-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--background);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

tr:hover {
    background-color: rgba(37, 99, 235, 0.02);
}

tr:last-child td {
    border-bottom: none;
}

.loading-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 30px;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 0.85rem;
}

/* Status badges */
.status-printed {
    color: var(--success-color);
    font-weight: 500;
    font-size: 0.85rem;
}

.status-pending {
    color: var(--secondary-color);
    font-size: 0.85rem;
}

/* Printed row style - Gray background for printed items */
.row-printed {
    background-color: #f0f0f0;
    color: #6b7280;
}

.row-printed:hover {
    background-color: #e5e5e5;
}

.row-printed td {
    opacity: 0.8;
}

/* Received row style */
.row-received {
    background-color: rgba(37, 99, 235, 0.05);
}

.row-received:hover {
    background-color: rgba(37, 99, 235, 0.1);
}

/* Checkbox styles */
.received-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.received-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.received-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.status-received {
    color: var(--primary-color);
    font-weight: 500;
    font-size: 0.85rem;
}

.status-waiting {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ==================== */
/* Pagination */
/* ==================== */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.pagination-controls {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-wrap: wrap;
}

.pagination-btn {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-primary);
    font-family: 'Sarabun', sans-serif;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-weight: 600;
}

.pagination-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination-ellipsis {
    padding: 6px 4px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

@media (max-width: 600px) {
    .pagination {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    .pagination-controls {
        justify-content: center;
    }
}

/* ==================== */
/* Print Styles */
/* ==================== */
.print-only {
    display: none;
}

@media print {
    @page {
        size: A4 portrait;
        margin: 5mm;
    }

    /* Hide everything first */
    html, body {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    body * {
        visibility: hidden !important;
    }

    /* Hide specific containers completely */
    .header,
    .main-content,
    .summary-panel,
    .data-panel,
    .tabs-panel,
    .modal-overlay,
    .form-panel,
    .preview-panel,
    .pagination,
    nav,
    footer {
        display: none !important;
    }

    /* Show only print template */
    #printTemplate,
    #printTemplate * {
        visibility: visible !important;
    }

    #printTemplate {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .receipt-barcode {
        display: inline-block !important;
        visibility: visible !important;
    }

    .print-only {
        display: block !important;
    }

    /* Force single page per receipt */
    .print-receipt-page {
        page-break-after: auto;
        page-break-inside: avoid;
        width: 190mm !important;
        max-width: 190mm !important;
        min-height: auto !important;
        max-height: 260mm !important;
        overflow: hidden !important;
        margin: 0 auto !important;
        padding: 3mm 8mm !important;
        box-sizing: border-box !important;
    }

    /* Compact print: reduce image and spacing */
    .print-receipt-page img {
        max-height: 180px !important;
    }

    .print-receipt-page table td {
        padding: 6px 10px !important;
    }
}

/* ==================== */
/* Responsive */
/* ==================== */
@media (max-width: 1200px) {
    .summary-cards {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .data-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .data-controls {
        width: 100%;
    }

    .search-input {
        width: 100%;
    }
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .image-upload-container {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .receipt-images {
        grid-template-columns: 1fr;
    }

    .receipt-footer {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }

    .summary-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ==================== */
/* Batch Print Checkbox */
/* ==================== */
.batch-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

#selectAllCheckbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

#batchPrintBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#batchPrintBtn:not(:disabled) {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

/* ==================== */
/* Monthly Report Panel */
/* ==================== */
.monthly-report-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-top: 20px;
}

.monthly-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.monthly-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.monthly-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.monthly-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-card.success {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    border-color: var(--success-color);
}

.stat-card.info {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-color: var(--primary-color);
}

.stat-card.warning {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    border-color: var(--warning-color);
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.daily-breakdown {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.daily-breakdown table {
    width: 100%;
    border-collapse: collapse;
}

.daily-breakdown th,
.daily-breakdown td {
    padding: 10px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.daily-breakdown th {
    background-color: var(--background);
    font-weight: 600;
}

.daily-breakdown tr:last-child td {
    border-bottom: none;
}

.daily-breakdown-empty {
    padding: 30px;
    text-align: center;
    color: var(--text-secondary);
}

/* ==================== */
/* Activity Log Panel */
/* ==================== */
.activity-log-panel {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-top: 20px;
}

.activity-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.activity-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.activity-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.activity-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.activity-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    gap: 12px;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-item:hover {
    background-color: rgba(37, 99, 235, 0.02);
}

.activity-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.activity-icon.add {
    background-color: #dcfce7;
    color: var(--success-color);
}

.activity-icon.edit {
    background-color: #fef3c7;
    color: var(--warning-color);
}

.activity-icon.delete {
    background-color: #fee2e2;
    color: var(--danger-color);
}

.activity-icon.print {
    background-color: #dbeafe;
    color: var(--primary-color);
}

.activity-icon.receive {
    background-color: #f3e8ff;
    color: #9333ea;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.activity-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.activity-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
}

/* Scrollbar styling for activity list */
.activity-list::-webkit-scrollbar {
    width: 6px;
}

.activity-list::-webkit-scrollbar-track {
    background: var(--background);
    border-radius: 3px;
}

.activity-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.activity-list::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* ==================== */
/* Tab Navigation */
/* ==================== */
.reports-section {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    margin: 20px;
    overflow: hidden;
}

.tab-navigation {
    display: flex;
    background: var(--background);
    border-bottom: 1px solid var(--border-color);
    padding: 0;
}

.tab-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    position: relative;
    border-bottom: 3px solid transparent;
}

.tab-btn:hover {
    background: rgba(37, 99, 235, 0.05);
    color: var(--primary-color);
}

.tab-btn.active {
    background: white;
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    padding: 0;
}

.tab-pane {
    display: none;
    padding: 20px;
}

.tab-pane.active {
    display: block;
}

/* Update monthly and activity styles for tab layout */
.reports-section .monthly-header,
.reports-section .activity-header {
    padding: 0 0 15px 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.reports-section .monthly-summary {
    padding: 0;
}

.reports-section .activity-list {
    max-height: 400px;
}

/* ==================== */
/* Responsive for new panels */
/* ==================== */
@media (max-width: 1024px) {
    .monthly-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .monthly-header,
    .activity-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .monthly-controls,
    .activity-controls {
        width: 100%;
        flex-wrap: wrap;
    }
}

@media (max-width: 600px) {
    .monthly-stats {
        grid-template-columns: 1fr;
    }
}

/* ==================== */
/* Import from VP Styles */
/* ==================== */
.import-sheet-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: linear-gradient(135deg, #e0f2fe 0%, #dbeafe 100%);
    border-radius: 8px;
    border: 1px solid #bae6fd;
    flex-wrap: wrap;
    position: relative;
}

.sheet-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sheet-status.success {
    color: var(--success-color);
}

.sheet-status.error {
    color: var(--danger-color);
}

/* Modal Large */
.modal-large {
    max-width: 900px;
    width: 95%;
}

.sheet-search-section {
    margin-bottom: 16px;
}

.search-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.search-input-large {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.search-input-large:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* Sheet Results Table */
.sheet-results-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.sheet-results-table {
    width: 100%;
    border-collapse: collapse;
}

.sheet-results-table th,
.sheet-results-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

.sheet-results-table th {
    background: var(--background);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
}

.sheet-results-table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.sheet-results-table .loading-cell {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.sheet-results-table .btn-select {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.sheet-results-table .no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

/* Highlight matched row */
.sheet-results-table tbody tr.selected {
    background: rgba(34, 197, 94, 0.1);
    border-left: 3px solid var(--success-color);
}

/* Pending Badge */
.pending-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 11px;
    background: var(--danger-color);
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    margin-left: -8px;
    margin-top: -8px;
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Pending Photo Thumbnail */
.pending-photo-thumb {
    width: 40px;
    height: 50px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s;
}

.pending-photo-thumb:hover {
    transform: scale(2);
    z-index: 100;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Toast Animations */
@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Modal Overlay Flex */
.modal-overlay {
    display: none;
    justify-content: center;
    align-items: center;
}

/* Version Badge */
.version-badge {
    position: fixed;
    bottom: 8px;
    right: 12px;
    font-size: 0.7rem;
    color: var(--text-secondary);
    opacity: 0.5;
    z-index: 1;
    pointer-events: none;
}

@media print {
    .version-badge {
        display: none;
    }
}

/* ==================== */
/* v7.0 - Webcam & Signature Pad */
/* ==================== */

/* Webcam Capture Area */
.webcam-capture-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    background: #fafbfc;
}

.webcam-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
    aspect-ratio: 4/3;
    background: #1f2937;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.webcam-video,
.webcam-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 6px;
}

.webcam-canvas {
    display: none;
}

.webcam-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.webcam-placeholder .upload-icon {
    font-size: 2rem;
}

.webcam-controls {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.camera-select {
    flex: 1;
    min-width: 120px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    background: white;
}

/* Signature Pad */
.signature-pad-wrapper {
    border: 2px solid var(--border-color);
    border-radius: var(--radius);
    background: white;
    padding: 8px;
}

.signature-pad-canvas {
    width: 100%;
    height: 150px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    cursor: crosshair;
    touch-action: none;
}

.signature-pad-modal .signature-pad-canvas {
    height: 200px;
}

.signature-pad-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* Officer Signature Display */
.officer-signature-display {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafbfc;
}

.officer-signature-img {
    max-width: 200px;
    max-height: 80px;
    object-fit: contain;
}

.officer-signature-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--warning-color);
    font-size: 0.85rem;
}

/* Officer Signature Modal */
.modal-description {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

.current-signature-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
}

.current-signature-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.current-signature-img {
    max-width: 250px;
    max-height: 100px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    background: white;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: flex-end;
}

/* Receipt Preview - Photo & Signature */
.receipt-photo-box {
    text-align: center;
    margin-bottom: 8px;
}

.receipt-photo-box img {
    max-width: 120px;
    max-height: 120px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.signature-img-preview {
    max-width: 80%;
    max-height: 40px;
    object-fit: contain;
    margin-bottom: 4px;
}

/* Print styles for photo & signature */
@media print {
    .webcam-capture-area,
    .signature-pad-wrapper,
    .officer-signature-display,
    .webcam-controls,
    .signature-pad-controls {
        display: none;
    }
}
