/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:CSS-START] */
.tfh-transport-invoice-screen {
  width: 100vw;
  height: 100dvh;
  position: fixed;
  inset: 0;
  z-index: 46;
  display: grid;
  grid-template-rows: auto minmax(0,1fr) auto;
  overflow: hidden;
  background:
    radial-gradient(circle at 90% 0%, rgba(185,135,50,.13), transparent 28%),
    linear-gradient(135deg,#eaf1f7,#f8fafc 48%,#e7eef5);
}

.tfh-transport-invoice-body {
  min-height: 0;
  overflow: auto;
  padding: 14px 16px 18px;
}

.tfh-transport-invoice-form {
  width: min(1580px,100%);
  margin: auto;
  display: grid;
  gap: 13px;
}

.tfh-invoice-header-card,
.tfh-invoice-lines-card,
.tfh-invoice-bottom-grid {
  border: 1px solid rgba(17,49,84,.13);
  border-radius: 15px;
  background: rgba(255,255,255,.97);
  box-shadow: 0 10px 30px rgba(18,52,92,.08);
}

.tfh-invoice-header-card { padding: 14px; }

.tfh-invoice-header-top {
  display: grid;
  grid-template-columns: minmax(240px,auto) 160px minmax(180px,1fr) minmax(180px,1fr);
  gap: 12px;
  align-items: end;
}

.tfh-invoice-status-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.tfh-invoice-status-button {
  min-height: 45px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--tfh-line);
  border-radius: 10px;
  background: #f4f7fa;
  color: #6c7b8d;
  font-size: .73rem;
  cursor: pointer;
}

.tfh-invoice-status-button.is-active {
  border-color: rgba(24,121,78,.45);
  color: #11683f;
  background: linear-gradient(#effbf5,#dff5e9);
  box-shadow: 0 0 0 3px rgba(24,121,78,.08);
}

.tfh-invoice-party-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1.35fr 1fr 1fr .8fr;
  gap: 11px;
}
.tfh-invoice-address-field { grid-column: 1 / -1; }

.tfh-invoice-lines-card {
  min-height: 390px;
  padding: 12px;
  border-top: 4px solid var(--tfh-gold-500);
}

.tfh-invoice-lines-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.tfh-invoice-lines-toolbar > div:first-child span {
  color: var(--tfh-blue-600);
  font-size: .59rem;
  font-weight: 850;
  letter-spacing: .13em;
  text-transform: uppercase;
}
.tfh-invoice-lines-toolbar h2 { margin: 2px 0 0; font-size: 1rem; }

.tfh-invoice-line-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}
.tfh-invoice-line-actions .tfh-primary-button,
.tfh-invoice-line-actions .tfh-secondary-button,
.tfh-invoice-line-actions .tfh-danger-button {
  min-height: 37px;
  padding: 7px 11px;
  font-size: .67rem;
}

.tfh-invoice-sort-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--tfh-line);
  border-radius: 9px;
  background: #eef3f7;
}
.tfh-invoice-sort-toggle button {
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: 7px;
  color: #687789;
  background: transparent;
  font-size: .62rem;
  font-weight: 800;
  cursor: pointer;
}
.tfh-invoice-sort-toggle button.is-active {
  color: #fff;
  background: var(--tfh-blue-600);
  box-shadow: 0 4px 10px rgba(29,95,159,.22);
}

.tfh-invoice-grid-wrap {
  width: 100%;
  max-height: 380px;
  overflow: auto;
  border: 1px solid var(--tfh-line);
  border-radius: 11px;
}

.tfh-invoice-grid {
  width: 100%;
  min-width: 2020px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

.tfh-invoice-grid th {
  position: sticky;
  top: 0;
  z-index: 3;
  padding: 9px 6px;
  color: #fff;
  background: linear-gradient(#55728e,#263f58);
  font-size: .57rem;
  white-space: nowrap;
  text-align: left;
}
.tfh-invoice-grid td {
  padding: 4px;
  border-right: 1px solid #e3e9ef;
  border-bottom: 1px solid #e3e9ef;
  vertical-align: middle;
  font-size: .64rem;
}
.tfh-invoice-grid tr.is-selected td {
  background: #eef6fd;
  box-shadow: inset 0 1px 0 rgba(47,127,196,.22), inset 0 -1px 0 rgba(47,127,196,.22);
}

.tfh-invoice-grid input,
.tfh-invoice-grid textarea {
  width: 100%;
  min-height: 34px;
  padding: 5px 6px;
  border: 1px solid #d3dde7;
  border-radius: 6px;
  background: #fff;
  font-size: .63rem;
}
.tfh-invoice-grid textarea { resize: none; }

.tfh-invoice-grid th:nth-child(1), .tfh-invoice-grid td:nth-child(1) { width: 42px; text-align:center; }
.tfh-invoice-grid th:nth-child(2), .tfh-invoice-grid td:nth-child(2) { width: 116px; }
.tfh-invoice-grid th:nth-child(3), .tfh-invoice-grid td:nth-child(3) { width: 245px; }
.tfh-invoice-grid th:nth-child(4), .tfh-invoice-grid td:nth-child(4) { width: 155px; }
.tfh-invoice-grid th:nth-child(5), .tfh-invoice-grid td:nth-child(5) { width: 175px; }
.tfh-invoice-grid th:nth-child(6), .tfh-invoice-grid td:nth-child(6),
.tfh-invoice-grid th:nth-child(7), .tfh-invoice-grid td:nth-child(7) { width: 100px; }
.tfh-invoice-grid th:nth-child(8), .tfh-invoice-grid td:nth-child(8) { width: 82px; text-align:center; }
.tfh-invoice-grid th:nth-child(n+9), .tfh-invoice-grid td:nth-child(n+9) { width: 102px; text-align:right; }

.tfh-inv-calculated {
  color: #27445f;
  background: #f4f7fa;
  font-weight: 800;
}
.tfh-inv-net {
  color: #765700;
  background: #fff8d8;
  font-weight: 900;
}
.tfh-inv-driver-pay {
  color: #11683f;
  background: #e8f7ef;
  font-weight: 900;
}

.tfh-mini-switch {
  display: inline-grid;
  place-items: center;
  cursor: pointer;
}
.tfh-mini-switch input { position:absolute; opacity:0; pointer-events:none; }
.tfh-mini-switch span {
  min-width: 48px;
  padding: 6px;
  border-radius: 999px;
  color: #fff;
  background: #1d5f9f;
  text-align:center;
  font-size:.54rem;
  font-weight:900;
}
.tfh-mini-switch input:checked + span { background:#9e6c20; }

.tfh-invoice-grid-empty {
  height: 100px;
  color: #788697;
  text-align: center !important;
}

.tfh-invoice-grid-summary {
  display:flex;
  gap:18px;
  justify-content:flex-end;
  padding:9px 3px 0;
  color:#607084;
  font-size:.67rem;
}
.tfh-invoice-grid-summary span { margin-right:auto; }
.tfh-invoice-grid-summary b { color:var(--tfh-navy-800); }

.tfh-invoice-bottom-grid {
  display:grid;
  grid-template-columns:1fr 1fr 330px;
  gap:12px;
  padding:12px;
}

.tfh-invoice-totals-card {
  overflow:hidden;
  border:1px solid rgba(17,49,84,.14);
  border-radius:11px;
  background:#f8fafc;
}
.tfh-invoice-totals-card > div,
.tfh-invoice-totals-card > label {
  min-height:42px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:7px 11px;
  border-bottom:1px solid rgba(17,49,84,.1);
  font-size:.72rem;
}
.tfh-invoice-totals-card input {
  width:120px;
  height:30px;
  padding:4px 7px;
  border:1px solid #d4dde7;
  border-radius:6px;
  text-align:right;
  font-weight:800;
}
.tfh-invoice-totals-card .is-net {
  color:#fff;
  background:linear-gradient(135deg,#12345c,#1d5f9f);
}
.tfh-invoice-totals-card strong { font-variant-numeric:tabular-nums; }

@media (max-width: 1050px) {
  .tfh-invoice-header-top { grid-template-columns: 1fr 1fr; }
  .tfh-invoice-party-grid { grid-template-columns: 1fr 1fr; }
  .tfh-invoice-bottom-grid { grid-template-columns: 1fr; }
}
@media (max-width: 650px) {
  .tfh-invoice-header-top,
  .tfh-invoice-party-grid { grid-template-columns: 1fr; }
  .tfh-invoice-lines-toolbar { align-items:flex-start; flex-direction:column; }
}
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:CSS-END] */
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:V023-CSS-START] */
.tfh-transport-invoice-body {
  overflow-x: hidden;
}

.tfh-transport-invoice-form,
.tfh-invoice-lines-card {
  min-width: 0;
  max-width: 100%;
}

.tfh-invoice-lines-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

/*
 * Toolbar remains outside the scrolling table.
 * Only the grid viewport owns vertical and horizontal scrolling.
 */
.tfh-invoice-grid-wrap {
  width: 100%;
  min-width: 0;
  height: clamp(245px, 38vh, 405px);
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
  touch-action: pan-x pan-y;
}

.tfh-invoice-grid {
  width: 100%;
  min-width: 1515px;
}

/* Compact desktop widths designed for an approximately 1650px screen. */
.tfh-invoice-grid th:nth-child(1),
.tfh-invoice-grid td:nth-child(1) {
  width: 34px;
}

.tfh-invoice-grid th:nth-child(2),
.tfh-invoice-grid td:nth-child(2) {
  width: 102px;
}

.tfh-invoice-grid th:nth-child(3),
.tfh-invoice-grid td:nth-child(3) {
  width: 205px;
}

.tfh-invoice-grid th:nth-child(4),
.tfh-invoice-grid td:nth-child(4) {
  width: 128px;
}

.tfh-invoice-grid th:nth-child(5),
.tfh-invoice-grid td:nth-child(5) {
  width: 150px;
}

.tfh-invoice-grid th:nth-child(6),
.tfh-invoice-grid td:nth-child(6),
.tfh-invoice-grid th:nth-child(7),
.tfh-invoice-grid td:nth-child(7),
.tfh-invoice-grid th:nth-child(8),
.tfh-invoice-grid td:nth-child(8) {
  width: 82px;
}

.tfh-invoice-grid th:nth-child(9),
.tfh-invoice-grid td:nth-child(9),
.tfh-invoice-grid th:nth-child(10),
.tfh-invoice-grid td:nth-child(10) {
  width: 88px;
}

.tfh-invoice-grid th:nth-child(11),
.tfh-invoice-grid td:nth-child(11) {
  width: 67px;
}

.tfh-invoice-grid th:nth-child(12),
.tfh-invoice-grid td:nth-child(12),
.tfh-invoice-grid th:nth-child(13),
.tfh-invoice-grid td:nth-child(13),
.tfh-invoice-grid th:nth-child(14),
.tfh-invoice-grid td:nth-child(14),
.tfh-invoice-grid th:nth-child(15),
.tfh-invoice-grid td:nth-child(15),
.tfh-invoice-grid th:nth-child(16),
.tfh-invoice-grid td:nth-child(16),
.tfh-invoice-grid th:nth-child(17),
.tfh-invoice-grid td:nth-child(17) {
  width: 83px;
}

.tfh-invoice-grid th,
.tfh-invoice-grid td {
  min-width: 0;
}

.tfh-invoice-grid th {
  padding: 8px 4px;
  font-size: .53rem;
}

.tfh-invoice-grid td {
  padding: 3px;
}

.tfh-invoice-grid input,
.tfh-invoice-grid textarea {
  min-height: 32px;
  padding: 4px 5px;
  font-size: .61rem;
}

.tfh-invoice-grid textarea {
  min-height: 44px;
}

.tfh-invoice-grid .tfh-inv-driver-head {
  background: linear-gradient(#5d725d, #304c36);
}

.tfh-invoice-grid .tfh-inv-client-head {
  background: linear-gradient(#55728e, #263f58);
}

.tfh-inv-driver-input {
  background: #f3faf6;
}

.tfh-invoice-line-actions {
  flex-wrap: nowrap;
}

.tfh-invoice-validation-layer {
  position: fixed;
  inset: 0;
  z-index: 122;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 16, 31, .64);
  backdrop-filter: blur(8px);
}

.tfh-invoice-validation-card {
  position: relative;
  width: min(470px, 100%);
  padding: 28px;
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 28px 70px rgba(4,16,31,.32);
  text-align: center;
}

.tfh-invoice-validation-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #8a6200;
  background: linear-gradient(#fff7cf,#f6df83);
  box-shadow: 0 0 0 7px rgba(185,135,50,.11);
  font-family: Georgia, serif;
  font-size: 2rem;
  font-weight: 800;
}

.tfh-invoice-validation-card h2 {
  margin: 6px 0 8px;
  color: var(--tfh-navy-900);
}

.tfh-invoice-validation-card p {
  margin: 0;
  color: var(--tfh-ink-600);
}

.tfh-invoice-validation-card ul {
  margin: 17px 0 21px;
  padding: 0;
  display: grid;
  gap: 8px;
  list-style: none;
  text-align: left;
}

.tfh-invoice-validation-card li {
  position: relative;
  padding: 10px 12px 10px 36px;
  border: 1px solid rgba(180,35,24,.13);
  border-radius: 10px;
  color: #7c2720;
  background: #fff7f6;
  font-size: .82rem;
  font-weight: 720;
}

.tfh-invoice-validation-card li::before {
  content: "!";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  display: grid;
  place-items: center;
  transform: translateY(-50%);
  border-radius: 50%;
  color: #fff;
  background: var(--tfh-danger);
  font-size: .63rem;
}

@media (min-width: 1650px) {
  .tfh-invoice-grid {
    min-width: 100%;
  }
}

@media (max-width: 1100px) {
  .tfh-invoice-line-actions {
    flex-wrap: wrap;
  }

  .tfh-invoice-grid {
    min-width: 1450px;
  }
}

@media (max-width: 700px) {
  .tfh-transport-invoice-body {
    padding-inline: 8px;
  }

  .tfh-invoice-lines-card {
    padding-inline: 8px;
  }

  .tfh-invoice-grid-wrap {
    height: clamp(280px, 48vh, 440px);
  }

  .tfh-invoice-grid {
    min-width: 1380px;
  }
}
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:V023-CSS-END] */
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:V024-CSS-START] */

/* Database-only Client field and compact guest-information row. */
.tfh-invoice-party-grid {
  grid-template-columns:
    minmax(250px, 1.45fr)
    minmax(170px, .9fr)
    minmax(185px, .95fr)
    minmax(145px, .72fr)
    minmax(240px, 1.15fr);
  align-items: end;
  gap: 9px;
}

.tfh-invoice-address-field {
  grid-column: auto;
}

.tfh-invoice-address-field textarea {
  min-height: 40px;
  max-height: 44px;
  resize: vertical;
}

.tfh-invoice-client-field .tfh-field-help {
  margin-top: 4px;
  font-size: .6rem;
}

/*
 * Invoice grid uses the requested Segoe UI 12-point presentation.
 * Financial columns through Amount are prioritized within a 1650px view.
 */
.tfh-invoice-grid,
.tfh-invoice-grid input,
.tfh-invoice-grid textarea,
.tfh-invoice-grid select {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12pt;
}

.tfh-invoice-grid th {
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 9.5pt;
}

.tfh-invoice-grid {
  min-width: 1780px;
}

/* Upfront columns: # through Amount */
.tfh-invoice-grid th:nth-child(1),
.tfh-invoice-grid td:nth-child(1) { width: 34px; }

.tfh-invoice-grid th:nth-child(2),
.tfh-invoice-grid td:nth-child(2) { width: 112px; }

.tfh-invoice-grid th:nth-child(3),
.tfh-invoice-grid td:nth-child(3) { width: 230px; }

.tfh-invoice-grid th:nth-child(4),
.tfh-invoice-grid td:nth-child(4) { width: 140px; }

.tfh-invoice-grid th:nth-child(5),
.tfh-invoice-grid td:nth-child(5) { width: 165px; }

.tfh-invoice-grid th:nth-child(6),
.tfh-invoice-grid td:nth-child(6),
.tfh-invoice-grid th:nth-child(7),
.tfh-invoice-grid td:nth-child(7),
.tfh-invoice-grid th:nth-child(8),
.tfh-invoice-grid td:nth-child(8) { width: 88px; }

/* Time fields widened by about 10px. */
.tfh-invoice-grid th:nth-child(9),
.tfh-invoice-grid td:nth-child(9),
.tfh-invoice-grid th:nth-child(10),
.tfh-invoice-grid td:nth-child(10) { width: 104px; }

.tfh-invoice-grid th:nth-child(11),
.tfh-invoice-grid td:nth-child(11) { width: 72px; }

.tfh-invoice-grid th:nth-child(12),
.tfh-invoice-grid td:nth-child(12),
.tfh-invoice-grid th:nth-child(13),
.tfh-invoice-grid td:nth-child(13),
.tfh-invoice-grid th:nth-child(14),
.tfh-invoice-grid td:nth-child(14) { width: 92px; }

/* Remaining columns intentionally continue in local horizontal scroll. */
.tfh-invoice-grid th:nth-child(15),
.tfh-invoice-grid td:nth-child(15),
.tfh-invoice-grid th:nth-child(16),
.tfh-invoice-grid td:nth-child(16),
.tfh-invoice-grid th:nth-child(17),
.tfh-invoice-grid td:nth-child(17) { width: 96px; }

.tfh-invoice-grid input,
.tfh-invoice-grid textarea {
  min-height: 36px;
  padding: 5px 6px;
}

.tfh-invoice-grid input[type="time"] {
  min-width: 94px;
}

@media (min-width: 1650px) {
  .tfh-invoice-grid-wrap {
    overflow-x: auto;
  }

  .tfh-invoice-grid {
    min-width: 1780px;
  }
}

@media (max-width: 1200px) {
  .tfh-invoice-party-grid {
    grid-template-columns: 1fr 1fr;
  }

  .tfh-invoice-address-field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .tfh-invoice-party-grid {
    grid-template-columns: 1fr;
  }

  .tfh-invoice-address-field {
    grid-column: auto;
  }
}
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:V024-CSS-END] */
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:V025-CSS-START] */

/* Client and guest fields align evenly after helper text removal. */
.tfh-invoice-party-grid {
  align-items: start;
}

.tfh-invoice-party-grid > .tfh-form-field {
  min-width: 0;
}

.tfh-invoice-party-grid .tfh-form-field > span {
  min-height: 18px;
  display: flex;
  align-items: center;
}

.tfh-invoice-party-grid input,
.tfh-invoice-party-grid textarea {
  min-height: 42px;
}

.tfh-invoice-address-field textarea {
  height: 42px;
  min-height: 42px;
  max-height: 42px;
  resize: none;
}

/* Refined line-grid proportions. */
.tfh-invoice-grid {
  min-width: 1855px;
}

/* Date +20px */
.tfh-invoice-grid th:nth-child(2),
.tfh-invoice-grid td:nth-child(2) {
  width: 132px;
}

/* Description +55px */
.tfh-invoice-grid th:nth-child(3),
.tfh-invoice-grid td:nth-child(3) {
  width: 285px;
}

/* Vehicle +30px */
.tfh-invoice-grid th:nth-child(4),
.tfh-invoice-grid td:nth-child(4) {
  width: 170px;
}

/* Driver widened; financial values nested underneath. */
.tfh-invoice-grid th:nth-child(5),
.tfh-invoice-grid td:nth-child(5) {
  width: 225px;
}

/* Time fields +15px */
.tfh-invoice-grid th:nth-child(6),
.tfh-invoice-grid td:nth-child(6),
.tfh-invoice-grid th:nth-child(7),
.tfh-invoice-grid td:nth-child(7) {
  width: 119px;
}

.tfh-invoice-grid th:nth-child(8),
.tfh-invoice-grid td:nth-child(8) {
  width: 76px;
}

.tfh-invoice-grid th:nth-child(9),
.tfh-invoice-grid td:nth-child(9),
.tfh-invoice-grid th:nth-child(10),
.tfh-invoice-grid td:nth-child(10),
.tfh-invoice-grid th:nth-child(11),
.tfh-invoice-grid td:nth-child(11),
.tfh-invoice-grid th:nth-child(12),
.tfh-invoice-grid td:nth-child(12),
.tfh-invoice-grid th:nth-child(13),
.tfh-invoice-grid td:nth-child(13) {
  width: 96px;
}

.tfh-invoice-grid th:nth-child(14),
.tfh-invoice-grid td:nth-child(14) {
  width: 115px;
  min-width: 115px;
}

/* Headings centered directly over their values. */
.tfh-invoice-grid th {
  text-align: center !important;
  vertical-align: middle;
}

.tfh-invoice-grid th small {
  display: block;
  margin-top: 2px;
  font-size: 8pt;
  font-weight: 650;
  opacity: .82;
}

/* Inputs and values align consistently. */
.tfh-invoice-grid td {
  vertical-align: middle;
}

.tfh-invoice-grid td:nth-child(n+8),
.tfh-invoice-grid input[inputmode="decimal"] {
  text-align: right;
}

.tfh-invoice-grid td:nth-child(9),
.tfh-invoice-grid td:nth-child(10),
.tfh-invoice-grid td:nth-child(11),
.tfh-invoice-grid td:nth-child(12),
.tfh-invoice-grid td:nth-child(13),
.tfh-invoice-grid td:nth-child(14) {
  text-align: right;
}

.tfh-invoice-grid td:nth-child(9) input,
.tfh-invoice-grid td:nth-child(10) input,
.tfh-invoice-grid td:nth-child(12) input,
.tfh-invoice-grid td:nth-child(13) input {
  text-align: right;
}

/* Driver stack presentation. */
.tfh-inv-driver-stack {
  display: grid;
  gap: 5px;
}

.tfh-inv-driver-financials {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.tfh-inv-driver-financials input,
.tfh-inv-driver-financials .tfh-inv-readonly-field {
  min-width: 0;
  min-height: 28px;
  height: 28px;
  padding: 3px 4px;
  font-size: 10pt;
  text-align: right;
}

/* Read-only calculated values match editable field typography. */
.tfh-inv-readonly-field {
  width: 100%;
  min-height: 36px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 5px 6px;
  border: 1px solid #d3dde7;
  border-radius: 6px;
  background: #f4f7fa;
  color: var(--tfh-ink-900);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 12pt;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.tfh-inv-calculated,
.tfh-inv-net,
.tfh-inv-driver-pay {
  font-size: 12pt !important;
}

.tfh-inv-calculated .tfh-inv-readonly-field {
  background: #f4f7fa;
}

.tfh-inv-net .tfh-inv-readonly-field {
  background: #fff8d8;
  color: #765700;
}

.tfh-invoice-grid input[type="time"] {
  min-width: 109px;
}

/* Ensure last column is fully reachable in local horizontal scroll. */
.tfh-invoice-grid-wrap {
  padding-right: 16px;
  scroll-padding-right: 24px;
}

.tfh-invoice-grid::after {
  content: "";
  display: table-cell;
  width: 10px;
}

@media (min-width: 1650px) {
  .tfh-invoice-grid {
    min-width: 1855px;
  }
}

/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:V025-CSS-END] */
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:CSS-GRID-SPACE-START] */
/*
  Transport Invoice Entry - lines grid layout
  2026-09-25          : maximum rows on screen, one row per line, sortable headers,
                        compact header card and horizontal totals strip.
  2026-09-25 (refine 2): screen uses the full monitor width; grid runs edge to edge in
                        its card (no gutter before the header); every column wide enough
                        for its heading and values (no clipped values); Description wraps
                        and grows with its text (and can be stretched by hand); all cells
                        top-aligned; user-resizable columns (drag header edge, double-click
                        to reset). Column widths come from TFH_applyTransportInvoiceColumnLayout().
  Scoped to #tfhTransportInvoiceScreen: Flight / Hotel / Receipt / Payment grids are not affected.
*/
#tfhTransportInvoiceScreen {
  --tfh-inv-ctl-h: 36px;
  --tfh-inv-cell-h: 30px;
  --tfh-inv-grid-line: #d5dee7;
}

#tfhTransportInvoiceScreen .tfh-transport-invoice-body {
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 14px;
}

#tfhTransportInvoiceScreen .tfh-transport-invoice-form {
  width: 100%;
  max-width: none;
  flex: 1 0 auto;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

/* ---------- Header card (same layout, compact) ---------- */
#tfhTransportInvoiceScreen .tfh-invoice-header-card {
  flex: 0 0 auto;
  gap: 8px;
  padding: 10px 14px 12px;
}

#tfhTransportInvoiceScreen .tfh-invoice-header-top,
#tfhTransportInvoiceScreen .tfh-invoice-party-grid {
  gap: 9px;
  align-items: end;
}

#tfhTransportInvoiceScreen .tfh-invoice-header-card .tfh-form-field {
  gap: 4px;
  min-width: 0;
}

#tfhTransportInvoiceScreen .tfh-invoice-header-card .tfh-form-field > span,
#tfhTransportInvoiceScreen .tfh-invoice-bottom-grid .tfh-form-field > span {
  font-size: .72rem;
  line-height: 1.2;
}

#tfhTransportInvoiceScreen .tfh-invoice-header-card input,
#tfhTransportInvoiceScreen .tfh-invoice-header-card textarea {
  height: var(--tfh-inv-ctl-h);
  min-height: var(--tfh-inv-ctl-h);
  padding: 0 10px;
  border-radius: 7px;
  font-size: .88rem;
}

#tfhTransportInvoiceScreen .tfh-invoice-header-card textarea {
  padding-top: 8px;
  resize: none;
  font-family: inherit;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
}

#tfhTransportInvoiceScreen .tfh-invoice-status-button,
#tfhTransportInvoiceScreen .tfh-invoice-header-card .tfh-mode-button {
  min-height: var(--tfh-inv-ctl-h);
  height: var(--tfh-inv-ctl-h);
  padding-top: 0;
  padding-bottom: 0;
}

/* ---------- Lines card: toolbar on top, grid edge to edge below ---------- */
#tfhTransportInvoiceScreen .tfh-invoice-lines-card {
  flex: 1 1 0;
  min-height: 250px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  padding: 0;
  overflow: hidden;
}

#tfhTransportInvoiceScreen .tfh-invoice-lines-toolbar {
  min-height: 0;
  align-items: center;
  gap: 12px;
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--tfh-inv-grid-line);
}

#tfhTransportInvoiceScreen .tfh-invoice-lines-title {
  min-width: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 16px;
}

#tfhTransportInvoiceScreen .tfh-invoice-lines-title h2 {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.2;
  white-space: nowrap;
}

#tfhTransportInvoiceScreen .tfh-invoice-lines-title .tfh-invoice-grid-summary {
  width: auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 3px 12px;
  border: 1px solid #d3dde6;
  border-radius: 999px;
  background: #f4f7fa;
  color: #5b6b7c;
  font-size: .74rem;
  white-space: nowrap;
}

#tfhTransportInvoiceScreen .tfh-invoice-lines-title .tfh-invoice-grid-summary strong {
  font-weight: 600;
}

#tfhTransportInvoiceScreen .tfh-invoice-lines-title .tfh-invoice-grid-summary b {
  color: #0f2c47;
}

#tfhTransportInvoiceScreen .tfh-invoice-line-actions {
  gap: 8px;
}

#tfhTransportInvoiceScreen .tfh-invoice-line-actions button {
  min-height: 34px;
  height: 34px;
  padding: 0 14px;
  font-size: .8rem;
}

/* Grid area: no side padding, no reserved scrollbar gutter, no border inside the card */
#tfhTransportInvoiceScreen .tfh-invoice-grid-wrap {
  width: 100%;
  height: auto;
  min-height: 0;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  scrollbar-gutter: auto;
  scroll-padding: 0;
  background: #fff;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid {
  min-width: 0;
  max-width: none;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .84rem;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid::after {
  display: none;
  content: none;
}

/* Widths come from <colgroup> (set in JS), never from the older per-cell rules */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th,
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td {
  width: auto;
  min-width: 0;
  max-width: none;
}

/* ---------- Header ---------- */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 40px;
  padding: 0;
  font-size: .74rem;
  line-height: 1.15;
  vertical-align: middle;
  white-space: normal;
  border-right: 1px solid rgba(255,255,255,.14);
}

#tfhTransportInvoiceScreen .tfh-inv-sort-button {
  width: 100%;
  min-height: 40px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 3px 12px 3px 8px;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: 700;
  text-align: center;
  background: transparent;
  cursor: pointer;
}

#tfhTransportInvoiceScreen .tfh-inv-sort-button:hover,
#tfhTransportInvoiceScreen .tfh-inv-sort-button.is-active {
  background: rgba(255,255,255,.12);
}

#tfhTransportInvoiceScreen .tfh-inv-sort-label {
  min-width: 0;
  overflow-wrap: normal;
  word-break: normal;
}

#tfhTransportInvoiceScreen .tfh-inv-sort-arrow {
  flex: 0 0 auto;
  font-size: .62rem;
  line-height: 1;
}

#tfhTransportInvoiceScreen .tfh-inv-sort-button:not(.is-active) .tfh-inv-sort-arrow {
  opacity: .45;
}

/* Column resize handle (right edge of every heading) */
#tfhTransportInvoiceScreen .tfh-inv-col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 6;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  touch-action: none;
}

#tfhTransportInvoiceScreen .tfh-inv-col-resizer::after {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  right: 0;
  width: 1px;
  background: rgba(255,255,255,.35);
}

#tfhTransportInvoiceScreen th:hover .tfh-inv-col-resizer::after,
#tfhTransportInvoiceScreen th.is-resizing .tfh-inv-col-resizer::after {
  top: 0;
  bottom: 0;
  right: 0;
  width: 3px;
  background: #d8b56e;
}

body.tfh-col-resizing,
body.tfh-col-resizing * {
  cursor: col-resize !important;
  user-select: none !important;
}

/* ---------- Rows: all cells top-aligned ---------- */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td {
  height: auto;
  padding: 4px 4px;
  vertical-align: top;
  border-bottom: 1px solid var(--tfh-inv-grid-line);
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid td input,
#tfhTransportInvoiceScreen .tfh-transport-lines-grid .tfh-inv-readonly-field {
  width: 100%;
  min-width: 0;
  height: var(--tfh-inv-cell-h);
  min-height: var(--tfh-inv-cell-h);
  padding: 0 8px;
  border-radius: 6px;
  font-size: .84rem !important;
  line-height: calc(var(--tfh-inv-cell-h) - 2px);
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid td input[type="time"],
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td input[type="date"] {
  min-width: 0;
  padding-right: 4px;
}

/* Description: wraps, grows with its content, can be stretched by hand */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td textarea {
  display: block;
  width: 100%;
  min-width: 0;
  height: var(--tfh-inv-cell-h);
  min-height: var(--tfh-inv-cell-h);
  padding: 5px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: .84rem !important;
  line-height: 1.3;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow: hidden;
  resize: vertical;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid .tfh-inv-line-number {
  line-height: var(--tfh-inv-cell-h);
  text-align: center;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid .tfh-mini-switch {
  height: var(--tfh-inv-cell-h);
  display: flex;
  align-items: center;
  justify-content: center;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid .tfh-mini-switch span {
  font-size: .64rem;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid .tfh-inv-calculated,
#tfhTransportInvoiceScreen .tfh-transport-lines-grid .tfh-inv-net {
  font-size: .84rem !important;
}

/* Numbers right-aligned (Driver Rate onwards, except Time In / Time Out / Manual) */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(n+6):not(:nth-child(9)):not(:nth-child(10)):not(:nth-child(11)) input,
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(n+6) .tfh-inv-readonly-field {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* #, Trip Date, Description fixed on the left while scrolling sideways (offsets from JS) */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(-n+3),
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(-n+3) {
  position: sticky;
  z-index: 2;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(-n+3) { z-index: 5; }
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(1),
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(1) { left: var(--tfh-line-sticky-1, 0px); }
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(2),
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(2) { left: var(--tfh-line-sticky-2, 46px); }
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(3),
#tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(3) { left: var(--tfh-line-sticky-3, 188px); }

#tfhTransportInvoiceScreen .tfh-transport-lines-grid.is-scrolling-x th:nth-child(3),
#tfhTransportInvoiceScreen .tfh-transport-lines-grid.is-scrolling-x td:nth-child(3) {
  box-shadow: 6px 0 8px -6px rgba(15,44,71,.28);
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid tbody td:nth-child(-n+3) {
  background: #fff;
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid tbody tr.is-selected td:nth-child(-n+3) {
  background: #e9f2fb;
}

/* Driver columns: subtle group tint */
#tfhTransportInvoiceScreen .tfh-transport-lines-grid th.tfh-inv-driver-head {
  background: linear-gradient(180deg,#4d6680,#2c4560);
}

#tfhTransportInvoiceScreen .tfh-transport-lines-grid td.tfh-inv-driver-cell {
  background-color: #f7f9fc;
}

/* ---------- Bottom section: notes + horizontal totals ---------- */
#tfhTransportInvoiceScreen .tfh-invoice-bottom-grid {
  flex: 0 0 auto;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(600px,1.7fr);
  align-items: stretch;
  gap: 10px;
}

#tfhTransportInvoiceScreen .tfh-invoice-bottom-grid .tfh-form-field {
  gap: 4px;
}

#tfhTransportInvoiceScreen .tfh-invoice-bottom-grid textarea {
  height: 58px;
  min-height: 58px;
  padding: 6px 10px;
  resize: none;
  font-family: inherit;
  font-size: .86rem;
  line-height: 1.3;
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card {
  display: grid;
  grid-template-columns: repeat(5, minmax(0,1fr));
  align-items: stretch;
  gap: 6px;
  padding: 6px;
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card > div,
#tfhTransportInvoiceScreen .tfh-invoice-totals-card > label {
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr;
  align-content: center;
  justify-items: end;
  gap: 4px;
  margin: 0;
  padding: 6px 9px;
  border: 1px solid #d6dfe7;
  border-radius: 8px;
  background: #fff;
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card span {
  justify-self: start;
  max-width: 100%;
  color: #4b5f73;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .04em;
  line-height: 1.15;
  text-transform: uppercase;
  white-space: normal;
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card strong {
  font-size: .98rem;
  white-space: nowrap;
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card input {
  width: 100%;
  height: 30px;
  min-height: 30px;
  padding: 0 8px;
  text-align: right;
  font-size: .92rem;
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card .is-net {
  border-color: #0f2c47;
  background: linear-gradient(180deg,#24527a,#0f2c47);
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card .is-net span {
  color: rgba(255,255,255,.78);
}

#tfhTransportInvoiceScreen .tfh-invoice-totals-card .is-net strong {
  color: #f1d49a;
}

/* ---------- Smaller screens ---------- */
@media (max-width: 1280px) {
  #tfhTransportInvoiceScreen .tfh-invoice-bottom-grid {
    grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  }

  #tfhTransportInvoiceScreen .tfh-invoice-totals-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  #tfhTransportInvoiceScreen .tfh-invoice-lines-toolbar {
    flex-wrap: wrap;
  }

  #tfhTransportInvoiceScreen .tfh-invoice-totals-card {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 650px) {
  #tfhTransportInvoiceScreen .tfh-invoice-bottom-grid {
    grid-template-columns: 1fr;
  }

  #tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(-n+3),
  #tfhTransportInvoiceScreen .tfh-transport-lines-grid td:nth-child(-n+3) {
    position: static;
    box-shadow: none;
  }

  #tfhTransportInvoiceScreen .tfh-transport-lines-grid th:nth-child(-n+3) {
    position: sticky;
    left: auto;
  }
}
/* [TFH-301:TFH_TRANSPORT_INVOICE_ENTRY:CSS-GRID-SPACE-END] */
