/* App frame (docs/DESIGN.md "Shell"). Owner: lead. Screens never style these classes.
   - Admin:  .suite header (48 px) + nav.navpane (240 px, rail 52 px, drawer < 1024 px) + main.content
   - Tenant: .thead (light header + tabs) + main.content.tcontent (1200 px column)
   - Anonymous (login, reset, privacy, errors): .anon-top + main.anon-main + .anon-foot
   - View as tenant: .viewas-bar above the tenant header + .viewas-frame around the viewport */

/* ---- Suite header (admin) ----------------------------------------------- */
.suite {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--spacingHorizontalS);
  height: 48px; padding: 0 var(--spacingHorizontalS) 0 0;
  background: var(--fm-suite-bg); color: var(--fm-suite-fg);
  border-bottom: 1px solid var(--fm-suite-stroke);
}
.suite-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-width: 40px; height: 40px; padding: 0 10px;
  border: 0; border-radius: var(--borderRadiusMedium);
  background: transparent; color: var(--fm-suite-fg); cursor: pointer; position: relative;
}
.suite-btn:hover { background: var(--fm-suite-hover); }
.suite-btn:active { background: var(--fm-suite-pressed); }
.suite :focus-visible { outline: 2px solid var(--fm-suite-fg); outline-offset: -2px; box-shadow: inset 0 0 0 3px var(--fm-suite-bg); }
.suite-menu { display: none; width: 48px; height: 48px; border-radius: 0; }
.brand {
  display: flex; align-items: center; gap: 10px; height: 48px; min-width: 0;
  padding: 0 var(--spacingHorizontalL); color: var(--fm-suite-fg); white-space: nowrap;
}
.brand:hover { color: var(--fm-suite-fg); text-decoration: none; background: var(--fm-suite-hover); }
.logo {
  display: inline-grid; place-items: center; width: 24px; height: 24px; flex: none;
  border-radius: var(--borderRadiusMedium);
  background: var(--colorBrandBackground); color: var(--colorNeutralForegroundOnBrand);
}
.logo .i { width: 16px; height: 16px; }
.brand-name { font-size: var(--fontSizeBase400); line-height: var(--lineHeightBase400); font-weight: var(--fontWeightSemibold); }
.brand-area {
  font-size: var(--fontSizeBase300); color: var(--fm-suite-fg2); padding-left: 10px; border-left: 1px solid var(--fm-suite-stroke);
  overflow: hidden; text-overflow: ellipsis;
}
.brand-area:empty { display: none; }
.suite-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.persona-btn { padding: 0 4px 0 8px; gap: 8px; }
.persona-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 16px; }
.persona-text b { font-weight: var(--fontWeightSemibold); font-size: var(--fontSizeBase200); }
.persona-text span { font-size: var(--fontSizeBase100); color: var(--fm-suite-fg2); line-height: 14px; }
.avatar {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--colorPaletteCornflowerBackground2); color: var(--colorPaletteCornflowerForeground2);
  font-size: var(--fontSizeBase200); font-weight: var(--fontWeightSemibold);
}
.avatar.teal { background: var(--colorPaletteTealBackground2); color: var(--colorPaletteTealForeground2); }
.avatar.sys { background: var(--colorNeutralBackground5); color: var(--colorNeutralForeground2); }
.viewas-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px; border-radius: 12px;
  background: var(--colorStatusWarningBackground1); color: var(--colorStatusWarningForeground3);
  border: 1px solid var(--colorStatusWarningBorder1); font-size: var(--fontSizeBase200); font-weight: var(--fontWeightSemibold); white-space: nowrap;
}
.viewas-chip .i { width: 16px; height: 16px; }

/* ---- Popovers (native [popover]: open/close/Esc/light dismiss without JS) ---- */
.pop {
  margin: 0; padding: 4px; border: 1px solid var(--colorTransparentStroke, transparent);
  border-radius: var(--borderRadiusMedium); min-width: 220px; max-width: min(320px, calc(100vw - 16px));
  background: var(--colorNeutralBackground1); color: var(--colorNeutralForeground1);
  box-shadow: var(--shadow16); inset: auto; position: fixed; text-align: left;
}
/* Account menu: under the header's right edge. Building switcher: under the nav card
   (anchor positioning where supported, else a fixed spot below the header). */
#acct-menu { top: 52px; right: 8px; min-width: 280px; }
.viewas #acct-menu { top: 96px; }
#bld-menu { top: 108px; left: 8px; width: 280px; }
@supports (anchor-name: --a) {
  .nav-ctx { anchor-name: --fm-bld; }
  #bld-menu { position-anchor: --fm-bld; top: anchor(bottom); left: anchor(left); margin-top: 4px; width: anchor-size(width); min-width: 260px; }
  .persona-btn { anchor-name: --fm-acct; }
  #acct-menu { position-anchor: --fm-acct; top: anchor(bottom); right: anchor(right); margin-top: 6px; }
}
.pop-head { padding: 12px 12px 8px; display: flex; gap: 12px; align-items: center; }
.pop-sep { height: 1px; background: var(--colorNeutralStroke2); margin: 4px -4px; }
.pop-label { padding: 8px 8px 4px; font-size: var(--fontSizeBase200); line-height: 16px; font-weight: var(--fontWeightSemibold); color: var(--colorNeutralForeground3); }
.menu-link {
  display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 6px 8px; border-radius: var(--borderRadiusMedium);
  color: var(--colorNeutralForeground1); width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer;
  font-size: var(--fontSizeBase300); line-height: var(--lineHeightBase300);
}
.menu-link:hover { background: var(--colorSubtleBackgroundHover); color: var(--colorNeutralForeground1); text-decoration: none; }
.menu-link:active { background: var(--colorSubtleBackgroundPressed); }
.menu-link .i { color: var(--colorNeutralForeground2); }
.menu-link .chk { visibility: hidden; margin-left: auto; color: var(--colorBrandForeground1); }
.menu-link[aria-pressed="true"] .chk, .menu-link[aria-current] .chk { visibility: visible; }
.menu-link[aria-pressed="true"], .menu-link[aria-current] { font-weight: var(--fontWeightSemibold); }
.menu-link.danger, .menu-link.danger .i { color: var(--fm-danger-fg); }
.pop form { margin: 0; }
.acct-text { display: flex; flex-direction: column; min-width: 0; }
.acct-text b { font-weight: var(--fontWeightSemibold); }
.acct-text small { font-size: var(--fontSizeBase200); line-height: 16px; color: var(--colorNeutralForeground3); overflow: hidden; text-overflow: ellipsis; }
.acct-text a { font-size: var(--fontSizeBase200); line-height: 16px; }
.bld-row { display: grid; grid-template-columns: 32px minmax(0, 1fr) 20px; gap: 10px; align-items: center; }
.bld-row small { display: block; font-size: var(--fontSizeBase200); line-height: 16px; color: var(--colorNeutralForeground3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bld-row .avatar { border-radius: var(--borderRadiusMedium); }

/* ---- Frame -------------------------------------------------------------- */
.frame { display: flex; min-height: calc(100vh - 48px); }

/* Nav pane (Fluent NavDrawer on links). Also a [popover], so the same element is the
   overlay drawer below 1024 px (hamburger popovertarget, no JS). */
.navpane {
  position: sticky; inset: 48px auto auto auto; align-self: flex-start;
  display: flex; flex-direction: column;
  width: var(--fm-nav-w); height: calc(100vh - 48px); flex: none;
  margin: 0; padding: 0; border: 0; overflow: hidden;
  background: var(--fm-pane); color: var(--colorNeutralForeground2);
  border-right: 1px solid var(--fm-pane-stroke);
}
.navpane::backdrop { background: var(--colorBackgroundOverlay); }
.nav-scroll { flex: 1; overflow-y: auto; padding: 8px 8px 12px; scrollbar-width: thin; }
.nav-ctx {
  display: grid; grid-template-columns: 32px minmax(0, 1fr) 20px; align-items: center; gap: 10px;
  width: 100%; padding: 8px; margin-bottom: 4px; text-align: left; cursor: pointer;
  border: 1px solid var(--colorNeutralStroke2); border-radius: var(--borderRadiusLarge);
  background: var(--colorNeutralBackground1); color: var(--colorNeutralForeground1);
}
.nav-ctx:hover { background: var(--colorNeutralBackground1Hover); border-color: var(--colorNeutralStroke1Hover); }
.ctx-ico {
  display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--borderRadiusMedium);
  background: var(--colorBrandBackground2); color: var(--colorBrandForeground2);
}
.nav-ctx b { display: block; font-weight: var(--fontWeightSemibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-ctx small { display: block; font-size: var(--fontSizeBase200); line-height: 16px; color: var(--colorNeutralForeground3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-ctx > .i { color: var(--colorNeutralForeground3); }
.nav-sec { margin-top: 12px; }
.nav-sec h2 { padding: 4px 10px; font-size: var(--fontSizeBase200); line-height: 16px; font-weight: var(--fontWeightSemibold); color: var(--colorNeutralForeground3); }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px;
  border-radius: var(--borderRadiusMedium); color: var(--colorNeutralForeground2); white-space: nowrap;
}
.nav-item:hover { background: var(--colorSubtleBackgroundHover); color: var(--colorNeutralForeground2Hover); text-decoration: none; }
.nav-item .i { color: var(--colorNeutralForeground2); }
.nav-item .i.on { display: none; }
.nav-item[aria-current="page"] { background: var(--colorSubtleBackgroundSelected); color: var(--colorNeutralForeground1); font-weight: var(--fontWeightSemibold); }
.nav-item[aria-current="page"] .i.off { display: none; }
.nav-item[aria-current="page"] .i.on { display: inline-block; color: var(--colorBrandForeground1); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: var(--colorBrandStroke1);
}
.nav-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
/* Counters: filled red for alarms/offline (attn), neutral tint otherwise. The number is
   aria-hidden; an .sr-only sibling says what it counts. */
.nav-count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; text-align: center;
  font-size: var(--fontSizeBase200); line-height: 20px; font-weight: var(--fontWeightSemibold);
  background: var(--fm-count-bg); color: var(--colorNeutralForeground1);
}
.nav-count.attn { background: var(--colorPaletteRedBackground3); color: var(--colorNeutralForegroundOnBrand); }
.nav-foot { border-top: 1px solid var(--fm-pane-stroke); padding: 8px; }
.nav-collapse {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 10px;
  border: 0; border-radius: var(--borderRadiusMedium); background: transparent; color: var(--colorNeutralForeground2); cursor: pointer; text-align: left;
}
.nav-collapse:hover { background: var(--colorSubtleBackgroundHover); }
.nav-collapse .i.on { display: none; }
.nav-legal { display: flex; gap: 8px; padding: 6px 10px 2px; font-size: var(--fontSizeBase200); line-height: 16px; color: var(--colorNeutralForeground3); white-space: nowrap; }
.nav-legal a { color: var(--colorNeutralForeground3); }
.nav-legal a:hover { color: var(--colorNeutralForeground2); }
.nav-close { display: none; }

/* Collapsed to an icon rail (fmeter_nav=rail cookie → body.rail, toggled by shell.js) */
@media (min-width: 1024px) {
  .rail { --fm-nav-w: 52px; }
  .rail .nav-scroll { padding: 8px 6px; }
  .rail .nav-label, .rail .nav-sec h2, .rail .nav-ctx > div, .rail .nav-ctx > .i:last-child, .rail .nav-legal, .rail .nav-collapse span { display: none; }
  .rail .nav-ctx { grid-template-columns: 32px; padding: 3px; border-color: transparent; background: transparent; justify-content: center; }
  .rail .nav-sec { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--fm-pane-stroke); }
  .rail .nav-item { justify-content: center; padding: 0; }
  .rail .nav-count { position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px; line-height: 16px; padding: 0 4px; font-size: var(--fontSizeBase100); }
  .rail .nav-collapse { justify-content: center; padding: 0; }
  .rail .nav-collapse .i.on { display: inline-block; }
  .rail .nav-collapse .i.off { display: none; }
}

/* ---- Content ------------------------------------------------------------ */
.content { flex: 1; min-width: 0; padding: var(--spacingVerticalXL) var(--spacingHorizontalXXXL) 88px; }
.page { max-width: 1440px; margin: 0 auto; }
#flash:not(:empty) { margin-bottom: var(--spacingVerticalL); }

/* ---- View as tenant ----------------------------------------------------- */
.viewas-bar {
  position: sticky; top: 0; z-index: 31; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 12px 4px 16px;
  background: var(--colorStatusWarningBackground1); color: var(--colorNeutralForeground1);
  border-bottom: 1px solid var(--colorStatusWarningBorder1);
}
.viewas-bar > .i { color: var(--colorStatusWarningForeground3); }
.viewas-bar p { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewas-bar p b { font-weight: var(--fontWeightSemibold); }
.viewas-bar form { flex: none; }
.viewas-frame { position: fixed; inset: 0; z-index: 40; pointer-events: none; box-shadow: inset 0 0 0 2px var(--colorStatusWarningBorderActive); }
.viewas .suite, .viewas .thead { top: 40px; }

/* ---- Tenant header: Background1 + hairline, section tabs, no nav pane ------ */
.thead {
  position: sticky; top: 0; z-index: 30;
  background: var(--colorNeutralBackground1); color: var(--colorNeutralForeground1);
  border-bottom: 1px solid var(--colorNeutralStroke2);
  --fm-suite-bg: var(--colorNeutralBackground1); --fm-suite-fg: var(--colorNeutralForeground1); --fm-suite-fg2: var(--colorNeutralForeground3);
  --fm-suite-hover: var(--colorSubtleBackgroundHover); --fm-suite-pressed: var(--colorSubtleBackgroundPressed); --fm-suite-stroke: var(--colorNeutralStroke2);
}
.thead-in { max-width: 1264px; margin: 0 auto; padding: 0 var(--spacingHorizontalXXXL); }
.thead-row { display: flex; align-items: center; gap: 8px; height: 52px; }
.thead .brand { padding: 0; height: 40px; border-radius: var(--borderRadiusMedium); }
.thead .brand:hover { background: transparent; }
.thead .suite-btn:focus-visible { outline: 2px solid var(--colorStrokeFocus2); outline-offset: 1px; box-shadow: 0 0 0 1px var(--colorStrokeFocus1); }
.tabs ul { display: flex; gap: 4px; margin-left: -10px; }
.tabs a {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 10px; margin-bottom: 2px;
  border-radius: var(--borderRadiusMedium); color: var(--colorNeutralForeground2);
}
.tabs a .i.on { display: none; }
.tabs a:hover { color: var(--colorNeutralForeground1); text-decoration: none; }
.tabs a:hover::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -2px; height: 3px; border-radius: 2px; background: var(--colorNeutralStroke1Hover); }
.tabs a[aria-current] { color: var(--colorNeutralForeground1); font-weight: var(--fontWeightSemibold); }
.tabs a[aria-current] .i.off { display: none; }
.tabs a[aria-current] .i.on { display: inline-block; color: var(--colorBrandForeground1); }
.tabs a[aria-current]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -2px; height: 3px; border-radius: 2px; background: var(--colorCompoundBrandStroke); }
.tcontent { max-width: 1264px; margin: 0 auto; padding: var(--spacingVerticalXXL) var(--spacingHorizontalXXXL) 40px; }
.tcontent .page { max-width: 1200px; }
.tfoot { max-width: 1264px; margin: 0 auto; padding: 0 var(--spacingHorizontalXXXL) 32px; font-size: var(--fontSizeBase200); color: var(--colorNeutralForeground3); }
.tfoot a { color: var(--colorNeutralForeground3); }

/* ---- Anonymous pages (login, reset, privacy, errors) -------------------- */
.shell-anon { display: grid; grid-template-rows: auto 1fr auto; }
.anon-top { display: flex; justify-content: flex-end; padding: 12px 16px; }
.anon-main { display: grid; place-items: center; padding: 24px 16px 48px; }
.anon-main > .page { width: 100%; max-width: 720px; }
.anon-foot { display: flex; justify-content: center; gap: 16px; padding: 16px; color: var(--colorNeutralForeground3); font-size: var(--fontSizeBase200); }
.anon-foot a { color: var(--colorNeutralForeground3); }
/* Language switch (segmented, a form with two submit buttons) */
.lang { display: inline-flex; gap: 2px; padding: 2px; border-radius: var(--borderRadiusMedium); background: var(--colorNeutralBackground1); border: 1px solid var(--colorNeutralStroke2); }
.lang button {
  padding: 2px 10px; border: 0; border-radius: var(--borderRadiusSmall); background: transparent; cursor: pointer;
  color: var(--colorNeutralForeground2); font-size: var(--fontSizeBase200); line-height: 20px;
}
.lang button:hover { background: var(--colorSubtleBackgroundHover); color: var(--colorNeutralForeground1); }
.lang button[aria-pressed="true"] { background: var(--colorSubtleBackgroundSelected); color: var(--colorNeutralForeground1); font-weight: var(--fontWeightSemibold); }

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 1100px) {
  .content { padding-left: var(--spacingHorizontalXXL); padding-right: var(--spacingHorizontalXXL); }
}
@media (max-width: 1023px) {
  .suite-menu { display: inline-flex; }
  .brand { padding-left: 4px; }
  .navpane { display: none; }
  .navpane:popover-open {
    display: flex; position: fixed; inset: 0 auto 0 0; top: 0; height: 100vh; width: 300px; max-width: 85vw; z-index: 60;
    box-shadow: var(--shadow64, var(--shadow28)); border-right: 0;
  }
  .nav-close { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 0 16px; }
  .nav-close b { font-weight: var(--fontWeightSemibold); }
  .nav-collapse { display: none; }
}
@media (max-width: 767px) {
  .persona-text, .brand-area { display: none; }
  .content { padding: var(--spacingVerticalL) var(--spacingHorizontalL) 88px; }
  .viewas-bar { padding: 6px 8px 6px 12px; position: relative; }
  .viewas-bar p { white-space: normal; font-size: var(--fontSizeBase200); line-height: 16px; }
  .viewas .suite, .viewas .thead { top: 0; position: relative; }
  .viewas-frame { display: none; }
  .viewas #acct-menu { top: 52px; }
  .thead-in { padding: 0 var(--spacingHorizontalL); }
  .thead-row { height: 48px; }
  .tcontent { padding: var(--spacingVerticalL) var(--spacingHorizontalL) 32px; }
  .tfoot { padding: 0 var(--spacingHorizontalL) 24px; }
}
