/*
  Shared ClarkConnect app-chrome styles (header + sidebar + shell grid).

  De-scoped from the per-component MainLayout/AppHeader/AppSidebar `.razor.css`
  files so the SAME chrome can be styled in two render contexts:
    1. The interactive Blazor shell (App.razor links this; the AppHeader/AppSidebar
       components render the cc-* class structure as interactive islands), and
    2. The static /mfe-doc document (MfeDocumentRenderer emits the same cc-* markup
       server-side as plain HTML — no per-component scope-id attributes, so the
       styling had to be global rather than scoped).

  `::deep` from the old scoped sidebar CSS is dropped here: the selectors target
  the nav-item markup directly, which is fine as plain global descendant selectors.
*/

/* ----- Structural invariants that must survive a MFE !important -------- */
/* The MFE's stylesheets load into the cc-mfe cascade layer (MfeDocumentRenderer).
   Unlayered chrome rules already beat every *normal* MFE declaration, but a MFE
   !important on a bare element selector — e.g. procurement-hub's app.css does
   `a { display: -webkit-box !important }` to 2-line-clamp all anchors — outranks every
   *normal* author rule regardless of layer, turning `<a class="cc-sidebar-item">` into
   -webkit-box. Once it isn't a flex box the `gap` collapses and the icon jams against the
   label (the per-MFE sidebar regression). Re-assert the load-bearing `display` here as
   !important inside the cc-chrome layer, which MfeDocumentRenderer declares FIRST: for
   !important, earlier layers win, so this beats the MFE's cc-mfe !important. Keep this
   list to genuine structural invariants on the chrome's element-selector-collidable nodes
   (its `<a>`s), not cosmetics — the unlayered rules below already handle everything normal. */
@layer cc-chrome {
    .cc-sidebar-item {
        display: flex !important;
    }

    .cc-brand-link {
        display: inline-flex !important;
    }

    /* Same `a { display: … !important }` exposure as .cc-sidebar-item, and since the item became
       an icon+label flex row the gap is load-bearing too: knocked off flex the 16px glyph jams
       against "Log out". Pin the row, and the glyph's box + fill — its fill="currentColor" is a
       presentation attribute (the weakest cascade source), so any MFE `svg path { fill: … }`
       recolors it and `svg { width: 1em }` resizes it, exactly as they do the bell. */
    .cc-user-menu-item {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
    }

    .cc-user-menu-icon {
        width: 16px !important;
        height: 16px !important;
        flex: none !important;
    }

    .cc-user-menu-icon path {
        fill: currentColor !important;
    }

    /* The skip link (WCAG 2.4.1) is the document's first focusable element and must be
       visually hidden by the position/clip technique — NOT display:none or
       visibility:hidden, either of which drops it out of the tab order and defeats the
       whole point. That makes it the chrome node most exposed to a MFE bare `a {}` rule,
       in both directions: `a { position: static !important }` or
       `a { clip-path: none !important; width: auto !important; overflow: visible !important }`
       drops it into normal flow, permanently visible above the header on every MFE page,
       while `a { display: none !important }` / `a { visibility: hidden !important }` makes
       it unfocusable and silently removes the bypass. Pin BOTH states here — for
       !important the earliest layer wins, and cc-chrome is declared first. */
    .cc-skip-link {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        overflow: hidden !important;
        clip-path: inset(50%) !important;
    }

    /* Higher specificity than the rule above, so the focused state still wins inside the
       layer. The whole revealed chip is pinned, not just the un-hiding: a MFE
       `a:focus { background: … !important; padding: 0 !important }` could otherwise leave
       the link technically revealed but invisible (white-on-white, zero-size) — WCAG 2.4.7
       needs the chip to stay *perceivable*, so every value the unlayered rule gives it is
       re-asserted here. */
    .cc-skip-link:focus {
        position: fixed !important;
        top: 8px !important;
        left: 8px !important;
        z-index: 1000 !important;
        width: auto !important;
        height: auto !important;
        padding: 10px 16px !important;
        overflow: visible !important;
        clip: auto !important;
        clip-path: none !important;
        background: var(--colorFill) !important;
        color: #060E28 !important;
        border-radius: 6px !important;
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24) !important;
        outline: 2px solid #060E28 !important;
        outline-offset: 2px !important;
        text-decoration: none !important;
    }

    /* The notification bell is a stroked SVG whose fill=none + stroke=currentColor come
       ONLY from presentation attributes — the weakest source in the cascade — so any MFE
       `svg {...}` rule changes the bell (a normal fill fills the outline into a solid blob;
       an !important outranks normal author rules regardless of layer). Re-assert fill/stroke
       (and size, vs a MFE `svg { width: 1em !important }`) here so the bell renders identically
       under every MFE's global stylesheet. The icon's color still flows from the chrome via
       currentColor — only its overridability is pinned, not the hue. */
    .cc-notif-icon {
        width: 20px !important;
        height: 20px !important;
    }

    .cc-notif-icon,
    .cc-notif-icon path {
        fill: none !important;
        stroke: currentColor !important;
    }

    /* The bell trigger is a fixed 36x36 button with the badge absolutely positioned at its
       top-right corner. The org button base ships `button { max-height: fit-content }`; loaded
       in a MFE's layer it caps the trigger to its ~20px icon height, collapsing the box so the
       badge slides from top-right to mid-right per MFE (visible as the badge jumping position). Lock the
       trigger box and the badge corner so the bell + badge sit identically under every MFE CSS. */
    .cc-notif-trigger {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        min-height: 36px !important;
        max-width: 36px !important;
        max-height: 36px !important;
    }

    .cc-notif-badge {
        position: absolute !important;
        top: 1px !important;
        right: 1px !important;
    }

    /* The bell row's content is a <button> (the keyboard expand/mark-read path), so a MFE
       bare `button {}` rule can reshape it the same way `a {}` hit .cc-sidebar-item — once
       it isn't a flex box the dot/body `gap` collapses and the dot jams the title. */
    .cc-notif-expand {
        display: flex !important;
    }

    /* The bell's aria-live region is clip-hidden text — the same both-directions `span {}`
       exposure as the skip link above, minus a focus state (it is never focusable):
       `span { position: static !important }` parks it visible next to the bell, while
       `span { display: none !important }` silences every announcement with no visible
       symptom. */
    .cc-visually-hidden {
        display: block !important;
        visibility: visible !important;
        position: absolute !important;
        width: 1px !important;
        height: 1px !important;
        overflow: hidden !important;
        clip-path: inset(50%) !important;
    }

    /* Other chrome buttons inherit the org button base too: `max-height: fit-content` (harmless on
       content-sized buttons but a per-MFE computed-style drift) and, on the collapse button which
       sets no color of its own, the MFE's heading `color`. Pin them so the chrome is byte-identical
       across MFEs. (The bell trigger has its own max-height above; don't fold it into a broader
       `.cc-header button` rule — that would outrank and undo the 36px lock.) */
    .cc-user-trigger {
        max-height: none !important;
    }

    .cc-sidebar-collapse {
        max-height: none !important;
        color: rgba(255, 255, 255, 0.75) !important;
    }

    /* Focus indicators (WCAG 2.4.7). The chrome's :focus-visible rules below are unlayered,
       so a MFE's `a:focus { outline: none !important }` / `button:focus-visible { outline:
       none !important }` reset strips the keyboard focus ring from every chrome control on
       every /{view} page — the one state a keyboard user cannot do without. Values mirror
       the unlayered rules exactly (pinned, not redesigned). */
    .cc-brand-link:focus-visible,
    .cc-user-trigger:focus-visible,
    .cc-sidebar-collapse:focus-visible,
    .cc-sidebar-legal-link:focus-visible,
    .cc-notif-trigger:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.6) !important;
        outline-offset: 2px !important;
    }

    /* Inset: these rows span the sidebar's full width inside overflow clips, so an outside
       ring is cut off at the left/right (and the top of the first row). */
    .cc-sidebar-item:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.6) !important;
        outline-offset: -2px !important;
    }

    .cc-sidebar-folder:focus-visible {
        outline: 2px solid rgba(255, 255, 255, 0.6) !important;
        outline-offset: -2px !important;
        border-radius: 4px !important;
    }

    /* :focus-visible so a mouse press/click gets no ring; arrow-key focus() still does. */
    .cc-user-menu-item:focus-visible {
        outline: 2px solid #060E28 !important;
        outline-offset: -2px !important;
        background: #f4f7f8 !important;
    }

    .cc-notif-expand:focus-visible {
        outline: 2px solid #2563eb !important;
        outline-offset: 2px !important;
        border-radius: 4px !important;
    }

    /* The per-item delete hides at opacity 0 until hover/focus reveals it — a MFE
       `button { opacity: … !important }` must not be able to keep it invisible while it
       holds keyboard focus. */
    .cc-notif-del:focus-visible {
        opacity: 1 !important;
    }
}

/* ----- Isolation from MFE CSS ---------------------------------------------- */
/* MFE views render in the same document as this chrome and load the MFE's own
   global stylesheets (e.g. AntDesign) via styles[]. Pin the chrome's inherited
   typography + box model on its roots (header + sidebar, NOT .cc-main) so a MFE's
   global resets can't cascade in and reshape the chrome. Without this the sidebar font
   / row height shifts when a heavyweight MFE like the AntDesign-based vendor MFE loads. */
.cc-header,
.cc-sidebar {
    box-sizing: border-box;
    font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
    font-size: 14px;
    font-weight: 400;
    font-style: normal;
    line-height: 1.4;
    letter-spacing: normal;
}

.cc-header *,
.cc-sidebar * {
    box-sizing: border-box;
}

/* ----- Skip link (WCAG 2.4.1 Bypass Blocks) --------------------------------- */
/* Rendered as a sibling immediately before .cc-shell in both chrome pipelines
   (MainLayout.razor + MfeDocumentRenderer.Render) — never inside it, because the shell is a
   grid with explicit grid-template-areas and an unplaced child would take a new implicit row.
   Hidden by clip + a 1px box rather than display/visibility so it keeps its place in the tab
   order; on focus it becomes a fixed, fully visible chip over the dark header. */
.cc-skip-link {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.cc-skip-link:focus {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1000;
    width: auto;
    height: auto;
    padding: 10px 16px;
    overflow: visible;
    clip: auto;
    clip-path: none;
    /* A white chip reads against both backdrops it can land over at top-left — the #060E28
       header and the #b45309 impersonation bar — and #060E28 text on it is ~16:1. The ring +
       shadow give the chip a non-color edge so it doesn't melt into a pale MFE backdrop if
       one ever renders there. */
    background: var(--colorFill);
    color: #060E28;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
    outline: 2px solid #060E28;
    outline-offset: 2px;
    font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
}

/* ----- Shell grid (was MainLayout.razor.css) -------------------------------- */
.cc-shell {
    display: grid;
    grid-template-columns: auto 1fr;
    /* minmax, not a fixed 56px: at 200% text zoom the header content outgrows a fixed row
       and clips (WCAG 1.4.4 Resize Text); while the content fits, minmax(56px, auto)
       resolves to exactly 56px, so default-zoom rendering is unchanged. The DEFINITE
       height (not min-height) is load-bearing at desktop: it is what sizes the 1fr row to
       the leftover viewport so .cc-main scrolls INTERNALLY — under min-height the grid's
       height is indefinite and the 1fr row sizes to .cc-main's content, moving the
       scrollbar to the document. The narrow-viewport block at the end of this file makes
       exactly that trade below 768px. 100dvh after 100vh: identical on desktop, but tracks
       the visible viewport where mobile browser toolbars shrink it. */
    grid-template-rows: minmax(56px, auto) 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    height: 100vh;
    height: 100dvh;
}

.cc-main {
    grid-area: main;
    padding: 1.5rem;
    overflow: auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

/* MFE content is injected raw, so each root caps its own max-width. In a column flex an auto
   margin drops the stretch and shrinks the item to its content, hence width: 100% — a capped
   root then centres on a wide screen, an uncapped one still fills. Unlayered on purpose: an
   MFE's `margin: 0` in the cc-mfe layer would otherwise win. */
.cc-main > * {
    width: 100%;
    margin-inline: auto;
}

/* An MFE document's root is usually an uncapped wrapper, with the max-width on its child —
   so the cap needs centring one level down. Scoped to MFE documents: on the Blazor pages
   the second level is often a flex column where an auto margin would shrink the items. */
.cc-main-mfe > * > * {
    margin-inline: auto;
}

/* Focus target for the skip link (tabindex="-1"), not a control: a ring on the whole landmark is noise. */
.cc-main:focus {
    outline: none;
}

/* BareLayout's main — the /Error page, which renders with no shell grid around it, so
   this element IS the page: it has to fill the viewport and be a flex column itself,
   or content that centres inside .cc-main on the chromed routes collapses to the top. */
.cc-bare-main {
    box-sizing: border-box;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

/* ----- Impersonation banner ------------------------------------------------ */
/* Rendered as the first child of .cc-shell only during an impersonation session
   (ImpersonationBanner.razor / MfeDocumentRenderer). When present, insert a
   banner row above the header; absent, the default two-row grid is unchanged. */
.cc-shell:has(.cc-impersonation-bar) {
    /* minmax for the same WCAG 1.4.4 reason as the base rows above: the banner text now
       wraps at zoom / narrow widths, so its row must be able to grow past 38px. */
    grid-template-rows: minmax(38px, auto) minmax(56px, auto) 1fr;
    grid-template-areas:
        "imp imp"
        "header header"
        "sidebar main";
}

.cc-impersonation-bar {
    grid-area: imp;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    /* 4px vertical padding is invisible at default zoom (one 13px line centered in the
       38px row) but keeps wrapped lines off the row edges when the banner grows. */
    padding: 4px 1rem;
    background: #b45309;
    color: var(--colorTextLight);
    font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
    font-size: 13px;
    font-weight: 600;
    /* No nowrap/hidden/ellipsis: the banner carries the impersonation target's email and
       the Stop link (role="status"), so it must wrap instead of truncating at zoom
       (WCAG 1.4.4 / 1.4.10) — the minmax grid row above grows with it. overflow-wrap lets
       the email itself break; an address is one unbreakable word otherwise, wider than a
       320px viewport. */
    overflow-wrap: anywhere;
}

.cc-impersonation-bar .cc-impersonation-stop {
    color: var(--colorTextLight);
    font-weight: 700;
    text-decoration: underline;
    white-space: nowrap;
}

/* HeaderOnlyLayout: the same shell with the sidebar column removed. Compound selectors so
   both rules outrank the two-column .cc-shell / .cc-shell:has(...) rules above. */
.cc-shell.cc-shell-header-only {
    grid-template-columns: 1fr;
    grid-template-areas:
        "header"
        "main";
}

.cc-shell.cc-shell-header-only:has(.cc-impersonation-bar) {
    grid-template-areas:
        "imp"
        "header"
        "main";
}

/* ----- Header (was AppHeader.razor.css) ------------------------------------- */
.cc-header {
    grid-area: header;
    /* min-height, not height: 12px padding + the 32px logo hit exactly 56px at default
       zoom (pixel-identical), but zoomed text must grow the bar instead of clipping —
       the grid row is minmax(56px, auto) for the same reason. */
    min-height: 56px;
    box-sizing: border-box;
    background: #060E28;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--colorTextLight);
}

.cc-brand {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cc-brand-link {
    display: inline-flex;
    align-items: center;
    line-height: 0;
    border-radius: 4px;
}

.cc-brand-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Phone-only drawer toggle (NavToggleChrome); the phone block at the end of this file shows it. */
.cc-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 44px;
    height: 44px;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: var(--colorTextLight);
    cursor: pointer;
}

.cc-nav-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
}

.cc-nav-toggle:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.cc-brand-logo {
    height: 32px;
    width: auto;
    display: block;
}

.cc-brand-wordmark,
.cc-brand-vendor {
    font-family: 'Poppins', -apple-system, system-ui, sans-serif;
    font-weight: 300;
    font-size: 18px;
    line-height: 23px;
    color: var(--colorTextLight);
    /* The mark's capitals centre at 28/60 of its box, Poppins' near the line box's centre; lift the
       text by 2/60 of the 32px logo less Poppins' own 0.026em cap rise so the cap centres share one line. */
    position: relative;
    top: -0.6px;
}

.cc-user {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cc-user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    /* min-height (4px padding + 24px avatar = 32px at default zoom): the user's name is
       text and must grow the pill at text zoom rather than overflow it. */
    min-height: 32px;
    padding: 4px 8px;
    background: transparent;
    border: 0;
    border-radius: 999px;
    color: rgba(255, 255, 255, 0.75);
    font: inherit;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.cc-user-trigger:hover,
.cc-user.open .cc-user-trigger {
    background: rgba(255, 255, 255, 0.08);
}

.cc-user-trigger:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.cc-avatar {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--colorAvatarBg);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    color: var(--colorTextLight);
    flex: none;
}

.cc-user-name {
    font-size: 14px;
    line-height: 22px;
    color: rgba(255, 255, 255, 0.75);
}

.cc-user-chevron {
    width: 16px;
    height: 16px;
    opacity: 0.85;
    transition: transform 0.15s ease;
}

.cc-user.open .cc-user-chevron {
    transform: rotate(180deg);
}

.cc-user-menu-backdrop {
    position: fixed;
    inset: 0;
    background: transparent;
    z-index: 99;
}

.cc-user-menu {
    display: none; /* shown when .cc-user has .open (toggled by cc-chrome.js) */
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    min-width: 160px;
    background: var(--colorFill);
    border-radius: 6px;
    box-shadow: 0px 6px 16px rgba(0, 0, 0, 0.12), 0px 3px 6px rgba(0, 0, 0, 0.08);
    padding: 4px;
    z-index: 100;
}

.cc-user.open .cc-user-menu {
    display: block;
}

/* A flex row: LogoutOutlined glyph, 8px gap, then the label. */
.cc-user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 12px;
    border-radius: 4px;
    font-size: 14px;
    line-height: 22px;
    color: #262626;
    text-decoration: none;
}

/* flex:none so the 16px box never shrinks under a long label; currentColor ties the glyph to
   the item's color so hover/focus can't leave it a different shade from its own text. */
.cc-user-menu-icon {
    width: 16px;
    height: 16px;
    flex: none;
}

/* Takes the remaining width and never wraps — the menu grows (min-width 160px) rather than
   folding a two-word label onto two lines beside a vertically-centered icon. */
.cc-user-menu-label {
    flex: 1 1 auto;
    white-space: nowrap;
}

.cc-user-menu-item:hover {
    background: #f4f7f8;
}

/* :focus-visible, not :focus — a mouse press on the item must not ring; keyboard-driven
   focus() (arrow keys / keyboard open) still matches. outline-offset is negative so the
   ring stays inside the menu's 4px padding instead of straddling its rounded edge. */
.cc-user-menu-item:focus-visible {
    outline: 2px solid #060E28;
    outline-offset: -2px;
    background: #f4f7f8;
}

/* ----- Sidebar (was AppSidebar.razor.css; ::deep dropped) ------------------- */
.cc-sidebar {
    grid-area: sidebar;
    width: 256px;
    background: linear-gradient(5.29deg, #18756A -4.07%, var(--colorBrandDeep) 22.81%, #0A2A45 49.64%, #060E28 90.53%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 8px 0 12px;
    gap: 8px;
    transition: width 0.2s ease;
    min-height: 0;
    overflow: hidden;
}

.cc-sidebar.collapsed {
    width: 56px;
}

.cc-sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.cc-sidebar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cc-sidebar-folder {
    margin: 8px 0 4px;
    padding: 4px 16px;
    background: transparent;
    border: 0;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    text-align: left;
}

.cc-sidebar-folder:hover {
    color: rgba(255, 255, 255, 0.75);
}

.cc-sidebar-folder:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: -2px;
    border-radius: 4px;
}

.cc-sidebar-folder-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 10px;
    height: 10px;
    transition: transform 0.15s ease;
}

.cc-sidebar-group.expanded .cc-sidebar-folder-chevron {
    transform: rotate(90deg);
}

/* Folder accordion: a group's items are hidden unless the group has .expanded
   (toggled by cc-chrome.js). Groups render expanded by default. */
.cc-sidebar-group:not(.expanded) .cc-sidebar-list {
    display: none;
}

.cc-sidebar.collapsed .cc-sidebar-folder {
    display: none;
}

/* Collapsed (icon-only) sidebar always shows the items, regardless of accordion state. */
.cc-sidebar.collapsed .cc-sidebar-list {
    display: flex;
}

/* Nest a folder's pages under its header: indent items so their icon aligns
   beneath the folder label (header content starts at 16px pad + 10px chevron +
   6px gap = 32px). Only groups that actually have a folder header are indented
   (`:has` skips folderless top-level runs), and only in the expanded sidebar —
   the collapsed icon-only rail centers items, so `:not(.collapsed)` leaves it be. */
.cc-sidebar:not(.collapsed) .cc-sidebar-group:has(.cc-sidebar-folder) .cc-sidebar-item {
    padding-left: 32px;
}

.cc-sidebar-empty {
    margin: 8px 16px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
}

.cc-sidebar-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    /* min-height, not height: identical 40px row at default zoom (22px line centered),
       but the row grows instead of clipping the label at text zoom (WCAG 1.4.4). */
    min-height: 40px;
    padding: 0 16px;
    gap: 8px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-family: 'DM Sans', -apple-system, system-ui, sans-serif;
    font-size: 14px;
    font-weight: 400;
    line-height: 22px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.cc-sidebar-item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--colorTextLight);
}

.cc-sidebar-item.active {
    color: var(--colorTextLight);
    font-weight: 590;
}

/* Inset: the row is full sidebar width inside .cc-sidebar-nav / .cc-sidebar overflow clips. */
.cc-sidebar-item:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: -2px;
}

.cc-sidebar-item-icon {
    width: 16px;
    height: 16px;
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
}

.cc-sidebar-item-icon svg {
    width: 100%;
    height: 100%;
}

.cc-sidebar-item.active .cc-sidebar-item-icon {
    color: var(--colorTextLight);
}

.cc-sidebar-item-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cc-sidebar.collapsed .cc-sidebar-item {
    width: auto;
    min-height: 40px;
    padding: 0;
    justify-content: center;
}

.cc-sidebar.collapsed .cc-sidebar-item-icon {
    width: 24px;
    height: 24px;
}

.cc-sidebar.collapsed .cc-sidebar-item-label {
    display: none;
}

/* Collapsed rail: each item is icon-only and named by its title attribute, which a sighted
   keyboard user never sees — reveal the (display:none) label as a chip when the item takes
   focus, and on hover for parity with the title tooltip. position: fixed, not absolute: the
   label sits inside two clipping ancestors (.cc-sidebar's overflow:hidden and
   .cc-sidebar-nav's overflow-y:auto), so a chip anchored to the item would be cut off at the
   rail's 56px edge — fixed escapes both (no ancestor transform creates a containing block),
   at the cost of a constant position: the chip appears just right of the rail, under the
   header, for every item. The focus ring on the icon still shows *which* item; the chip
   supplies its name. */
.cc-sidebar.collapsed .cc-sidebar-item:focus-visible .cc-sidebar-item-label,
.cc-sidebar.collapsed .cc-sidebar-item:hover .cc-sidebar-item-label {
    display: block;
    position: fixed;
    top: 64px;
    left: 64px;
    z-index: 1000;
    width: max-content;
    max-width: 280px;
    padding: 6px 12px;
    background: #060E28;
    color: var(--colorTextLight);
    font-size: 13px;
    border-radius: 6px;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.24);
    outline: 1px solid rgba(255, 255, 255, 0.25);
}

.cc-sidebar-collapse {
    width: 240px;
    height: 48px;
    margin: 0 auto;
    padding: 4px 8px;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cc-sidebar.collapsed .cc-sidebar-collapse {
    width: 40px;
    padding: 4px;
}

.cc-sidebar-collapse-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 224px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.75);
}

.cc-sidebar.collapsed .cc-sidebar-collapse-icon {
    width: 40px;
}

.cc-sidebar-collapse-icon svg {
    width: 20px;
    height: 20px;
}

.cc-sidebar-collapse-icon.expand svg {
    transform: scaleX(-1);
}

.cc-sidebar-collapse:hover .cc-sidebar-collapse-icon {
    background: rgba(255, 255, 255, 0.2);
    color: var(--colorTextLight);
}

.cc-sidebar-collapse:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Legal footer below the collapse arrow (Figma 4413:26926): 12/20 muted text, 8px apart and
   8px below the arrow via the sidebar's own gap. The collapsed rail has no room for it, and
   hiding it lets space-between drop the arrow to the sidebar bottom. */
.cc-sidebar-legal {
    display: flex;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
}

.cc-sidebar.collapsed .cc-sidebar-legal {
    display: none;
}

.cc-sidebar-legal-link {
    display: inline-flex;
    align-items: center;
    gap: var(--spacingXXS);
    color: var(--colorTextOnDarkMuted);
    font-size: var(--fontSizeSM);
    line-height: var(--lineHeightSM);
    text-decoration: underline;
    border-radius: 2px;
    transition: color 0.15s ease;
}

.cc-sidebar-legal-link:hover {
    color: var(--colorTextLight);
}

.cc-sidebar-legal-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* Anonymous visitor's "Log in" link (AppHeader, static-SSR shell only — an MFE document
   always has a session, so this has no MfeDocumentRenderer twin). Same pill + type as the
   signed-in user trigger it replaces. */
.cc-header-login {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 14px;
    line-height: 22px;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.cc-header-login:hover {
    background: rgba(255, 255, 255, 0.08);
}

.cc-header-login:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

/* --- Notification bell (cc-notifications.js + /hubs/notifications) --- */
.cc-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cc-notif {
    position: relative;
}

/* Visually hidden, still announced — the clip technique (same as .cc-skip-link), never
   display:none/visibility:hidden, which would silence a live region. Carries the bell's
   aria-live region (data-cc-notif-live). */
.cc-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.cc-notif-trigger {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.cc-notif-trigger:hover,
.cc-notif.open .cc-notif-trigger {
    background: rgba(255, 255, 255, 0.12);
}

.cc-notif-trigger:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.6);
    outline-offset: 2px;
}

.cc-notif-icon {
    width: 20px;
    height: 20px;
}

.cc-notif-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--colorDanger);
    color: var(--colorTextLight);
    font-size: 10px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
}

.cc-notif-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 340px;
    max-width: 92vw;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--colorFill);
    color: #1f2430;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    z-index: 1000;
}

.cc-notif-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    font-weight: 600;
}

.cc-notif-readall {
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}

.cc-notif-readall:hover {
    text-decoration: underline;
}

.cc-notif-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cc-notif-item {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    cursor: pointer;
}

/* The row's dot + title/body/time live inside a real <button> (the keyboard path for
   expand + mark-read); style it back to look like plain row content, not a button —
   it takes the flexible width, the delete button stays a flex sibling. */
.cc-notif-expand {
    display: flex;
    flex: 1 1 auto;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    font: inherit;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.cc-notif-expand:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Expandable detail — wraps below the dot/body/delete row. */
.cc-notif-detail {
    flex: 0 0 100%;
    margin-top: 6px;
    padding-top: 8px;
    border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.cc-notif-detail-body {
    font-size: 12px;
    color: var(--colorText);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cc-notif-detail-roster {
    margin-top: 6px;
    font-size: 11px;
    color: var(--colorTextDescription);
}

.cc-notif-detail-view {
    display: inline-block;
    margin-top: 8px;
    color: #2563eb;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.cc-notif-detail-view:hover {
    text-decoration: underline;
}

.cc-notif-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.cc-notif-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin-top: 5px;
    border-radius: 50%;
    background: #2563eb;
}

.cc-notif-success {
    background: var(--colorSuccess);
}

.cc-notif-warning {
    background: var(--colorWarning);
}

.cc-notif-error {
    background: var(--colorDanger);
}

.cc-notif-read {
    opacity: 0.55;
}

.cc-notif-read .cc-notif-dot {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.25);
}

.cc-notif-body {
    min-width: 0;
}

.cc-notif-item-title {
    font-weight: 600;
    font-size: 13px;
}

.cc-notif-item-text {
    font-size: 12px;
    color: #5b6472;
    margin-top: 2px;
    overflow-wrap: anywhere;
}

.cc-notif-time {
    display: block;
    font-size: 11px;
    color: var(--colorTextDescription);
    margin-top: 3px;
}

.cc-notif-empty {
    padding: 22px 14px;
    margin: 0;
    text-align: center;
    font-size: 13px;
    color: var(--colorTextDescription);
}

.cc-notif-head-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cc-notif-unread-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 500;
    color: #5b6472;
    cursor: pointer;
    user-select: none;
}

.cc-notif-unread-toggle input {
    margin: 0;
    cursor: pointer;
}

/* Per-item delete (×). Tucked right; revealed on row hover/focus. */
.cc-notif-del {
    flex: 0 0 auto;
    align-self: flex-start;
    width: 20px;
    height: 20px;
    margin: -2px -4px 0 0;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--colorTextDescription);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
}

/* focus-within: a keyboard user on the row's expand button sees that the delete
   affordance exists, mirroring the hover reveal. */
.cc-notif-item:hover .cc-notif-del,
.cc-notif-item:focus-within .cc-notif-del,
.cc-notif-del:focus-visible {
    opacity: 1;
}

.cc-notif-del:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--colorDanger);
}

.cc-notif-foot {
    padding: 10px 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    text-align: center;
}

.cc-notif-viewall {
    color: #2563eb;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.cc-notif-viewall:hover {
    text-decoration: underline;
}

/* ----- Brand lockup on light surfaces --------------------------------------- */
/* The Clark wordmark + chevron (ClarkWordmark.LockupSvg) followed by a word of real
   text — the vendor name on the splash fallback, "Connect" on the /status pages.
   Global rather than per-page scoped CSS because the svg arrives as a MarkupString and
   so carries no scope attribute; the page owns only its own margins around this block. */
.cc-brand-lockup {
    display: flex;
    align-items: center;
    gap: 4px;
    height: 40px;
}

.cc-brand-lockup-logo {
    display: block;
    height: 40px;
    width: auto;
}

/* The wordmark paths carry fill="white" for the dark chrome header; a presentation
   attribute is the weakest cascade source, so this repaints them for a light panel. */
.cc-brand-lockup-logo path {
    fill: var(--colorBrandDark);
}

.cc-brand-lockup-text {
    font-family: 'Poppins', -apple-system, system-ui, sans-serif;
    font-weight: 300;
    font-size: 22.4px;
    line-height: 28px;
    color: var(--colorBrandDark);
    /* 2/60 of the 40px logo less 0.026em: aligns the cap centres (see .cc-brand-vendor). */
    position: relative;
    top: -0.75px;
}

/* ----- Reduced motion (WCAG 2.3.3) ------------------------------------------ */
/* The chrome's transitions are all decorative micro-animation (hover tints, the two
   chevron rotations, the sidebar width collapse, nav-item color fades) — drop them
   outright when the OS asks for reduced motion. */
@media (prefers-reduced-motion: reduce) {
    .cc-user-trigger,
    .cc-user-chevron,
    .cc-sidebar,
    .cc-sidebar-folder-chevron,
    .cc-sidebar-item,
    .cc-sidebar-legal-link {
        transition: none;
    }
}

/* ----- Narrow viewports / high zoom (WCAG 1.4.10 Reflow) --------------------- */
/* Minimum-viable reflow, not a responsive redesign: at or below 768px — which is what
   400% browser zoom on a 1280px window (the 1.4.10 320px-equivalent) or 200% on a
   half-screen window presents as — the chrome degrades gracefully instead of clipping.
   cc-chrome.js auto-collapses the sidebar to its 56px rail at this same breakpoint.
   Desktop widths never match, so nothing here can change desktop rendering. */
@media (max-width: 768px) {
    /* Swap the desktop containment (definite one-viewport shell + .cc-main internal
       scroll) for plain document flow: with an indefinite (min-)height the 1fr main row
       sizes to its content, .cc-main's overflow:auto never engages vertically, and the
       page scrolls as one column through banner, header, and content. Reopen body's
       overflow to `auto` below (app.css defaults it to `hidden`) so nothing is trapped
       however tall the chrome rows grow — this breakpoint is the only condition that
       legitimately needs body-level scroll. .cc-main keeps overflow:auto so over-wide
       MFE content (tables) scrolls horizontally inside the panel instead of forcing the
       whole document sideways. */
    .cc-shell {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
    }

    body {
        overflow: auto;
    }

    /* The brand cluster and the bell/user cluster can exceed 320px side by side; let the
       header wrap onto a second line inside its auto-sized grid row instead of
       overflowing the viewport. */
    .cc-header {
        flex-wrap: wrap;
    }

    /* The bell panel is absolute and right-anchored to a trigger that sits LEFT of the
       user menu, so its 340px body ran off the left viewport edge at 320px — and
       negative-direction overflow cannot be scrolled to. Fixed positioning re-anchors it
       to the viewport (the same escape the collapsed-rail focus chip uses; no chrome
       ancestor creates a transform containing block) just below the 56px header. */
    .cc-notif-panel {
        position: fixed;
        top: 64px;
        right: 8px;
        width: min(340px, calc(100vw - 16px));
    }

    /* Anchored at the viewport's right edge minus the header padding, so it only needs a
       width cap to stay on-screen when a long email widens it past min-width. */
    .cc-user-menu {
        max-width: calc(100vw - 32px);
    }

    /* The collapsed-rail focus-label chip is fixed at left: 64px; cap its width so a
       long page name stays inside the viewport (64px + the desktop 280px cap overruns
       320px). */
    .cc-sidebar.collapsed .cc-sidebar-item:focus-visible .cc-sidebar-item-label,
    .cc-sidebar.collapsed .cc-sidebar-item:hover .cc-sidebar-item-label {
        max-width: calc(100vw - 80px);
    }
}

/* ----- Phone (max-width: 576px, the --screenSM token) ------------------------ */
/* Sits on top of the reflow block above, which still applies: document-flow shell, wrapping
   header, capped popups. What changes here is the sidebar. The 56px rail that block settles on
   costs a 375px phone 15% of its width, so below this breakpoint the sidebar is an off-canvas
   drawer instead — opened by .cc-nav-toggle, closed by the scrim (.cc-shell::after), Escape, or
   navigating. cc-chrome.js holds the sidebar expanded in this range so the drawer shows full
   labels, and mirrors the open state onto .cc-shell.nav-open. Tablet widths (577-768px) keep
   the rail. env(safe-area-inset-*) needs viewport-fit=cover, set in App.razor and
   MfeDocumentRenderer. */
@media (max-width: 576px) {
    /* One column: the sidebar leaves the grid (position: fixed below), so keeping its column
       would leave an empty auto track beside .cc-main. Same shape as the header-only shell. */
    .cc-shell {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "header"
            "main";
    }

    .cc-shell:has(.cc-impersonation-bar) {
        grid-template-areas:
            "imp"
            "header"
            "main";
    }

    /* No gutter: the MFE gets the whole area. Only the notch/home-indicator insets remain (0 on
       a device without them), so landscape content can't slide under a cutout. */
    .cc-main {
        padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px)
            env(safe-area-inset-left, 0px);
    }

    .cc-bare-main {
        padding: 12px max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
            max(12px, env(safe-area-inset-left));
    }

    /* ----- Header: toggle, logo, vendor, bell, avatar on one row ----- */
    .cc-header {
        flex-wrap: nowrap;
        gap: 4px;
        padding: calc(8px + env(safe-area-inset-top, 0px)) max(4px, env(safe-area-inset-right)) 8px
            max(4px, env(safe-area-inset-left));
    }

    /* The impersonation bar is the topmost row when present, so it takes the inset instead. */
    .cc-impersonation-bar {
        padding-top: calc(4px + env(safe-area-inset-top, 0px));
    }

    .cc-shell:has(.cc-impersonation-bar) .cc-header {
        padding-top: 8px;
    }

    .cc-nav-toggle {
        display: inline-flex;
    }

    /* The shell with no sidebar (HeaderOnlyLayout) has nothing for the toggle to open. */
    .cc-shell-header-only .cc-nav-toggle {
        display: none;
    }

    /* margin-right: auto packs toggle + brand left and the bell/avatar right, whatever the
       toggle's presence does to space-between. min-width: 0 lets the vendor name shrink. */
    .cc-brand {
        min-width: 0;
        margin-right: auto;
    }

    .cc-brand-link {
        flex: none;
    }

    /* Logo only: the vendor name (or the anonymous header's "Connect") and the "<" chevron that
       leads into it are dropped. The chevron is the wordmark SVG's last path, so it is hidden
       there rather than cropped. */
    .cc-brand-vendor,
    .cc-brand-wordmark {
        display: none;
    }

    .cc-brand-logo path:last-child {
        display: none;
    }

    .cc-header-right {
        gap: 0;
    }

    .cc-notif-trigger {
        width: 44px;
        height: 44px;
    }

    .cc-user-trigger,
    .cc-header-login {
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }

    .cc-user-trigger {
        padding: 0;
    }

    /* Avatar only. The name stays the button's accessible name (display: none would drop it),
       so it is clipped like .cc-visually-hidden, not removed. */
    .cc-user-name {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .cc-user-chevron {
        display: none;
    }

    .cc-notif-panel {
        top: calc(64px + env(safe-area-inset-top, 0px));
    }

    .cc-user-menu-item {
        min-height: 44px;
    }

    /* ----- Sidebar as an off-canvas drawer ----- */
    .cc-sidebar,
    .cc-sidebar.collapsed {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        z-index: 200;
        width: min(300px, 85vw);
        padding-top: calc(8px + env(safe-area-inset-top, 0px));
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        padding-left: env(safe-area-inset-left, 0px);
        transform: translateX(-100%);
        /* visibility, not just the transform: it takes the closed drawer's links out of the
           tab order and the accessibility tree. Delayed so the slide-out plays before it flips. */
        visibility: hidden;
        transition: transform 0.2s ease, visibility 0s linear 0.2s;
    }

    .cc-shell.nav-open .cc-sidebar {
        transform: none;
        visibility: visible;
        transition: transform 0.2s ease, visibility 0s;
        box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);
    }

    /* The scrim. A pseudo-element so no markup is needed in either pipeline; a tap on it
       reports .cc-shell as the target, which cc-chrome.js treats as "close". */
    .cc-shell.nav-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 150;
        background: rgba(6, 14, 40, 0.55);
    }

    body:has(.cc-shell.nav-open) {
        overflow: hidden;
    }

    /* The collapse arrow is for the rail; the drawer closes by its own means. */
    .cc-sidebar-collapse {
        display: none;
    }

    .cc-sidebar-item,
    .cc-sidebar-folder {
        min-height: 44px;
    }
}

@media (max-width: 576px) and (prefers-reduced-motion: reduce) {
    .cc-sidebar,
    .cc-shell.nav-open .cc-sidebar {
        transition: none;
    }
}
