/* Shared phone presentation. Desktop rules intentionally remain in the base stylesheets. */
@media (max-width: 720px) {
  .content,
  .section,
  .card,
  .grid,
  .filters,
  .form-grid {
    min-width: 0;
    max-width: 100%;
  }

  .grid.cols-4,
  .grid.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric {
    min-width: 0;
    padding: 14px;
  }

  .metric-value,
  .metric-note {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .metric-value {
    font-size: clamp(20px, 6vw, 24px);
    font-variant-numeric: tabular-nums;
  }

  [data-mobile-page="fund-layers"] .grid.cols-4 {
    grid-template-columns: minmax(0, 1fr);
  }

  [data-mobile-page="fund-layers"] .metric-value {
    white-space: nowrap;
    overflow-wrap: normal;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .filters > *,
  .filters label,
  .filters .form-field {
    min-width: 0;
  }

  .filters label:has(input[type="date"]),
  .filters .form-field:has(input[type="date"]),
  .filters > .form-actions,
  .filters > .form-wide {
    grid-column: 1 / -1;
  }

  .filters input,
  .filters select,
  .form-field input,
  .form-field select,
  .form-field textarea {
    min-height: 44px;
    min-width: 0;
    max-width: 100%;
    font-size: 16px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    padding: 16px;
  }

  .form-grid > *,
  .form-field,
  .form-wide,
  .form-actions {
    grid-column: 1;
    min-width: 0;
  }

  .form-actions {
    flex-wrap: wrap;
  }

  .form-actions .button,
  .form-actions button,
  .row-actions .button,
  .row-actions button {
    min-height: 44px;
    min-width: 44px;
  }

  .button.primary {
    border-color: #075985;
    background: #075985;
    color: #fff;
  }

  .section-header,
  .toolbar,
  .materials-toolbar {
    flex-wrap: wrap;
  }

  .section-header button,
  .section-header .button,
  .toolbar button,
  .toolbar .button,
  .materials-toolbar button,
  .materials-toolbar .button {
    min-width: 44px;
    min-height: 44px;
  }

  .materials-toolbar > * {
    width: 100%;
    min-width: 0;
  }

  .mobile-finance-nav {
    align-items: stretch;
    gap: 6px;
    padding-inline: 8px;
  }

  .mobile-finance-nav button {
    display: grid;
    grid-template-rows: 22px auto;
    place-items: center;
    gap: 3px;
    min-width: 0;
    min-height: 44px;
    padding: 5px 4px;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    background: #e7f7fd;
    color: #075985;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.2;
  }

  .mobile-nav-icon,
  .mobile-nav-icon svg {
    display: block;
    width: 22px;
    height: 22px;
  }

  .mobile-nav-icon svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
  }

  .mobile-finance-nav button[aria-current="page"],
  .mobile-finance-nav button[aria-expanded="true"] {
    border-color: #075985;
    background: #075985;
    color: #fff;
    box-shadow: 0 5px 14px rgba(7, 89, 133, 0.24);
  }

  .mobile-finance-nav button:focus-visible,
  .mobile-entry:focus-visible {
    outline: 3px solid #f59e0b;
    outline-offset: 2px;
  }

  .mobile-entry-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .mobile-entry-group {
    grid-column: 1 / -1;
    margin: 8px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    color: #075985;
    font-size: 13px;
    font-weight: 750;
  }

  .mobile-entry-group:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .mobile-entry {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 56px;
    padding: 10px;
    border: 1px solid #bae6fd;
    border-radius: 10px;
    background: #f0f9ff;
    color: #075985;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .mobile-entry svg {
    width: 22px;
    height: 22px;
  }

  .mobile-profile-card {
    display: grid;
    gap: 12px;
    min-width: 0;
    padding: 16px;
    border: 1px solid #bae6fd;
    border-radius: 12px;
    background: #f8fcfe;
    overflow-wrap: anywhere;
  }

  .mobile-finance-card header span {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #e7f7fd;
    color: #075985;
    font-weight: 700;
  }

  .mobile-finance-card [data-receipt-action="view"],
  .mobile-finance-card [data-expense-action="view"] {
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    background: #e7f7fd;
    color: #075985;
    font-weight: 700;
  }

  .mobile-finance-card [data-receipt-action="void"],
  .mobile-finance-card [data-expense-action="void"] {
    min-height: 44px;
    padding-inline: 10px;
    border: 0;
    background: transparent;
    color: var(--danger);
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-list-table,
  .mobile-list-table tbody,
  .mobile-list-table tfoot,
  .mobile-list-table tr,
  .mobile-list-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .mobile-list-table thead {
    display: none;
  }

  .mobile-list-table tbody tr,
  .mobile-list-table tfoot tr {
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 4px 14px rgba(22, 34, 51, 0.06);
  }

  .mobile-list-table td {
    display: grid;
    grid-template-columns: minmax(88px, 38%) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 8px 0;
    border-bottom: 1px solid #edf1f5;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .mobile-list-table td:last-child {
    border-bottom: 0;
  }

  .mobile-list-table td[data-mobile-label]::before {
    content: attr(data-mobile-label);
    color: #526071;
    font-size: 12px;
    font-weight: 700;
  }

  .mobile-list-table td:has(button) {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .mobile-list-table td:has(button)[data-mobile-label]::before {
    flex-basis: 100%;
  }

  .mobile-list-table td:has(button) button {
    flex: 0 1 auto;
    min-width: 44px;
    min-height: 44px;
  }

  .mobile-list-table td[colspan] {
    display: block;
    padding: 18px 8px;
    text-align: center;
  }

  .mobile-list-table td[colspan]::before {
    content: none;
  }

  .mobile-list-table .row-actions {
    justify-content: flex-start;
  }

  .modal-backdrop {
    align-items: stretch;
  }

  .modal {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
    overscroll-behavior: contain;
  }

  .modal-header {
    position: sticky;
    top: 0;
    z-index: 3;
    gap: 12px;
    padding: 14px 16px;
    background: #fff;
  }

  .modal input,
  .modal select,
  .modal textarea {
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .modal button,
  .modal .button,
  .modal .icon-button {
    min-width: 44px;
    min-height: 44px;
  }

  .modal .form-error,
  .modal .form-meta,
  .modal .form-hint {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 390px) {
  .grid.cols-3 {
    grid-template-columns: minmax(0, 1fr);
  }

  .filters {
    grid-template-columns: minmax(0, 1fr);
  }

  .filters > *,
  .filters label:has(input[type="date"]),
  .filters .form-field:has(input[type="date"]) {
    grid-column: 1;
  }
}
/* A generated empty-state caption is only needed when the mobile header is hidden. */
.mobile-list-empty { display: none; }
@media (max-width: 720px) {
  .mobile-list-table > .mobile-list-empty {
    display: block;
    padding: 24px 12px;
    color: #64748b;
    text-align: center;
  }
}
