/* accounting page/module styles. Moved from styles.css for easier maintenance. */
.expense-view-tabs {
  display: flex;
  align-items: end;
  margin: 0 -24px 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
}

.expense-view-tabs button {
  min-width: 92px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-bottom: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.expense-view-tabs button.active {
  margin-bottom: -1px;
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.expense-view-tabs button:not(.active):hover {
  color: var(--accent);
}

.expense-page-filters {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.billing-page-filters {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.expense-select-add {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 6px 2px 0;
  text-decoration: underline;
}

.payment-payable-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.payment-add-vendor {
  border: 0;
  background: transparent;
  color: var(--accent);
  padding: 0 2px;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

.payment-add-vendor::after {
  content: "";
  display: inline-block;
  margin-left: 7px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  vertical-align: middle;
}

.payment-actions {
  min-width: 118px;
  text-align: right;
}

.accounting-payment-editor {
  display: grid;
  gap: 18px;
}

.payment-form-links {
  display: flex;
  gap: 16px;
  align-items: center;
  min-height: 18px;
}

.accounting-payment-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(210px, 1.45fr) minmax(190px, 1.25fr) minmax(170px, 1fr);
  gap: 10px 12px;
  align-items: end;
}

.accounting-payment-form .field {
  min-width: 0;
}

.accounting-payment-form .field.full {
  grid-column: span 2;
}

.accounting-payment-form input,
.accounting-payment-form select,
.accounting-payment-form .input-affix {
  min-height: 35px;
  border-radius: 4px;
}

.accounting-payment-form .readonly-control,
.accounting-payment-form .readonly-affix,
.accounting-payment-form input:disabled {
  background: color-mix(in srgb, var(--muted) 16%, var(--panel));
  color: var(--text);
  cursor: default;
}

.payment-editor-section {
  display: grid;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.payment-editor-section h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.payment-editor-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 32px;
}

.payment-editor-section .table-wrap {
  border-radius: 4px;
}

.accounting-payment-total-row {
  background: color-mix(in srgb, var(--warning, #f4c542) 25%, var(--panel));
}

.detention-payable-row {
  display: grid;
  grid-template-columns: minmax(0, 208px) auto;
  gap: 10px;
  align-items: end;
}

.detention-override {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
}

.report-filter-band:has([data-run-report="Gross Profit per Load"]) .report-billing-options {
  grid-column: 3;
  grid-row: 2 / span 2;
}

.tab-actions,
.billing-head {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}

.billing-head {
  justify-content: space-between;
}

.billing-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.billing-section {
  margin-bottom: 24px;
}

.billing-section h3 {
  margin: 0;
  font-size: 20px;
}

.billing-section p {
  margin: 5px 0 2px;
  color: var(--muted);
}

.billing-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
}

.billing-title-row.compact {
  align-items: center;
  margin-top: 12px;
}

.billing-links {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 2px;
}

.billing-section .billing-actions .primary,
.billing-title-row.compact .primary {
  min-width: 0;
  min-height: 32px;
  padding: 7px 14px;
  border-radius: 3px;
}

.billing-section .table-wrap {
  min-height: 0;
  flex: 0 0 auto;
}

.billing-section table {
  min-width: 0;
}

.billing-section th,
.billing-section td {
  height: 34px;
}

.billing-total-row td {
  background: #fff0b8;
  color: #172331;
  font-weight: 800;
}

body[data-theme="dark"] .billing-total-row td,
body[data-theme="dark-auto"] .billing-total-row td {
  background: #4b4326;
  color: #fff8d4;
}

.billing-head h3 {
  margin: 0;
  font-size: 20px;
}

.billing-head.compact {
  margin-top: 22px;
}

.billing-entries-grid .table-wrap {
  overflow-x: auto;
}

.billing-entries-grid td,
.billing-entries-grid th {
  white-space: nowrap;
}

.billing-entries-total-link {
  display: flex;
  justify-content: center;
  padding: 14px 0 4px;
}

.billing-entries-total-value {
  color: var(--accent, #087f92);
  font-size: 16px;
  font-weight: 700;
}

.payment-schedule {
  margin-top: 16px;
  min-width: 0;
}

.payment-schedule h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.payment-schedule table {
  min-width: 0;
}

.payment-schedule .table-wrap {
  min-height: 0;
  flex: 0 0 auto;
}

.payment-schedule th,
.payment-schedule td {
  height: 30px;
  padding: 6px 8px;
  font-size: 12px;
}

.chart-accounts-panel table {
  min-width: 1040px;
  table-layout: auto;
}

.chart-account-actions {
  min-width: 118px;
  text-align: right;
}

.chart-accounts-panel tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--panel-2) 45%, transparent);
}

body.reports-mode .report-filter-band:has([data-run-report="Gross Profit per Load"]) .report-billing-options {
  grid-column: 3;
  grid-row: 2 / span 2;
}

body.reports-mode .report-filter-band:has([data-run-report="Total Revenue"]) .report-status-options,
body.reports-mode .report-filter-band:has([data-run-report="Total Revenue"]) .report-billing-options {
  grid-template-columns: repeat(2, minmax(92px, max-content)) !important;
}

body.reports-mode .report-filter-band:has([data-run-report="Total Revenue"]) .report-billing-options {
  grid-column: 3 / span 2 !important;
}


/* Responsive rules moved from styles.css. */
@media (max-width: 900px) {
  .accounting-payment-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .accounting-payment-form .field.full {
    grid-column: 1 / -1;
  }

}


/* New charge category controls moved from styles.css. */
.new-charge-category {
  justify-self: center;
  margin-top: -8px;
  border: 0;
  background: transparent;
  color: var(--accent);
  text-decoration: underline;
}

.new-charge-category::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 14px;
  height: 14px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--success);
  color: white;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}
/* Scheduled payments title action, matching the original directory layout. */
.pagebar > div:first-child.scheduled-title {
  display: grid;
  grid-template-columns: max-content max-content;
  align-items: center;
  justify-content: start;
  column-gap: 12px;
}

.pagebar > div:first-child.scheduled-title > p {
  grid-column: 1 / -1;
}

.scheduled-title-run-now {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 13px;
}
.settlement-history-popover-layer {
  position: fixed;
  z-index: 36000;
  inset: 0;
  background: rgba(15, 23, 42, .18);
}

.settlement-history-popover {
  position: fixed;
  top: 50%;
  left: 50%;
  width: min(800px, calc(100vw - 32px));
  max-height: min(560px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 6px;
  background: var(--panel, #fff);
  box-shadow: 0 24px 70px rgba(15, 23, 42, .34);
}

.settlement-history-popover > header {
  min-height: 66px;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--panel, #fff);
}

.settlement-history-popover > header h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 750;
  letter-spacing: -.02em;
}

.settlement-history-close-icon {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted, #64748b);
  font-size: 18px;
  cursor: pointer;
}

.settlement-history-close-icon:hover {
  background: var(--panel-2, #f3f6f9);
  color: var(--text, #0f172a);
}

.settlement-history-popover > .settlement-history-modal {
  padding: 8px 22px 18px;
  overflow: auto;
}

.settlement-history-modal .table-wrap {
  margin: 0;
  overflow: visible;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.settlement-history-modal table {
  min-width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.settlement-history-modal th {
  padding: 10px 6px 8px;
  border-bottom: 1px solid var(--border, #d7e0e8);
  background: transparent;
  color: var(--text, #0f172a);
  font-size: 12px;
  font-weight: 700;
  text-align: left;
}

.settlement-history-modal td {
  padding: 10px 6px;
  border-bottom: 0;
  background: transparent;
  color: var(--text, #0f172a);
  font-size: 14px;
  line-height: 1.45;
  vertical-align: top;
  white-space: normal;
}

.settlement-history-modal td:nth-child(1),
.settlement-history-modal th:nth-child(1) {
  width: 130px;
  white-space: nowrap;
}

.settlement-history-modal td:nth-child(3),
.settlement-history-modal th:nth-child(3) {
  width: 125px;
}

.settlement-history-note {
  margin: 8px 6px 0;
  padding-top: 12px;
  border-top: 1px solid var(--border, #d7e0e8);
  color: var(--muted, #617187);
  font-size: 12px;
  line-height: 1.4;
}

.settlement-history-popover > footer {
  min-height: 60px;
  padding: 10px 22px 16px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  background: var(--panel, #fff);
}

.settlement-history-close-button {
  min-width: 82px;
  min-height: 36px;
  padding: 7px 16px;
  border: 1px solid #1f2937;
  border-radius: 4px;
  background: #1f2937;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.settlement-history-close-button:hover {
  border-color: #111827;
  background: #111827;
}

@media (max-width: 640px) {
.settlement-history-popover {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .settlement-history-modal td:nth-child(1),
  .settlement-history-modal th:nth-child(1) {
    width: 105px;
  }

  .settlement-history-modal td:nth-child(3),
  .settlement-history-modal th:nth-child(3) {
    width: 90px;
  }
}
