/* ============================================================================
   STYLE.CSS  —  Scan Industries Invoicing System
   Modern redesign: Segoe UI · Navy Blue & Gold palette
   ============================================================================ */

/* ---- Reset & base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #eef1f7;
  color: #1a2a4a;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Top navigation bar ---- */
.topbar {
  background: linear-gradient(135deg, #0f2040 0%, #1a3a6b 60%, #1e4480 100%);
  color: white;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
  box-shadow: 0 2px 14px rgba(10, 25, 60, 0.4);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-title::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 26px;
  background: linear-gradient(180deg, #f5d87a, #c8962c);
  border-radius: 3px;
}

.tabs {
  display: flex;
  gap: 4px;
}

.tab-btn {
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  border: none;
  padding: 8px 18px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 500;
  transition: background 0.18s, color 0.18s;
  letter-spacing: 0.2px;
}

.tab-btn:hover {
  background: rgba(200, 150, 44, 0.2);
  color: #f5d87a;
}

.tab-btn.active {
  background: linear-gradient(135deg, #c8962c, #e0ad3c);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(200, 150, 44, 0.4);
}

/* ---- Toast notifications ---- */
.toast {
  position: fixed;
  top: 78px;
  right: 22px;
  padding: 13px 20px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: white;
  z-index: 999;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
  max-width: 380px;
  animation: slideIn 0.2s ease;
}

@keyframes slideIn {
  from { transform: translateX(16px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.toast.success { background: linear-gradient(135deg, #1a7a3c, #22a355); }
.toast.error   { background: linear-gradient(135deg, #a52020, #c0392b); }
.hidden        { display: none !important; }

/* ---- Page container ---- */
.container {
  max-width: 1220px;
  margin: 28px auto;
  padding: 0 24px;
}

/* ---- Tab panels as cards ---- */
.tab-panel {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 2px 18px rgba(26, 42, 74, 0.09);
  padding: 30px 36px;
}

.tab-panel h2 {
  font-size: 20px;
  font-weight: 700;
  color: #0f2040;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 2px solid #eef1f7;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab-panel h2::before {
  content: "";
  display: inline-block;
  width: 4px;
  height: 22px;
  background: linear-gradient(180deg, #f5d87a, #c8962c);
  border-radius: 3px;
}

.tab-panel h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: #1a3a6b;
  margin: 26px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Data tables ---- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 13.5px;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(26, 42, 74, 0.07);
}

.data-table thead tr {
  background: linear-gradient(90deg, #0f2040, #1a3a6b);
}

.data-table th {
  color: #fff;
  padding: 12px 13px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table td {
  padding: 10px 13px;
  border-bottom: 1px solid #e8edf5;
  color: #263d6a;
}

.data-table tbody tr:hover {
  background: #f3f6fd;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.muted {
  color: #9aaac0;
  font-style: italic;
  text-align: center !important;
  padding: 24px !important;
}

/* ---- Forms ---- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.form-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  color: #4a6080;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-field input,
.form-field select {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid #ccd6e8;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  color: #1a2a4a;
  background: #f7f9fd;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  outline: none;
}

.form-field input:focus,
.form-field select:focus {
  border-color: #1a3a6b;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.13);
}

.form-field input::placeholder {
  color: #b0c0d4;
}

.label-hint {
  font-size: 10px;
  font-weight: 400;
  color: #9aaac0;
  text-transform: none;
  letter-spacing: 0;
}

/* Keep all line-item cells top-aligned so the stock warning div doesn't push qty input up */
#line-items-body td {
  vertical-align: top;
  padding-top: 10px;
}

/* Inline stock warning on line items */
.line-stock-warn {
  font-size: 10.5px;
  color: #e05b5b;
  margin-top: 3px;
  min-height: 14px;
}

input.input-error {
  border-color: #e05b5b !important;
  background: #fff5f5 !important;
}

/* Auto line numbers on new invoice form */
#line-items-body { counter-reset: line-row; }
#line-items-body tr { counter-increment: line-row; }
#line-items-body tr td.line-num {
  text-align: center;
  color: #8aaad0;
  font-size: 12px;
  font-weight: 700;
}
#line-items-body tr td.line-num::before {
  content: counter(line-row);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 22px;
  border: none;
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  margin: 10px 8px 10px 0;
  transition: background 0.18s, transform 0.1s, box-shadow 0.18s;
  letter-spacing: 0.2px;
}

.btn:active { transform: scale(0.97); }

.btn.primary {
  background: linear-gradient(135deg, #1a3a6b, #1e4c8a);
  color: white;
  box-shadow: 0 2px 10px rgba(26, 58, 107, 0.32);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #0f2040, #1a3a6b);
  box-shadow: 0 4px 14px rgba(26, 58, 107, 0.42);
}

.btn.secondary {
  background: #eef1f7;
  color: #1a3a6b;
  border: 1.5px solid #ccd6e8;
}
.btn.secondary:hover {
  background: #e0e8f5;
  border-color: #1a3a6b;
}

.btn.danger {
  background: linear-gradient(135deg, #a52020, #c0392b);
  color: white;
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.3);
}
.btn.danger:hover {
  background: linear-gradient(135deg, #8a1818, #a93226);
}

/* ---- Small inline table buttons ---- */
.btn-sm {
  padding: 4px 13px;
  border: none;
  border-radius: 5px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-block            { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6c6; }
.btn-block:hover      { background: #c0392b; color: white; }
.btn-unblock          { background: #edf7f0; color: #1a7a3c; border: 1px solid #b8e5c5; }
.btn-unblock:hover    { background: #1a7a3c; color: white; }

/* ---- Status badges ---- */
.status-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.status-badge.active  { background: #edf7f0; color: #1a7a3c; border: 1px solid #b8e5c5; }
.status-badge.blocked { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6c6; }

/* ---- Payment status & type badges ---- */
.payment-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: capitalize;
  white-space: nowrap;
}

.payment-badge.paid      { background: #edf7f0; color: #1a7a3c; border: 1px solid #b8e5c5; }
.payment-badge.partial   { background: #fff8e6; color: #b07800; border: 1px solid #f5d87a; }
.payment-badge.unpaid    { background: #eef1f7; color: #4a6080; border: 1px solid #ccd6e8; }
.payment-badge.overdue   { background: #fff0f0; color: #c0392b; border: 1px solid #f5c6c6; }
.payment-badge.due-soon  { background: #fff4e6; color: #c07000; border: 1px solid #ffd580; }
.payment-badge.on-track  { background: #edf7f0; color: #1a7a3c; border: 1px solid #b8e5c5; }
.payment-badge.cash-type { background: #eef1f7; color: #1a3a6b; border: 1px solid #ccd6e8; }
.payment-badge.credit-type { background: #f0ecff; color: #5b21b6; border: 1px solid #c4b5fd; }

/* ---- Overdue row highlight ---- */
.overdue-row { background: #fffaf8 !important; }
.overdue-row:hover { background: #fff3f0 !important; }

/* ---- View button in invoice table ---- */
.btn-view {
  background: #eef1f7;
  color: #1a3a6b;
  border: 1px solid #ccd6e8;
  font-weight: 600;
}
.btn-view:hover { background: #1a3a6b; color: white; }

/* ---- Invoice line-item inputs ---- */
.data-table .line-qty,
.data-table .line-price,
.data-table .line-product {
  width: 100%;
  padding: 6px 10px;
  border: 1.5px solid #ccd6e8;
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #f7f9fd;
  outline: none;
}

.data-table .line-qty:focus,
.data-table .line-price:focus,
.data-table .line-product:focus {
  border-color: #1a3a6b;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(26, 58, 107, 0.12);
}

/* ---- Totals box ---- */
.totals-box {
  max-width: 350px;
  margin-left: auto;
  margin-top: 22px;
  background: linear-gradient(135deg, #f5f8ff, #eef1f7);
  border: 1.5px solid #ccd6e8;
  border-radius: 12px;
  padding: 18px 22px;
  font-size: 14px;
}

.totals-box div {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  color: #3a5280;
}

.totals-box .grand {
  font-weight: 800;
  font-size: 18px;
  color: #0f2040;
  border-top: 2px solid #c8962c;
  margin-top: 10px;
  padding-top: 12px;
}

/* ============================================================================
   PRINTABLE INVOICE OVERLAY
   ============================================================================ */

.print-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 15, 35, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 30px;
  overflow-y: auto;
  z-index: 1000;
}

.print-sheet {
  background: white;
  width: 100%;
  max-width: 800px;
  padding: 44px 50px;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  font-size: 13px;
  color: #000;
  border-radius: 6px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
}

/* --- Government-format Tax Invoice layout (Gazette No. 2463/05) --- */

.print-invoice-title-bar {
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 8px 0 12px;
  color: #0f2040;
  border-bottom: 2px solid #1a3a6b;
  margin-bottom: 0;
}

.print-header-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #b0c0d4;
  border-top: none;
}

.print-header-left {
  border-right: 1px solid #b0c0d4;
  padding: 12px 14px;
}

.print-header-right {
  padding: 12px 14px;
}

.print-info-row {
  margin-bottom: 5px;
  font-size: 12.5px;
  line-height: 1.5;
}

.print-info-label {
  font-weight: 700;
  color: #0f2040;
  margin-right: 4px;
}

.print-info-value {
  color: #1a1a1a;
}

.print-supplier-block {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 10px;
}

.print-supplier-details {
  flex: 1;
}

.print-supplier-name {
  font-size: 16px;
  font-weight: 700;
  color: #0f2040;
  line-height: 1.3;
}

.print-supplier-sub {
  font-size: 11.5px;
  color: #444;
  line-height: 1.7;
}

.print-delivery-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid #b0c0d4;
  border-top: none;
}

.print-delivery-cell {
  padding: 7px 14px;
  font-size: 12.5px;
}

.print-delivery-cell:first-child {
  border-right: 1px solid #b0c0d4;
}

.print-additional-info {
  border: 1px solid #b0c0d4;
  border-top: none;
  padding: 7px 14px;
  font-size: 12.5px;
  min-height: 30px;
  margin-bottom: 0;
}

.print-words-block,
.print-payment-block {
  border: 1px solid #b0c0d4;
  border-top: none;
  padding: 7px 14px;
  font-size: 12.5px;
}

.print-items-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0;
  border: 1px solid #b0c0d4;
  border-top: none;
}

.print-items-table th {
  background: #0f2040;
  color: #fff;
  padding: 9px 10px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.print-items-table td {
  border: 1px solid #d0daea;
  padding: 8px 10px;
  font-size: 12.5px;
}

.print-items-table tbody tr:nth-child(even) { background: #f8fafd; }

.print-items-table td.num { text-align: right; }

.print-totals-row td {
  font-weight: 700;
  background: #eef1f7 !important;
}

.print-grand-row td {
  background: #0f2040 !important;
  color: #f5d87a !important;
  font-size: 13.5px;
}

.print-signature-block {
  display: flex;
  justify-content: space-between;
  margin-top: 100px;
  font-size: 13px;
  color: #444;
  border-top: 1px dashed #ccd6e8;
  padding-top: 20px;
}

.print-controls {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.print-tip {
  font-size: 11px;
  color: #8aaad0;
  font-style: italic;
}

/* ---- Logo ---- */
.topbar-logo {
  height: 38px;
  border-radius: 5px;
  object-fit: contain;
  flex-shrink: 0;
}

.print-logo {
  height: 52px;
  object-fit: contain;
  flex-shrink: 0;
}

/* ---- Checkbox column ---- */
.data-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #1a3a6b;
}

/* ---- Admin sections ---- */
.admin-section {
  margin-bottom: 32px;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.collapse-btn {
  background: none;
  border: 1.5px solid #ccd6e8;
  color: #1a3a6b;
  font-size: 11px;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.collapse-btn:hover {
  background: #eef1f7;
  border-color: #1a3a6b;
}

.section-body.collapsed { display: none; }

.admin-section-title {
  font-size: 15px;
  font-weight: 700;
  color: #1a3a6b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---- Danger zone ---- */
.danger-zone {
  margin-top: 40px;
  padding: 22px 26px;
  border: 2px solid #f5c6c6;
  border-radius: 12px;
  background: #fffafb;
}

.danger-zone-title {
  font-size: 15px;
  font-weight: 700;
  color: #c0392b;
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.danger-zone p {
  font-size: 13px;
  color: #7a4040;
  margin-bottom: 14px;
}

/* ---- Edit Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 15, 35, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.modal-box {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 640px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  background: linear-gradient(135deg, #0f2040, #1a3a6b);
  color: white;
}

.modal-title-text {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.15s;
}

.modal-close-btn:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

#modal-body {
  padding: 22px 24px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid #eef1f7;
  background: #f8fafd;
}

/* ---- Print media (PDF / default) ---- */
@media print {
  @page { size: A4 portrait; margin: 12mm 15mm; }

  body * { visibility: hidden; }
  .print-sheet, .print-sheet * { visibility: visible; }
  .print-sheet {
    position: fixed;
    top: 0; left: 0;
    width: 100% !important;
    max-width: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
    font-size: 11pt;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .no-print { display: none !important; }

  /* ---- Dot-matrix mode (LQ-310, 9.5"×11") ---- */
  .dot-matrix-mode,
  .dot-matrix-mode * {
    background: white !important;
    color: black !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    text-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .dot-matrix-mode .print-invoice-title-bar {
    font-size: 14pt;
    border: 2px solid black;
    padding: 5px 0;
    letter-spacing: 4px;
  }

  .dot-matrix-mode .print-header-grid,
  .dot-matrix-mode .print-header-left,
  .dot-matrix-mode .print-header-right,
  .dot-matrix-mode .print-delivery-grid,
  .dot-matrix-mode .print-delivery-cell,
  .dot-matrix-mode .print-additional-info,
  .dot-matrix-mode .print-words-block,
  .dot-matrix-mode .print-payment-block {
    border-color: black !important;
  }

  .dot-matrix-mode .print-info-label { font-weight: 900; }
  .dot-matrix-mode .print-supplier-name { font-size: 13pt; font-weight: 900; }
  .dot-matrix-mode .print-supplier-sub { font-size: 10pt; }

  .dot-matrix-mode .print-items-table,
  .dot-matrix-mode .print-items-table th,
  .dot-matrix-mode .print-items-table td {
    border: 1px solid black !important;
    font-size: 11pt;
  }

  .dot-matrix-mode .print-items-table th {
    font-weight: 900;
    text-transform: uppercase;
    font-size: 10pt;
  }

  .dot-matrix-mode .print-items-table tbody tr:nth-child(even) {
    background: white !important;
  }

  .dot-matrix-mode .print-totals-row td,
  .dot-matrix-mode .print-grand-row td {
    font-weight: 900;
    font-size: 11pt;
    border: 1px solid black !important;
  }

  .dot-matrix-mode .print-words-block,
  .dot-matrix-mode .print-payment-block { font-size: 11pt; }

  .dot-matrix-mode .print-signature-block {
    border-top: 1px solid black;
    margin-top: 40px;
    font-size: 11pt;
  }
}


/* ============================================================
   PAYMENT DASHBOARD CARDS
   ============================================================ */

.pay-dashboard {
  background: linear-gradient(135deg, #0d1e3a 0%, #1a3a6b 100%);
  border-radius: 14px;
  padding: 22px 22px 18px;
  margin-bottom: 30px;
  box-shadow: 0 8px 36px rgba(10, 24, 54, 0.32);
}

.pay-dash-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.pay-dash-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #f5d87a;
}

.pay-month-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pay-month-filter label {
  font-size: 11.5px;
  color: #8aaad0;
}

.pay-month-filter select {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 6px 30px 6px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-family: inherit;
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238aaad0'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  transition: border-color 0.15s;
}

.pay-month-filter select:focus {
  outline: none;
  border-color: #f5d87a;
}

.pay-month-filter select option {
  background: #1a3a6b;
  color: #fff;
}

.pay-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}

.pay-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 11px;
  padding: 16px 13px 13px;
  display: flex;
  align-items: center;
  gap: 11px;
  position: relative;
  overflow: hidden;
  cursor: default;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.pay-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.11);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
}

/* Coloured top accent bar */
.pay-card::after {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 11px 11px 0 0;
}

.card-pending::after    { background: linear-gradient(90deg, #f5d87a, #c8962c); }
.card-overdue::after    { background: linear-gradient(90deg, #e05b5b, #c02020); }
.card-received::after   { background: linear-gradient(90deg, #4caf8a, #2d7a5e); }
.card-collected::after  { background: linear-gradient(90deg, #c8962c, #8a6218); }
.card-outstanding::after  { background: linear-gradient(90deg, #7b9fd4, #3d66a8); }
.card-cash-inv::after    { background: linear-gradient(90deg, #56c27a, #2d8a52); }

/* Icon box */
.pay-card-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.card-pending    .pay-card-icon-box { background: rgba(245,216,122,0.14); color: #f5d87a; }
.card-overdue    .pay-card-icon-box { background: rgba(224,91,91,0.14);   color: #e07070; }
.card-received   .pay-card-icon-box { background: rgba(76,175,138,0.14);  color: #4caf8a; }
.card-collected  .pay-card-icon-box { background: rgba(200,150,44,0.14);  color: #c8962c; }
.card-outstanding .pay-card-icon-box  { background: rgba(123,159,212,0.14); color: #7b9fd4; }
.card-cash-inv   .pay-card-icon-box  { background: rgba(86,194,122,0.14);  color: #56c27a; }

.pay-card-body { flex: 1; min-width: 0; }

.pay-card-value {
  font-size: 30px;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.1;
  letter-spacing: -1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pay-card-value--sm {
  font-size: 16px;
  letter-spacing: -0.2px;
}

.pay-card-label {
  font-size: 10px;
  color: #8aaad0;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  margin-top: 4px;
}

.pay-card-sub {
  font-size: 10px;
  color: #4e6a8a;
  margin-top: 2px;
}

/* ============================================================
   RESPONSIVE — Tablet & Mobile
   ============================================================ */

/* ---- Tablet (≤ 768px) ---- */
@media (max-width: 768px) {
  .topbar {
    padding: 0 14px;
    height: auto;
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-title {
    padding: 10px 0;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }

  /* Tabs wrap into a 3-per-row grid (DWPMS pattern) */
  .tabs {
    flex-wrap: wrap;
    gap: 3px;
    padding: 5px 0 8px;
    overflow: visible;
  }

  .tab-btn {
    flex: 1 0 calc(33.333% - 2px);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 12px;
    padding: 8px 6px;
    min-width: 0;
    border-radius: 7px;
  }

  .container {
    padding: 0 12px;
    margin: 12px auto;
  }

  .tab-panel {
    padding: 20px 16px;
  }

  .pay-cards {
    grid-template-columns: repeat(3, 1fr);
  }

  .pay-dash-header {
    flex-wrap: wrap;
    gap: 10px;
  }

  /* Print view — stack two-column header & delivery grids */
  .print-header-grid {
    grid-template-columns: 1fr;
  }
  .print-header-left {
    border-right: none;
    border-bottom: 1px solid #b0c0d4;
  }
  .print-delivery-grid {
    grid-template-columns: 1fr;
  }
  .print-delivery-cell:first-child {
    border-right: none;
    border-bottom: 1px solid #b0c0d4;
  }
  .print-items-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .print-signature-block {
    flex-direction: column;
    gap: 20px;
    margin-top: 40px;
  }
  /* Print controls: stack buttons on narrow screens */
  .print-controls {
    flex-direction: column;
    align-items: stretch;
  }
  .print-controls .btn {
    width: 100%;
    justify-content: center;
    margin: 0;
  }
  .print-tip {
    text-align: center;
  }
}

/* ---- Mobile (≤ 540px) ---- */
@media (max-width: 540px) {
  /* Topbar */
  .topbar-title {
    font-size: 13px;
    gap: 8px;
  }
  .topbar-title::before {
    width: 3px;
    height: 18px;
  }
  .topbar-logo { height: 26px; }

  .tab-btn {
    font-size: 11px;
    padding: 7px 4px;
  }

  /* Container & panel */
  .container {
    padding: 0 8px;
    margin: 8px auto;
  }
  .tab-panel {
    padding: 14px 12px;
    border-radius: 10px;
  }
  .tab-panel h2 {
    font-size: 16px;
    margin-bottom: 14px;
    padding-bottom: 10px;
  }
  .tab-panel h3 {
    font-size: 13px;
    margin: 18px 0 8px;
  }

  /* Data tables — horizontal scroll */
  .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 12.5px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }

  /* Form grids — single column */
  .form-grid {
    grid-template-columns: 1fr !important;
    gap: 10px;
  }

  /* Totals box — full width */
  .totals-box {
    max-width: 100%;
    margin-top: 14px;
  }

  /* Buttons */
  .btn {
    font-size: 12.5px;
    padding: 8px 15px;
    margin: 6px 6px 6px 0;
  }

  /* Payment dashboard */
  .pay-dashboard {
    padding: 14px 12px 12px;
    border-radius: 10px;
    margin-bottom: 20px;
  }
  .pay-dash-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }
  .pay-month-filter {
    width: 100%;
    justify-content: space-between;
  }
  .pay-month-filter select {
    flex: 1;
  }
  .pay-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .pay-card {
    padding: 12px 9px 10px;
    gap: 8px;
    border-radius: 9px;
  }
  .pay-card-icon-box {
    width: 34px;
    height: 34px;
    font-size: 8.5px;
    border-radius: 8px;
    flex-shrink: 0;
  }
  .pay-card-value {
    font-size: 22px;
    letter-spacing: -0.5px;
  }
  .pay-card-value--sm {
    font-size: 13px;
    letter-spacing: 0;
  }
  .pay-card-label {
    font-size: 8.5px;
    letter-spacing: 0.5px;
    margin-top: 3px;
  }
  .pay-card-sub {
    font-size: 9px;
  }

  /* Modal — near full screen */
  .modal-overlay {
    padding: 12px;
  }
  .modal-box {
    border-radius: 12px;
  }
  .modal-header {
    padding: 14px 16px;
  }
  #modal-body {
    padding: 16px;
    max-height: 65vh;
  }
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }

  /* Admin */
  .danger-zone {
    padding: 16px;
  }

  /* Print overlay */
  .print-overlay {
    padding: 6px;
  }
  .print-sheet {
    padding: 14px 12px;
    font-size: 12px;
    border-radius: 4px;
  }
  .print-invoice-title-bar {
    font-size: 13px;
    letter-spacing: 1.5px;
  }
  .print-supplier-name { font-size: 13px; }
  .print-supplier-sub  { font-size: 10.5px; }
  .print-logo          { height: 38px; }
  .print-words-block,
  .print-payment-block,
  .print-delivery-cell,
  .print-additional-info,
  .print-info-row      { font-size: 11.5px; }
  .print-controls {
    gap: 6px;
    margin-top: 10px;
    padding: 0 6px;
  }
  .print-tip { font-size: 10px; }

  /* Toast: sit below the taller stacked topbar */
  .toast {
    top: 96px;
    right: 10px;
    left: 10px;
    max-width: none;
  }

  /* Add-line button wrapper */
  #add-line-btn {
    width: 100%;
    justify-content: center;
    margin-top: 6px;
  }
}
