/* Stitch AR/AP aging: restrained native-currency cards, bucket controls and readable register. */
.tv-stitch-aging {
  padding: 24px;
  background: var(--tv-surface-muted, #f3f7fb);
  border-radius: 12px;
  container-type: inline-size;
}
.tv-stitch-aging .workspace-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}
.tv-stitch-aging .workspace-hero h2 {
  font-size: 28px;
  letter-spacing: -0.035em;
  margin: 0 0 8px;
}
.tv-stitch-aging .workspace-hero p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--tv-text-muted, #4d6178);
  max-width: 85ch;
}
.tv-stitch-aging .workspace-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tv-stitch-aging .tv-route-context {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--tv-text-muted, #4d6178);
  font-size: 12px;
  margin-top: 12px;
}
.tv-stitch-aging .tv-route-summary-toggle {
  display: none;
}
.tv-stitch-aging .workspace-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 24px 0;
}
.tv-stitch-aging .workspace-stat {
  display: grid;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
  padding: 20px;
  min-width: 0;
}
.tv-stitch-aging .workspace-stat strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}
.tv-stitch-aging .workspace-stat :is(span, small) {
  font-size: 12px;
  color: var(--tv-text-muted, #4d6178);
}
.tv-stitch-aging .tv-route-main {
  display: grid;
  gap: 20px;
  min-width: 0;
}
.tv-stitch-aging :is(.workspace-main, .workspace-body, .workspace-stats) {
  min-width: 0;
  max-width: 100%;
}
.tv-stitch-aging .filters {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
}
.tv-stitch-aging .filters > label {
  display: grid;
  gap: 8px;
  min-width: 130px;
  flex: 1;
}
.tv-stitch-aging .filters > label:first-child {
  flex: 2;
}
.tv-stitch-aging .filters :is(input, select) {
  width: 100%;
}
.tv-stitch-aging .ar-aging-filter-actions {
  display: flex;
  gap: 8px;
}
.tv-stitch-aging :is(.ar-aging-distribution, .ap-aging-matrix) {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}
.tv-stitch-aging :is(.ar-aging-segment, .ap-aging-bucket) {
  display: grid;
  justify-items: start;
  align-content: start;
  gap: 8px;
  padding: 16px;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
  background: #fff;
  text-align: left;
}
.tv-stitch-aging :is(.ar-aging-segment, .ap-aging-bucket) strong {
  font-size: 22px;
}
.tv-stitch-aging :is(.ar-aging-segment, .ap-aging-bucket) small {
  line-height: 1.5;
  color: var(--tv-text-muted, #4d6178);
}
.tv-stitch-aging :is(.ar-aging-segment, .ap-aging-bucket).is-active {
  border-color: var(--tv-brand, #006cba);
  background: var(--tv-brand-soft, #e8f3fc);
}
.tv-stitch-aging :is([data-risk="critical"], .bucket-90-) {
  color: #be123c;
}
.tv-stitch-aging :is([data-risk="high"], .bucket-61-90) {
  color: #c2410c;
}
.tv-stitch-aging .table-card {
  overflow-x: auto;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
}
.tv-stitch-aging table {
  min-width: 960px;
}
.tv-stitch-aging td {
  vertical-align: top;
  padding: 16px;
}
.tv-stitch-aging td > div {
  display: grid;
  gap: 6px;
}
.tv-stitch-aging td small {
  color: var(--tv-text-muted, #4d6178);
  font-size: 12px;
}
.tv-stitch-aging tbody tr:hover {
  background: var(--tv-brand-soft, #e8f3fc);
}
.tv-stitch-aging .ledger-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px;
}
.tv-stitch-aging .ledger-pagination-actions {
  display: flex;
  gap: 8px;
}
.tv-stitch-aging .ar-aging-customer-register-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 8px;
  background: #fff;
}
.tv-stitch-aging .ar-aging-customer-register-heading h3,
.tv-stitch-aging .ar-aging-customer-detail-heading h3 {
  margin: 0;
  color: var(--tv-text, #122c46);
  font-size: 18px;
}
.tv-stitch-aging .ar-aging-customer-register-heading p,
.tv-stitch-aging .ar-aging-customer-detail-heading p {
  margin: 5px 0 0;
  color: var(--tv-text-muted, #4d6178);
  font-size: 13px;
  line-height: 1.5;
}
.tv-stitch-aging .ar-aging-customer-register table {
  min-width: 1320px;
}
.tv-stitch-aging .ar-aging-customer-register th:not(:first-child),
.tv-stitch-aging .ar-aging-customer-register td:not(:first-child) {
  text-align: right;
}
.tv-stitch-aging .ar-aging-customer-register td[data-column-key="customer"] {
  min-width: 220px;
}
.tv-stitch-aging
  .ar-aging-customer-register
  td[data-column-key="total_amount"] {
  background: rgba(232, 243, 252, 0.48);
}
.tv-stitch-aging .ar-aging-bucket-cell {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.tv-stitch-aging .ar-aging-bucket-cell strong {
  font-size: 14px;
}
.tv-stitch-aging .ar-aging-bucket-cell small {
  color: var(--tv-text-muted, #4d6178);
  font-size: 11px;
}
.tv-stitch-aging .ar-aging-customer-register tbody tr.is-selected {
  background: var(--tv-brand-soft, #e8f3fc);
  outline: 2px solid var(--tv-brand, #006cba);
  outline-offset: -2px;
}
.tv-stitch-aging .ar-aging-customer-detail {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 10px;
  background: #fff;
}
.tv-stitch-aging .ar-aging-customer-detail-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  min-width: 0;
}
.tv-stitch-aging .ar-aging-customer-detail-body {
  min-width: 0;
  max-width: 100%;
}
.tv-stitch-aging .ar-aging-invoice-detail-table {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}
.tv-stitch-aging .ar-aging-customer-detail-body > .tv-empty-state,
.tv-stitch-aging .ar-aging-customer-detail-body > .ar-aging-detail-error {
  padding: 14px;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 8px;
  background: var(--tv-surface-muted, #f3f7fb);
}
.tv-stitch-aging .ar-aging-detail-error p {
  margin: 0 0 12px;
  line-height: 1.5;
}
.tv-stitch-aging .ar-aging-customer-register-unavailable {
  padding: 20px;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 10px;
  background: #fff;
}
.tv-stitch-aging .ar-aging-customer-register-unavailable h3 {
  margin: 0 0 6px;
  font-size: 18px;
}
.tv-stitch-aging .ar-aging-customer-register-unavailable p {
  margin: 0;
  color: var(--tv-text-muted, #4d6178);
  line-height: 1.5;
}
.tv-stitch-aging-detail {
  display: grid;
  gap: 20px;
  padding: 20px;
  background: var(--tv-surface-muted, #f3f7fb);
}
.tv-stitch-aging-detail .panel {
  padding: 20px;
  background: #fff;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
  min-width: 0;
}
.tv-stitch-aging-detail .info-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--tv-surface-muted, #f3f7fb);
  overflow-wrap: anywhere;
}
/* Statement exports share the reporting foundation, with a bounded balance equation. */
.tv-stitch-statements :is(.customer-statement-main, .supplier-statement-main) {
  display: grid;
  gap: 20px;
  min-width: 0;
}
.tv-stitch-statements .statement-equation {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  padding: 20px;
  background: #fff;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
}
.tv-stitch-statements .statement-equation-item {
  display: grid;
  gap: 6px;
  flex: 1;
  min-width: 150px;
}
.tv-stitch-statements .statement-equation-item strong {
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}
.tv-stitch-statements .statement-equation-item.is-total {
  color: var(--tv-text, #122c46);
  font-weight: 600;
}
.tv-stitch-statements :is(.statement-amount-cell, .statement-balance-cell) {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.tv-stitch-statements .statement-equation-item span {
  color: var(--tv-text-muted, #4d6178);
  font-size: 12px;
}
.tv-stitch-collection-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  gap: 20px;
  align-items: start;
}
.tv-stitch-collection-inspection {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
  background: #fff;
}
.tv-stitch-collection-inspection > h3 {
  margin: 0 0 8px;
  font-size: 18px;
  overflow-wrap: anywhere;
}
.tv-stitch-collection-inspection > p {
  color: var(--tv-text-muted, #4d6178);
  font-size: 13px;
  line-height: 1.6;
}
.tv-stitch-collection-inspection .tv-stitch-aging-detail {
  padding: 0;
  background: transparent;
}
.tv-stitch-collection-inspection .panel {
  padding: 16px;
}
.tv-stitch-collection-inspection .info-line {
  display: grid;
  gap: 4px;
}
.tv-stitch-collection-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.tv-stitch-aging-detail .editor-card {
  padding: 20px;
  background: #fff;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 12px;
  overflow-x: auto;
}
.tv-stitch-aging-detail .health-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--tv-surface-muted, #f3f7fb);
  overflow-wrap: anywhere;
}
@media (max-width: 1100px) {
  .tv-stitch-collection-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
@media (max-width: 1100px) {
  .tv-stitch-aging :is(.ar-aging-distribution, .ap-aging-matrix) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 900px) {
  .tv-stitch-aging .workspace-hero {
    flex-direction: column;
  }
}
@media (max-width: 540px) {
  .tv-stitch-aging,
  .tv-stitch-aging-detail {
    padding: 12px;
  }
  .tv-stitch-aging
    :is(.ar-aging-distribution, .ap-aging-matrix, .workspace-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tv-stitch-aging .ledger-pagination {
    align-items: flex-start;
    flex-direction: column;
  }
}
@media (max-width: 540px) {
  .tv-stitch-aging .ar-aging-customer-detail {
    padding: 12px;
  }
  .tv-stitch-aging .ar-aging-customer-detail-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .tv-stitch-aging .ar-aging-customer-register-heading {
    padding: 14px;
  }
}

/* Exact Stitch screen owners for statements, aging, collections and disputes.
   Shared renderer contracts remain authoritative for rows, totals and actions. */
:is(
  [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
  [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
  [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
  [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
  [data-stitch-screen="6863623b966a41e49f9244987233b725"],
  [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
) {
  display: block;
  min-width: 0;
  padding: 22px;
  border: 0;
  border-radius: 0;
  background: var(--tv-surface-muted, #f3f7fb);
  color: var(--tv-text, #122c46);
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  > .tv-route-frame {
  display: grid;
  gap: 16px;
  max-width: 1600px;
  margin-inline: auto;
  min-width: 0;
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  .workspace-hero {
  align-items: center;
  margin: 0;
  padding: 20px 22px;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 10px;
  background: var(--tv-surface, #fff);
  box-shadow: none;
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  .workspace-stats {
  gap: 10px;
  margin: 0;
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  .workspace-stat {
  min-height: 92px;
  padding: 14px 16px;
  border-radius: 8px;
  box-shadow: none;
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"]
  )
  :is(.statement-equation, .table-card) {
  margin: 0;
  border: 1px solid var(--tv-border, #c7d4e2);
  border-radius: 10px;
  background: var(--tv-surface, #fff);
  box-shadow: none;
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"]
  )
  .statement-equation {
  gap: 12px;
  padding: 16px;
}
:is(
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"]
  )
  :is(.ar-aging-distribution, .ap-aging-matrix) {
  gap: 8px;
}
:is(
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"]
  )
  :is(.ar-aging-segment, .ap-aging-bucket) {
  padding: 14px;
  border-radius: 8px;
  box-shadow: none;
  transition:
    background-color 0.12s,
    border-color 0.12s;
}
:is(
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"]
  )
  :is(.filters, .table-card) {
  margin: 0;
  border-radius: 10px;
  box-shadow: none;
}
:is(
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  .table-card {
  border: 1px solid var(--tv-border, #c7d4e2);
  background: var(--tv-surface, #fff);
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  table
  th {
  background: var(--tv-surface-muted, #f3f7fb);
  color: var(--tv-text-muted, #4d6178);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
:is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  )
  :is(button, a, input, select, textarea):focus-visible {
  outline: 3px solid var(--tv-brief-focus, #005fcc);
  outline-offset: 2px;
}
@media (max-width: 900px) {
  :is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  ) {
    padding: 16px;
  }
}
@media (max-width: 560px) {
  :is(
    [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
    [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"],
    [data-stitch-screen="82caa26ccd8f47b982887349dd4c3141"],
    [data-stitch-screen="671ae285c96c44fdbbb3bae0567fce57"],
    [data-stitch-screen="6863623b966a41e49f9244987233b725"],
    [data-stitch-screen="e6c1fa51867a4a18ae037811fe63cad9"]
  ) {
    padding: 10px;
  }
  :is(
      [data-stitch-screen="f052d364682a45f58ee6df00badfb5ad"],
      [data-stitch-screen="ea0bf85fcb2141ed96c69269b09cffec"]
    )
    .statement-equation {
    align-items: stretch;
    padding: 12px;
  }
}

/* The application shell reduces the route's content width well before the
   browser itself reaches a tablet breakpoint. Respond to the route container
   so bucket cards, filters and page actions stay inside that real workspace. */
@container (max-width: 1100px) {
  .tv-stitch-aging .workspace-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
  }
  .tv-stitch-aging .workspace-hero-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .tv-stitch-aging .ar-aging-customer-detail-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .tv-stitch-aging .ar-aging-customer-detail-heading > div {
    min-width: 0;
    max-width: 100%;
  }
  .tv-stitch-aging
    :is(.ar-aging-distribution, .ap-aging-matrix, .workspace-stats) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .tv-stitch-aging .filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
  }
  .tv-stitch-aging .filters > label {
    min-width: 0;
  }
  .tv-stitch-aging .filters > label:first-child,
  .tv-stitch-aging .ar-aging-filter-actions {
    grid-column: 1 / -1;
  }
}

@container (max-width: 640px) {
  .tv-stitch-aging
    :is(.ar-aging-distribution, .ap-aging-matrix, .workspace-stats) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tv-stitch-aging .filters {
    grid-template-columns: minmax(0, 1fr);
  }
  .tv-stitch-aging .filters > label:first-child,
  .tv-stitch-aging .ar-aging-filter-actions {
    grid-column: 1;
  }
  .tv-stitch-aging .ar-aging-filter-actions > * {
    flex: 1;
  }
}
