/* ==========================================================================
   IEC Customer Portal — Billing, Interactive Aging & Payment Scheduling
   ========================================================================== */

.billing-heading {
  align-items: center;
}

/* --- Persistent Confirmation Receipt -------------------------------------- */

.confirmation-receipt {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  padding: 20px 22px;
  border-color: #98cda9;
  border-left: 5px solid var(--green);
  background: #f3faf5;
}

.confirmation-receipt__badge {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.confirmation-receipt__copy {
  min-width: 0;
  flex: 1;
}

.confirmation-receipt__copy h2 {
  margin: 4px 0 12px;
  color: var(--navy);
  font-size: 19px;
}

.confirmation-receipt__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin: 0;
}

.confirmation-receipt__meta dt {
  color: var(--muted2);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confirmation-receipt__meta dd {
  margin: 2px 0 0;
  color: var(--navy);
  font-size: 15px;
  font-weight: 800;
}

.confirmation-receipt__actions {
  margin-top: 14px;
}

/* --- 2-Tab Billing Workspace Switcher ------------------------------------- */

.billing-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #e9eff3;
  max-width: 100%;
  overflow-x: auto;
}

.billing-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 6px 15px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.billing-tab:hover {
  color: var(--navy);
}

.billing-tab.is-active,
.billing-tab[aria-selected="true"] {
  background: #fff;
  color: var(--navy);
  box-shadow: 0 1px 3px rgba(0, 44, 78, 0.1);
}

/* --- Interactive Aging Summary Strip -------------------------------------- */

.aging-impact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 232px;
  gap: 14px 16px;
  margin-bottom: 20px;
}

.aging-impact__heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.aging-impact__heading h2 {
  margin: 4px 0 0;
  color: var(--navy);
  font-size: 21px;
  font-weight: 800;
}

.aging-impact__caption {
  max-width: 540px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  text-align: right;
}

.aging-total-card {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  min-height: 136px;
  flex-direction: column;
  justify-content: center;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: var(--navy);
  color: #fff;
}

.aging-total-card > span {
  color: #bfd1dd;
  font-size: 12px;
  font-weight: 700;
}

.aging-total-card > strong {
  margin: 6px 0 2px;
  font-size: 26px;
}

.aging-total-card > small {
  margin-bottom: 10px;
  color: #bfd1dd;
  font-size: 11px;
}

.aging-total-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  color: #d2e0e8;
  font-size: 11px;
}

.aging-total-card b {
  color: #fff;
  font-size: 15px;
}

.aging-bucket-wrap {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.aging-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.aging-filter-pill {
  padding: 5px 11px;
  border: 1px solid var(--input-bd);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font-size: 12px;
  font-weight: 800;
}

.aging-filter-pill.is-active,
.aging-filter-pill[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: #fff;
}

.aging-filter-bar__hint {
  color: var(--muted2);
  font-size: 12px;
  font-weight: 600;
}

.aging-bucket-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  flex: 1;
}

.aging-bucket-grid--six {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.aging-bucket-card {
  display: flex;
  min-width: 0;
  min-height: 116px;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  padding: 13px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

.aging-bucket-card:hover {
  border-color: var(--blue);
  background: #f8fbfd;
}

.aging-bucket-card.is-filter-active,
.aging-bucket-card[aria-pressed="true"] {
  border-color: var(--blue);
  background: #edf6fb;
  box-shadow: 0 0 0 2px rgba(0, 86, 140, 0.18);
}

.aging-bucket-card > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.aging-bucket-card > strong {
  overflow: hidden;
  width: 100%;
  margin: 7px 0 auto;
  color: var(--navy);
  font-size: 17px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.aging-bucket-card > div {
  display: flex;
  width: 100%;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted2);
  font-size: 10px;
}

.aging-bucket-card b {
  color: var(--muted);
  font-size: 13px;
}

.aging-bucket-card.has-change {
  border-color: #7bb592;
  box-shadow: 0 0 0 2px rgba(29, 111, 60, 0.1);
}

.aging-bucket-card.has-change b {
  color: var(--green);
}

/* --- Open Invoices Panel -------------------------------------------------- */

.invoice-shop {
  overflow: hidden;
  margin-bottom: 20px;
}

.invoice-shop__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.invoice-shop__heading h2 {
  margin: 4px 0 3px;
  color: var(--navy);
  font-size: 21px;
  font-weight: 800;
}

.invoice-shop__heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.invoice-shop__controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.invoice-search input {
  width: 220px;
  min-height: 36px;
  padding: 6px 12px;
  border: 1px solid var(--input-bd);
  border-radius: var(--r-sm);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
}

.invoice-search input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 86, 140, 0.12);
  outline: none;
}

.invoice-shop__actions {
  display: flex;
  gap: 8px;
}

.invoice-list {
  display: grid;
}

.invoice-item {
  border-bottom: 1px solid var(--line);
  background: #fff;
  transition: background 0.14s ease, box-shadow 0.14s ease;
}

.invoice-item:last-child {
  border-bottom: 0;
}

.invoice-item.is-selected {
  background: #f4f9fc;
  box-shadow: inset 0 0 0 1px rgba(0, 86, 140, 0.22);
}

.invoice-item__summary {
  display: grid;
  grid-template-columns: 32px 34px minmax(140px, 1fr) max-content max-content minmax(110px, 0.45fr);
  align-items: center;
  gap: 12px;
  min-height: 70px;
  padding: 12px 22px;
}

.invoice-item.has-active-promise .invoice-item__summary {
  grid-template-columns: 32px 34px minmax(110px, 0.65fr) minmax(240px, 1.35fr) max-content max-content minmax(100px, 0.45fr);
}

.invoice-selector {
  position: relative;
  display: grid;
  width: 32px;
  height: 40px;
  place-items: center;
  cursor: pointer;
}

.invoice-selector input {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
}

.invoice-selector__box {
  display: grid;
  width: 21px;
  height: 21px;
  place-items: center;
  border: 2px solid #9db0bc;
  border-radius: 6px;
  background: #fff;
}

.invoice-selector input:checked + .invoice-selector__box {
  border-color: var(--blue);
  background: var(--blue);
}

.invoice-selector input:checked + .invoice-selector__box::after {
  width: 9px;
  height: 5px;
  border-bottom: 2px solid #fff;
  border-left: 2px solid #fff;
  content: "";
  transform: rotate(-45deg) translate(1px, -1px);
}

.invoice-selector input:focus-visible + .invoice-selector__box {
  outline: 3px solid rgba(0, 86, 140, 0.2);
  outline-offset: 2px;
}

.invoice-selector input:disabled + .invoice-selector__box {
  border-color: #c9d4da;
  background: #edf2f4;
}

.invoice-selector:has(input:disabled) {
  cursor: default;
}

.invoice-detail-toggle {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  padding: 0;
}

.invoice-detail-toggle:hover {
  border-color: var(--blue);
  background: #eef6fa;
}

.invoice-detail-toggle svg {
  display: block;
  width: 16px;
  height: 16px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transform-origin: 50% 50%;
  transition: transform 0.18s ease;
}

.invoice-detail-toggle[aria-expanded="true"] svg {
  transform: rotate(180deg);
}

.invoice-item__identity,
.invoice-item__balance {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.invoice-item__identity span,
.invoice-item__balance span {
  color: var(--muted2);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.invoice-item__identity strong,
.invoice-item__balance strong {
  overflow: hidden;
  color: var(--navy);
  font-size: 15px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-item__sub {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoice-item__balance {
  align-items: flex-end;
  text-align: right;
}

.invoice-item__meta {
  display: contents;
  color: var(--muted);
  font-size: 13px;
}

.invoice-date {
  white-space: nowrap;
}

.aging-chip {
  justify-self: start;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--soft);
  color: #394d59;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.invoice-promise {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 5px 9px;
  border: 1px solid #a8d0b7;
  border-radius: 999px;
  background: #f3faf6;
  color: var(--navy);
  justify-self: start;
  white-space: nowrap;
}

.invoice-promise__icon {
  display: grid;
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.invoice-promise strong {
  font-size: 11px;
}

.invoice-promise__detail,
.invoice-promise__availability {
  color: var(--muted);
  font-size: 10px;
}

.invoice-promise__availability {
  font-weight: 700;
}

.invoice-item__selection {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 0 22px 16px 100px;
}

.invoice-item__selection .field {
  width: 200px;
}

.invoice-item__selection .link-button {
  min-height: 44px;
}

.partial-mark {
  margin-bottom: 12px;
  color: var(--amber);
  font-size: 12px;
  font-weight: 800;
}

.invoice-item__details {
  padding: 20px 24px 24px 100px;
  border-top: 1px solid var(--line);
  background: #fbfcfd;
}

.invoice-item__details > p,
.invoice-detail-empty {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.invoice-detail-content {
  display: grid;
  gap: 18px;
}

.invoice-detail-content h3 {
  margin: 0 0 9px;
  color: var(--navy);
  font-size: 15px;
}

.invoice-equipment-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.invoice-equipment-list > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: #fff;
}

.invoice-equipment-list strong {
  color: var(--navy);
}

.invoice-equipment-list span {
  color: var(--muted);
  font-size: 12px;
}

.invoice-period {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.invoice-charge-list,
.invoice-detail-totals {
  display: grid;
  margin: 0;
}

.invoice-charge-list > div,
.invoice-detail-totals > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.invoice-charge-list small {
  color: var(--muted);
}

.invoice-detail-totals {
  justify-self: end;
  width: min(100%, 360px);
}

.invoice-detail-totals > div {
  grid-template-columns: 1fr auto;
}

.invoice-detail-totals dd {
  margin: 0;
  color: var(--navy);
  font-weight: 800;
}

.invoice-document-actions {
  display: flex;
  gap: 9px;
}

.invoice-filter-empty {
  padding: 24px;
  text-align: center;
}

/* --- Sticky Selection Action Bar ------------------------------------------ */

.payment-cart {
  position: sticky;
  z-index: 16;
  bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 12px 24px;
  padding: 13px 16px 13px 20px;
  border: 1px solid #3c627e;
  border-radius: var(--r-md);
  background: rgba(0, 44, 78, 0.97);
  color: #fff;
  box-shadow: 0 16px 40px rgba(0, 44, 78, 0.24);
  backdrop-filter: blur(8px);
}

.payment-cart > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: #c2d4e0;
  font-size: 12px;
  font-weight: 700;
}

.payment-cart strong {
  color: #fff;
  font-size: 22px;
}

.payment-cart .button {
  background: var(--btn-red);
}

.payment-cart .button:hover {
  background: var(--red-dark);
}

/* --- Schedule / Report Payment Panel -------------------------------------- */

.payment-panel {
  margin-top: 20px;
  scroll-margin-top: 18px;
}

.payment-panel__summary {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #f5f9fb;
  text-align: right;
}

.payment-panel__summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.payment-panel__summary strong {
  color: var(--navy);
  font-size: 20px;
}

.payment-methods {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.payment-methods label {
  position: relative;
  display: flex;
  cursor: pointer;
}

.payment-methods input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.payment-methods label > span {
  display: flex;
  width: 100%;
  min-height: 76px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.payment-methods strong {
  color: var(--navy);
  font-size: 17px;
}

.payment-methods small {
  color: var(--muted);
  font-size: 12px;
}

.payment-methods input:checked + span {
  border-color: var(--blue);
  background: #eef6fa;
  box-shadow: 0 0 0 3px rgba(0, 86, 140, 0.08);
}

.payment-methods input:focus-visible + span {
  outline: 3px solid rgba(0, 86, 140, 0.22);
  outline-offset: 2px;
}

.remit-guidance {
  margin: 0 0 18px;
  padding: 13px 16px;
  border: 1px solid #c3d9e6;
  border-left: 4px solid var(--blue);
  border-radius: var(--r-md);
  background: #f3f9fc;
}

.remit-guidance strong {
  display: block;
  color: var(--navy);
  font-size: 13px;
}

.remit-guidance p {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
}

.payment-common-fields {
  margin-bottom: 20px;
}

.ach-authorization-fields {
  margin: 8px 0 22px;
  background: #f7fafb;
}

.ach-authorization-fields .section-help {
  max-width: 850px;
}

.ach-authorization-fields .section-help a {
  color: var(--blue);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.ach-form-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 22px 0 18px;
  color: var(--navy);
  font-size: 14px;
  font-weight: 800;
}

.ach-form-divider::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.ach-security-note {
  margin: 18px 0 0;
  padding: 12px 15px;
  border-radius: var(--r-sm);
  background: #eaf3f7;
  color: #364f5c;
  font-size: 13px;
  line-height: 1.45;
}

.ach-authorization-fields input[type="file"] {
  padding: 9px 12px;
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 1120px) {
  .aging-impact {
    grid-template-columns: 1fr;
  }

  .aging-total-card,
  .aging-bucket-wrap {
    grid-column: 1;
    grid-row: auto;
  }

  .aging-bucket-grid,
  .aging-bucket-grid--six {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 1023px) {
  .invoice-item__summary,
  .invoice-item.has-active-promise .invoice-item__summary {
    grid-template-columns: 32px 34px minmax(140px, 1fr) auto;
    row-gap: 8px;
    padding: 14px 18px;
  }

  .invoice-item__balance {
    grid-column: 4;
    grid-row: 1;
  }

  .invoice-item__meta {
    display: flex;
    grid-column: 3 / -1;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
  }

  .invoice-promise {
    max-width: 100%;
    white-space: normal;
    flex-wrap: wrap;
  }

  .payment-cart {
    bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    margin: 0 0 20px;
  }
}

@media (max-width: 760px) {
  .confirmation-receipt {
    flex-direction: column;
  }

  .aging-impact__heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .aging-impact__caption {
    text-align: left;
  }

  .aging-bucket-grid,
  .aging-bucket-grid--six {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .invoice-shop__heading {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .invoice-shop__controls {
    width: 100%;
  }

  .invoice-search,
  .invoice-search input {
    width: 100%;
  }

  .invoice-item__summary,
  .invoice-item.has-active-promise .invoice-item__summary {
    grid-template-columns: 32px 34px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 14px 14px;
  }

  .invoice-item__meta {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .invoice-item__selection,
  .invoice-item__details {
    padding-right: 14px;
    padding-left: 14px;
  }

  .invoice-item__selection {
    flex-wrap: wrap;
  }

  .invoice-item__selection .field {
    width: 100%;
  }

  .invoice-equipment-list {
    grid-template-columns: 1fr;
  }

  .payment-cart {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 14px;
  }

  .payment-cart .button {
    width: 100%;
  }

  .payment-panel .panel__heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .payment-panel__summary {
    align-items: flex-start;
    text-align: left;
  }

  .payment-methods {
    grid-template-columns: 1fr;
  }
}
