.mobile-only { display: none; }

@media (max-width: 720px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  main, header, .card, .metric, .fields > *, .grid > * { min-width: 0; }
  main { padding-inline: .75rem; overflow-wrap: anywhere; }
  header { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem .75rem; }
  header .app-brand { order: 0; min-width: 0; max-width: 58%; }
  header .app-brand img { max-width: 100%; height: auto; }
  header .menu-toggle { order: 1; display: inline-flex; margin-left: auto; }
  header > :is(div,nav) { width: 100%; }
  header > div { order: 2; }
  header > span { order: 2; }
  header nav:not([hidden]) { order: 3; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); }
  header nav a { white-space: normal; min-width: 0; overflow-wrap: anywhere; }
  header :is(a,button) .ui-icon { flex: none; }
  header nav .nav-count { flex: none; margin-left: 0; }
  input:not([type=hidden]):not([type=checkbox]):not([type=radio]),select,textarea {
    min-width: 0; max-width: 100%; font-size: 16px; min-height: 44px;
  }
  input[type=date] { width: 100%; min-inline-size: 0; max-inline-size: 100%; appearance: none; }
  input[type=date]::-webkit-date-and-time-value { text-align: left; }
  form, fieldset, .directory-select { min-width: 0; max-width: 100%; }
  :is(button,.btn,.menu-toggle) { max-width: 100%; min-height: 44px; }
  button { white-space: normal; }
  :is(form,.card) :is(input,select,textarea,button) { scroll-margin-block: 1rem 5rem; }
  .fields { grid-template-columns: minmax(0,1fr); }
  .overview .summary-grid,[data-view=bad_debt] main .grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .overview .summary-card,[data-view=bad_debt] main .metric { padding: .65rem; }
  .overview .summary-card b { overflow-wrap: anywhere; }
  .dashboard-money-line :is(dt,dd) { min-width: 0; overflow-wrap: anywhere; }
  .management-staff-scroll { overflow: visible; }
  .management-staff-scroll :is(th,td) { min-width: 0; }
  .mobile-card-table,.mobile-card-table > tbody { display: block; }
  .mobile-card-table > thead,.mobile-card-table .mobile-table-heading { display: none; }
  .mobile-card-table > tbody > tr:not(.mobile-table-heading) {
    display: grid; grid-template-columns: repeat(2,minmax(0,1fr));
    gap: .3rem .6rem; margin: .65rem 0; padding: .65rem;
    border: 1px solid var(--line); border-radius: .65rem; background: white;
  }
  .mobile-card-table > tbody > tr > :is(td,th) {
    display: block; padding: .3rem; border: 0; min-width: 0;
    overflow-wrap: anywhere; white-space: normal; text-align: left;
  }
  .mobile-card-table > tbody > tr > [colspan],
  .mobile-card-table .mobile-wide { grid-column: 1/-1; }
  .mobile-card-table > tbody > tr > .mobile-card-extra[hidden] { display: none; }
  .mobile-card-table caption { display: block; text-align: left; }
  .mobile-card-table .mobile-label {
    display: block; font-size: .78rem; color: var(--dark); font-weight: 650;
    margin-bottom: .15rem;
  }
  .mobile-only.mobile-loan-balance { display: block; margin-top: .45rem; }
  .mobile-only.mobile-row-toggle { display: block; margin-top: .45rem; }
  .mobile-only.mobile-loan-link { display: inline-flex; margin-right: .4rem; }
  [data-view=bad_debt] .bad-debt-table { overflow: visible; }
  .bad-debt-table .bad-debt-expanded[hidden] { display: none; }
  .bad-debt-table .bad-debt-expanded { margin-top: -.5rem !important; }
  .bad-debt-table .bad-debt-expanded > td { grid-column: 1/-1; }
  .bad-debt-table .bad-debt-summary > :is(th,td) { white-space: normal; }
  .bad-debt-table .bad-debt-toggle,.bad-debt-actions :is(a,button) { white-space: normal; }
  .bad-debt-facts { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .mobile-section {
    border: 1px solid var(--line); border-radius: .65rem; padding: .65rem;
    margin: .55rem 0; min-width: 0; background: white;
  }
  .mobile-section > summary { cursor: pointer; padding-block: .38rem; font-weight: 700; }
  .mobile-loan-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .45rem; }
  [data-mobile-loan] .mobile-loan-summary .metric { padding: .45rem; }
  [data-mobile-loan] .mobile-section .metric { padding: .45rem; margin: .25rem 0; }
  .mobile-loan-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-block: .65rem; }
  [data-view=expenses] main details { margin-block: .5rem; border: 1px solid var(--line); border-radius: .6rem; padding: .7rem; }
  :is([data-view=new],[data-view=collect],[data-view=settle],[data-view=renew]) main form > button:last-child { width: 100%; }
  :is([data-view=collect],[data-view=settle],[data-view=renew]) [data-direct-preview] {
    color: var(--dark); font-weight: 750; overflow-wrap: anywhere;
  }
  [data-view=cash] .mobile-amount-in { color: #08624e; font-weight: 700; }
  [data-view=cash] .mobile-amount-out { color: #a12121; font-weight: 700; }
}
@media (max-width: 340px) {
  .overview .summary-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 720px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  [data-collection-preview] tbody td:not([colspan])::before {
    display: block; font-size: .78rem; color: var(--dark); font-weight: 650;
  }
  [data-collection-preview] tbody td:nth-child(1):not([colspan])::before { content: "Kỳ"; }
  [data-collection-preview] tbody td:nth-child(2)::before { content: "Phải thu"; }
  [data-collection-preview] tbody td:nth-child(3)::before { content: "Đã thu"; }
  [data-collection-preview] tbody td:nth-child(4)::before { content: "Đề nghị"; }
  [data-collection-preview] tbody td:nth-child(5)::before { content: "Còn thiếu dự kiến"; }
  #renewal-net { font-weight: 750; color: var(--dark); }
}
@media (max-width: 720px), (max-width: 1000px) and (max-height: 500px) and (pointer: coarse) {
  main .mobile-card-table { width: 100%; min-width: 0; }
  main .mobile-card-table > tfoot { display: block; width: 100%; }
  main .mobile-card-table > tfoot > tr {
    display: flex; flex-wrap: wrap; gap: .25rem; background: #f5faf9;
  }
  main .mobile-card-table > tfoot :is(th,td) { min-width: 0; padding: .4rem; }
  .management-group .management-staff-scroll { overflow: visible; }
  .management-group .mobile-card-table :is(td,th) { min-width: 0; text-align: left; }
  .mobile-only.mobile-loan-shortcuts { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .5rem; }
  :is(.mobile-loan-shortcuts,.bad-debt-actions) a { display: inline-flex; align-items: center; min-height: 44px; }
}
