/* Facilities Maintenance Console — responsive overrides.
   Tablet (≤900px): the sidebar becomes a strip across the top.
   Phone (≤720px): a bottom tab bar, list rows as cards, full-screen forms,
   a compact calendar, and touch-sized controls. */

/* ---------- tablet ---------- */
@media(max-width:900px){
  #app{grid-template-columns:1fr}
  #side{position:static;height:auto}
  .nav{flex-direction:row;overflow-x:auto;padding:8px}
  .nav .lbl{display:none}.nav a .ct{display:none}.side-foot{display:none}
  .nav a{white-space:nowrap}
  .tiles{grid-template-columns:repeat(2,minmax(0,1fr))}
  .brand-logo{height:28px}
  .rem-row,.reg-row,.req-row,.utable .urow,.vend-row,.cat-row,.srv-tpl-row,.srv-run-row{grid-template-columns:minmax(0,1fr);gap:6px}
  .thead{display:none}.content{padding:16px}.rd-grid,.frow{grid-template-columns:minmax(0,1fr)}
  .cal-dow,.cal-weeks{grid-template-columns:repeat(7,minmax(0,1fr))}
  .cal-cell{min-height:80px}
  .topbar{padding:10px 14px;gap:10px;flex-wrap:wrap;row-gap:8px}
  .topbar-div{display:none}
  #backbtn{padding:6px 9px}
  .tt{flex:1 1 40px}
  .tt h1{font-size:16px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .tt .desc{display:none}
  .saved{min-width:0}
  .saved #savedtx{display:none}
  #themebtn,#helpbtn{padding:6px 9px}
  #themebtn .tl,#helpbtn .tl{display:none}
  .actorbox{padding:4px 5px 4px 10px;gap:6px}
  .actorbox .rl{display:none}
  .actorbox select{max-width:150px}
}

/* ---------- phone ---------- */
@media(max-width:720px){
  html{-webkit-text-size-adjust:100%}
  body{overflow-x:hidden}
  #app{grid-template-columns:minmax(0,1fr);min-height:100dvh}
  #main{padding-bottom:calc(66px + env(safe-area-inset-bottom))}

  /* bottom tab bar */
  #side{position:fixed;left:0;right:0;bottom:0;top:auto;height:auto;z-index:30;border-top:1px solid var(--ink-line);padding-bottom:env(safe-area-inset-bottom);box-shadow:0 -6px 20px rgba(0,0,0,.18)}
  .brand,.side-foot{display:none}
  .nav{flex-direction:row;justify-content:space-around;padding:4px 4px 3px;gap:0;overflow:visible}
  .nav a{display:none;position:relative;flex:1 1 0;flex-direction:column;align-items:center;justify-content:center;gap:3px;min-height:54px;padding:8px 2px 6px;font-size:0;font-weight:600;border-radius:8px;white-space:nowrap}
  .nav a[data-mobile]{display:flex}
  .nav a[data-mobile]::after{content:attr(data-mobile);font-size:10.5px;line-height:1}
  .nav a .ico{font-size:19px;width:auto;opacity:1;line-height:1}
  .nav a:hover{background:transparent}
  .nav a.on{background:transparent;color:#fff}
  .nav a.on .ico{color:#8FC1EE}
  .nav a .ct{display:block;position:absolute;top:3px;left:calc(50% + 6px);margin:0;font-size:9.5px;line-height:1.5;padding:0 5px;background:var(--accent);color:#fff}

  /* top bar */
  .topbar{padding:8px 12px;gap:8px;flex-wrap:nowrap;row-gap:0}
  .brand-logo{height:24px;padding:0}
  .tt{flex:1 1 auto;min-width:0}
  .tt h1{font-size:15px}
  .saved{gap:0}
  .actorbox{display:none}
  #backbtn{padding:6px 8px;font-size:12.5px}
  #themebtn,#helpbtn{padding:6px 8px;min-height:34px}

  /* content */
  .content{padding:12px 12px 24px}
  .panel{border-radius:10px;margin-bottom:14px}
  .panel .ph{padding:12px 14px;flex-wrap:wrap;gap:8px}
  .panel .ph h2{font-size:14px;flex:1 1 auto}
  .panel .ph .sp{display:none}
  .panel>div[style*="padding:12px 18px"]{padding:10px 14px!important}
  .tiles{gap:10px;margin-bottom:14px}
  .tile{padding:12px 12px 11px;border-radius:10px}
  .tile .v{font-size:24px;margin-top:6px}
  .tile .m{font-size:11px}
  .banner{padding:10px 12px;font-size:12.5px;flex-wrap:wrap}
  .banner .sp{display:none}
  .banner .btn{flex:1 1 100%;justify-content:center}
  .eyebrow{flex:1 1 100%}

  /* list rows become cards: tag and date on the first line, the title next, pills after */
  .row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 10px;padding:12px 14px}
  .row>*{min-width:0}
  .row>div{flex:1 1 100%;order:4}
  .row>span.tag,.row>.tag{flex:0 0 auto;order:0}
  .row>.date{flex:0 0 auto;order:1;margin-left:auto;font-size:12px;text-align:right}
  .row>div:has(>.primary-cell){order:2}
  .row>div:has(>.pill),.row>div:has(>.grp),.row>div:has(>.dotstat){flex:0 0 auto;order:3}
  .row>.ability-pills{order:3}
  .row .sub-cell{white-space:normal}
  .row .actionbar{flex:1 1 100%;order:9;margin-top:4px}
  .row .actionbar .btn,.row>button.btn{flex:1 1 auto;justify-content:center;min-height:38px}
  .row>button.btn{order:9;flex:1 1 100%}
  .srv-field{flex-wrap:wrap;padding:12px 14px}
  .sf-notes{white-space:normal;max-width:none}
  .sf-meta{flex:1 1 100%;justify-content:flex-start}
  .sf-meta>span{justify-content:flex-start!important}

  /* filters */
  .filters{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .filters .searchbox{grid-column:1/-1}
  .searchbox{flex:1 1 100%}
  .searchbox input{width:100%}
  .filters select{width:100%;min-width:0}

  /* touch-sized controls; 16px text stops iOS zooming into fields */
  input,select,textarea,.txtin,.filters select,.searchbox input{font-size:16px}
  .btn{min-height:40px}
  .btn-sm{min-height:36px;padding:7px 12px;font-size:12.5px}
  .field{margin-bottom:13px}
  .assign-grid{grid-template-columns:minmax(0,1fr);max-height:240px}
  .frow[style]{grid-template-columns:minmax(0,1fr)!important}
  .pwd-row{flex-wrap:nowrap}
  .stepper .st .cn{font-size:9px}
  .stepper .st:not(.cur) .cn{visibility:hidden}
  .linkadd select{flex:1 1 100%}

  /* forms and records open as full-screen sheets */
  /* a block overlay, not a flex one: as a flex item the sheet stayed the height
     of the screen and a long form spilled out past its own background */
  #modal .scrim{padding:0;display:block}
  #modal .modal,#modal .modal.wide{max-width:none;width:100%;min-height:100%;height:auto;border-radius:0;display:flex;flex-direction:column;overflow:visible;animation:none;box-shadow:none}
  #modal .mh{position:sticky;top:0;z-index:2;background:var(--surface);padding:12px 16px}
  #modal .mh h2{font-size:16px}
  #modal .mh .x{font-size:24px;padding:4px 8px}
  /* flex:1 1 auto, not flex:1 — a zero flex-basis would size the sheet to the
     screen and let a long form spill out past its own background */
  #modal .mb{padding:14px 16px;max-height:none;flex:1 1 auto;overflow:visible}
  #modal .mf{position:sticky;bottom:0;z-index:2;padding:12px 16px calc(12px + env(safe-area-inset-bottom))}
  #modal .mf .btn{flex:1 1 auto;justify-content:center;min-height:44px}
  #modal .mf .btn[style*="margin-right:auto"]{flex:1 1 100%;margin-right:0!important}
  /* confirmations and prompts stay small and centred */
  #confirm .scrim{display:flex;padding:16px;align-items:center}
  #confirm .modal{max-width:440px!important;border-radius:12px}

  /* calendar: days are tappable cells with colour bars; the day list shows the detail */
  .cal-top{flex-wrap:wrap;gap:8px;margin-bottom:10px}
  .cal-top h2{font-size:16px;flex:1 1 auto}
  .cal-top .sp{display:none}
  .cal-legend{flex:1 1 100%;gap:10px;font-size:11px}
  .cal-nav button{width:34px;height:34px}
  .cal-dow span{padding:6px 2px;text-align:center;font-size:9.5px;letter-spacing:.02em}
  .cal-cell{min-height:58px;padding:4px 3px;gap:2px}
  .cal-cell[data-act]{cursor:pointer}
  .cal-cell[data-act]:active{background:var(--accent-bg)}
  .cal-num{font-size:11px;text-align:center}
  .cal-cell.today .cal-num{margin:0 auto;width:20px;height:20px}
  .cal-item{height:6px;padding:0;border-radius:3px;font-size:0;gap:0;pointer-events:none}
  .cal-item .d,.cal-item .ct,.cal-item .cn{display:none}
  .cal-item.red{background:var(--red)}.cal-item.amber{background:var(--amber)}.cal-item.accent{background:var(--accent)}.cal-item.green{background:var(--green)}
  .cal-more{font-size:9px;padding:0;text-align:center;pointer-events:none}
  .hint{font-size:11.5px}

  /* buildings */
  .bgrid{grid-template-columns:minmax(0,1fr);gap:10px}
  .bcard{padding:14px}

  /* toast sits above the tab bar and spans the width */
  #toast{left:12px;right:12px;bottom:calc(74px + env(safe-area-inset-bottom));transform:translateY(80px);width:auto}
  #toast.show{transform:none}

  /* attachments */
  .att-thumbs{gap:8px}
  .thumb,.thumb img{width:88px}

  /* sign-in */
  .auth-screen{padding:16px}
  .auth-card{padding:22px 18px}
}
