/* Shared staff workspace sizing. The public client portal and sign-in have their own layouts. */
@media (min-width: 981px) {
  html:has(body:not(.portal-mode) .shell) { font-size: 87.5%; }
  body:not(.portal-mode):has(.shell) { font-size: 1rem; }

  body:not(.portal-mode) .shell {
    --ui-text: 1rem;
    --ui-small: .857rem;
    --ui-heading: 2rem;
    --ui-heading-md: 1.43rem;
    --ui-heading-sm: 1.14rem;
    --ui-gap: .857rem;
    --ui-panel: 1rem;
    --ui-row-padding: .429rem;
    --ui-cell-padding: .571rem;
    --ui-control-padding: .429rem .714rem;
    --ui-gutter: clamp(1rem, 1.5vw, 2rem);
    --ui-header-height: 4rem;
    --sidebar-width: 15rem;
    --sidebar-rail-width: 3.75rem;
    font-size: var(--ui-text);
    line-height: 1.4;
  }

  :where(body:not(.portal-mode)) .shell .main > :is(.content, .projects-view, .project-workspace) {
    max-width: none;
    padding: var(--ui-panel) var(--ui-gutter) calc(2 * var(--ui-gutter));
  }
  :where(body:not(.portal-mode)) .shell .top { padding-inline: var(--ui-gutter, 34px); }
  :where(body:not(.portal-mode)) .shell .sub { font-size: var(--ui-text, 18px); }
  :where(body:not(.portal-mode)) .shell .crumb { font-size: var(--ui-heading-sm, 22px); }
  :where(body:not(.portal-mode)) .shell .headline { align-items: start; }
  :where(body:not(.portal-mode)) .shell :is(.headline, .workspace-head) { gap: var(--ui-gap); margin-bottom: var(--ui-gap); }
  :where(body:not(.portal-mode)) .shell .main h1 { font-size: var(--ui-heading, 40px); letter-spacing: -.025em; }
  :where(body:not(.portal-mode)) .shell .main h2 { font-size: var(--ui-heading-md, 26px); }
  :where(body:not(.portal-mode)) .shell .main h3 { font-size: var(--ui-heading-sm, 20px); }
  :where(body:not(.portal-mode)) .shell .headline > :is(button, .btn-primary) { flex-shrink: 0; }

  :where(body:not(.portal-mode)) .shell .main :is(.os-stack, .os-grid, .project-stats, .project-fields, .workspace-grid, .ops-toolbar) { gap: var(--ui-gap); min-width: 0; }
  :where(body:not(.portal-mode)) .shell .main :is(.os-card, .stat, .project-form, .workspace-section, .dd-main, .dd-steps) { padding: var(--ui-panel); min-width: 0; }
  :where(body:not(.portal-mode)) .shell .main :is(.os-stat b, .stat b) { font-size: var(--ui-heading-md); margin-top: 2px; }
  :where(body:not(.portal-mode)) .shell .main .workspace-back { padding: var(--ui-control-padding); }
  :where(body:not(.portal-mode)) .shell .main .workspace-tabs { margin-bottom: var(--ui-gap); }
  :where(body:not(.portal-mode)) .shell .main :is(.workspace-tab, .stage-bar .stage) { padding: var(--ui-control-padding); font-size: var(--ui-text); }
  :where(body:not(.portal-mode)) .shell .main .workspace-meta span { padding: 3px var(--ui-cell-padding); }

  :where(body:not(.portal-mode)) .shell .main :is(.os-table, .projects-table) :is(th, td) {
    padding: var(--ui-row-padding) var(--ui-cell-padding);
    overflow-wrap: anywhere;
  }
  :where(body:not(.portal-mode)) .shell .main :is(.os-table, .projects-table) th { font-size: var(--ui-small); }
  :where(body:not(.portal-mode)) .shell .main :is(.status-tag, .os-pill, .pill) { padding: 2px var(--ui-cell-padding); font-size: var(--ui-small); }
  :where(body:not(.portal-mode)) .shell .main :is(.os-field, .project-fields, .ops-inline) :is(input, select, textarea) {
    min-width: 0;
    max-width: 100%;
    font-size: var(--ui-text);
    padding: var(--ui-control-padding);
  }

  body:not(.portal-mode) .shell.sidebar-collapsed { --sidebar-width: var(--sidebar-rail-width); }
  :where(body:not(.portal-mode)) .shell .side {
    position: sticky;
    top: 0;
    align-self: start;
    max-height: 100dvh;
    min-height: 100dvh;
    padding: var(--ui-gap, 12px);
  }
  :where(body:not(.portal-mode)) .shell .side .brand { font-size: 1rem; }
  :where(body:not(.portal-mode)) .shell .side .brand-mark { width: 2rem; height: 2rem; font-size: 1.2rem; }
  :where(body:not(.portal-mode)) .shell .side small, .shell .side .company label { font-size: .857rem; }
  :where(body:not(.portal-mode)) .shell .side .company { padding-top: .571rem; }
  :where(body:not(.portal-mode)) .shell .side .company select { padding: var(--ui-control-padding); font-size: var(--ui-small); }
  :where(body:not(.portal-mode)) .shell .side .nav {
    display: flex;
    flex-direction: column;
    margin-top: var(--ui-gap);
    padding: 2px 3px;
    gap: 3px;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #68574b transparent;
  }
  .side .nav .nav-group[hidden], .side .nav button[hidden] { display: none; }
  .side .nav .nav-group > button:not([hidden]) { display: flex; align-items: center; width: 100%; min-height: 2rem; }
  .side .nav .nav-group > summary { padding: 4px var(--ui-cell-padding) 2px; }
  .side .sidebar-toggle {
    position: absolute;
    inset: var(--ui-gap) var(--ui-gap) auto auto;
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    background: #33241a;
    color: #fff;
    border: 1px solid #68574b;
    border-radius: 7px;
    cursor: pointer;
  }
  .side .sidebar-toggle:hover { background: #4a3426; }
  .side .sidebar-toggle svg, .side .nav-icon { width: 1.25rem; height: 1.25rem; flex: none; }
  .sidebar-collapsed .side { padding-inline: 3px; align-items: center; }
  .sidebar-collapsed .side .brand-name,
  .sidebar-collapsed .side small,
  .sidebar-collapsed .side .company,
  .sidebar-collapsed .side .nav summary { display: none; }
  .sidebar-collapsed .side .sidebar-toggle { position: static; margin-top: 6px; }
  .sidebar-collapsed .side .sidebar-toggle svg { transform: scaleX(-1); }
  .sidebar-collapsed .side .nav { width: 100%; }
  .sidebar-collapsed .side .nav details { border-top: 1px solid #4a3a2e; padding-top: 4px; }
  .sidebar-collapsed .side .nav .nav-group > button:not([hidden]) {
    justify-content: center;
    padding: 4px;
    min-height: 2.5rem;
    font-size: 0;
    line-height: 0;
    letter-spacing: 0;
  }
  .sidebar-collapsed .side .nav-icon { display: block; }

  .sidebar-tooltip {
    position: fixed;
    transform: translateY(-50%);
    z-index: 60;
    pointer-events: none;
    color: #fff;
    background: var(--ink);
    border: 1px solid #68574b;
    border-radius: 6px;
    padding: .4rem .65rem;
    box-shadow: 0 3px 12px #17100a30;
    font-size: .857rem;
  }
}
.sidebar-toggle, .nav-icon, .sidebar-backdrop { display: none; }
.side .brand-name { color: inherit; }
/* The staff navigation is replaced by the client's own project tabs. */
body.portal-mode .side :is(.sidebar-toggle, .side-menu-btn) { display: none; }

@media (max-width: 980px) {
  .side.menu-open .nav {
    position: absolute;
    z-index: 1;
    inset: 100% auto auto 0;
    width: min(20rem, 88vw);
    margin: 0;
    padding: 8px 12px 16px;
    max-height: calc(100vh - 60px);
    max-height: calc(100dvh - 60px);
    background: var(--ink);
    box-shadow: 4px 8px 24px #17100a38;
    overscroll-behavior: contain;
    animation: workspace-drawer-enter .18s ease-out;
  }
  .side.menu-open .sidebar-backdrop:not([hidden]) {
    display: block;
    position: absolute;
    inset: 100% 0 auto;
    height: 100vh;
    height: 100dvh;
    background: #17100a60;
  }
  .side .nav details.nav-group > summary { min-height: 36px; }
  @keyframes workspace-drawer-enter { from { transform: translateX(-100%); } }
}

@media (max-width: 700px) {
  :where(body:not(.portal-mode) .shell .main) :where(button, select, input:not([type=checkbox], [type=radio]), textarea) { min-height: 36px; }
  .shell .main .project-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
