/* ==========================================================================
   GCC Asset Command — 2. App shell
   Sidebar rail + topbar + scrolling worksurface + page header.
   ========================================================================== */

.shell {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* --------------------------------------------------------------- Sidebar -- */
.nav {
  flex: 0 0 var(--nav-w);
  width: var(--nav-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(180deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
  border-right: 1px solid rgba(0, 0, 0, .35);
  z-index: 60;
  transition: width .2s var(--ease), flex-basis .2s var(--ease),
              transform .24s var(--ease);
}

.nav-brand {
  display: flex; align-items: center; gap: .625rem;
  height: var(--topbar-h); flex: none;
  padding: 0 .875rem 0 1rem;
  border-bottom: 1px solid var(--nav-line);
  text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-logo {
  width: 30px; height: 30px; flex: none; border-radius: var(--r-sm);
  background: var(--amber);
  -webkit-mask: var(--logo-url) center / 26px 26px no-repeat;
  mask: var(--logo-url) center / 26px 26px no-repeat;
}
.nav-wordmark { min-width: 0; line-height: 1.15; }
.nav-wordmark b {
  display: block; font-size: var(--fs-sm); font-weight: 650;
  letter-spacing: -.01em; color: var(--nav-ink-on);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-wordmark span {
  display: block; font-size: var(--fs-3xs); letter-spacing: .06em;
  text-transform: uppercase; color: var(--nav-ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

.nav-scroll {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  padding: .625rem .5rem 1rem;
  scrollbar-width: thin; scrollbar-color: #333B4C transparent;
}
.nav-scroll::-webkit-scrollbar { width: 8px; }
.nav-scroll::-webkit-scrollbar-thumb {
  background: #333B4C; border-radius: var(--r-pill);
  border: 2px solid transparent; background-clip: content-box;
}

.nav-group {
  font-size: var(--fs-3xs); font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: #6B7590;
  padding: .875rem .625rem .3125rem; white-space: nowrap;
}
.nav-group:first-child { padding-top: .3125rem; }

.nav-link {
  position: relative;
  display: flex; align-items: center; gap: .625rem;
  min-height: 38px; padding: .4375rem .625rem;
  margin-bottom: 1px; border-radius: var(--r-sm);
  color: var(--nav-ink); text-decoration: none;
  font-size: var(--fs-sm); font-weight: 500; white-space: nowrap;
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: var(--nav-ink-hover); text-decoration: none; }
.nav-link .i { width: 18px; height: 18px; opacity: .85; }
.nav-link.on { background: var(--nav-active-bg); color: var(--nav-ink-on); font-weight: 600; }
.nav-link.on .i { opacity: 1; color: var(--amber); }
.nav-link.on::before {
  content: ""; position: absolute; left: -.5rem; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--amber);
}
.nav-count {
  margin-left: auto; flex: none;
  min-width: 20px; height: 19px; padding: 0 6px;
  display: inline-grid; place-items: center;
  border-radius: var(--r-pill);
  font-size: var(--fs-3xs); font-weight: 700; font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, .11); color: var(--nav-ink-hover);
}
.nav-count.hot { background: var(--crit); color: #fff; }

.nav-foot { flex: none; border-top: 1px solid var(--nav-line); padding: .5rem; }
.nav-toggle {
  display: flex; align-items: center; gap: .625rem; width: 100%;
  min-height: 36px; padding: .375rem .625rem; border-radius: var(--r-sm);
  color: #6B7590; font-size: var(--fs-xs); font-weight: 500; white-space: nowrap;
}
.nav-toggle:hover { background: rgba(255, 255, 255, .06); color: var(--nav-ink-hover); }
.nav-toggle .i { width: 18px; height: 18px; transition: transform .2s var(--ease); }

/* Collapsed rail (desktop) */
@media (min-width: 1080px) {
  html.nav-min { --nav-w: var(--nav-w-min); }
  html.nav-min .nav-wordmark,
  html.nav-min .nav-group,
  html.nav-min .nav-label,
  html.nav-min .nav-toggle span { display: none; }
  html.nav-min .nav-brand { justify-content: center; padding: 0; }
  html.nav-min .nav-link,
  html.nav-min .nav-toggle { justify-content: center; padding-left: 0; padding-right: 0; }
  html.nav-min .nav-link.on::before { left: 0; }
  html.nav-min .nav-toggle .i { transform: rotate(180deg); }
  html.nav-min .nav-count {
    position: absolute; top: 3px; right: 3px; margin: 0;
    min-width: 8px; height: 8px; padding: 0; font-size: 0;
    background: var(--amber);
  }
  html.nav-min .nav-count.hot { background: var(--crit); }
  html.nav-min .nav-group + .nav-link { margin-top: .5rem; }
}

/* Mobile drawer */
.nav-scrim { display: none; }
@media (max-width: 1079.98px) {
  .nav {
    position: fixed; inset: 0 auto 0 0; width: min(var(--nav-w), 84vw);
    transform: translateX(-100%); box-shadow: var(--shadow-3);
  }
  html.nav-open .nav { transform: none; }
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(8, 10, 14, .55); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .2s var(--ease);
  }
  html.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .nav-foot { display: none; }
}

/* ---------------------------------------------------------------- Topbar -- */
.main {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; min-height: 0;
}

.topbar {
  flex: none; height: var(--topbar-h);
  display: flex; align-items: center; gap: .375rem;
  padding: 0 var(--content-px);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}

.tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4375rem;
  height: 36px; min-width: 36px; padding: 0 .5rem;
  border-radius: var(--r-sm); color: var(--ink-2);
  font-size: var(--fs-sm); white-space: nowrap;
  transition: background-color .12s var(--ease), color .12s var(--ease);
}
.tb-btn:hover { background: var(--surface-3); color: var(--ink); }
.tb-btn[aria-expanded="true"], .tb-btn.on { background: var(--surface-3); color: var(--ink); }
.tb-btn .i { width: 18px; height: 18px; }
.tb-sep { width: 1px; height: 22px; background: var(--line); margin: 0 .25rem; flex: none; }

/* Global search trigger */
.tb-search {
  display: flex; align-items: center; gap: .5rem;
  width: min(360px, 30vw); height: 36px; padding: 0 .625rem;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); color: var(--ink-muted);
  font-size: var(--fs-sm); text-align: left;
  transition: border-color .12s var(--ease), background-color .12s var(--ease);
}
.tb-search:hover { border-color: var(--line-strong); background: var(--surface); }
.tb-search .i { width: 16px; height: 16px; flex: none; }
.tb-search .kbd { margin-left: auto; }
@media (max-width: 900px) {
  .tb-search {
    flex: none; width: 36px; min-width: 36px; padding: 0;
    justify-content: center; border: 0; background: none;
  }
  .tb-search span, .tb-search .kbd { display: none; }
}
/* Below this the topbar only has room for glyphs. */
@media (max-width: 640px) {
  .topbar .tb-btn > .truncate,
  .topbar .tb-sep { display: none; }
}

.kbd {
  display: inline-block;
  font-family: var(--font-mono); font-size: var(--fs-3xs); line-height: 1.5;
  color: var(--ink-muted); background: var(--surface);
  border: 1px solid var(--line-strong); border-bottom-width: 2px;
  border-radius: var(--r-xs); padding: 0 .3125rem;
}

.tb-dot {
  position: absolute; top: 5px; right: 5px;
  width: 8px; height: 8px; border-radius: var(--r-pill);
  background: var(--crit); box-shadow: 0 0 0 2px var(--surface);
}

/* Role-preview stripe */
.preview-band {
  flex: none; display: flex; align-items: center; gap: .5rem;
  padding: .3125rem var(--content-px);
  font-size: var(--fs-xs); font-weight: 600;
  color: #2A2100; background: var(--amber);
}
.preview-band .i { width: 15px; height: 15px; }
.preview-band form { margin-left: auto; }
.preview-band button {
  font-size: var(--fs-2xs); font-weight: 700; text-decoration: underline;
  color: #2A2100; text-underline-offset: .2em;
}

/* ----------------------------------------------------------- Worksurface -- */
.surface {
  flex: 1 1 auto; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-gutter: stable;
}
.wrapper {
  max-width: var(--shell-max);
  margin: 0 auto;
  padding: var(--sp-5) var(--content-px) var(--sp-9);
}
.wrapper-wide { max-width: none; }

/* ----------------------------------------------------------- Page header -- */
.page-head {
  display: flex; align-items: flex-end; gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.page-head-main { min-width: 0; flex: 1 1 260px; }
.page-title {
  font-size: var(--fs-xl); font-weight: 650; letter-spacing: -.018em;
  display: flex; align-items: center; gap: .5rem; min-width: 0;
}
.page-sub {
  margin-top: .1875rem; font-size: var(--fs-sm); color: var(--ink-muted);
  max-width: 78ch;
}
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

.crumbs {
  display: flex; align-items: center; gap: .3125rem; flex-wrap: wrap;
  font-size: var(--fs-2xs); color: var(--ink-muted); margin-bottom: .3125rem;
}
.crumbs a { color: var(--ink-muted); }
.crumbs a:hover { color: var(--ink-2); }
.crumbs .i { width: 13px; height: 13px; opacity: .6; }

/* ------------------------------------------------------------- Bento grid -- */
/* One 12-column grid the whole app lays out on. Panels declare their span at
   the desktop breakpoint and collapse predictably below it. */
.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: stretch;
}
/* Cards fill their row so a band of panels shares one baseline at the bottom.
   :only-child is load-bearing — six cells stack several cards (requests/view
   has one holding seven), and height:100% on each would overflow the cell.
   Use .grid-start for the rare row that should keep its natural heights. */
.grid > * > .card:only-child { height: 100%; }
.grid-start { align-items: start; }
.grid-start > * > .card:only-child { height: auto; }
.grid + .grid { margin-top: var(--gap); }

.c1  { grid-column: span 1;  } .c2  { grid-column: span 2;  }
.c3  { grid-column: span 3;  } .c4  { grid-column: span 4;  }
.c5  { grid-column: span 5;  } .c6  { grid-column: span 6;  }
.c7  { grid-column: span 7;  } .c8  { grid-column: span 8;  }
.c9  { grid-column: span 9;  } .c10 { grid-column: span 10; }
.c11 { grid-column: span 11; } .c12 { grid-column: span 12; }

/* The remap MUST be sum-preserving: a row authored as 5+4+3 has to stay a
   whole 12 at every breakpoint. Sending .c5 to 6 while .c3 goes to 4 made it
   14, so the third panel wrapped and left a dangling 2-column hole. */
@media (max-width: 1400px) {
  .c3, .c5 { grid-column: span 4; }
  .c7 { grid-column: span 8; }
  .c9, .c10, .c11 { grid-column: span 12; }
}
@media (max-width: 1080px) {
  .c2, .c3, .c4, .c5 { grid-column: span 6; }
  .c7, .c8 { grid-column: span 12; }
}
@media (max-width: 640px) {
  .grid > * { grid-column: span 12 !important; }
}

/* Retained: .grid is stretch by default now, so this is a no-op alias. */
.grid-stretch { align-items: stretch; }

/* Auto-fit tile strips (KPI rows, category tiles) */
.tiles {
  display: grid; gap: var(--gap);
  /* auto-fit, not auto-fill: auto-fill keeps empty tracks, so a 5-tile strip
     on a 1920 screen filled 5 of 7 columns and every page's tiles came out a
     different width. auto-fit collapses the empties and the strip is always
     full-bleed. */
  grid-template-columns: repeat(auto-fit, minmax(var(--tile-min, 210px), 1fr));
}
.tiles-sm { --tile-min: 168px; }
.tiles-lg { --tile-min: 280px; }

/* Print: drop the chrome, keep the sheet */
@media print {
  .nav, .topbar, .nav-scrim, .toasts, .preview-band, .no-print, .progress { display: none !important; }
  .shell, .main, .surface { display: block; height: auto; overflow: visible; }
  .wrapper { max-width: none; padding: 0; }
  body { background: #fff; }
  .card, .panel { box-shadow: none; break-inside: avoid; border-color: #ccc; }

  /* At a letter/A4 page width the 1080px breakpoint otherwise halves any
     column that isn't a .c7/.c8 (e.g. a sidebar), leaving an empty gap
     where it should run the full sheet width. */
  .grid > * { grid-column: span 12 !important; }

  /* A printed page is a document, not a dashboard — trim the on-screen
     spacing scale so a sheet reads tight instead of airy. */
  :root {
    --gap: .5rem;
    --card-pad: .75rem;
    --sp-4: .5rem; --sp-5: .625rem; --sp-6: .75rem; --sp-7: .875rem;
  }
}

/* Navigation progress bar */
.progress {
  position: fixed; inset: 0 0 auto; height: 2px; z-index: 200;
  background: var(--accent); transform-origin: 0 50%; transform: scaleX(0);
  opacity: 0; pointer-events: none;
}
html.busy .progress { animation: prog 1.4s var(--ease-out) forwards; opacity: 1; }
@keyframes prog {
  0% { transform: scaleX(0); } 55% { transform: scaleX(.7); } 100% { transform: scaleX(.94); }
}
