/* Shared responsive foundations. Wide data stays in labelled scroll regions;
   forms, cards and navigation reflow with the available content width. */
:root{--mobile-nav-height:64px;--header-height:76px}
body{overflow-wrap:anywhere}
.shell,.main,.content,.pubwrap,.card,.stack,.grid,.split,.formgrid,.row,.between,.pagehead{min-width:0}
.grid>*,.split>*,.formgrid>*,.row>*,.between>*,.pagehead>*,.card>*{min-width:0}
.g2,.formgrid{grid-template-columns:repeat(2,minmax(0,1fr))}
.g3{grid-template-columns:repeat(3,minmax(0,1fr))}
.g4{grid-template-columns:repeat(4,minmax(0,1fr))}
.radiogrid{grid-template-columns:repeat(2,minmax(0,1fr))}
.matrix{grid-template-columns:repeat(auto-fit,minmax(min(100%,190px),1fr))}
.btn,.badge,.vbadge,.tag,.rolebadge{max-width:100%;white-space:normal;overflow-wrap:anywhere}
.btn{text-align:center;line-height:1.4}
.badge.dot::before{flex-shrink:0}
input,select,textarea{min-width:0;max-width:100%}
input[type=url],input[type=time],input[type=search]{width:100%;background:var(--bg-2);border:1px solid var(--line);border-radius:10px;color:var(--ink);padding:9px 12px;font:inherit}
input[type=checkbox],input[type=radio]{flex-shrink:0;accent-color:var(--volt)}
select{overflow:hidden;text-overflow:ellipsis}
pre{white-space:pre-wrap;overflow-wrap:anywhere;max-width:100%}
img,video,iframe,canvas{max-width:100%}
.tablewrap,.board,.tabs{min-width:0;max-width:100%;overscroll-behavior-x:contain}
.tablewrap{scrollbar-width:auto}
.tablewrap table:not(.rwd):not(.kv){min-width:420px;overflow-wrap:normal}
.tablewrap table:not(.rwd):not(.kv):has(tr>:nth-child(4)){min-width:640px}
.tablewrap table:not(.rwd):not(.kv):has(tr>:nth-child(7)){min-width:880px}
.tablewrap td{overflow-wrap:break-word}
.tscore,.hbar .num{white-space:nowrap;overflow-wrap:normal}
.bars .b{height:100%;display:grid;grid-template-rows:18px minmax(0,1fr) 28px;justify-items:center;align-items:end;gap:4px}
.bars .b .l{white-space:normal;overflow:visible;line-height:1.2;align-self:start}
.kpi .spark{pointer-events:none}
.tablewrap:focus-visible,.board:focus-visible,.tabs:focus-visible{outline:2px solid var(--volt);outline-offset:3px}
.tabs{overflow-x:auto;flex-wrap:nowrap}
.tabs>a{flex-shrink:0}
.board{scroll-snap-type:none}
.kcol{scroll-snap-align:start}
.khead b{overflow-wrap:anywhere}
.topbar{flex-wrap:wrap}
.topbar>form{min-width:160px;flex:1 1 200px}
.searchbox{min-width:0}
.searchbox input[type=search]{padding:0;border:0;background:transparent;border-radius:0;box-shadow:none}
.ats-focus{min-width:0;max-width:260px;flex:0 1 260px}
.ats-focus select{min-width:0;flex:1;width:100%}
.ats-focus span{flex-shrink:0}
.userchip{flex-shrink:0;gap:8px}
.sidebar{height:100dvh;overscroll-behavior-y:contain}
.sidebar-close,.sidebar-focus{display:none}
.flash{max-width:min(420px,calc(100vw - 24px));right:max(12px,env(safe-area-inset-right));top:max(12px,env(safe-area-inset-top))}
.installbar{flex-wrap:wrap}
.movesheet .sheet{max-height:80dvh;overscroll-behavior:contain}
.movesheet .stageopt{width:100%;font:inherit;color:var(--ink);text-align:left;gap:12px}
.kcard .movebtn{display:inline-flex;min-height:32px}
/* Sticky elements track the real header height (including wrapping/zoom). */
html{scroll-padding-top:calc(var(--header-height) + 12px)}
.timerbox{top:calc(var(--header-height) + 12px)}
.bulkbar{top:calc(var(--header-height) + 8px)!important}
#backTop{bottom:calc(18px + env(safe-area-inset-bottom));background:var(--panel);color:var(--ink)}
#cmdk{padding:max(16px,env(safe-area-inset-top)) 12px;align-items:center}
#cmdk .box{max-height:calc(100dvh - 32px);display:flex;flex-direction:column;background:var(--panel)}
#cmdk .cmdk-close{align-self:flex-end;margin:8px 8px 0;min-height:44px}
#cmdk .res{max-height:60dvh;min-height:0;overscroll-behavior:contain}
#cmdk .res a{gap:12px;align-items:center}
#cmdk .res .k{overflow-wrap:anywhere;min-width:0}
@media (max-width:1180px){
  .g4{grid-template-columns:repeat(2,minmax(0,1fr))}
  .split{grid-template-columns:minmax(0,1fr)}
  .g3{grid-template-columns:repeat(2,minmax(0,1fr))}
  .topbar{gap:10px;padding:12px 18px}
  .ats-focus{flex-basis:200px}
}
@media (max-width:1024px){
  .sidebar{position:fixed;inset:0 auto 0 0;z-index:80;width:min(310px,calc(100vw - 48px));height:100dvh;transform:translateX(-100%);visibility:hidden;transition:transform .2s ease,visibility .2s;padding-top:max(14px,env(safe-area-inset-top));padding-bottom:max(18px,env(safe-area-inset-bottom))}
  .sidebar.open{transform:none;visibility:visible;box-shadow:var(--shadow)}
  .sidebar-close{display:flex;align-self:flex-end;flex-shrink:0;margin-bottom:8px}
  .sidebar-focus{display:grid;gap:6px;padding:6px 10px 14px;font-size:12px;color:var(--muted)}
  .scrim{z-index:70}
  body.nav-open{overflow:hidden}
  .menubtn{display:inline-flex!important;align-items:center;justify-content:center;flex-shrink:0;min-width:44px;min-height:44px}
  .topbar{gap:10px;padding:10px max(14px,env(safe-area-inset-right)) 10px max(14px,env(safe-area-inset-left))}
  .topbar .ats-focus{display:none}
  .topbar>form{max-width:none}
  .nav a{min-height:44px}
  .mobilenav{display:flex;position:fixed;inset:auto 0 0;z-index:60;background:var(--bg-2);border-top:1px solid var(--line);justify-content:space-around;align-items:stretch;padding-bottom:env(safe-area-inset-bottom)}
  .mobilenav a{flex:1;min-width:0;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;padding:8px 2px 6px;color:var(--dim);font-size:10px;font-weight:700;text-decoration:none;min-height:58px}
  .mobilenav a .mi{font-size:19px;line-height:1}
  .mobilenav a.active{color:var(--volt-2)}
  .main .content{padding:20px max(18px,env(safe-area-inset-right)) calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 24px) max(18px,env(safe-area-inset-left))}
  .has-mobilenav #backTop{bottom:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px)}
  .btn,.btn.sm,.btn.xs,.themebtn{min-height:44px}
  .themebtn{min-width:44px;justify-content:center}
  input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select,textarea{font-size:16px!important;min-height:44px}
  .searchbox input[type=search]{min-height:28px;font-size:16px}
  .board{scroll-snap-type:none}
  .kcol{min-width:0;flex:0 0 min(300px,85%);width:auto;max-height:none}
  .kbody{max-height:none}
  .kcard .movebtn{display:inline-flex;min-height:44px}
}
@media (max-width:860px){
  .g2,.formgrid{grid-template-columns:minmax(0,1fr)}
  .span2{grid-column:auto}
  .filterbar input,.filterbar select{max-width:100%;min-width:0}
}
@media (max-width:720px){
  /* Block flow keeps multiple tags, nested forms and links readable in card cells. */
  table.rwd td{display:block;text-align:left;overflow-wrap:anywhere;min-width:0}
  table.rwd td::before{display:block;margin-bottom:5px;white-space:normal}
  table.rwd td:not([data-label])::before,table.rwd td[data-label=""]::before{display:none}
  table.rwd td .sub{text-align:left}
  table.rwd td .row{justify-content:flex-start}
  table.rwd tr{margin:0 0 10px;max-width:100%}
  table.rwd tr:last-child{margin-bottom:0}
  table.rwd td[colspan]{width:100%}
}
@media (max-width:600px){
  .topbar>form{order:3;flex-basis:100%;min-width:0}
  .topbar .userchip{margin-left:auto}
  .topbar .rolebadge{display:none}
  .topbar .hide-xs{display:inline-flex!important}
  .topbar .avatar{display:none}
  .main .content{padding-top:18px;padding-left:max(12px,env(safe-area-inset-left));padding-right:max(12px,env(safe-area-inset-right))}
  .g3,.g4,.radiogrid{grid-template-columns:minmax(0,1fr)}
  .pagehead{align-items:flex-start}
  .pagehead>.row{width:100%;gap:8px}
  .pagehead>.row>.btn{flex:1 1 auto}
  .filterbar input,.filterbar select{flex-basis:100%;width:100%}
  .filterbar>.btn{flex:1}
  .row>input:not([type=hidden]):not([type=checkbox]):not([type=radio]),.row>select,.row>textarea{flex:1 1 100%;width:100%!important;max-width:100%!important}
  .row>.tmplpick{flex-basis:100%!important;max-width:100%!important}
  .btn{white-space:normal}
  .hbar{grid-template-columns:minmax(65px,100px) minmax(0,1fr) 44px}
  .timerbox{position:static}
  .installbar .btn{margin-left:0}
}
@media (max-height:500px) and (orientation:landscape){
  .topbar{position:static}
  .timerbox,.bulkbar{position:static!important}
  .mobilenav a{min-height:46px;padding-block:4px}
  .movesheet .sheet{max-height:90dvh}
}
@media (pointer:coarse){
  .btn,.btn.sm,.btn.xs,.nav a,.tabs a,.themebtn{min-height:44px}
  input[type=checkbox],input[type=radio]{width:20px;height:20px}
  .kcard .movebtn{display:inline-flex;min-height:44px}
}
@media print{
  .mobilenav,.scrim,.sidebar-close,.movesheet,#backTop,#cmdk{display:none!important}
  .main .content{padding:0}
}

/* Final responsive shell contract. Keep the application viewport itself at
   the device width; only intentional tables/boards may scroll horizontally. */
html,body{max-width:100%;overflow-x:hidden}
html.nav-open{overflow:hidden}
.shell{width:100%;max-width:100%;min-width:0;overflow-x:hidden}
.main{width:auto;max-width:100%;min-width:0;overflow-x:hidden}
.topbar{width:100%;max-width:100%;min-width:0}

@media (max-width:1024px){
  .shell{display:block}
  .main{width:100%;max-width:100%;margin:0}
  .sidebar,
  body.nav-collapsed .sidebar{
    width:min(310px,calc(100vw - 24px))!important;
    max-width:calc(100vw - 24px)!important;
    transform:translate3d(-100%,0,0)!important;
    visibility:hidden!important;
    opacity:0;
    pointer-events:none;
  }
  .sidebar.open{
    transform:translate3d(0,0,0)!important;
    visibility:visible!important;
    opacity:1;
    pointer-events:auto;
  }
}

@media (min-width:1025px){
  /* Keep the workspace rail pinned while the page content scrolls. The rail
     owns its own scroll position, so long menus never disappear with the page. */
  .shell{display:block;min-height:100vh}
  .sidebar{position:fixed!important;inset:0 auto 0 0;width:256px;height:100dvh;min-height:100vh;max-height:100dvh;align-self:flex-start;overflow-y:auto;overscroll-behavior-y:contain;z-index:40}
  .sidebar-collapse{display:inline-flex!important;align-items:center;justify-content:center;position:absolute;top:18px;right:10px;width:34px;height:34px;padding:0;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--muted);cursor:pointer}
  .sidebar-collapse:hover,.sidebar-collapse:focus-visible{color:var(--ink);border-color:var(--volt);outline:none}
  .main{width:auto;margin-left:256px;min-height:100vh}
  body.nav-collapsed .main{margin-left:76px}
  /* The full navigation rail is already visible on desktop; reserve the
     hamburger for the off-canvas tablet/phone drawer only. */
  .menubtn{display:none!important}
}

/* A 768px tablet/compact desktop still has enough room for the workspace
   rail. Keep it visible so users can move between sections without opening a
   drawer; the off-canvas navigation begins only on phone-sized screens. */
@media (min-width:768px) and (max-width:1024px){
  .shell{display:block;min-height:100vh}
  .sidebar{position:fixed!important;inset:0 auto 0 0;width:256px!important;max-width:256px!important;height:100dvh;min-height:100vh;max-height:100dvh;overflow-y:auto;overscroll-behavior-y:contain;transform:none!important;visibility:visible!important;opacity:1;pointer-events:auto;z-index:40}
  .sidebar-collapse{display:inline-flex!important;align-items:center;justify-content:center;position:absolute;top:18px;right:10px;width:34px;height:34px;padding:0;border:1px solid var(--line);border-radius:8px;background:var(--panel);color:var(--muted);cursor:pointer}
  .sidebar-collapse:hover,.sidebar-collapse:focus-visible{color:var(--ink);border-color:var(--volt);outline:none}
  .sidebar-close,.mobilenav,.scrim{display:none!important}
  .main{width:auto;margin-left:256px;min-height:100vh}
  body.nav-collapsed .sidebar{width:76px}
  body.nav-collapsed .main{margin-left:76px}
  .menubtn{display:none!important}
  #scrollControls{bottom:18px!important}
}

@media (max-width:1024px){
  /* Keep the page scroll controls above the fixed mobile navigation. */
  #scrollControls{
    right:max(10px,env(safe-area-inset-right));
    bottom:calc(var(--mobile-nav-height) + env(safe-area-inset-bottom) + 12px)!important;
  }
}

@media (max-width:767.98px){
  /* Phone layout: navigation becomes a contained drawer and the page remains
     the only horizontal viewport. */
  .sidebar{width:min(310px,calc(100vw - 24px))!important;max-width:calc(100vw - 24px)!important}
}
@media (max-width:360px){
  .mobilenav a{
    min-height:52px;
    padding:3px 0 4px;
    font-size:8px;
    letter-spacing:-.02em;
    white-space:nowrap;
    overflow:hidden;
  }
  .mobilenav a span{min-width:0;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
  .mobilenav a .mi{font-size:16px}
  #scrollControls{right:6px!important;gap:4px}
  #scrollControls button{width:38px!important;height:38px!important;font-size:16px}
}

/* Header search stays an icon beside notifications until explicitly opened. */
.header-search-toggle{display:inline-flex;align-items:center;justify-content:center;flex:0 0 38px;width:38px;height:38px;padding:0;border:1px solid var(--line);border-radius:5px;background:var(--panel);color:var(--ink);cursor:pointer;transition:background-color .15s ease,border-color .15s ease,color .15s ease}
.header-search-toggle:hover,.header-search-toggle:focus-visible{border-color:var(--volt);color:var(--volt);background:var(--panel-2)}
.header-search-toggle:focus-visible{outline:2px solid var(--volt);outline-offset:2px}
.header-search-form{min-width:0}
.header-search-form[hidden]{display:none!important}
.header-search-form .searchbox{width:100%;max-width:none}
.topbar.search-open{height:auto;min-height:68px;row-gap:8px}
.topbar.search-open .header-search-form{display:block;order:10;flex:1 0 100%;width:100%;max-width:none;min-width:0}
@media (max-width:1024px){
  .header-search-toggle{flex-basis:44px;width:44px;height:44px}
  .topbar.search-open{height:auto}
}
@media (max-width:600px){
  .topbar.search-open .header-search-form{flex-basis:100%}
  .topbar.search-open .header-search-form .searchbox{height:44px}
}
