/* Mobile View — loaded only on screens up to 740px.
   Desktop, tablet, print and PDF styles stay untouched in assets/css/app.css. */

@media screen and (max-width: 740px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { font-size: 15px; }

  /* ---------- Shell ---------- */
  .content { padding: 4px 14px 30px; }
  .topbar { padding: 12px 14px 10px; gap: 8px; }
  .topbar-title { flex: 1 1 auto; min-width: 0; }
  .topbar-title h1 { font-size: 20px; line-height: 1.25; }
  .topbar-title p { font-size: 12px; line-height: 1.4; }
  .top-actions { gap: 4px; }
  .icon-btn { width: 36px; height: 36px; }
  .app-footer { font-size: 12px; }
  .page-actions { gap: 8px; margin: 2px 0 14px; }

  /* Sidebar drawer */
  .sidebar { width: min(86vw, 320px); flex-basis: min(86vw, 320px); padding: 18px 14px 16px; }
  .nav-link { font-size: 14px; padding: 10px 12px; }
  .nav-group { font-size: 10.5px; }
  .side-org strong { font-size: 13px; }

  /* ---------- Readable type scale ---------- */
  .small { font-size: 12.5px; }
  .xs { font-size: 11.5px; }
  .mono { font-size: 12.5px; }
  .card-head h2 { font-size: 16px; }
  .card-head p { font-size: 12px; line-height: 1.45; }
  .field > label { font-size: 13px; }
  .field .hint, .field-error { font-size: 11.5px; }
  .btn { font-size: 13px; }
  .btn-sm { font-size: 12px; }
  .btn-xs { font-size: 11px; }
  .badge { font-size: 11px; }
  .table { font-size: 13px; }
  .table th { font-size: 11px; padding: 9px 11px; }
  .table td { padding: 11px; }
  .tabs { width: 100%; max-width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .tab { white-space: nowrap; font-size: 12.5px; padding: 9px 13px; }
  .filters { padding: 12px 14px; gap: 9px; }
  .filters .field > label { font-size: 11.5px; }
  .kv { grid-template-columns: 112px 1fr; gap: 6px 10px; font-size: 12.5px; }
  .list-clean li { font-size: 12.5px; padding: 11px 0; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-action { font-size: 12.5px; padding: 12px 10px; }
  .empty-state { padding: 36px 16px; }
  .empty-state h3 { font-size: 15px; }
  .empty-state p { font-size: 13px; }

  /* ---------- Cards ---------- */
  .card + .card { margin-top: 14px; }
  .card-head { padding: 14px 15px; gap: 10px; }
  .card-body { padding: 15px; }
  .card-foot { padding: 12px 15px; font-size: 12.5px; }
  .grid { gap: 12px; }
  /* Two compact stat boxes per row instead of one tall box. */
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 13px; }
  .stat-top { margin-bottom: 8px; }
  .stat-label { font-size: 11px; letter-spacing: .04em; line-height: 1.3; }
  .stat-value { font-size: 20px; }
  .stat-sub { font-size: 11px; margin-top: 4px; }
  .stat-ico { width: 30px; height: 30px; border-radius: 9px; }
  .stat-ico .ico { width: 16px; height: 16px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* ---------- Inputs ---------- */
  /* 16px stops iOS from zooming into a field; 44px is a comfortable touch target. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 11px;
  }
  textarea { min-height: 96px; }
  input[type="file"] { font-size: 12.5px; }
  .check { font-size: 13px; min-height: 32px; }
  .check input[type="checkbox"] { width: 18px; height: 18px; }

  /* ---------- Banners ---------- */
  .global-banner { flex-wrap: wrap; align-items: flex-start; gap: 9px; padding: 12px 13px; font-size: 13px; }
  .global-banner > div { flex: 1 1 calc(100% - 42px); }
  .global-banner strong { font-size: 13px; }
  .global-banner span { font-size: 12px; line-height: 1.45; }
  .global-banner > .btn { flex: 1 1 100%; }
  .flash { font-size: 13px; padding: 11px 13px; }

  /* ---------- Modals ---------- */
  .modal-head h3 { font-size: 16px; }
  .modal-head p { font-size: 12px; }
  .modal-body { font-size: 14px; }

  /* ---------- Sign in ---------- */
  .auth-panel { padding: 26px 18px; }
  .auth-card h2 { font-size: 26px; }
  .auth-card > p { font-size: 13px; }
  .auth-form .btn { font-size: 14px; min-height: 46px; }
  .auth-meta { font-size: 12px; }
  .auth-consent { font-size: 12px; }
  .admin-auth-card { padding: 26px 20px 22px; }

  /* ---------- Invoice preview ---------- */
  /* A full A4-height sheet looks like one oversized box on a phone. */
  .doc-paper { min-height: 0; padding: 16px 14px 18px; border-radius: 10px; font-size: 12.5px; overflow-x: auto; }
  .doc-paper .paper-head { gap: 12px; padding-bottom: 12px; margin-bottom: 12px; }
  .doc-paper .paper-brand-text h2 { font-size: 18px; }
  .doc-paper .paper-title { font-size: 20px; }
  .doc-paper .paper-grid { gap: 12px; margin-bottom: 12px; }
  .doc-paper .paper-table { font-size: 11.5px; min-width: 560px; }
  .doc-paper .paper-table th { font-size: 10px; }
  .doc-paper .paper-totals { width: 100%; max-width: 360px; }
  .doc-paper .paper-url { position: static; margin-top: 14px; padding-top: 8px; }
  .doc-paper.is-half { height: auto; min-height: 0; max-height: none; }
}

/* Narrow phones: one field per row, so labels and values stop fighting for space. */
@media screen and (max-width: 620px) {
  body.app .form-grid,
  body.admin .form-grid,
  body.app .form-grid.three,
  body.admin .form-grid.three,
  body.app .form-grid.four,
  body.admin .form-grid.four { grid-template-columns: 1fr; gap: 12px; }
  body.app .span-2, body.admin .span-2,
  body.app .span-3, body.admin .span-3,
  body.app .span-full, body.admin .span-full { grid-column: auto; }
}

@media screen and (max-width: 480px) {
  .content { padding: 4px 12px 26px; }
  .topbar { padding: 10px 12px 8px; gap: 6px; }
  .topbar-title h1 { font-size: 19px; }
  .topbar-title p { font-size: 11.5px; }
  .icon-btn { width: 34px; height: 34px; }
  .top-actions { gap: 3px; }
  .stats { gap: 9px; }
  .stat { padding: 12px; }
  .stat-value { font-size: 18px; }
  .stat-label { font-size: 10.5px; }
  .card-head, .card-body { padding-left: 13px; padding-right: 13px; }
  .card-foot { padding-left: 13px; padding-right: 13px; }
  .filters { grid-template-columns: 1fr; }
  .page-actions .btn { flex: 1 1 100%; }
  .modal-backdrop { padding: 8px 8px 16px; }
  .auth-panel { padding: 22px 15px; }
}
