/* ============================================================================
   /lib/header.css — Sidebar layout (Phase 2.46)
   ----------------------------------------------------------------------------
   Loaded by every page that uses the unified `.ch-topbar` + `.ch-nav` chrome.
   On desktop we transform the topbar/nav into a fixed left-rail sidebar
   without touching any page HTML; on mobile we fall back to the previous
   horizontal layout so phone widths keep working.
   Brand palette is preserved — green stays #46D926, dark stays #173404.
   ============================================================================ */

:root {
  /* Brand-green sidebar — matches the login brand panel exactly.
     The rail uses a radial-gradient stack on top of the base green so
     it looks dimensional, not flat. */
  --sidebar-bg:          #22b34a;
  --sidebar-bg-base:     #22b34a;
  --sidebar-bg-dark:     #1c9a3e;    /* color-mix(#22b34a + black 8%) */
  --sidebar-bg-deep:     #178233;    /* color-mix(#22b34a + black 18%) */
  --sidebar-bg-light:    #4ec172;    /* color-mix(#22b34a + white 18%) */
  --sidebar-text:        rgba(255,255,255,0.88);
  --sidebar-text-faint:  rgba(255,255,255,0.60);
  --sidebar-text-strong: #ffffff;
  --sidebar-hover:       rgba(255,255,255,0.10);
  --sidebar-active:      rgba(255,255,255,0.18);
  --sidebar-active-border: rgba(255,255,255,0.28);
  --sidebar-divider:     rgba(255,255,255,0.14);
  --sidebar-width:       248px;
  --sidebar-width-collapsed: 64px;
  --sidebar-accent:      #ffffff;
}

/* Collapsed-sidebar override — narrower rail, icon-only nav. State is
   persisted in localStorage('chestnut-sidebar') and applied via
   html.sidebar-collapsed by /lib/theme.js BEFORE first paint so we
   never see a width snap on page load. */
html.sidebar-collapsed {
  --sidebar-width: var(--sidebar-width-collapsed);
}

/* ============================================================================
   Per-user sidebar palette. Default is the brand green above; the user can
   switch via the picker in the user dropdown. Six distinct options rather than
   shades of the same dark: green (default), black, light grey, dark grey,
   light blue, dark blue. The two LIGHT options flip the text/overlay vars to
   dark-on-light so the rail stays readable.
   The choice is persisted in localStorage('chestnut-sidebar-theme') and
   applied to <html data-sidebar-theme="..."> by /lib/theme.js BEFORE the
   first paint so we never see a colour flash on navigation.
   ============================================================================ */
:root[data-sidebar-theme="black"] {
  --sidebar-bg-base: #1a1a1a;
  --sidebar-bg-dark: #111111;
  --sidebar-bg-deep: #000000;
  --sidebar-bg-light: #2c2c2c;
  --sidebar-hover: rgba(255,255,255,0.07);
  --sidebar-active: rgba(255,255,255,0.12);
  --sidebar-active-border: rgba(255,255,255,0.18);
}
:root[data-sidebar-theme="dark-grey"] {
  --sidebar-bg-base: #3b4148;
  --sidebar-bg-dark: #31363c;
  --sidebar-bg-deep: #262a2f;
  --sidebar-bg-light: #4a525b;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: rgba(255,255,255,0.13);
  --sidebar-active-border: rgba(255,255,255,0.20);
}
:root[data-sidebar-theme="dark-blue"] {
  --sidebar-bg-base: #1e3a8a;
  --sidebar-bg-dark: #182f6f;
  --sidebar-bg-deep: #122555;
  --sidebar-bg-light: #2f4ea3;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active: rgba(255,255,255,0.14);
  --sidebar-active-border: rgba(255,255,255,0.22);
}
:root[data-sidebar-theme="light-grey"] {
  --sidebar-bg-base: #e7e7e3;
  --sidebar-bg-dark: #dadad5;
  --sidebar-bg-deep: #ccccc6;
  --sidebar-bg-light: #f2f2ef;
  --sidebar-text: rgba(44,44,42,0.82);
  --sidebar-text-faint: rgba(44,44,42,0.52);
  --sidebar-text-strong: #2c2c2a;
  --sidebar-accent: #2c2c2a;
  --sidebar-hover: rgba(0,0,0,0.05);
  --sidebar-active: rgba(0,0,0,0.09);
  --sidebar-active-border: rgba(0,0,0,0.16);
  --sidebar-divider: rgba(0,0,0,0.12);
}
:root[data-sidebar-theme="light-blue"] {
  --sidebar-bg-base: #d6e6fa;
  --sidebar-bg-dark: #c3d9f5;
  --sidebar-bg-deep: #b0ccf0;
  --sidebar-bg-light: #e8f1fe;
  --sidebar-text: rgba(15,40,80,0.84);
  --sidebar-text-faint: rgba(15,40,80,0.54);
  --sidebar-text-strong: #0e2850;
  --sidebar-accent: #1e5faa;
  --sidebar-hover: rgba(15,40,80,0.06);
  --sidebar-active: rgba(15,40,80,0.11);
  --sidebar-active-border: rgba(15,40,80,0.20);
  --sidebar-divider: rgba(15,40,80,0.14);
}

/* Resets ------------------------------------------------------------------- */
.ch-topbar, .ch-topbar *, .ch-nav, .ch-nav *, .ch-menu, .ch-menu * { box-sizing: border-box; }
.ch-home-btn { display: none !important; }

/* Consistent body backdrop across every studio page that loads this
   stylesheet. */
body { background: #F7F7F7; }

/* Universal card elevation. On the lighter #F7F7F7 page background a
   plain white card has only ~8 levels of contrast against the page, so
   common card classes get a gentle drop-shadow on top of whatever the
   page's own CSS provides. Sized to be near-invisible up close but
   enough to read as 'lifted'. Skip mobile (cards stack edge-to-edge
   there and a shadow on every row looks heavy). */
@media (min-width: 641px) {
  .card,
  .tile,
  .kpi,
  .table-card,
  .panel,
  .svc-section,
  .connect-card {
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 12px rgba(0, 0, 0, 0.05);
  }
}

/* When the Stock module is launched as an installed PWA (standalone
   display), the studio chrome is hidden — the user is in the dedicated
   Stock app and doesn't need cross-section navigation. The .pwa-standalone
   class is set by an early inline script on each stock-*.html. */
html.pwa-standalone .ch-topbar,
html.pwa-standalone .ch-nav { display: none !important; }
html.pwa-standalone body { padding-left: 0 !important; }
html.pwa-standalone body::before { display: none !important; }

/* ============================================================================
   DESKTOP — sidebar layout
   The body gets a permanent left gutter. .ch-topbar fills the top of the
   sidebar (brand top-left, user-button pinned to the bottom). .ch-nav slots
   between them and scrolls if it overflows.
   ============================================================================ */
@media (min-width: 901px) {
  body { padding-left: var(--sidebar-width); }

  /* Pre-paint the sidebar column dark-green from first paint. The
     three child sections (.ch-topbar / .ch-nav / .ch-topbar-right) load
     and populate independently — header.js fetches /api/dashboard
     before it can build the grouped nav, which takes 0.5–1.5s on a
     cold backend. Without this strip the body cream bleeds through
     during navigation and the sidebar looks broken for a beat. */
  body::before {
    content: '';
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--sidebar-width);
    /* Same radial-gradient stack as the login brand panel — keeps the
       sidebar dimensional even before .ch-topbar / .ch-nav have loaded. */
    background:
      radial-gradient(ellipse 80% 60% at 100% 0%, var(--sidebar-bg-light) 0%, transparent 60%),
      radial-gradient(ellipse 100% 80% at 0% 100%, var(--sidebar-bg-deep) 0%, transparent 60%),
      linear-gradient(180deg, var(--sidebar-bg-dark), var(--sidebar-bg-deep));
    z-index: 1;
    pointer-events: none;
  }

  /* Top section: brand + user pinned to bottom via fixed positioning.
     Transparent so the body::before gradient shows through; the whole
     rail reads as one continuous panel. */
  .ch-topbar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-width); height: 90px;
    background: transparent;
    color: var(--sidebar-text-strong);
    padding: 20px 22px;
    display: flex; align-items: center;
    z-index: 100;
  }
  .ch-brand {
    /* Brand mark area. Real markup (leaf SVG + "CN Connect" / "Chestnut
       Infrastructure") is injected by /lib/header.js into .ch-brand at
       boot — see initBrandMark(). The per-page hardcoded markup
       (ch-brand-name / ch-brand-tag) is hidden by the rules below so we
       don't have to edit every page to swap the label. */
    display: flex; align-items: center; gap: 12px;
    text-decoration: none; color: inherit;
    flex: 1; min-width: 0;
    background: none;
    height: auto;
  }
  .ch-brand-leaf {
    width: 32px; height: 32px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
  }
  .ch-brand-leaf img { width: 100%; height: 100%; object-fit: contain; display: block; }
  .ch-brand-injected {
    display: flex; flex-direction: column; line-height: 1.05;
    min-width: 0;
  }
  .ch-brand-injected .b1 {
    font-size: 14px; font-weight: 600;
    color: var(--sidebar-text-strong);
    letter-spacing: -0.01em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .ch-brand-injected .b2 {
    font-size: 10.5px; font-weight: 500;
    color: var(--sidebar-text-faint);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  /* Hide the legacy per-page brand markup (small 32px leaf icon + 'Chestnut
     Studio · Simple · Scalable · Affordable' tagline). The new mark is
     injected by header.js. */
  .ch-brand > img,
  .ch-brand > .ch-brand-text { display: none !important; }
  .ch-brand-name { font-size: 14px; font-weight: 500; color: var(--sidebar-text-strong); }
  .ch-brand-tag  { display: none; }

  /* User pill — pinned to the bottom of the sidebar. Transparent so the
     body::before gradient shows through; the pill itself is a soft
     rounded rectangle floating on the green. */
  .ch-topbar-right {
    position: fixed; left: 0; bottom: 0;
    width: var(--sidebar-width);
    padding: 8px 14px 14px;
    background: transparent;
    display: flex; align-items: center; gap: 8px;
    z-index: 100;
  }
  .ch-user-btn {
    /* Avatar · stacked (name + role) · chevron — same layout as the
       design's .user-pill in /tmp/chestnut-mockup/dashboard.css. */
    display: inline-flex; align-items: center; gap: 10px;
    background: var(--sidebar-hover);
    /* Driven by the theme's overlay vars so the pill stays outlined on light
       palettes (dark border) as well as dark ones (white border). */
    border: 1px solid var(--sidebar-active-border);
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    color: var(--sidebar-text);
    font-family: inherit; font-size: 12px;
    cursor: pointer; width: 100%;
    transition: background 0.12s, border-color 0.12s;
  }
  .ch-user-btn:hover {
    background: var(--sidebar-active);
    border-color: var(--sidebar-active-border);
  }
  .ch-user-btn .ch-avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, #ffffff, #d1fae5);
    color: #173404;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 11.5px; font-weight: 700;
    letter-spacing: 0.04em;
    flex-shrink: 0;
  }
  /* Stacked who-am-I block injected by header.js inside .ch-user-btn.
     Contains a .name (bold) over a .role (small, dim, uppercase). */
  .ch-user-who {
    flex: 1;
    display: flex; flex-direction: column;
    line-height: 1.1;
    text-align: left;
    min-width: 0;
  }
  .ch-user-who .name {
    font-size: 12.5px; font-weight: 600;
    color: var(--sidebar-text-strong);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .ch-user-who .role {
    font-size: 10px; font-weight: 500;
    color: var(--sidebar-text-faint);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 2px;
  }
  /* Hide the old standalone role-tag chip — its data now feeds .role
     inside .ch-user-who. Kept in the DOM for callers that look it up
     by id (#ch-user-role). */
  .ch-role-tag {
    position: absolute; left: -9999px; width: 1px; height: 1px;
    overflow: hidden;
  }
  .ch-user-btn .ti {
    font-size: 14px; color: var(--sidebar-text-faint);
    margin-left: auto; flex-shrink: 0;
  }

  /* Sidebar palette picker inside the user dropdown. Row of 7 colour
     swatches matching the design's THEMES list. */
  .ch-menu-palette {
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.06);
    margin-bottom: 4px;
  }
  .ch-menu-palette-label {
    font-size: 11px; font-weight: 600;
    color: #5F5E5A;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
  }
  .ch-menu-palette-swatches {
    display: flex; flex-wrap: wrap; gap: 6px;
  }
  .ch-palette-swatch {
    width: 30px; height: 30px;
    border-radius: 8px;
    border: 1.5px solid transparent;
    cursor: pointer;
    padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    transition: transform 0.1s, border-color 0.1s, box-shadow 0.1s;
    /* Outer dark hairline so the pale swatches (light grey / blue) stay
       outlined against the white dropdown; inner white ring for the dark ones. */
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 0 0 1px rgba(0,0,0,0.12);
  }
  .ch-palette-swatch:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 2px 6px rgba(0,0,0,0.18);
  }
  .ch-palette-swatch.active {
    border-color: #2C2C2A;
  }
  .ch-palette-swatch svg { display: block; }

  /* Dropdown menu — opens UPWARD from the bottom-left now. */
  .ch-menu {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 8px; right: 8px;
    top: auto;
    background: #fff; color: #2C2C2A;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 10px;
    box-shadow: 0 -6px 24px rgba(0,0,0,0.18);
    padding: 6px;
    z-index: 1000;
    display: none;
  }
  .ch-menu.open { display: block; }

  /* Nav strip → vertical list inside the sidebar */
  .ch-nav {
    position: fixed; left: 0; top: 90px;
    width: var(--sidebar-width);
    /* Fill between the topbar (90) and the user footer (~64), scroll if needed */
    height: calc(100vh - 90px - 64px);
    overflow-y: auto;
    background: transparent;
    border: 0;
    padding: 8px 12px 16px;
    display: flex; flex-direction: column;
    align-items: stretch;
    gap: 2px;
    z-index: 99;
    /* Themed scrollbar — semi-transparent white on green. Firefox + WebKit. */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.22) transparent;
  }
  .ch-nav::-webkit-scrollbar { width: 6px; }
  .ch-nav::-webkit-scrollbar-track { background: transparent; }
  .ch-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.22);
    border-radius: 3px;
  }
  .ch-nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.35); }
  /* All nav links visible by default in the sidebar — overriding the old
     per-page show/hide rules that paired with a horizontal top-nav.
     header.js still hides links the user lacks capability for. */
  .ch-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px;
    margin: 0;
    text-decoration: none;
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 8px;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
  }
  .ch-nav a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
  }
  .ch-nav a.active {
    background: var(--sidebar-active);
    border-color: var(--sidebar-active-border);
    color: var(--sidebar-text-strong);
    font-weight: 600;
  }
  .ch-nav a .ti { font-size: 15px; opacity: 0.85; flex-shrink: 0; width: 18px; text-align: center; }
  .ch-nav-home {
    margin-bottom: 8px;
    padding-bottom: 9px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--sidebar-divider) !important;
    border-radius: 8px;
  }

  /* Section labels between groups in the sidebar. */
  .ch-nav-section {
    font-size: 10.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    color: var(--sidebar-text-faint);
    padding: 16px 12px 6px;
    margin: 0;
  }
  .ch-nav-section:first-child { padding-top: 4px; }

  /* Settings group reads as a configuration menu, not as another set of
     apps. Pushed down with extra space + a top divider, label gets a
     gear glyph, and the items themselves are slightly muted so the eye
     skips them by default. */
  .ch-nav-section[data-section="settings"] {
    margin-top: 14px;
    padding-top: 18px;
    border-top: 1px solid var(--sidebar-divider);
    color: var(--sidebar-text-faint);
    display: flex; align-items: center; gap: 8px;
  }
  .ch-nav-section[data-section="settings"]::before {
    content: '\ea8a';   /* Tabler ti-settings */
    font-family: 'tabler-icons';
    font-size: 14px;
    font-weight: 400;
    color: var(--sidebar-text-faint);
  }
  .ch-nav a[data-section="settings"] {
    color: var(--sidebar-text-faint);
    font-size: 13px;
    padding-top: 8px; padding-bottom: 8px;
  }
  .ch-nav a[data-section="settings"]:hover { color: var(--sidebar-text-strong); }
  .ch-nav a[data-section="settings"] .ti { opacity: 0.7; }

  /* Per-item count badge — e.g. Renewals (6), Stock (21), Tickets (7). */
  .ch-nav-badge {
    margin-left: auto;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    line-height: 1.4;
  }
  .ch-nav-badge.warn { background: #BA7517; color: #fff; }
  .ch-nav-badge.info { background: var(--sidebar-active); color: var(--sidebar-text-strong); }
  .ch-nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Avoid a brief un-grouped flash while header.js is still loading. */
  .ch-nav:not([data-grouped]) > * { visibility: hidden; }

  /* ---- Collapse / expand toggle (Phase 2.46d) ----
     Toggle button injected by header.js into .ch-topbar. */
  /* Sidebar collapse-to-icons toggle: hidden on desktop too — the user
     didn't want it crowding the new white logo header. The button is still
     injected by header.js but stays invisible everywhere. */
  .ch-sidebar-toggle { display: none !important; }
  /* Mobile hamburger button (injected by initMobileNavToggle). Hidden by
     default so it only ever shows inside the @media (max-width: 900px)
     block below. Without this base rule the button renders inline on
     desktop next to the brand logo. */
  .ch-nav-toggle { display: none; }
  .ch-nav-backdrop { display: none; }

  /* When collapsed: hide text labels, shrink padding, center icons. */
  html.sidebar-collapsed .ch-brand-text,
  html.sidebar-collapsed .ch-nav-label,
  html.sidebar-collapsed .ch-nav-section,
  html.sidebar-collapsed .ch-nav-badge,
  html.sidebar-collapsed .ch-role-tag,
  html.sidebar-collapsed .ch-user-btn .ti-chevron-down,
  html.sidebar-collapsed .ch-brand-tag { display: none !important; }

  html.sidebar-collapsed .ch-topbar { padding: 14px 8px; justify-content: center; }
  html.sidebar-collapsed .ch-brand { gap: 0; justify-content: center; }
  html.sidebar-collapsed .ch-sidebar-toggle { margin-left: 0; }

  html.sidebar-collapsed .ch-nav a { justify-content: center; padding: 9px 0; }
  html.sidebar-collapsed .ch-nav a .ti { font-size: 18px; width: auto; }
  html.sidebar-collapsed .ch-nav-home { padding-bottom: 9px; }

  html.sidebar-collapsed .ch-topbar-right {
    padding: 10px 6px;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }
  html.sidebar-collapsed .ch-user-btn { justify-content: center; padding: 4px; width: auto; }
  html.sidebar-collapsed .ch-menu {
    /* The dropdown menu can't fit inside a 64px column — float it to
       the right of the sidebar instead. */
    left: calc(100% + 6px);
    right: auto;
    bottom: 0;
    min-width: 240px;
  }
  html.sidebar-collapsed .ch-bell-btn { margin: 0; width: 36px; height: 36px; }

  /* Tooltip-style label on hover when collapsed, so the user can still
     read the link names without expanding the rail. */
  html.sidebar-collapsed .ch-nav a { position: relative; }
  html.sidebar-collapsed .ch-nav a::after {
    content: attr(data-label);
    position: absolute;
    left: calc(100% + 8px);
    top: 50%; transform: translateY(-50%);
    background: var(--sidebar-bg);
    color: #fff;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s;
    z-index: 200;
    text-transform: capitalize;
  }
  html.sidebar-collapsed .ch-nav a:hover::after { opacity: 1; }
}

/* ============================================================================
   MOBILE — keep the previous horizontal layout. Nothing else changes on phones.
   ============================================================================ */
@media (max-width: 900px) {
  body { padding-left: 0; }
  .ch-topbar {
    background: #fff; color: #2C2C2A;
    padding: 8px 14px;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 2px solid #46D926;
    position: sticky; top: 0; height: auto; width: auto;
    z-index: 90;
  }
  /* Topbar slims: keep the brand visible but drop the "Simple · Scalable …"
     tagline so the row is short. */
  .ch-brand-tag { display: none; }

  /* Hamburger button (injected by header.js initMobileNavToggle). */
  .ch-nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent; border: 0;
    padding: 6px 8px; margin-right: 6px;
    color: #2C2C2A; cursor: pointer; font-size: 22px; line-height: 1;
  }
  .ch-nav-toggle:hover { color: #173404; }

  /* Backdrop behind the open drawer. */
  .ch-nav-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    opacity: 0; pointer-events: none; transition: opacity 0.18s ease;
    z-index: 94;
  }
  html.nav-open .ch-nav-backdrop { opacity: 1; pointer-events: auto; }
  html.nav-open { overflow: hidden; }  /* lock body scroll while drawer is open */

  /* Slide-out drawer (was a horizontal scrollable strip before). */
  .ch-nav {
    background: #fff; color: inherit;
    position: fixed; top: 0; right: 0; bottom: 0; left: auto;
    width: 84vw; max-width: 320px; height: 100dvh;
    border-bottom: 0; border-left: 1px solid rgba(0,0,0,0.08);
    padding: 14px 0 28px;
    display: flex; flex-direction: column; align-items: stretch;
    transform: translateX(100%); transition: transform 0.2s ease;
    overflow-y: auto; overflow-x: hidden;
    box-shadow: -10px 0 30px rgba(0,0,0,0.12);
    z-index: 95;
  }
  html.nav-open .ch-nav { transform: translateX(0); }

  .ch-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; color: #2C2C2A; border: 0;
    border-radius: 0; font-size: 14px; line-height: 1.3;
    white-space: normal; text-decoration: none;
  }
  .ch-nav a .ti { font-size: 18px; color: #5F5E5A; flex-shrink: 0; width: 22px; text-align: center; }
  .ch-nav a:hover { background: #F6F5F0; }
  .ch-nav a.active { background: #E8F9E1; color: #173404; font-weight: 500; }
  .ch-nav a.active .ti { color: #173404; }
  .ch-nav a:hover { color: #2C2C2A; background: transparent; }
  .ch-nav a.active { color: #2C2C2A; font-weight: 500; border-bottom-color: #46D926; background: transparent; }
  .ch-brand img { height: 32px; width: auto; max-width: 80px; background: transparent; padding: 0; }
  .ch-brand-name { color: #2C2C2A; font-size: 15px; }
  .ch-brand-tag  { color: #5F5E5A; font-size: 11px; letter-spacing: 0.4px; }
  .ch-topbar-right {
    position: static; padding: 0; background: transparent; border-top: 0;
    width: auto; display: flex; align-items: center; gap: 10px;
  }
  .ch-user-btn {
    background: transparent; border: 1px solid rgba(0,0,0,0.08);
    padding: 4px 12px 4px 4px; color: #2C2C2A; width: auto;
  }
  .ch-user-btn:hover { background: #F7F7F7; border-color: rgba(0,0,0,0.18); }
  .ch-user-btn .ch-avatar { background: #E8F9E1; color: #173404; }
  .ch-user-btn .ti { color: #5F5E5A; }
  .ch-role-tag { background: transparent; color: inherit; margin-left: 0; }
  .ch-role-tag.role-admin    { background: #EEEDFE; color: #3C3489; }
  .ch-role-tag.role-manager  { background: #E8F9E1; color: #173404; }
  .ch-role-tag.role-partner  { background: #E6EAF5; color: #1C2444; }
  /* Mobile dropdown — same toggle semantics as desktop (.ch-menu hidden,
     .ch-menu.open visible). Without this the desktop's display:none rule
     is out of scope and the menu stays permanently open. */
  .ch-menu { position: absolute; top: calc(100% + 6px); right: 0; bottom: auto; left: auto; background: #fff; color: #2C2C2A; box-shadow: 0 6px 24px rgba(0,0,0,0.08); min-width: 240px; display: none; }
  .ch-menu.open { display: block; }
  /* Sidebar collapse/expand button only makes sense when there IS a sidebar.
     On mobile the nav is a horizontal strip, so hide the toggle. */
  .ch-sidebar-toggle { display: none !important; }
  .ch-nav-home { border-bottom: 0 !important; padding-bottom: 12px; margin-bottom: 0; }
  /* Section labels: visible in the drawer to keep the same grouping the
     desktop sidebar shows. */
  .ch-nav-section {
    display: block;
    padding: 16px 20px 6px;
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
    color: #9A9A95; font-weight: 500;
  }
  .ch-nav-section:first-child { padding-top: 8px; }
  /* Badges in the mobile drawer sit on the right of each row so they
     read like a count, not crowding the label. */
  .ch-nav-badge { margin-left: auto; padding: 2px 8px; font-size: 11px; font-weight: 500; border-radius: 999px; }
  .ch-nav-badge.warn { background: #FBF3E5; color: #BA7517; }
  .ch-nav-badge.info { background: #E6F1FB; color: #1E5FAA; }
}

.ch-menu-info {
  padding: 10px 12px 8px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  margin-bottom: 4px;
}
.ch-menu-info #ch-menu-name {
  font-size: 13px; font-weight: 500; color: #2C2C2A;
}
.ch-menu-info #ch-menu-email {
  font-size: 11px; color: #5F5E5A; margin-top: 2px; word-break: break-all;
}
.ch-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border: 0; background: transparent;
  width: 100%; text-align: left; cursor: pointer;
  font-family: inherit; font-size: 13px;
  color: #2C2C2A; border-radius: 6px;
}
.ch-menu-item:hover { background: #F7F7F7; }
.ch-menu-item .ti { font-size: 16px; color: #5F5E5A; }
.ch-menu-item.danger { color: #C24B3F; }
.ch-menu-item.danger .ti { color: #C24B3F; }
/* Used by the Settings group inside the user dropdown. */
a.ch-menu-item { text-decoration: none; }
.ch-menu-section {
  font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
  text-transform: uppercase; color: #9A9A95;
  padding: 10px 12px 4px;
}
.ch-menu-divider {
  height: 1px; background: rgba(0,0,0,0.08);
  margin: 6px 4px;
}

/* Print: never show the sidebar on print previews. */
@media print {
  body { padding-left: 0 !important; }
  .ch-topbar, .ch-nav, .ch-topbar-right { display: none !important; }
}

/* Change-password modal ------------------------------------------------------ */
.ch-modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center;
  z-index: 1100;
}
.ch-modal-backdrop.open { display: flex; }
.ch-modal {
  background: white; border-radius: 12px;
  padding: 24px 28px;
  width: 460px; max-width: 92vw;
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  font-family: inherit;
}
.ch-modal h2 { margin: 0 0 6px; font-size: 18px; font-weight: 500; color: #2C2C2A; }
.ch-modal .sub { margin: 0 0 18px; color: #5F5E5A; font-size: 13px; }
.ch-modal label { display: block; font-size: 12px; color: #5F5E5A; margin: 12px 0 4px; font-weight: 500; }
.ch-modal input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid rgba(0,0,0,0.08); border-radius: 6px;
  background: white; font-family: inherit; color: #2C2C2A;
}
.ch-modal input:focus { outline: none; border-color: #46D926; box-shadow: 0 0 0 2px #E8F9E1; }
.ch-modal-foot { margin-top: 22px; display: flex; gap: 10px; justify-content: flex-end; }
.ch-modal-btn {
  padding: 9px 16px; border-radius: 6px; font-family: inherit;
  font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid rgba(0,0,0,0.08); background: white; color: #2C2C2A;
}
.ch-modal-btn:hover { background: #F7F7F7; }
.ch-modal-btn.primary { background: #46D926; color: #173404; border-color: transparent; }
.ch-modal-btn.primary:hover { filter: brightness(0.95); background: #46D926; }
.ch-modal-btn.primary:disabled { opacity: 0.6; cursor: progress; }
.ch-modal .msg { margin-top: 10px; padding: 9px 12px; border-radius: 6px; font-size: 12px; display: none; }
.ch-modal .msg.show { display: block; }
.ch-modal .msg.err { background: #FBEDEC; color: #C24B3F; }
.ch-modal .msg.ok  { background: #E8F9E1; color: #173404; }

/* Suggestion Inbox bell (admin only) ---------------------------------------- */
.ch-bell-btn {
  display: none;
  position: relative;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 50%;
  width: 32px; height: 32px;
  align-items: center; justify-content: center;
  cursor: pointer; color: var(--sidebar-text);
  font-family: inherit;
}
.ch-bell-btn:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.ch-bell-btn.show { display: inline-flex; }
.ch-bell-btn .ti { font-size: 16px; }
.ch-bell-badge {
  position: absolute; top: -4px; right: -4px;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  background: #BA7517; color: white;
  font-size: 11px; font-weight: 600;
  display: none; align-items: center; justify-content: center;
  border: 2px solid var(--sidebar-bg);
  line-height: 1;
}
.ch-bell-badge.show { display: inline-flex; }
@media (max-width: 900px) {
  .ch-bell-btn { border-color: rgba(0,0,0,0.08); color: #2C2C2A; }
  .ch-bell-btn:hover { background: #F7F7F7; }
  .ch-bell-badge { border-color: #fff; }
}

/* Inbox modal */
.ch-inbox-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: center; justify-content: center; z-index: 250; }
.ch-inbox-backdrop.open { display: flex; }
.ch-inbox { background: white; border-radius: 12px; padding: 22px 26px; width: 620px; max-width: 94vw; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,0.18); }
.ch-inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.ch-inbox-head h2 { margin: 0; font-size: 18px; font-weight: 500; }
.ch-inbox-tabs { display: inline-flex; gap: 6px; }
.ch-inbox-tab { background: transparent; border: 0; padding: 5px 12px; font-size: 12px; font-weight: 500; border-radius: 999px; color: #5F5E5A; cursor: pointer; font-family: inherit; }
.ch-inbox-tab.active { background: #E8F9E1; color: #173404; }
.ch-inbox-body { overflow-y: auto; flex: 1; margin: 0 -8px; padding: 0 8px; border-top: 0.5px solid rgba(0,0,0,0.08); }
.ch-inbox-empty { padding: 40px 20px; text-align: center; color: #5F5E5A; font-size: 13px; }
.ch-sugg { padding: 14px 4px; border-bottom: 0.5px solid rgba(0,0,0,0.08); }
.ch-sugg:last-child { border-bottom: 0; }
.ch-sugg.read { opacity: 0.65; }
.ch-sugg-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.ch-sugg-from { font-size: 12px; color: #5F5E5A; }
.ch-sugg-from strong { color: #2C2C2A; font-weight: 500; }
.ch-sugg-when { font-size: 11px; color: #9A9A95; }
.ch-sugg-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.ch-sugg-actions { margin-top: 8px; display: flex; gap: 6px; }
.ch-sugg-btn { background: transparent; border: 1px solid rgba(0,0,0,0.12); border-radius: 6px; padding: 4px 10px; font-size: 11px; font-weight: 500; color: #5F5E5A; cursor: pointer; font-family: inherit; }
.ch-sugg-btn:hover { background: #F7F7F7; color: #2C2C2A; }
.ch-sugg-btn.primary { background: #E8F9E1; color: #173404; border-color: transparent; }
.ch-sugg-pill { display: inline-block; font-size: 10px; font-weight: 500; padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.ch-sugg-pill.new      { background: #FBF3E5; color: #BA7517; }
.ch-sugg-pill.read     { background: #F7F7F7; color: #5F5E5A; }
.ch-sugg-pill.resolved { background: #E8F9E1; color: #173404; }

/* ============================================================================
   Notification popups — prominent toast cards (top-right) that fire when a new
   director-notification arrives, so important things (HR incidents, ticket
   alerts) can't be missed in the small sidebar bell. High-priority kinds are
   red and stay until dismissed; routine ones auto-dismiss.
   ============================================================================ */
.ch-noti-stack {
  position: fixed; top: 16px; right: 16px; z-index: 99999;
  display: flex; flex-direction: column; gap: 10px;
  width: 370px; max-width: calc(100vw - 32px);
  pointer-events: none;
}
.ch-noti {
  pointer-events: auto;
  background: #fff; border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.10); border-left: 4px solid var(--brand-green, #46D926);
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  padding: 13px 14px; display: flex; gap: 11px; align-items: flex-start;
  animation: ch-noti-in 0.28s cubic-bezier(.2,.8,.2,1);
}
.ch-noti.high { border-left-color: #C24B3F; box-shadow: 0 14px 36px rgba(194,75,63,0.30); }
.ch-noti-ico {
  width: 36px; height: 36px; border-radius: 9px; flex: 0 0 auto;
  background: var(--brand-green-soft, #E8F9E1); color: var(--brand-green-dark, #173404);
  display: inline-flex; align-items: center; justify-content: center; font-size: 19px;
}
.ch-noti.high .ch-noti-ico { background: #FBEDEC; color: #C24B3F; }
.ch-noti-main { flex: 1; min-width: 0; }
.ch-noti-kind { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: #9A9A95; }
.ch-noti.high .ch-noti-kind { color: #C24B3F; }
.ch-noti-title { font-size: 13.5px; font-weight: 600; color: #2C2C2A; margin: 1px 0 2px; line-height: 1.3; }
.ch-noti-body { font-size: 12.5px; color: #5F5E5A; line-height: 1.4; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.ch-noti-actions { display: flex; gap: 8px; margin-top: 9px; }
.ch-noti-view { font: inherit; font-size: 12px; font-weight: 600; border: 0; border-radius: 7px; padding: 5px 12px; background: var(--brand-green, #46D926); color: var(--brand-green-dark, #173404); cursor: pointer; }
.ch-noti.high .ch-noti-view { background: #C24B3F; color: #fff; }
.ch-noti-x { font: inherit; background: transparent; border: 0; color: #9A9A95; cursor: pointer; font-size: 19px; line-height: 1; padding: 0 2px; flex: 0 0 auto; }
.ch-noti-x:hover { color: #2C2C2A; }
@keyframes ch-noti-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 640px) { .ch-noti-stack { top: 10px; right: 10px; left: 10px; width: auto; } }

/* ---- Popup Open / Acknowledge buttons + rich body --------------------------- */
.ch-noti-open { font: inherit; font-size: 12px; font-weight: 600; border: 1px solid rgba(0,0,0,0.14); border-radius: 7px; padding: 5px 12px; background: #fff; color: #2C2C2A; cursor: pointer; }
.ch-noti-ack { font: inherit; font-size: 12px; font-weight: 700; border: 0; border-radius: 7px; padding: 5px 13px; background: #173404; color: #fff; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.ch-noti-ack[disabled] { opacity: 0.6; }
.ch-noti.ack { border-left-color: #BA7517; box-shadow: 0 14px 36px rgba(186,117,23,0.30); }
.ch-noti.ack .ch-noti-ico { background: #FBF3E5; color: #BA7517; }
.ch-noti.ack .ch-noti-kind { color: #BA7517; }
.ch-noti.ack .ch-noti-body { -webkit-line-clamp: 8; }
.ch-noti-body b, .ch-noti-body strong { font-weight: 700; }

/* ---- Manager "Notify team" compose ----------------------------------------- */
.ch-compose { width: 540px; max-width: calc(100vw - 28px); }
.ch-compose .ch-inbox-body { padding: 16px 18px; }
.ch-cmp-tab { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 6px 4px; margin-right: 14px; font: inherit; font-size: 13px; font-weight: 600; color: #5F5E5A; cursor: pointer; }
.ch-cmp-tab.active { color: #173404; border-bottom-color: #46D926; }
.ch-cmp-label { display: block; font-size: 11.5px; font-weight: 700; color: #5F5E5A; margin: 14px 0 5px; }
.ch-cmp-label:first-child { margin-top: 0; }
.ch-cmp-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 13.5px; padding: 8px 10px; border: 1px solid rgba(0,0,0,0.16); border-radius: 8px; }
.ch-cmp-recip { max-height: 150px; overflow: auto; border: 1px solid rgba(0,0,0,0.12); border-radius: 8px; padding: 4px; }
.ch-cmp-recip-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; font-size: 13px; border-radius: 6px; cursor: pointer; }
.ch-cmp-recip-row:hover { background: #F7F7F7; }
.ch-cmp-recip-row.all { border-bottom: 1px solid rgba(0,0,0,0.08); margin-bottom: 3px; }
.ch-cmp-role { font-size: 10.5px; color: #9A9A95; text-transform: capitalize; }
.ch-cmp-toolbar { display: flex; align-items: center; gap: 5px; padding: 5px; border: 1px solid rgba(0,0,0,0.14); border-bottom: 0; border-radius: 8px 8px 0 0; background: #FAFAF8; }
.ch-cmp-toolbar [data-cmd] { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-size: 14px; color: #2C2C2A; }
.ch-cmp-toolbar [data-cmd]:hover { background: #ECECEA; }
.ch-cmp-toolbar select { font: inherit; font-size: 12px; border: 1px solid rgba(0,0,0,0.14); border-radius: 6px; padding: 4px 6px; background: #fff; }
.ch-cmp-colour { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; font-weight: 700; }
.ch-cmp-colour input { width: 22px; height: 22px; border: 0; background: none; padding: 0; cursor: pointer; }
.ch-cmp-editor { min-height: 110px; max-height: 240px; overflow: auto; border: 1px solid rgba(0,0,0,0.14); border-radius: 0 0 8px 8px; padding: 10px 12px; font-size: 13.5px; line-height: 1.5; outline: none; }
.ch-cmp-editor:empty::before { content: attr(data-ph); color: #9A9A95; }
.ch-cmp-check { display: flex; align-items: flex-start; gap: 8px; margin-top: 12px; font-size: 13px; cursor: pointer; }
.ch-cmp-check input { margin-top: 2px; }
.ch-cmp-foot { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.ch-cmp-note { flex: 1; font-size: 12.5px; color: #5F5E5A; }
.ch-cmp-batch { border: 1px solid rgba(0,0,0,0.10); border-radius: 9px; padding: 11px 13px; margin-bottom: 10px; }
.ch-cmp-batch-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.ch-cmp-batch-when { font-size: 11px; color: #9A9A95; margin-top: 2px; }
.ch-cmp-stat { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: #F2F1EC; color: #5F5E5A; white-space: nowrap; }
.ch-cmp-stat.ok { background: #E8F9E1; color: #173404; }
.ch-cmp-stat.wait { background: #FBF3E5; color: #BA7517; }
.ch-cmp-pending { font-size: 12px; color: #5F5E5A; margin-top: 7px; }
.ch-cmp-pending.done { color: #173404; }
