/* ==========================================================
   Additions for the Laravel build (app.css is the untouched
   prototype stylesheet). Shimmer skeletons reuse the real
   layout classes so the loaded page lands in the same place.
   ========================================================== */
.sk{display:block;height:.85em;border-radius:var(--r-xs);background:linear-gradient(90deg,var(--sunk) 0%,var(--sunk) 38%,color-mix(in srgb,var(--sunk) 40%,var(--surface)) 50%,var(--sunk) 62%,var(--sunk) 100%);background-size:300% 100%;animation:shimmer 1.35s linear infinite}
:root[data-radius=round] .sk{border-radius:8px}
@keyframes shimmer{from{background-position:0 0}to{background-position:100% 0}} /* RTL: highlight travels right → left */
.sk-row{display:flex;align-items:center;gap:12px}
.sk-stack{display:flex;flex-direction:column;gap:10px}
.skel{pointer-events:none;user-select:none}
.skel .tabs button{padding:12px 14px}
.sub .sk{display:inline-block;vertical-align:middle}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* request in flight */
.btn[aria-busy=true],.iconbtn[aria-busy=true]{opacity:.65;pointer-events:none}

/* hidden form sections (base .field sets display:flex) */
[hidden]{display:none!important}

/* team form: one card per company membership, with its project scope */
.mrow{display:grid;grid-template-columns:minmax(0,1.3fr) minmax(0,1fr) minmax(0,1.1fr) 76px;gap:8px;align-items:center;padding:6px 0;border-bottom:1px solid var(--line)}
.mrow:last-child{border-bottom:none}
.mcard{border-bottom:1px solid var(--line)}
.mcard:last-child{border-bottom:none}
.mcard .mrow{border-bottom:none}
.mscope{padding:0 0 10px 0;margin-inline-start:26px}
.mprojects{display:grid;grid-template-columns:repeat(auto-fit,minmax(200px,1fr));gap:4px 14px;margin-top:7px;padding:8px 10px;background:var(--surface-2);border:1px solid var(--line);border-radius:var(--r-sm)}
@media (max-width:640px){.mrow{grid-template-columns:1fr 1fr}.mscope{margin-inline-start:0}.mprojects{grid-template-columns:1fr}}

/* ---- dialog scrolling & motion ---- */
/* contain stops the wheel from dragging the page behind once the box hits its end */
.modal .box{overscroll-behavior:contain;scroll-behavior:smooth;scroll-padding-block:10px;scrollbar-width:thin;scrollbar-color:var(--line-strong) transparent}
.modal .box::-webkit-scrollbar{width:11px}
.modal .box::-webkit-scrollbar-track{background:transparent}
.modal .box::-webkit-scrollbar-thumb{background:var(--line-strong);border:3px solid var(--surface);background-clip:padding-box;border-radius:999px}
.modal .box::-webkit-scrollbar-thumb:hover{background:var(--muted);border:3px solid var(--surface);background-clip:padding-box}
/* a tall dialog reads better easing in than springing: the overshoot fights the scroll position */
.modal .box[data-user-form]{transform:translateY(10px) scale(.985);transition:transform .34s var(--ease),opacity .22s}
.modal.open .box[data-user-form]{transform:none;transition:transform .34s var(--ease),opacity .22s}
@media (prefers-reduced-motion:reduce){
  .modal .box,.modal.open .box,.modal .box[data-user-form],.modal.open .box[data-user-form]{transform:none;transition:opacity .15s}
  .modal .box{scroll-behavior:auto}
}

/* team form: the permission matrix needs more room than a normal dialog */
.modal .box[data-user-form]{width:min(1140px,94vw)}
.modal .box[data-user-form] .kv{grid-template-columns:repeat(3,minmax(0,1fr))}
/* one scroller only — the dialog. A nested scroller here made the wheel fight itself. */
.permgrid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:10px;padding:2px}
.permgroup{border:1px solid var(--line);border-radius:var(--r-sm);background:var(--surface-2);overflow:hidden;align-self:start}
.permgroup-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:7px 10px;background:var(--sunk);font-weight:600;font-size:.86rem;color:var(--text)}
.permgroup-head .btn{opacity:0;transition:opacity .15s}
.permgroup:hover .permgroup-head .btn,.permgroup-head .btn:focus-visible{opacity:1}
/* no hover on touch: the select-all button would be unreachable */
@media (hover:none){.permgroup-head .btn{opacity:1}}
.permrow{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:8px;align-items:start;padding:7px 10px;border-top:1px solid var(--line);font-weight:400;color:var(--text);font-size:.88rem;cursor:pointer}
.permrow:hover{background:var(--surface)}
.permrow input{width:18px;height:18px;margin-top:1px}
.permrow b{font-weight:500}
.permrow.is-override{background:color-mix(in srgb,var(--accent) 7%,transparent)}
.perm-flag{color:var(--accent-text,var(--accent));font-weight:500;white-space:nowrap}

@media (max-width:900px){.modal .box[data-user-form] .kv{grid-template-columns:1fr 1fr}}

/* phones: full-bleed sheet, one scroller, save always in reach */
@media (max-width:640px){
  .modal .box[data-user-form]{width:100%;max-width:100%;max-height:100vh;max-height:100dvh;border-radius:0;border:none;padding:16px}
  .modal .box[data-user-form] .kv{grid-template-columns:1fr}
  /* the dialog itself scrolls — a nested scroller here traps touch drags */
  .permgrid{grid-template-columns:1fr;max-height:none;overflow:visible}
  .permrow{padding:9px 10px;font-size:.9rem}
  .permrow input{width:20px;height:20px}
  .permgroup-head .btn{opacity:1}
  .modal .box[data-user-form] #uSave{position:sticky;bottom:-16px;z-index:2}
}

/* department page */
.dept-hero{display:grid;grid-template-columns:1fr auto;gap:24px;align-items:center}
.am-grid{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1.3fr) minmax(0,1.2fr) 96px auto;gap:10px;align-items:end}
@media (max-width:900px){.am-grid{grid-template-columns:1fr 1fr}}
@media (max-width:640px){.dept-hero{grid-template-columns:1fr}.am-grid{grid-template-columns:1fr}}

/* project form milestones & risk form */
.msrow{display:grid;grid-template-columns:minmax(0,2fr) minmax(0,1.3fr) 80px auto;gap:8px;align-items:center;margin-bottom:8px}
.rk-grid{display:grid;grid-template-columns:minmax(0,2.4fr) 90px 90px minmax(0,1.2fr) auto;gap:10px;align-items:end}
@media (max-width:900px){.rk-grid{grid-template-columns:1fr 1fr}}
@media (max-width:640px){.msrow{grid-template-columns:1fr 1fr}.rk-grid{grid-template-columns:1fr}}

/* sidebar logout sits under the simulation controls */
.me form{margin:0}

/* ===== Login ===== */
body.auth-body{overflow:auto}
.auth{min-height:100vh;min-height:100dvh;display:grid;place-items:center;padding:24px 16px}
.auth .box{width:420px;max-width:100%;background:var(--surface);border:1px solid var(--line);border-radius:calc(var(--r) + 4px);padding:28px;box-shadow:var(--pop-shadow);animation:rise .6s var(--spring) both}
.auth .brand{border-bottom:1px solid var(--line);margin-bottom:20px}
.auth .brand small{color:var(--muted)}
.auth form{display:flex;flex-direction:column;gap:14px}
.auth .err{color:var(--crit);font-size:.82rem;font-weight:500}
.auth .demo{margin-top:18px;border-top:1px solid var(--line);padding-top:14px}
.auth .demo h3{font-size:.82rem;color:var(--muted);margin-bottom:8px;font-weight:500}
