/* ===================== PHONE LAYOUT (v5.173) =====================
   Only below 760px wide (phones). Tablets and computers are unchanged. */
.m-burger, .m-drawer, .m-drawer-ov { display: none; }

@media (max-width: 760px) {
  html, body { overflow-x: hidden; }
  body { font-size: 15px; -webkit-text-size-adjust: 100%; }
  #app { height: 100dvh; }

  /* ---- top bar: logo, menu button, Proposal | CRM ---- */
  .topbar { padding: 0; }
  .topbar .tb-row, .topbar > * { flex-wrap: nowrap; }
  #topbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: nowrap; }
  #topbar .tb-left, #topbar .tb-nav, #tb-layout { display: none !important; }
  #topbar .tb-brand img { width: 32px; height: 32px; }
  #topbar .tb-right { margin-left: auto; gap: 6px; }
  .m-burger { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,.16); color: #fff; border: 0;
    border-radius: 10px; height: 40px; padding: 0 14px; font: inherit; font-size: 16px; font-weight: 700; cursor: pointer; }
  .mode-switch button { padding: 9px 11px !important; font-size: 14px !important; }
  .mode-switch button[data-mode="proposal"] .m-long { display: none; }

  /* ---- menu drawer ---- */
  .m-drawer-ov.open { display: block; position: fixed; inset: 0; background: rgba(13,17,23,.5); z-index: 500; }
  .m-drawer.open { display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; width: min(88vw, 360px);
    background: #fff; z-index: 501; box-shadow: 0 0 40px rgba(0,0,0,.3); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .m-drawer .m-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--rail-bg); color: #fff; font-weight: 800; font-size: 16px; position: sticky; top: 0; }
  .m-drawer .m-head img { width: 32px; height: 32px; background: #fff; border-radius: 8px; }
  .m-drawer .m-head button { margin-left: auto; background: rgba(255,255,255,.18); border: 0; color: #fff; font-size: 22px; width: 40px; height: 40px; border-radius: 10px; }
  .m-drawer .m-grp { padding: 14px 16px 4px; font-weight: 800; color: var(--heading); font-size: 13.5px; text-transform: uppercase; letter-spacing: .04em; }
  .m-drawer .m-item { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; font-size: 16px; color: #000;
    padding: 12px 20px; min-height: 46px; cursor: pointer; }
  .m-drawer .m-item.on { background: #E8F5EE; font-weight: 800; color: var(--heading); }
  .m-drawer .m-item:active { background: #F3F4F6; }
  .m-drawer .m-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 12px 16px 20px; border-top: 1px solid var(--border); margin-top: 10px; }
  .m-drawer .m-tools button { min-height: 44px; }

  /* ---- sub-tabs: one swipeable row; totals underneath ---- */
  .subbar { flex-wrap: wrap; padding: 6px 8px; gap: 6px; }
  .sb-left { flex-wrap: nowrap !important; overflow-x: auto; width: 100%; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .sb-left::-webkit-scrollbar { display: none; }
  .sb-btn { padding: 9px 12px; }
  .sb-right { width: 100%; flex-wrap: wrap; gap: 8px 12px; white-space: normal; font-size: 13.5px; }
  .sb-right .btn { padding: 8px 12px; }
  .sb-proj { max-width: 60vw; }

  /* ---- page content ---- */
  .content { -webkit-overflow-scrolling: touch; }
  .view, .view.wide { padding: 16px 12px 90px !important; max-width: 100% !important; }
  .view-header { flex-direction: column; align-items: stretch !important; gap: 10px; margin-bottom: 14px; }
  .view-header > * { max-width: 100%; }
  .view-header > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .view-title { font-size: 23px !important; }
  .card { border-radius: 12px; margin-bottom: 14px; max-width: 100%; }
  .card-head { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-head h3 { font-size: 16px !important; }
  .card-body { padding: 12px 14px; }
  /* wide tables scroll inside their card instead of pushing the page sideways */
  .card, .card-body, .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.grid, .crm-grid { min-width: max-content; }
  table.grid th, table.grid td { padding: 9px 10px; }
  /* everything side by side goes to one column */
  .field-row, .field-row3, .grid2, .two-col, .cols-2, .cols-3 { grid-template-columns: 1fr !important; display: grid; }
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .stat-row, .summary-strip { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 10px; }
  .stat-row .stat, .stat { min-width: 0; padding: 12px; }
  .stat-v, .stat .stat-value { font-size: 21px !important; }
  input, select, textarea { font-size: 16px !important; }       /* stops iPhone zooming into fields */
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  img { max-width: 100%; height: auto; }
  .toast { left: 12px; right: 12px; transform: none; bottom: 16px; text-align: center; }
  /* popups use the whole screen width */
  .modal-overlay > div, .modal-overlay > form { width: calc(100vw - 20px) !important; max-width: calc(100vw - 20px) !important; max-height: 92dvh; overflow: auto; }
  .pal { width: calc(100vw - 20px) !important; }
  /* the in-app proposal preview shrinks to fit */
  .proposal-doc { padding: 18px 14px !important; font-size: 12.5px; max-width: 100%; overflow-x: auto; box-sizing: border-box; }
  .proposal-doc .pricing-row { grid-template-columns: 18px minmax(0,1.3fr) minmax(0,1fr) minmax(0,1fr) !important; gap: 4px !important; font-size: 11px; }
  .proposal-doc .pc-num, .proposal-doc .pc-name { min-width: 0; overflow-wrap: anywhere; }
  .proposal-doc .doc-two-col { grid-template-columns: 1fr; gap: 10px; }
  .proposal-doc .doc-cover-body { padding: 30px 6px 20px; }
  .proposal-doc .doc-cover-heading { font-size: 22px; margin-bottom: 24px; }
  .proposal-doc table { display: block; overflow-x: auto; max-width: 100%; }
  .proposal-doc img { max-width: 100% !important; height: auto !important; }
  .demo-banner { flex-direction: column; align-items: flex-start; gap: 8px; }
  /* First Time Account Setup */
  .su-foot { flex-wrap: wrap; padding: 10px 14px !important; gap: 8px; }
  .su-foot .su-prog { order: -1; flex: 1 0 100%; margin: 0 0 4px; }
  .su-foot .btn { flex: 1; }
  .su-body { padding: 18px 16px !important; }
  .su-m-later { display: block !important; text-align: center; padding: 8px; font-size: 14px; color: var(--heading); font-weight: 700; }
}
.su-m-later { display: none; }
