/* Invoicing module styles. Shared portal primitives remain in style.css. */

.invoice-row-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.broker-onboard-alert {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #b45309;
  font-size: 11px;
  font-weight: 950;
  white-space: nowrap;
}

.invoice-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.invoice-summary-card {
  appearance: none;
  min-width: 0;
  width: 100%;
  padding: 14px;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 77, 74, 0.06);
  font: inherit;
  text-align: left;
}

.invoice-summary-card[data-invoice-summary-tab] {
  cursor: pointer;
}

.invoice-summary-card[data-invoice-summary-tab]:hover {
  border-color: rgba(0, 128, 123, 0.35);
  background: #f7fbfb;
  filter: brightness(0.995);
}

.invoice-summary-card span,
.invoice-summary-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-summary-card span {
  color: #111827;
  font-size: 24px;
  font-weight: 900;
  line-height: 1;
}

.invoice-summary-card small {
  margin-top: 6px;
  color: #6c757d;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

  .invoice-section-tabs,
.invoice-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #fff;
  width: fit-content;
}

.invoice-section-tab,
.invoice-tab {
  appearance: none;
  min-width: 86px;
  height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #495057;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
}

.invoice-section-tab,
.invoice-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.invoice-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc3545;
  color: #fff;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(132, 32, 41, 0.24);
}

.invoice-section-tab {
  min-width: 138px;
}

.invoice-section-tab.active,
.invoice-tab.active {
  background: rgb(0, 128, 123);
  color: #fff;
}

#invoice-queue-view[hidden],
#revrec-view[hidden],
#brokers-view[hidden] {
  display: none !important;
}

#invoice-table-wrap,
.revrec-table-wrap {
  overflow: auto;
  overscroll-behavior: auto;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 77, 74, 0.06);
}

.open-invoices-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: min(680px, calc(100vh - 318px));
  min-height: 340px;
  overflow: hidden;
}

.open-invoices-toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(118px, 0.38fr) minmax(180px, 0.65fr) minmax(145px, 0.46fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f1;
  background: #f7fbfb;
}

.open-invoice-search {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #ced4da;
  border-radius: 999px;
  background: #fff;
  color: rgb(0, 128, 123);
}

.open-invoice-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.open-invoices-toolbar select,
.open-invoice-clear {
  height: 32px;
  min-width: 0;
  border: 1px solid #ced4da;
  border-radius: 7px;
  background: #fff;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.open-invoices-toolbar select {
  padding: 0 8px;
}

.open-invoice-clear {
  padding: 0 10px;
  cursor: pointer;
  color: #004d4a;
}

.open-invoice-count {
  justify-self: end;
  color: #6c757d;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.open-invoices-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: auto;
}

.open-invoice-empty {
  min-height: 100%;
}

.invoice-preview-layout {
  display: grid;
  grid-template-columns: minmax(560px, 1.05fr) minmax(360px, 0.75fr);
  gap: 10px;
  min-height: min(720px, calc(100vh - 312px));
  max-height: min(780px, calc(100vh - 252px));
  padding: 10px;
  overflow: hidden;
  background: #f7fbfb;
}

.invoice-preview-layout.no-preview {
  grid-template-columns: minmax(0, 1fr);
}

.invoice-preview-table,
.invoice-preview-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 77, 74, 0.06);
}

.invoice-preview-table {
  overflow: hidden;
}

.invoice-preview-scroll {
  width: 100%;
  height: 100%;
  overflow: auto;
  overscroll-behavior: auto;
}

.invoice-preview-row {
  cursor: pointer;
}

.invoice-copy-text {
  appearance: none;
  max-width: 190px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #004d4a;
  cursor: copy;
  font: inherit;
  font-weight: 900;
  text-align: left;
}

.invoice-copy-text:hover {
  text-decoration: underline;
}

.invoice-copy-text[data-invoice-open-load] {
  cursor: pointer;
}

.invoice-preview-row.selected td {
  background: #e9fbf8;
}

.invoice-preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.invoice-preview-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid #e7efee;
  background: #fff;
}

.invoice-preview-head div {
  min-width: 0;
}

.invoice-preview-head span,
.invoice-preview-head small {
  display: block;
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.invoice-preview-head strong {
  display: block;
  margin-top: 2px;
  color: #004d4a;
  font-size: 16px;
  font-weight: 950;
}

.invoice-preview-head small {
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: 0;
}

.invoice-preview-head-actions {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.invoice-preview-head a,
.invoice-preview-head button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid rgba(0, 128, 123, 0.26);
  border-radius: 7px;
  color: #004d4a;
  background: #effafa;
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 950;
  text-decoration: none;
}

.invoice-preview-head button[data-invoice-preview-close] {
  border-color: #f1aeb5;
  background: #fff5f5;
  color: #b02a37;
}

.invoice-preview-tabs {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  overflow-x: auto;
  border-bottom: 1px solid #edf2f1;
  background: #fbfefe;
}

.invoice-preview-tabs button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 9px;
  border: 1px solid #cfe1df;
  border-radius: 999px;
  background: #fff;
  color: #004d4a;
  cursor: pointer;
  font-size: 11px;
  font-weight: 900;
}

.invoice-preview-tabs button.active {
  border-color: rgb(0, 128, 123);
  background: rgb(0, 128, 123);
  color: #fff;
}

.invoice-preview-frame-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: auto;
  background: #f8f9fa;
}

.invoice-preview-frame {
  display: block;
  width: calc(100% * var(--invoice-preview-zoom, 1));
  height: calc(100% * var(--invoice-preview-zoom, 1));
  min-height: calc(560px * var(--invoice-preview-zoom, 1));
  border: 0;
  background: #f8f9fa;
  pointer-events: auto;
}

.invoice-preview-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 280px;
  color: #6c757d;
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.invoice-preview-empty i {
  color: #9eb7b5;
  font-size: 34px;
}

.brokers-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.42fr) minmax(520px, 1fr);
  gap: 12px;
  align-items: start;
}

.brokers-directory,
.broker-detail-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 77, 74, 0.06);
}

.brokers-directory {
  height: min(720px, calc(100vh - 245px));
  display: flex;
  flex-direction: column;
}

.brokers-toolbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid #edf2f1;
  background: #f7fbfb;
}

.brokers-search {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  height: 32px;
  padding: 0 10px;
  border: 1px solid #ced4da;
  border-radius: 999px;
  background: #fff;
  color: rgb(0, 128, 123);
}

.brokers-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.broker-add-btn {
  appearance: none;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  border: 1px solid rgba(0, 128, 123, 0.24);
  border-radius: 7px;
  background: rgb(0, 128, 123);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.brokers-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: auto;
}

.broker-list-row {
  appearance: none;
  width: 100%;
  display: grid;
  gap: 3px;
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid #edf2f1;
  background: #fff;
  color: #212529;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.broker-list-row:hover,
.broker-list-row.selected {
  background: #e8f7f6;
}

.broker-list-row strong,
.broker-list-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.broker-list-row strong {
  color: #111827;
  font-size: 13px;
  font-weight: 900;
}

.broker-list-row span {
  color: #6c757d;
  font-size: 11px;
  font-weight: 800;
}

.broker-list-row small {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #495057;
  font-size: 10px;
  font-weight: 900;
}

.broker-list-row em {
  font-style: normal;
  color: #0f5132;
}

.broker-list-row em.warn {
  color: #842029;
}

.broker-empty {
  min-height: 180px;
}

.broker-detail-panel {
  display: grid;
  gap: 12px;
  padding: 12px;
}

.broker-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f1;
}

.broker-detail-head h2 {
  margin: 2px 0 0;
  color: #111827;
  font-size: 22px;
  line-height: 1.1;
}

.broker-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.broker-metric {
  min-width: 0;
  padding: 11px;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #f8fbfb;
}

.broker-metric.warn {
  border-color: #ffec99;
  background: #fff9e6;
}

.broker-metric.danger {
  border-color: #f1aeb5;
  background: #fff0f1;
}

.broker-metric span,
.broker-metric small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.broker-metric span {
  color: #111827;
  font-size: 17px;
  font-weight: 900;
}

.broker-metric small {
  margin-top: 4px;
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.broker-detail-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
  padding: 11px;
  border: 1px solid #edf2f1;
  border-radius: 8px;
  background: #fbfdfd;
}

.broker-detail-form .revrec-field:nth-child(4) {
  grid-column: span 3;
}

.broker-detail-form input[readonly] {
  background: #f1f5f5;
  color: #6c757d;
}

.broker-form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

.broker-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.broker-history-head h3 {
  margin: 0;
  color: #004d4a;
  font-size: 13px;
  font-weight: 900;
}

.broker-history-head span {
  color: #6c757d;
  font-size: 11px;
  font-weight: 800;
}

.broker-history-scroll {
  max-height: min(360px, calc(100vh - 520px));
  overflow: auto;
  overscroll-behavior: auto;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
}

.broker-history-table {
  min-width: 920px;
}

.broker-history-empty {
  min-height: 180px;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
}

.broker-add-modal {
  width: min(560px, 100%);
}

.broker-add-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.revrec-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.revrec-layout {
  display: grid;
  grid-template-columns: minmax(320px, 0.9fr) minmax(460px, 1.4fr);
  gap: 12px;
  align-items: start;
}

.revrec-stack {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.revrec-panel {
  min-width: 0;
  border: 1px solid #d9e4e3;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 77, 74, 0.06);
  overflow: hidden;
}

.revrec-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  border-bottom: 1px solid #edf2f1;
  background: #f7fbfb;
}

.revrec-panel-title {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.revrec-panel-head h2 {
  margin: 0;
  color: #004d4a;
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
}

.revrec-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #edf2f1;
}

.revrec-field {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.revrec-field.full {
  grid-column: 1 / -1;
}

.revrec-field label {
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.revrec-field input,
.revrec-field select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.revrec-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 12px;
}

.revrec-actions.full {
  grid-column: 1 / -1;
  padding: 2px 0 0;
}

.revrec-payment-search {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 1 1 210px;
  min-width: 180px;
  height: 29px;
  padding: 0 9px;
  border: 1px solid #c7dfdd;
  border-radius: 999px;
  background: #f8fbfb;
  color: rgb(0, 128, 123);
}

.revrec-payment-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.revrec-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 29px;
  padding: 0 9px;
  border: 1px solid rgba(0, 128, 123, 0.24);
  border-radius: 6px;
  background: rgb(0, 128, 123);
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.revrec-btn.secondary {
  background: #f8fbfb;
  color: #004d4a;
}

.revrec-btn.danger {
  border-color: #f1aeb5;
  background: #dc3545;
}

.revrec-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.revrec-payment-row,
.revrec-invoice-row {
  cursor: pointer;
}

.revrec-payment-row.needs-match td {
  background: #fff1f2;
}

.revrec-payment-row.needs-match:hover td {
  background: #ffe4e6;
}

.revrec-payment-row.selected td,
.revrec-invoice-row.selected td {
  background: #e8f7f6;
}

.revrec-payment-row.bulk-selected td {
  box-shadow: inset 0 0 0 999px rgba(0, 128, 123, 0.055);
}

.revrec-payment-check {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 128, 123, 0.35);
  background: #fff;
  color: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 9px;
  padding: 0;
  vertical-align: middle;
}

.revrec-payment-check.checked {
  background: rgb(0, 128, 123);
  border-color: rgb(0, 128, 123);
  color: #fff;
}

.revrec-payment-check:hover {
  border-color: rgb(0, 128, 123);
}

.revrec-invoice-row.matched-active-payment td {
  background: #fff8df;
}

.revrec-linked-icon {
  color: rgb(0, 128, 123);
}

.revrec-select-cell {
  width: 22px;
  text-align: center !important;
}

.revrec-table-wrap .portal-table {
  min-width: 720px;
}

.revrec-payment-panel .revrec-table-wrap {
  max-height: min(360px, calc(100vh - 430px));
}

.revrec-invoice-panel .revrec-table-wrap {
  max-height: calc(100vh - 270px);
}

.revrec-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid #edf2f1;
  background: #fff;
}

.revrec-search-row label {
  color: rgb(0, 128, 123);
  font-size: 12px;
}

.revrec-search-row input {
  width: 100%;
  min-width: 0;
  height: 31px;
  padding: 0 10px;
  border: 1px solid #ced4da;
  border-radius: 999px;
  background: #f8fbfb;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.revrec-note {
  display: block;
  padding: 8px 12px 0;
  color: #6c757d;
  font-size: 11px;
  font-weight: 700;
}

.revrec-note-inline {
  min-width: 0;
  color: #6c757d;
  font-size: 11px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.revrec-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.42);
}

.revrec-modal {
  width: min(420px, 100%);
  overflow: hidden;
  border: 1px solid #b9d9d7;
  border-radius: 9px;
  background: #fff;
  box-shadow: 0 20px 50px rgba(17, 24, 39, 0.28);
}

.invoice-detail-modal {
  width: min(980px, 100%);
  max-height: min(92vh, 820px);
  display: flex;
  flex-direction: column;
}

.revrec-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #edf2f1;
  background: #f2fbfa;
}

.revrec-modal-head h2 {
  margin: 0;
  color: #004d4a;
  font-size: 14px;
  font-weight: 900;
}

.revrec-modal-close {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid #d9e4e3;
  border-radius: 7px;
  background: #fff;
  color: #343a40;
  cursor: pointer;
}

.revrec-modal-body {
  display: grid;
  gap: 10px;
  padding: 14px;
  color: #343a40;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.invoice-detail-modal form {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.invoice-detail-body {
  min-height: 0;
  overflow: auto;
}

.invoice-detail-section {
  display: grid;
  gap: 9px;
  padding: 10px;
  border: 1px solid #edf2f1;
  border-radius: 8px;
  background: #fbfdfd;
}

.invoice-detail-section h3 {
  margin: 0;
  color: #004d4a;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.invoice-detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.invoice-detail-grid.one-column {
  grid-template-columns: minmax(0, 1fr);
}

.invoice-detail-grid .revrec-field span {
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.invoice-detail-grid input,
.invoice-detail-grid select {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 9px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.invoice-detail-grid input[readonly] {
  background: #f1f5f5;
  color: #6c757d;
}

.invoice-detail-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.invoice-detail-value {
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #edf2f1;
  border-radius: 7px;
  background: #fff;
}

.invoice-detail-value small,
.invoice-detail-value strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-detail-value small {
  color: #6c757d;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.invoice-detail-value strong {
  margin-top: 3px;
  color: #212529;
  font-size: 12px;
  font-weight: 900;
}

.revrec-modal-field {
  display: grid;
  gap: 5px;
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.revrec-modal-field input,
.revrec-modal-field select,
.revrec-modal-field textarea {
  height: 33px;
  padding: 0 10px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  color: #212529;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
}

.revrec-modal-field textarea {
  height: auto;
  min-height: 128px;
  padding: 9px 10px;
  resize: vertical;
  line-height: 1.35;
  white-space: pre-wrap;
}

.revrec-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #edf2f1;
  background: #f8fbfb;
}

.invoice-email-modal {
  width: min(1080px, 100%);
  max-height: min(92vh, 820px);
  display: flex;
  flex-direction: column;
}

.invoice-email-modal form {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.invoice-email-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(340px, 1.1fr);
  gap: 0;
}

.invoice-email-body {
  min-height: 0;
  overflow: auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.invoice-email-body .span-2 {
  grid-column: 1 / -1;
}

.invoice-email-attachments {
  display: grid;
  gap: 7px;
}

.invoice-email-message-preview {
  display: grid;
  gap: 6px;
}

.invoice-email-message-preview > span {
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.invoice-email-message-preview > div {
  max-height: 220px;
  overflow: auto;
  padding: 12px;
  border: 1px solid #d9e4e3;
  border-radius: 7px;
  background: #fff;
  color: #212529;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
}

.invoice-email-attachments > span {
  color: #6c757d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.invoice-email-attachments label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #d9e4e3;
  border-radius: 7px;
  background: #f8fbfb;
  color: #004d4a;
}

.invoice-email-attachments label.missing {
  border-color: #f1aeb5;
  background: #fff5f5;
  color: #842029;
}

.invoice-email-attachments label strong {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 900;
}

.invoice-email-attachments label small {
  min-width: 0;
  overflow: hidden;
  color: #6c757d;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-email-warning {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #856404;
  font-size: 12px;
  font-weight: 800;
}

.invoice-email-preview {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #edf2f1;
  background: #f8fbfb;
}

.invoice-email-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid #edf2f1;
}

.invoice-email-preview-head strong {
  color: #004d4a;
  font-size: 12px;
  font-weight: 900;
}

.invoice-email-preview-head a {
  color: rgb(0, 128, 123);
  font-size: 12px;
}

.invoice-email-preview-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid #edf2f1;
  overflow-x: auto;
}

.invoice-email-preview-tabs button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 27px;
  padding: 0 8px;
  border: 1px solid rgba(0, 128, 123, 0.18);
  border-radius: 999px;
  background: #fff;
  color: #004d4a;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.invoice-email-preview-tabs button.active {
  background: rgb(0, 128, 123);
  color: #fff;
}

.invoice-email-preview-frame {
  flex: 1 1 auto;
  width: 100%;
  min-height: 420px;
  border: 0;
  background: #fff;
}

.portal-table.open-invoices-table {
  min-width: 1640px;
}

.invoice-docs {
  display: flex;
  align-items: center;
  gap: 5px;
}

.invoice-doc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid #d6dde3;
  border-radius: 6px;
  background: #f8f9fa;
  color: #0d6efd;
  text-decoration: none;
  font-size: 11px;
  font-weight: 900;
}

.invoice-doc.muted {
  color: #adb5bd;
  font-size: 0;
}

.invoice-doc.muted::after {
  content: '-';
  font-size: 11px;
}

.invoice-actions-cell {
  width: 104px;
  white-space: nowrap;
}

.invoice-icon-action {
  appearance: none;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 4px;
  border: 1px solid rgba(0, 128, 123, 0.28);
  border-radius: 7px;
  background: rgb(0, 128, 123);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.invoice-icon-action.secondary {
  background: #f8fbfb;
  color: #004d4a;
}

.invoice-icon-action.danger {
  border-color: #f1aeb5;
  background: #dc3545;
  color: #fff;
}

.invoice-icon-action:hover {
  filter: brightness(0.95);
}

.invoice-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  white-space: nowrap;
}

.invoice-status.ready {
  background: #d1ecf1;
  color: #0c5460;
}

.invoice-status.open {
  background: #fff3cd;
  color: #664d03;
}

.invoice-status.paid {
  background: #d1e7dd;
  color: #0f5132;
}

.revrec-btn.is-busy {
  cursor: wait;
  opacity: 0.88;
}

.invoice-icon-action:focus-visible,
.invoice-section-tab:focus-visible,
.invoice-tab:focus-visible,
.revrec-btn:focus-visible,
.revrec-search-row input:focus-visible,
.broker-add-btn:focus-visible,
.broker-list-row:focus-visible,
.brokers-search input:focus-visible,
.revrec-modal-close:focus-visible,
.revrec-modal-field input:focus-visible,
.invoice-detail-grid input:focus-visible,
.invoice-detail-grid select:focus-visible,
.broker-detail-form input:focus-visible {
  outline: 2px solid #111827;
  outline-offset: 2px;
}

/* Mercury imported payments */
.revrec-payment-row.mercury-imported td:first-child::after {
    content: 'Mercury';
    display: inline-block;
    margin-left: 0.4rem;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: rgb(0, 128, 123);
    opacity: 0.7;
}

.revrec-unset em {
    color: #9ca3af;
    font-style: italic;
    font-size: 0.85rem;
}

.mercury-hint {
    display: block;
    font-size: 0.72rem;
    color: #6c757d;
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

[data-editable-broker] {
    cursor: pointer;
    border-bottom: 1px dashed #6c757d;
}

[data-editable-broker]:hover {
    color: rgb(0, 128, 123);
    border-bottom-color: rgb(0, 128, 123);
}

.revrec-edit-amount {
    border: 0;
    border-bottom: 1px dashed #6c757d;
    background: transparent;
    color: inherit;
    font: inherit;
    font-weight: 800;
    padding: 0;
    cursor: pointer;
}

.revrec-edit-amount:hover {
    color: rgb(0, 128, 123);
    border-bottom-color: rgb(0, 128, 123);
}

.revrec-actions.full {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (max-width: 767px) {
  .invoice-email-layout,
  .invoice-email-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .invoice-email-body .span-2 {
    grid-column: auto;
  }
.invoice-section-tabs,
  .invoice-tabs { width: 100%; overflow-x: auto; }
  .open-invoices-view {
    height: min(620px, calc(100vh - 286px));
    min-height: 360px;
  }
  .open-invoices-toolbar {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
  .open-invoice-search {
    grid-column: 1 / -1;
  }
  .open-invoice-count {
    justify-self: start;
  }
  .invoice-preview-layout {
    grid-template-columns: minmax(0, 1fr);
    min-height: auto;
    max-height: none;
    overflow: visible;
  }
  .invoice-preview-scroll {
    max-height: 360px;
  }
  .invoice-preview-panel {
    min-height: 420px;
  }
  .invoice-email-preview {
    border-left: 0;
    border-top: 1px solid #edf2f1;
  }
  .brokers-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .brokers-directory {
    height: 320px;
  }
  .broker-metrics,
  .broker-detail-form,
  .broker-add-body {
    grid-template-columns: minmax(0, 1fr);
  }
  .broker-detail-form .revrec-field:nth-child(4) {
    grid-column: auto;
  }
  .broker-history-scroll {
    max-height: 320px;
  }
  .invoice-detail-modal { max-height: 94vh; }
  .invoice-detail-grid,
  .invoice-detail-values { grid-template-columns: minmax(0, 1fr); }
  
  .mercury-hint {
    max-width: 120px;
  }
  .revrec-actions.full {
    flex-direction: column;
  }
  #revrec-mercury-import {
    width: 100%;
    justify-content: center;
  }
}
