
:root{--bg:#f6f7fb;--card:#fff;--text:#1f2937;--muted:#6b7280;--primary:#b91c1c;--line:#e5e7eb;--soft:#fef2f2}
*{box-sizing:border-box}body{margin:0;font-family:Arial,Helvetica,sans-serif;background:var(--bg);color:var(--text)}
.topbar{background:#111827;color:white;padding:14px 22px;display:flex;justify-content:space-between;align-items:center;gap:18px;flex-wrap:wrap;box-shadow:0 4px 16px rgba(0,0,0,.12)}
.topbar span{color:#d1d5db;margin-left:10px;font-size:13px}.topbar nav{display:flex;gap:10px;flex-wrap:wrap}.topbar a{color:white;text-decoration:none;padding:8px 10px;border-radius:8px}.topbar a:hover{background:#374151}
.container{max-width:1240px;margin:24px auto;padding:0 16px}.grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:16px}.card{background:var(--card);border:1px solid var(--line);border-radius:14px;padding:18px;box-shadow:0 8px 20px rgba(0,0,0,.04)}
.kpi{font-size:30px;font-weight:700;margin-top:8px}.muted{color:var(--muted);font-size:13px}.toolbar{display:flex;justify-content:space-between;gap:12px;align-items:center;flex-wrap:wrap;margin:14px 0}.btn{border:0;border-radius:9px;background:var(--primary);color:white;padding:10px 14px;text-decoration:none;cursor:pointer;font-weight:600}.btn.secondary{background:#374151}.btn.light{background:#fff;color:#111827;border:1px solid var(--line)}
.table-wrap{overflow:auto;background:white;border-radius:14px;border:1px solid var(--line)}table{width:100%;border-collapse:collapse;background:white}th,td{padding:10px 12px;border-bottom:1px solid var(--line);text-align:left;white-space:nowrap}th{background:#f9fafb;font-size:13px;color:#374151}tr:hover td{background:#fafafa}.right{text-align:right}.danger{color:#b91c1c}
.form-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:14px}.form-row{display:flex;flex-direction:column;gap:6px}label{font-size:13px;font-weight:700;color:#374151}input,select,textarea{padding:10px;border:1px solid #d1d5db;border-radius:9px;width:100%;font-size:14px;background:white}textarea{min-height:70px}.line-items input{min-width:60px}.line-items .item-name{min-width:240px}.totals{display:flex;gap:12px;justify-content:flex-end;flex-wrap:wrap}.totals .card{min-width:190px}.notice{background:#ecfdf5;border:1px solid #bbf7d0;color:#065f46;padding:12px;border-radius:10px;margin-bottom:14px}.error{background:#fef2f2;border:1px solid #fecaca;color:#991b1b;padding:12px;border-radius:10px;margin-bottom:14px}
@media(max-width:900px){.grid,.form-grid{grid-template-columns:1fr}.topbar{align-items:flex-start}.line-items th:nth-child(6),.line-items td:nth-child(6){display:none}}

/* User-friendly purchase entry page */
.purchase-card{background:#fff;border:1px solid var(--line);border-radius:14px;padding:0 18px 18px;box-shadow:0 8px 20px rgba(0,0,0,.04);overflow:hidden}
.purchase-title{background:#0f4c81;color:#fff;text-align:center;font-weight:800;font-size:22px;letter-spacing:.5px;padding:14px;margin:0 -18px 18px;text-transform:uppercase}
.purchase-header-grid{display:grid;grid-template-columns:1fr 1.3fr;gap:16px;margin-bottom:18px}.purchase-box{border:1px solid #b7c9d8;border-radius:10px;background:#f8fbff;padding:14px}.supplier-box label,.details-box label{color:#0f4c81}.mini-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.search-input,.item-search{border:2px solid #b7c9d8}.search-input:focus,.item-search:focus{border-color:#0f4c81;box-shadow:0 0 0 3px rgba(15,76,129,.12);outline:none}.section-title{font-size:18px;margin:12px 0;color:#0f4c81}.purchase-table th{background:#0f4c81;color:#fff;border-color:#0b3c66}.purchase-table td{vertical-align:middle}.purchase-table-wrap{overflow-x:auto}.purchase-table .form-control{min-width:55px}.purchase-table .item-search{min-width:420px;width:100%}.purchase-table .qty{width:75px;min-width:65px}.purchase-table .price{width:105px;min-width:95px}.purchase-table .vat-rate{width:75px;min-width:65px}.purchase-table td.excl,.purchase-table td.incl,.purchase-table td.vat{min-width:105px}.remove-row,button.remove-row{background-color:#dc3545!important;border:1px solid #dc3545!important;color:#fff!important;width:32px;height:32px;padding:0;line-height:1;border-radius:4px;font-weight:700;cursor:pointer;font-size:15px;-webkit-appearance:none;appearance:none}.remove-row:hover,button.remove-row:hover{background-color:#bb2d3b!important;border-color:#b02a37!important;color:#fff!important}.purchase-totals .card{border-top:4px solid #0f4c81}.actions-row{margin-top:12px}.save-bar{display:flex;justify-content:flex-end;margin-top:18px}.btn-save:disabled{opacity:.55;cursor:not-allowed}.field-note{display:block;margin-top:4px;font-size:12px}.text-danger{color:#b91c1c!important}.text-success{color:#047857!important}.text-warning{color:#92400e!important}.filter-card{justify-content:flex-start}.filter-card input{max-width:260px}
@media(max-width:900px){.purchase-header-grid,.mini-grid{grid-template-columns:1fr}.purchase-card{padding-left:12px;padding-right:12px}.purchase-title{margin-left:-12px;margin-right:-12px}.purchase-table .item-search{min-width:320px}}


/* Main file style purchase display */
.excel-sheet-wrap{overflow:auto;background:white;border:1px solid #b7b7b7;border-radius:6px;box-shadow:0 8px 20px rgba(0,0,0,.04);max-height:72vh}
.excel-main-file{border-collapse:collapse;min-width:1500px;width:100%;font-size:13px;background:white}
.excel-main-file th,.excel-main-file td{border:1px solid #b7b7b7;padding:6px 8px;white-space:nowrap}
.excel-main-file th{position:sticky;top:0;z-index:2;background:#d9eaf7;color:#000;font-weight:700;text-align:left}
.excel-main-file tbody tr:nth-child(even) td{background:#f8fbff}
.excel-main-file tbody tr:hover td{background:#fff8d6}
.excel-main-file td:nth-child(2){min-width:280px}
.excel-main-file td:nth-child(7),.excel-main-file td:nth-child(13){min-width:320px}
.excel-main-file td:nth-child(3),.excel-main-file td:nth-child(6){min-width:130px}
.excel-main-file td:nth-child(4){min-width:130px}

/* Purchase invoice viewing and printing */
.button-group{display:flex;gap:10px;flex-wrap:wrap;align-items:center}.small-link{display:inline-block;background:#eff6ff;color:#0f4c81;border:1px solid #bfdbfe;padding:5px 8px;border-radius:7px;text-decoration:none;font-weight:700}.small-link:hover{background:#dbeafe}.full-row{grid-column:1/-1}.current-image-note{background:#f8fafc;border:1px dashed #94a3b8;border-radius:10px;padding:10px 12px;margin:-6px 0 14px}.current-image-note a{color:#0f4c81;font-weight:700}.print-invoice{background:white;border:1px solid var(--line);border-radius:14px;padding:24px;box-shadow:0 8px 20px rgba(0,0,0,.04)}.invoice-top{display:flex;justify-content:space-between;gap:20px;align-items:flex-start;border-bottom:2px solid #0f4c81;padding-bottom:14px;margin-bottom:16px}.invoice-top h2{margin:0;color:#0f4c81;font-size:24px}.invoice-meta{line-height:1.8;text-align:left;background:#f8fbff;border:1px solid #b7c9d8;border-radius:10px;padding:12px;min-width:260px}.invoice-supplier-box{background:#e8eef7;border-top:1px solid #5b8a82;padding:10px 12px;margin-bottom:16px;font-size:17px}.invoice-lines-wrap{margin-bottom:18px}.invoice-lines th{background:#0f4c81;color:white}.invoice-lines tfoot th{background:#e8eef7;color:#111827}.invoice-image-box{border:1px solid #222;max-width:760px;min-height:260px;margin:0 auto;padding:10px;text-align:center;background:white}.invoice-image-box img{max-width:100%;height:auto}.empty-invoice-image{border:1px dashed #94a3b8;background:#f8fafc;color:#6b7280;padding:60px;text-align:center;border-radius:10px}.invoice-book-card h2{margin-top:0}
@media print{body{background:white}.topbar,.no-print,.toolbar:not(.print-keep){display:none!important}.container{max-width:none;margin:0;padding:0}.print-invoice{border:0;box-shadow:none;border-radius:0;padding:0}.invoice-top{margin-top:0}.table-wrap{border:0;overflow:visible}.invoice-lines th,.invoice-lines td{border:1px solid #888}.invoice-image-box{page-break-inside:avoid}.no-print{display:none!important}}

/* Multiple invoice images */
.invoice-images-row{display:flex;gap:12px;flex-wrap:wrap;align-items:flex-start;justify-content:center}.invoice-image-box.multi{max-width:360px;min-height:180px;margin:0}.invoice-image-box.multi img{max-width:100%;height:auto}.current-image-note a{margin-right:6px}
@media print{.invoice-images-row{display:flex;flex-wrap:nowrap;gap:8px}.invoice-image-box.multi{max-width:32%;min-height:120px;page-break-inside:avoid}}

/* Bulk invoice recording */
.bulk-form .check-line{display:flex;gap:8px;align-items:center;font-weight:600;color:#374151}.bulk-form .check-line input{width:auto}.badge{display:inline-block;border-radius:999px;background:#e5e7eb;color:#374151;font-size:12px;padding:4px 8px;font-weight:700;text-transform:capitalize}.badge.ok{background:#dcfce7;color:#166534}.badge.warn{background:#fef3c7;color:#92400e}.badge.danger{background:#fee2e2;color:#991b1b}.bulk-help-grid{grid-template-columns:repeat(4,minmax(0,1fr))}.bulk-page-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:16px}.bulk-page-card{display:flex;flex-direction:column;gap:10px}.bulk-thumb-wrap{height:260px;border:1px solid var(--line);border-radius:10px;background:#f8fafc;display:flex;align-items:center;justify-content:center;overflow:hidden}.bulk-thumb-wrap img{max-width:100%;max-height:100%;object-fit:contain}.bulk-page-meta{line-height:1.65}.bulk-actions{margin-top:auto}.bulk-record-layout{display:grid;grid-template-columns:minmax(360px,48%) minmax(420px,52%);gap:18px;align-items:start}.bulk-image-panel{position:sticky;top:12px}.bulk-image-panel h2{font-size:18px;margin-top:0;color:#0f4c81}.bulk-record-image{width:100%;max-height:76vh;object-fit:contain;border:1px solid #111827;background:#fff}.ocr-box{margin-top:12px;border:1px solid var(--line);border-radius:10px;padding:10px;background:#f8fafc}.ocr-box pre{white-space:pre-wrap;max-height:260px;overflow:auto;font-size:12px}.bulk-entry-form{padding-bottom:16px}.bulk-form-grid{grid-template-columns:1fr}.extra-pages-box{margin-bottom:14px}.extra-page-row{display:flex;gap:10px;overflow:auto;padding:8px 0}.extra-page-option{min-width:150px;border:1px solid #b7c9d8;border-radius:10px;background:white;padding:8px;font-weight:600;color:#111827}.extra-page-option input{width:auto;margin-right:6px}.extra-page-option img{display:block;max-width:120px;max-height:120px;object-fit:contain;margin-top:6px;border:1px solid var(--line);background:#f8fafc}.quick-entry-tip{margin:4px 0 10px}.bulk-upload-card h2{margin-top:0}
@media(max-width:1100px){.bulk-record-layout{grid-template-columns:1fr}.bulk-image-panel{position:static}.bulk-help-grid{grid-template-columns:1fr 1fr}}
@media(max-width:700px){.bulk-help-grid{grid-template-columns:1fr}.bulk-thumb-wrap{height:210px}}

/* Browser PDF splitter */
.progress-shell {
  width: 100%;
  height: 30px;
  background: #eef2f7;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
}
.progress-bar-local {
  height: 100%;
  background: #0d6efd;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  transition: width .2s ease;
  min-width: 42px;
}
.browser-pdf-preview img {
  max-width: 260px;
  max-height: 340px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  padding: 4px;
}

/* Bulk recording improvements: form left, scanned image right */
.bulk-record-form-left{grid-template-columns:minmax(520px,56%) minmax(380px,44%)}
.bulk-record-form-left .bulk-form-panel{min-width:0}
.bulk-record-form-left .bulk-image-panel{position:sticky;top:12px;max-height:calc(100vh - 24px);overflow:auto}
.bulk-record-form-left .bulk-record-image{width:100%;max-height:calc(100vh - 170px);object-fit:contain;border:1px solid #111827;background:#fff}
.receipt-only-box{margin-bottom:14px;background:#fff7ed;border-color:#fdba74}
.receipt-only-check{display:flex;align-items:center;gap:8px;margin-bottom:6px;color:#9a3412!important;font-size:14px}
.receipt-only-check input{width:auto}
.bulk-save-bar{gap:10px;flex-wrap:wrap;align-items:center}
.danger-link{border-color:#fecaca!important;color:#991b1b!important;background:#fff!important}
.danger-link:hover{background:#fef2f2!important}
@media(max-width:1100px){.bulk-record-form-left{grid-template-columns:1fr}.bulk-record-form-left .bulk-image-panel{position:static;max-height:none}.bulk-record-form-left .bulk-record-image{max-height:75vh}}

/* Multi-page bulk recording */
.bulk-select-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:16px;position:sticky;top:0;z-index:8;background:#fff}
.bulk-card-select{display:flex;align-items:center;gap:8px;font-weight:700;color:#0f4c81;background:#eef6ff;border:1px solid #b7d8f5;border-radius:10px;padding:8px 10px}
.bulk-card-select input,.bulk-select-toolbar input{width:auto}
.bulk-page-card.is-pending{border-color:#b7d8f5}
.bulk-instructions h2{margin-top:0}.bulk-instructions .grid{display:grid;gap:14px}
.selected-pages-summary{margin-bottom:14px}.selected-page-chips{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px}.selected-page-chip{display:inline-flex;align-items:center;gap:8px;border:1px solid #b7d8f5;background:#eef6ff;color:#0f4c81;border-radius:999px;padding:6px 10px;font-weight:700}.remove-page-chip{border:0;background:#0f4c81;color:#fff;border-radius:50%;width:20px;height:20px;line-height:18px;cursor:pointer;font-weight:900}
.selected-image-thumbs{display:flex;gap:8px;overflow:auto;padding:6px 0 12px;margin-bottom:10px;border-bottom:1px solid var(--line)}.selected-image-thumb{display:block;min-width:92px;text-align:center;text-decoration:none;color:#111827;font-size:12px;font-weight:700}.selected-image-thumb img{display:block;width:88px;height:88px;object-fit:contain;border:1px solid var(--line);background:#f8fafc;border-radius:8px;margin-bottom:4px}.selected-image-stack{display:flex;flex-direction:column;gap:18px}.selected-image-card{border:1px solid #d1d5db;border-radius:12px;padding:10px;background:#fff}.selected-image-card-title{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px;color:#0f4c81}.selected-image-card.removed{display:none}.bulk-record-form-left .selected-image-card .bulk-record-image{max-height:calc(100vh - 230px)}
@media(max-width:900px){.bulk-select-toolbar{position:static;align-items:flex-start;flex-direction:column}.bulk-select-toolbar .button-group{justify-content:flex-start}.selected-image-thumbs{position:static}.bulk-record-form-left .selected-image-card .bulk-record-image{max-height:75vh}}
