/* ============ narrow screens ============
   Everything below is scoped to a width or pointer query, so the desktop
   layout above is untouched. */
.tabbar,.sheet,.sheet-back{display:none}
@media (max-width: 900px){
  .shell{grid-template-columns:1fr}
  /* the rail gives way to a thumb-reach tab bar: five places that matter, and a
     sheet behind "More" for the rest, so nothing is further than two taps */
  .side{display:none}
  .topbar{padding:10px 14px;gap:8px;flex-wrap:nowrap}
  .topbar>div:first-child{flex:1 1 auto;min-width:0}
  .topbar .lg{font-size:16px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .topbar .sub{font-size:11.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .topbar .grow{display:none}
  .topbar>.btn,.topbar>.menuwrap>.btn{padding:0;width:40px;min-width:40px}
  .topbar>.btn .bl,.topbar>.menuwrap>.btn .bl{display:none}
  .topbar .live{padding:4px 9px;flex:none}
  .content{padding:14px 14px calc(96px + env(safe-area-inset-bottom));max-width:100%}
  .card .hd{padding:15px 16px 0}
  .card .bd{padding:13px 16px 16px}
  /* a five-option segmented control is wider than a phone; let it wrap rather
     than push the page sideways */
  .seg{flex-wrap:wrap;max-width:100%}
  .kpi{padding:12px 14px}
  .kpi .val{font-size:22px}
  .hero{font-size:28px}
  .big{font-size:23px}
  .hypbar{padding:12px 14px}
  .picker{max-height:46vh}
  .tt{max-width:min(280px, calc(100vw - 24px))}
  .board{min-width:660px}
  .scroll-x{-webkit-overflow-scrolling:touch;overscroll-behavior-x:contain}

  .tabbar{display:grid;grid-template-columns:repeat(5,1fr);position:fixed;left:0;right:0;bottom:0;z-index:50;
    padding:6px 6px calc(6px + env(safe-area-inset-bottom));
    background:color-mix(in srgb, var(--surface-1) 96%, transparent);
    -webkit-backdrop-filter:saturate(1.6) blur(18px);backdrop-filter:saturate(1.6) blur(18px);
    border-top:1px solid var(--border);box-shadow:0 -10px 30px -18px rgba(18,22,48,.28)}
  .tab{display:flex;flex-direction:column;align-items:center;gap:3px;padding:6px 2px 4px;border:0;background:transparent;cursor:pointer;
    border-radius:12px;color:var(--text-muted);font-size:10.5px;font-weight:620;letter-spacing:.01em;min-width:0}
  .tab svg{width:22px;height:22px;transition:transform .2s var(--ease)}
  .tab.on{color:var(--brand)}
  .tab.on svg{transform:translateY(-1px) scale(1.06)}
  .tab.on span{font-weight:720}
  .tab span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:100%}
  .sheet-back{display:block;position:fixed;inset:0;z-index:70;background:rgba(8,10,24,.5);-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);animation:fade .2s both}
  .sheet{display:block;position:fixed;left:0;right:0;bottom:0;z-index:80;max-height:84vh;overflow-y:auto;
    background:var(--surface-1);border-radius:24px 24px 0 0;padding:10px 16px calc(22px + env(safe-area-inset-bottom));
    box-shadow:var(--shadow-lg);animation:slideup .3s var(--ease) both}
  .sheet .grab{width:38px;height:4px;border-radius:4px;background:var(--axis);margin:0 auto 14px}
  .sheet h4{font-size:17px;margin:0 4px 4px}
  .sheet .sg{font-size:10px;font-weight:720;letter-spacing:.12em;text-transform:uppercase;color:var(--text-muted);margin:16px 4px 8px}
  .sheet .sgrid{display:grid;grid-template-columns:1fr 1fr;gap:8px}
  .sitem{display:flex;align-items:center;gap:11px;padding:11px 12px;border-radius:14px;border:1px solid var(--border);background:var(--surface-2);
    cursor:pointer;text-align:left;font-size:13.5px;font-weight:600;min-width:0}
  .sitem svg{width:20px;height:20px;flex:none;color:var(--brand)}
  .sitem.on{border-color:var(--brand);background:var(--brand-soft)}
}
@keyframes fade{from{opacity:0}to{opacity:1}}
@keyframes slideup{from{transform:translateY(100%)}to{transform:none}}
@media (max-width: 560px){
  .content{padding:12px 12px calc(96px + env(safe-area-inset-bottom))}
  .card .hd{padding:14px 14px 0}
  .card .bd{padding:12px 14px 15px}
  :root[data-ui="simple"] .card .hd{padding:16px 16px 0}
  :root[data-ui="simple"] .card .bd{padding:14px 16px 18px}
  table.tbl{font-size:12.5px}
  /* a long franchise name should not push every number off the screen */
  table.tbl .tm{max-width:112px}
  /* inside a table cell a wrapping row puts the position pill on its own line
     and doubles the row height; the name should ellipsise instead */
  /* a two-line header is worth far more than a column pushed off the screen */
  table.tbl th{white-space:normal;line-height:1.2}
  table.tbl .row{flex-wrap:nowrap}
  table.tbl .pill,table.tbl .tag{flex:none}
  table.tbl .plink{min-width:0;max-width:124px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  table.tbl th,table.tbl td,:root[data-ui="simple"] table.tbl th,:root[data-ui="simple"] table.tbl td{padding:9px 5px}
  table.tbl th:first-child,table.tbl td:first-child{padding-left:2px}
  table.tbl th:last-child,table.tbl td:last-child{padding-right:2px}
  .grid,:root[data-ui="simple"] .grid{gap:12px}
  .kpi,:root[data-ui="simple"] .kpi{padding:12px 14px}
  .kpi .val,:root[data-ui="simple"] .kpi .val{font-size:22px}
  .kpi .sub,:root[data-ui="simple"] .kpi .sub{font-size:12px}
  .topbar{padding:9px 12px}
}
/* Touch devices and phone widths: fingers are not cursors. A desktop window is
   never below 560px in practice, so nothing here reaches a machine with a mouse. */
@media (pointer: coarse), (max-width: 560px){
  .btn{min-height:40px;padding:8px 14px}
  .btn.sm{min-height:34px;padding:6px 12px;font-size:12.5px}
  .chip{min-height:36px;padding:6px 13px}
  .seg button{min-height:36px;padding:7px 14px}
  .navbtn{min-height:38px}
  .asset{padding:8px 9px}
  .asset .x{padding:0 8px;font-size:15px}
  /* iOS zooms the whole page when a focused field is under 16px */
  input,select,textarea{font-size:16px;min-height:42px}
  table.tbl tbody tr:hover td{background:transparent}
  .plink{padding:2px 0}
}
@supports (height: 100dvh){
  /* a mobile browser's 100vh includes the toolbar that is actually covering it */
  .shell{min-height:100dvh}
  .splash{min-height:100dvh}
}
@media print{ .side,.topbar,.tabbar,.sheet,.sheet-back{display:none} .shell{display:block} .main{background:none} }
