/* Haven Command | shared phone layout
   One place for phone-width rules (800px and below), loaded last on every Command page so it
   wins over the older per-page patches. Layout only: no behavior or data changes.
   The Agency Owner pages (owner, revenue, commissions) style their own phone layout in owner.css.

   Scale used everywhere below:
   --hm-gap   10px  space between cards and between controls
   --hm-pad   12px  padding inside a card
   --hm-edge   8px  page edge on phones (cards run almost edge to edge)
   --hm-tap   40px  minimum height of anything you tap */
:root{--hm-gap:10px;--hm-pad:12px;--hm-edge:8px;--hm-radius:12px;--hm-tap:40px}

@media (max-width:800px){
  /* Never scroll sideways. clip (not hidden) keeps sticky headers working. */
  html,body{overflow-x:clip!important;max-width:100%}
  img,video,canvas,iframe{max-width:100%}
  body{padding-bottom:72px} /* room for the floating Tutorial and Feedback chips */

  /* iOS zooms the page when a field under 16px gets focus; 16px stops that. */
  input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea{font-size:16px!important}

  /* Tap targets */
  .btn,button.btn,a.btn,main button:not(.dq-chip):not(.dd-tab):not([role=tab]):not(.tc-back),main select{min-height:var(--hm-tap)}
  main a.btn{display:inline-flex;align-items:center;justify-content:center}

  /* Page edge: cards run nearly full width. */
  body>.shell>main,body>main,main#app{padding:var(--hm-edge)!important}
  :where(.card,.column,.pipeline-column){padding:var(--hm-pad)!important;border-radius:var(--hm-radius)!important}

  /* Wide tables scroll inside their card, never the page. */
  main table:not(.tablewrap table):not(.rpq table){display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}

  /* Metric tiles: two compact tiles per row instead of one tall tile each. */
  #metrics.cards,.cards#metrics{grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:8px!important}
  #metrics.cards>.card{padding:10px 12px!important}
  #metrics.cards :is(.big,.number){font-size:22px!important;line-height:1.15;margin-top:2px}

  /* Pill and tab rows: one line that scrolls sideways inside itself. */
  .hm-scroll-row,.dd-tabs,.dq-chips{flex-wrap:nowrap!important;overflow-x:auto;overflow-y:hidden;scrollbar-width:none;-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}
  .hm-scroll-row::-webkit-scrollbar,.dd-tabs::-webkit-scrollbar,.dq-chips::-webkit-scrollbar{display:none}
  .dd-tabs>*,.dq-chips>*{flex:0 0 auto;white-space:nowrap}

  /* Standalone pages (Partners, Daily Actions, Prospecting ...): title, then one sideways-scrolling
     row of links with Sign out at the end. */
  body>header:has(>nav){padding:10px var(--hm-edge)!important;gap:6px!important}
  body>header h1{font-size:22px!important;line-height:1.2!important;margin:2px 0 0!important}
  body>header>nav{display:flex!important;flex-wrap:nowrap!important;overflow-x:auto;scrollbar-width:none;gap:4px 14px!important;align-items:center;width:100%;padding-bottom:2px}
  body>header>nav::-webkit-scrollbar{display:none}
  body>header>nav>*{flex:0 0 auto;white-space:nowrap}
  body>header>nav>a{min-height:var(--hm-tap);display:inline-flex!important;align-items:center}
  body>header>nav>button{min-height:36px;padding:6px 12px!important;margin-left:auto}

  /* Contact / lead / partner page: the record column is an <aside>, and the old phone rule that
     turned every aside into a sideways strip squeezed its sections into thin columns. Stack them. */
  .haven-contact-360 aside.haven-360-side{display:block!important;overflow:visible!important;padding:0!important;background:transparent!important;border:0!important}
  .haven-contact-360 .haven-360-side>*{margin-bottom:var(--hm-gap)}

  /* ---------- Command home (index.html) ---------- */
  /* Header: brand and the two buttons on one row, search below, no tagline. */
  body>header{padding:8px 10px!important;row-gap:8px!important;column-gap:8px!important;min-height:0!important}
  body>header .logo{width:34px!important;height:34px!important;font-size:19px!important;border-radius:9px!important}
  body>header .brand{gap:8px!important;flex:1 1 auto!important}
  body>header .brand b{font-size:14px!important;letter-spacing:1.2px!important}
  body>header .micro{display:none!important}
  body>header>.actions{flex:0 0 auto!important;width:auto!important;gap:6px!important}
  body>header>.actions .btn{min-height:36px;padding:7px 10px!important}
  body>header .haven-contact-search form{gap:6px!important}
  body>header .haven-contact-search label{position:absolute!important;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  body>header .haven-contact-search input{min-height:var(--hm-tap)}

  /* Settings menu: a tidy sheet under the header instead of a half off-screen list. */
  #havenSettingsMenu .haven-settings-panel{position:fixed!important;left:var(--hm-edge)!important;right:var(--hm-edge)!important;top:56px!important;width:auto!important;z-index:1200;padding:8px!important;border:1px solid #d7e3f0!important;border-radius:var(--hm-radius)!important;box-shadow:0 14px 34px rgba(10,30,60,.2);display:flex;flex-direction:column;gap:2px;max-height:calc(100dvh - 72px);overflow:auto}
  #havenSettingsMenu .haven-settings-label{font-size:11px;font-weight:700;letter-spacing:.08em;color:#5a6b7e!important;padding:10px 10px 2px}
  #havenSettingsMenu .haven-settings-item{display:flex!important;align-items:center;gap:8px;width:100%!important;min-height:44px;margin:0!important;padding:8px 10px!important;background:transparent!important;border:0!important;border-radius:8px!important;box-shadow:none!important;text-align:left;font-size:15px!important;font-weight:600;text-decoration:none!important}
  #havenSettingsMenu .haven-settings-item:active{background:#eef4fb!important}
  #havenSettingsMenu #havenSettingsStatus{margin:6px 10px 4px;color:#5a6b7e!important}

  /* Menu: folded away until the Menu button opens it. */
  body>.shell>aside#nav:not(.mobile-open){display:none!important}
  body>.shell>aside#nav.mobile-open{display:flex!important;flex-direction:column!important;overflow:visible!important;padding:6px var(--hm-edge) 10px!important}
  body>.shell>aside#nav.mobile-open :where(a,button){min-height:var(--hm-tap);white-space:normal!important}
  .mobile-navigation-row{margin:var(--hm-edge) var(--hm-edge) 0!important;gap:var(--hm-edge)!important}
  .mobile-navigation-row .mobile-nav-toggle,.card-scanner-quick-mobile{min-height:44px!important;padding:8px 12px!important}

  /* Dashboard canvas: the dark frame drops its inset so cards use the full width. */
  #briefing.page{padding:10px var(--hm-edge) 16px!important;border-left:0!important;border-right:0!important;border-radius:var(--hm-radius)!important;margin:0 calc(var(--hm-edge) * -1)!important}
  #briefing .cockpit-hub{display:none!important} /* decorative system map */
  #briefing>.eyebrow{margin-top:2px}
  #briefing>.eyebrow+.row.wrap{gap:8px!important}
  #briefing>.eyebrow+.row.wrap h1{margin:2px 0!important}
  #briefing>.eyebrow+.row.wrap .sub{display:none}
  #briefing>.eyebrow+.row.wrap>.row{display:grid!important;grid-template-columns:1fr 1fr;gap:8px!important;width:100%}
  #briefing>.eyebrow+.row.wrap>.row>.btn{width:100%;margin:0!important;padding:8px!important;font-size:12.5px!important}
  #briefing>.eyebrow+.row.wrap>.row>.btn:first-child{grid-column:1/-1}
  #briefing .card{margin-left:0!important;margin-right:0!important}

  /* Day desk card (Today, Queue and the other tabs) */
  #havenDayDesk>*,#havenDayDesk .dd-panel,#havenDayDesk [role=tabpanel]{min-width:0;max-width:100%}
  #havenDayDesk.dd{padding:12px 10px!important;margin:10px 0!important;gap:10px!important;border-radius:var(--hm-radius)!important}
  #havenDayDesk .dd-head h2{font-size:20px!important}
  #havenDayDesk .dd-tabs{gap:0!important;margin:0 -10px;padding:0 6px}
  #havenDayDesk .dd .dd-tab,#havenDayDesk .dd-tab{padding:10px 10px!important;min-height:var(--hm-tap)!important}
  #havenDayDesk .dd-btn{min-height:36px!important;padding:6px 10px!important;font-size:13px!important;display:inline-flex!important;align-items:center;justify-content:center}
  #havenDayDesk .dd-row{grid-template-columns:minmax(0,1fr)!important;gap:6px!important;padding:10px!important}
  #havenDayDesk .dd-row>.t{display:flex!important;flex-direction:row!important;align-items:center;gap:8px!important}
  #havenDayDesk .dd-row .dd-acts{grid-column:1/-1!important;justify-content:flex-start!important}

  /* Executive tabs under the day desk: one compact row. */
  #ceoExecutiveTabs{grid-template-columns:repeat(3,minmax(0,1fr))!important;gap:6px!important}
  #ceoExecutiveTabs .btn{padding:8px 6px!important;font-size:11.5px!important;line-height:1.25;white-space:normal!important}

}

@media (max-width:420px){
  body>header .brand>div:not(.logo){display:none} /* the H logo carries the brand on small phones */
  body>header>.actions .btn{font-size:12px!important;padding:7px 9px!important}
}

/* Readability (all widths): these headings were light text on the white cockpit cards, and the
   Executive Cockpit title was navy on the dark frame, so both were close to invisible. */
#briefing>.eyebrow+.row.wrap h1{color:#eaf2ff!important;-webkit-text-fill-color:#eaf2ff!important}
#briefing :is(.cockpit-brief,.cockpit-calendar,#ceoExtraTasksSection) :is(h2,h3,.cockpit-todo-title,#cockpitMonthTitle):not(:is(#ceoCurrentRpWorkspace,#ceoNewRpWorkspace,#ceoTaskModal) *){color:#10233a!important;-webkit-text-fill-color:#10233a!important}
#briefing :is(#ceoCurrentRpWorkspace,#ceoNewRpWorkspace)>h3,#briefing :is(#ceoCurrentRpWorkspace,#ceoNewRpWorkspace) :is(h2,h3){color:#eaf2ff!important;-webkit-text-fill-color:#eaf2ff!important}
#briefing .cockpit-grid a.cockpit-textlink{color:#0b5fc4!important}
