/* Phone and tablet adjustments; keep data readable without shrinking text. */
.main, main, #content, .card, .charts > *, .stats > * { min-width: 0; }
button:focus-visible { outline: 3px solid #93bba0; outline-offset: 3px; }
.table-wrap { -webkit-overflow-scrolling: touch; }
@media (max-width: 900px) {
  .page-heading { flex-wrap: wrap; }
  .company-grid { grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); }
}
@media (max-width: 700px) {
  body { -webkit-text-size-adjust: 100%; }
  aside { padding: 16px max(16px, env(safe-area-inset-right)) 12px max(16px, env(safe-area-inset-left)); }
  nav { gap: 3px; }
  nav button { min-width: 0; min-height: 54px; font-size: 12px; padding: 8px 2px; }
  header { height: auto; min-height: 72px; padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  header > span { font-size: 12px; }
  header i { margin: 0 6px; }
  .account { min-width: 0; gap: 7px; margin-left: auto; }
  .account > div { max-width: 135px; overflow-wrap: anywhere; }
  .account small { font-size: 12px; }
  .avatar { flex-shrink: 0; }
  button, .primary, .secondary, .quiet { min-height: 44px; }
  .primary, .secondary, .quiet { font-size: 14px; }
  .quiet { padding: 8px; margin-left: 0; }
  main { padding: 24px 16px; }
  .page-heading { display: block; }
  .page-heading h1 { font-size: 27px; line-height: 1.2; }
  .page-heading .primary { font-size: 14px; margin-top: 16px; min-height: 44px; }
  p, .method { font-size: 13px; }
  .eyebrow { font-size: 10px; line-height: 1.6; }
  label { font-size: 14px; }
  input, select, .inline select, .search-tools input, .search-tools select,
  .form-card input, .form-card select, .login-box input { font-size: 16px; min-height: 46px; max-width: 100%; }
  .filter-line, .inline { width: 100%; }
  .inline select { flex: 1; width: auto; }
  .date-label { line-height: 1.6; }
  .stats article > div { font-size: 12px; gap: 4px; }
  .stat-icon { flex-shrink: 0; width: 25px; height: 25px; }
  .stats h2 { font-size: clamp(21px, 5.3vw, 29px); overflow-wrap: anywhere; }
  .stats small { font-size: 12px; line-height: 1.5; }
  .card-head { flex-wrap: wrap; }
  .card-head p, .legend, .subtle { font-size: 12px; }
  .legend { gap: 14px; }
  #age-chart { padding: 0 16px 16px; }
  .bar-row { gap: 8px; }
  .bar-row > span { font-size: 12px; width: 72px; }
  .bar-row small { font-size: 11px; width: 82px; }
  .party-row { padding: 14px 16px; gap: 10px; }
  .party-row strong { font-size: 12px; white-space: normal; overflow-wrap: anywhere; }
  .party-row b { font-size: 12px; flex-shrink: 0; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; min-width: 0; font-size: 12px; padding: 8px 5px; }
  .search-tools { flex-direction: column; }
  .search-tools input, .search-tools select { width: 100%; }
  .table-wrap { max-width: 100%; }
  th, td { font-size: 12px; padding: 14px 16px; }
  td strong { font-size: 13px; }
  td small, .pill, .badge, .overdue { font-size: 12px; }
  /* Invoice cards retain every column on a phone, with labels beside values. */
  .ledger table, .ledger tbody { display: block; white-space: normal; }
  .ledger thead { position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; }
  .ledger tbody tr { display: block; margin: 0 16px 16px; padding: 14px; border: 1px solid #e3e9e3; border-radius: 8px; }
  .ledger td { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; border: 0; padding: 7px 0; text-align: right; overflow-wrap: anywhere; }
  .ledger td:first-child { display: block; text-align: left; border-bottom: 1px solid #edf1eb; padding: 0 0 12px; margin-bottom: 6px; }
  .ledger td:first-child strong { font-size: 15px; }
  .ledger td::before { font-size: 12px; color: #839182; flex-shrink: 0; text-align: left; }
  .ledger td:nth-child(2)::before { content: 'Type'; }
  .ledger td:nth-child(3)::before { content: 'Broker'; }
  .ledger td:nth-child(4)::before { content: 'Due date'; }
  .ledger td:nth-child(5)::before { content: 'Status'; }
  .ledger td:nth-child(6)::before { content: 'Outstanding'; }
  .pagination { flex-wrap: wrap; gap: 12px; padding: 16px; font-size: 12px; }
  .pagination > div { display: flex; gap: 8px; width: 100%; }
  .pagination button { flex: 1; margin: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-card { padding: 20px; }
  .dropzone { padding: 20px 10px; }
  .dropzone input { width: 100%; font-size: 14px; }
  .dropzone span { font-size: 12px; line-height: 1.7; }
  .login-form { min-height: 100svh; padding: 28px 20px; }
  .login-box { width: 100%; max-width: 390px; }
  .login-box label { font-size: 14px; }
  .login-box small { font-size: 12px; }
  footer { padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  #toast { width: calc(100% - 32px); bottom: max(16px, env(safe-area-inset-bottom)); line-height: 1.5; }
}
@media (max-width: 360px) {
  .stats { grid-template-columns: 1fr; }
  .account > div { max-width: 95px; }
}
