/* Tablet bridge only. Phone (<768px) and desktop (>=1200px) rules stay intact. */
@media screen and (min-width: 768px) and (max-width: 1199.98px) {
  .main-content .row > *,
  .main-content .card,
  .main-content .card-body {
    min-width: 0;
  }

  .tablet-entry-form {
    width: 100%;
    max-width: 42rem;
  }

  .tablet-pagination {
    flex-wrap: wrap;
  }
  .tablet-pagination > nav {
    max-width: 100%;
  }
  .main-content .page-link,
  .main-content .btn {
    min-height: 44px;
    min-width: 44px;
  }
  .main-content .form-control,
  .main-content .form-select {
    min-height: 44px;
    font-size: 1rem;
  }

  .page-breadcrumb {
    flex-wrap: wrap;
    gap: .75rem 0;
  }
  .page-breadcrumb > *,
  .breadcrumb-div,
  .profile .info-list-item p {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .page-breadcrumb .ms-auto {
    flex-wrap: wrap;
  }

  /* Avoid half-width profiles containing third-width financial cards. */
  .client-summary > .col-lg-6 {
    width: 100%;
  }
  .client-summary > .border-end {
    border-right: 0 !important;
    margin-bottom: 1.5rem !important;
  }
  .client-summary > .ps-lg-4 {
    padding-left: calc(var(--bs-gutter-x) * .5) !important;
  }
  .client-summary h3,
  .client-summary h4 {
    overflow-wrap: anywhere;
  }

  .tablet-calculator {
    width: 100%;
  }
  .capital-summary > .col-md-6 {
    width: 100%;
  }
  /* Defaults must have room for full provider/payment labels at the lg transition. */
  #review-form .sheet-defaults > .row > .col-lg-4,
  #review-form .sheet-defaults > .row > .col-lg-8 {
    width: 100%;
  }
  #review-form .sheet-defaults-heading {
    font-size: 1rem;
    text-align: left;
  }
  #review-form h5,
  #review-form h6 {
    overflow-wrap: anywhere;
  }
  .tablet-loan-editor,
  .tablet-loan-editor + .col-lg-6 {
    width: 100%;
  }
  .tablet-loan-editor {
    margin-bottom: 1.5rem !important;
  }

  /* Local page styles follow this stylesheet, so scope these overrides to main. */
  .main-content #loan-delinquency .installment-schedule-controls,
  .main-content #loan-delinquency .fee-configuration.is-calculated .fee-structure-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main-content #loan-delinquency .loan-number-control {
    width: 100%;
    max-width: 22rem;
  }
  .main-content #loan-delinquency .loan-number-control > :not(.loan-step-buttons) {
    min-width: 0;
    flex: 1;
    width: 0;
  }
  .main-content #loan-delinquency .loan-step-buttons {
    position: static;
    flex-direction: row;
    gap: .25rem;
    width: auto;
  }
  .main-content #loan-delinquency .loan-step-buttons button {
    width: 44px;
    min-height: 44px;
    flex: none;
  }
  .main-content #loan-delinquency .loan-date-control {
    width: 100%;
    max-width: 22rem;
    flex-wrap: nowrap;
  }
  .main-content #loan-delinquency .loan-date-control .date-pick-btn {
    min-width: 44px;
  }

  /* Two useful columns instead of two fields in a three-column desktop grid. */
  .automation-settings .fee-settings-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem !important;
  }
  .main-content #late-fee-defaults .fee-rule-columns,
  .main-content #checkin-automation .checkin-value-columns {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .main-content #late-fee-defaults .fee-rule-columns > div:nth-child(n),
  .main-content #checkin-automation .checkin-before-value,
  .main-content #checkin-automation .checkin-after-value {
    width: auto;
    padding-left: 0;
    justify-self: stretch;
    box-sizing: border-box;
  }
  .main-content #late-fee-defaults .fee-rule-columns label,
  .main-content #late-fee-defaults .fee-rule-columns > div:nth-child(3) .form-switch {
    position: static;
    transform: none;
    width: auto;
    text-align: left;
    white-space: normal;
  }
  .main-content #late-fee-defaults .daily-percent-input,
  .main-content #late-fee-defaults .fee-step-input {
    width: calc(100% - 6rem);
    min-height: 44px;
  }
  .main-content #late-fee-defaults .fee-step-input > input {
    width: 100%;
  }
  .main-content #late-fee-defaults .fee-step-buttons {
    flex-direction: row;
    gap: .25rem;
    width: 5.75rem;
    height: 44px;
    left: calc(100% + .25rem);
  }
  .main-content #late-fee-defaults .fee-step-buttons button {
    min-width: 44px;
  }
  .main-content #checkin-automation .checkin-step-buttons {
    flex-direction: row;
  }
  .main-content #checkin-automation .checkin-step-buttons button {
    width: 44px;
    height: 44px;
  }
  .main-content #checkin-automation .checkin-step-input input {
    flex: 1;
    min-width: 0;
    width: 0;
  }
  .main-content #checkin-automation .checkin-footer,
  .automation-settings .checkin-settings-header {
    flex-wrap: wrap;
  }

  /* Each interval has its own labels; range inputs no longer collide with selects. */
  #advanced-checkins .custom-columns-header {
    display: none;
  }
  #advanced-checkins .custom-checkin-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--bs-border-color);
  }
  #advanced-checkins .custom-timing,
  #advanced-checkins .custom-frequency,
  #advanced-checkins .custom-days {
    width: 100%;
    max-width: none;
    margin: 0;
  }
  #advanced-checkins .custom-days {
    grid-column: 1 / -1;
    grid-row: 2;
  }
  #advanced-checkins .custom-remove {
    position: static;
    grid-column: 2;
    grid-row: 3;
    justify-self: end;
    width: 44px;
    height: 44px;
  }
  #advanced-checkins .custom-checkin-row label {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 0 .5rem !important;
    padding: 0;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
  }
  #advanced-checkins .custom-range-days > div {
    flex: 1;
    min-width: 0;
  }
  #advanced-checkins .custom-step-input input {
    flex: 1;
    min-width: 0;
    width: 0;
  }
  #advanced-checkins .custom-step-buttons {
    flex-direction: row;
  }
  #advanced-checkins .custom-step-buttons button {
    width: 44px;
    height: 44px;
  }
}

@media screen and (min-width: 992px) and (max-width: 1199.98px) {
  /* Keep date controls readable alongside the horizontally scrollable loan grid. */
  #filter-form > .row > .col-lg-9 { width: 66.666667%; }
  #filter-form > .row > .col-lg-3 { width: 33.333333%; }
}
