/* ══════════════════════════════════════════════════════════════════════
   shell.css — PAGE LAYOUT + 3-PANE WORKFRAME
   ──────────────────────────────────────────────────────────────────────
   .page                 centred content column (1180px)
   .page.wide            full-width 3-pane frame (left menu / centre / right summaries)
   .page-section         hash-router sections (only .active is shown)
   .wf-layout            the frame: .wf-sidenav | .wf-content | .wf-summary

   Desktop (≥861px):  rails are sticky in-flow columns; in .wide the CENTRE
                      scrolls internally and the page itself does not.
   Tablet (861–1180): right rail hidden, left rail stays.
   Mobile (≤860px):   both rails become slide-in drawers (left = Menu, right =
                      Summaries) driven by data-drawer on .wf-layout, with a
                      floating hamburger, a backdrop, and edge pull-tabs.
   Requires tokens.css. Behaviour lives in ui-kit.js (UI.wireDrawers,
   UI.fitShell, UI.router).
   ══════════════════════════════════════════════════════════════════════ */

/* ── Router sections ───────────────────────────────────────────────── */
.page-section          { display: none; }
.page-section.active   { display: block; }
.page-section.entering { animation: page-in .22s cubic-bezier(.4,0,.2,1) both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
/* NOTE: a section that hosts a .wf-layout with mobile drawers must NOT keep
   the transform animation (fill:both leaves a containing block that traps
   position:fixed). Give such sections .no-anim. */
.page-section.no-anim { animation: none !important; transform: none !important; }

/* ── Centre column ─────────────────────────────────────────────────── */
.page { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }
@media (min-width: 900px) { .page { padding: 32px 28px 80px; } }

.page.wide { max-width: 1840px; }
@media (min-width: 900px) {
  .page.wide { padding-left: clamp(24px, 3.5vw, 60px); padding-right: clamp(24px, 3.5vw, 60px); }
}

/* Narrow reading column for simple pages (account, forms). */
.page.narrow { max-width: 680px; }

/* ── Frame ─────────────────────────────────────────────────────────── */
.wf-layout  { display: flex; gap: 20px; align-items: flex-start; }
.wf-content { flex: 1; min-width: 0; }

/* Left rail: transparent, blended into the page; sticky under the header. */
.wf-sidenav {
  width: 224px; flex-shrink: 0; padding: 4px 6px 4px 0;
  position: sticky; top: var(--wf-rail-top);
  max-height: calc(100vh - var(--wf-rail-top) - 20px); overflow-y: auto;
}
.wf-nav-section + .wf-nav-section { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.wf-nav-title { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 12px 6px; }
.wf-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: 10px; border: none; background: none;
  font-size: 13px; font-weight: 600; color: var(--text); text-align: left; text-decoration: none;
  transition: background .12s, color .12s;
}
.wf-nav-item:hover  { background: rgba(255,255,255,0.7); }
.wf-nav-item.active { background: var(--accent-14); color: var(--accent-ink); font-weight: 700; box-shadow: inset 0 0 0 1px var(--accent-25); }
.wf-nav-ico { display: flex; flex-shrink: 0; color: var(--muted); }
.wf-nav-ico svg { width: 16px; height: 16px; }
.wf-nav-item.active .wf-nav-ico { color: var(--accent-ink); }
.wf-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wf-nav-count { font-size: 10.5px; font-weight: 800; color: var(--muted); background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 7px; }

/* Right rail: stack of summary cards; hidden on tablet. */
.wf-summary {
  width: 288px; flex-shrink: 0; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: var(--wf-rail-top);
  max-height: calc(100vh - var(--wf-rail-top) - 20px); overflow-y: auto;
}
.wf-summary-body { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1180px) { .wf-summary { display: none; } }

/* Desktop: no mobile-only affordances. */
.wf-nav-toggle, .wf-nav-backdrop, .wf-edge-tab, .wf-drawer-head { display: none; }
html.wf-locked, html.wf-locked body { overflow: hidden; }   /* drawer open → page can't scroll */

/* ── Desktop app-shell (viewport-locked centre) ────────────────────── */
@media (min-width: 861px) {
  .page.wide {
    height: calc(100vh - var(--wf-shell-top));
    display: flex; flex-direction: column; overflow: hidden;
    padding-top: 16px; padding-bottom: 0;
  }
  .page.wide > .back-link { flex: 0 0 auto; align-self: flex-start; }
  .page.wide .wf-layout { flex: 1 1 auto; min-height: 0; align-items: stretch; }
  .page.wide .wf-content {
    height: 100%; overflow-y: auto; min-height: 0; padding-bottom: 64px;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .page.wide .wf-content::-webkit-scrollbar { width: 0; height: 0; display: none; }
  .page.wide .wf-sidenav,
  .page.wide .wf-summary {
    position: static; top: auto; height: 100%; max-height: none; overflow-y: auto; padding-bottom: 28px;
    scrollbar-width: none; -ms-overflow-style: none;
  }
  .page.wide .wf-sidenav::-webkit-scrollbar,
  .page.wide .wf-summary::-webkit-scrollbar { width: 0; height: 0; display: none; }
  /* Let the last table in the centre grow to the shell's remaining height. */
  .page.wide .wf-content.fill { display: flex; flex-direction: column; }
  .page.wide .wf-content.fill > .table { flex: 1 1 auto; max-height: none; min-height: 0; margin-bottom: 0; }

  /* Alternative: whole page scrolls, left nav pinned (add .page-scroll to body). */
  body.page-scroll { padding-top: var(--wf-shell-top); }
  body.page-scroll .header { position: fixed; top: 0; left: 0; right: 0; }
  body.page-scroll .page.wide { height: auto; overflow: visible; display: block; padding-top: 16px; padding-bottom: 80px; }
  body.page-scroll .page.wide .wf-layout { align-items: flex-start; }
  body.page-scroll .page.wide .wf-content { height: auto; overflow: visible; padding-bottom: 0; }
  body.page-scroll .page.wide .wf-summary { position: static; height: auto; max-height: none; overflow: visible; }
  body.page-scroll .page.wide .wf-sidenav {
    position: sticky; top: calc(var(--wf-shell-top) + 8px); height: auto;
    max-height: calc(100vh - var(--wf-shell-top) - 24px); overflow-y: auto;
  }
}

/* ── Mobile: rails become drawers ──────────────────────────────────── */
@media (max-width: 860px) {
  .wf-layout { flex-direction: column; }
  .wf-content { width: 100%; }

  /* Floating frosted hamburger above the bottom nav. */
  .wf-nav-toggle {
    display: flex; align-items: center; justify-content: center;
    position: fixed; left: 16px; bottom: calc(var(--bottom-nav-h) + 14px + env(safe-area-inset-bottom, 0px));
    z-index: 1100; width: 52px; height: 52px; border-radius: 50%;
    background: color-mix(in srgb, var(--brand) 78%, transparent); color: #fff;
    backdrop-filter: blur(10px) saturate(1.2); -webkit-backdrop-filter: blur(10px) saturate(1.2);
    border: 1px solid rgba(255,255,255,0.16); box-shadow: 0 10px 26px rgba(0,40,60,0.34);
    -webkit-tap-highlight-color: transparent; transition: transform .14s ease, background .14s ease;
  }
  .wf-nav-toggle:active { transform: scale(.92); }
  .wf-nav-toggle svg { width: 22px; height: 22px; }

  /* Shared drawer chrome — solid panels floating over the content. */
  .wf-sidenav, .wf-summary {
    position: fixed; top: 0; bottom: 0; width: min(82vw, 320px); max-height: none; z-index: 1200;
    background: var(--panel); box-shadow: 0 24px 60px rgba(0,40,60,0.34);
    padding: 18px 14px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain;
    transition: transform .3s cubic-bezier(.32,.72,0,1);
  }
  .wf-sidenav { left: 0; border-right: 1px solid var(--border); border-radius: 0 18px 18px 0; transform: translateX(-100%); }
  .wf-layout[data-drawer="left"] .wf-sidenav { transform: translateX(0); }
  .wf-summary {
    display: flex; flex-direction: column; gap: 14px;
    right: 0; border-left: 1px solid var(--border); border-radius: 18px 0 0 18px; transform: translateX(100%);
  }
  .wf-layout[data-drawer="right"] .wf-summary { transform: translateX(0); }
  .wf-drawer-head { display: block; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 4px; }

  .wf-nav-backdrop {
    display: block; position: fixed; inset: 0; z-index: 1150;
    background: rgba(5,30,45,0.5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s ease; touch-action: none; overscroll-behavior: contain;
  }
  .wf-layout[data-drawer] .wf-nav-backdrop { opacity: 1; pointer-events: auto; }

  /* Edge pull-tab on the opposite side swaps drawers. */
  .wf-edge-tab {
    position: fixed; top: 50%; transform: translateY(-50%); z-index: 1180;
    display: none; align-items: center; justify-content: center; gap: 7px;
    background: color-mix(in srgb, var(--brand) 92%, transparent); color: #fff; border: none;
    font-size: 12.5px; font-weight: 800; letter-spacing: .03em; padding: 16px 9px; writing-mode: vertical-rl;
    box-shadow: 0 10px 28px rgba(0,40,60,0.34); -webkit-tap-highlight-color: transparent;
  }
  .wf-edge-tab svg { width: 15px; height: 15px; }
  .wf-edge-tab.tab-right { right: 0; border-radius: 14px 0 0 14px; }
  .wf-edge-tab.tab-left  { left: 0;  border-radius: 0 14px 14px 0; }
  .wf-layout[data-drawer="left"]  .wf-edge-tab.tab-right { display: flex; }
  .wf-layout[data-drawer="right"] .wf-edge-tab.tab-left  { display: flex; }

  .wf-nav-item { padding: 12px 13px; font-size: 14px; }
}

/* ── Breadcrumbs (optional, top of the centre) ─────────────────────── */
.wf-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 1px; margin-bottom: 16px; }
.wf-crumb { background: none; border: none; font-size: 13px; font-weight: 700; color: var(--accent); padding: 4px 7px; border-radius: 8px; transition: background .12s; }
.wf-crumb:hover { background: var(--accent-10); }
.wf-crumb.is-current { color: var(--brand); font-weight: 800; cursor: default; }
.wf-crumb.is-current:hover { background: none; }
.wf-crumb-sep { display: inline-flex; align-items: center; color: var(--muted); opacity: .45; }
.wf-crumb-sep svg { width: 14px; height: 14px; }

/* ── Master–detail board (list beside a sticky detail pane) ────────── */
.board { display: flex; flex-direction: column; gap: 18px; }
.board-list { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 900px) {
  .board { flex-direction: row; align-items: flex-start; }
  .board-list { flex: 0 0 344px; min-width: 0; }
  .board-detail { flex: 1 1 auto; min-width: 0; position: sticky; top: var(--wf-rail-top); }
}

/* ── Two-column "home" layout (identity card + featured tiles) ─────── */
.home-grid { display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 900px) {
  .home-grid {
    display: grid; grid-template-columns: minmax(280px, 30%) minmax(0, 1fr);
    gap: clamp(12px, 1vw, 20px) clamp(16px, 1.8vw, 30px); align-items: start;
  }
  .home-grid > .span-2 { grid-column: 1 / -1; }
}
