/* Top menu: the same bar, in the same place, at the same size, on every page. Every rule is scoped by #topmenu so no page
   stylesheet can restyle it, and the bar is position:fixed so a page's body margin, padding, background or flex layout
   cannot move or stretch it. A spacer right after it keeps the page content below the bar. */
:root { --tm-bg: #2b2d7a; --tm-fg: #f5f7fa; --tm-accent: #fbbf24; --tm-panel: #ffffff; --tm-panel-fg: #1f2933; --tm-h: 52px; }

#topmenu.tm { position: fixed; top: 0; left: 0; right: 0; z-index: 1000; width: 100%; height: 52px; min-height: 52px; max-height: 52px;
              margin: 0; padding: 0 20px; box-sizing: border-box; display: flex; align-items: center; gap: 20px; overflow: visible;
              background: var(--tm-bg); color: var(--tm-fg); border: 0; border-radius: 0; box-shadow: 0 1px 0 rgba(0,0,0,.25);
              font: 400 14px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
              letter-spacing: normal; text-transform: none; text-align: left; }
#topmenu.tm[hidden] { display: none; }
#topmenu + .tm-spacer { display: block; height: 52px; min-height: 52px; margin: 0; padding: 0; flex: 0 0 52px; }
#topmenu.tm *, #topmenu.tm *::before, #topmenu.tm *::after { box-sizing: border-box; letter-spacing: normal; text-transform: none; }

#topmenu .tm-brand { color: var(--tm-fg); font-size: 17px; font-weight: 700; line-height: 1.2; text-decoration: none; white-space: nowrap; margin: 0; padding: 0; }
#topmenu .tm-nav { min-width: 0; display: flex; align-items: stretch; flex: 1 1 auto; gap: 2px; height: 52px; margin: 0; padding: 0; overflow-x: auto; scrollbar-width: none; }
#topmenu .tm-nav::-webkit-scrollbar { display: none; }
#topmenu .tm-item { position: relative; display: flex; margin: 0; padding: 0; }
#topmenu .tm-btn { display: flex; align-items: center; gap: 6px; height: 52px; margin: 0; padding: 0 12px; background: none; border: 0; border-bottom: 3px solid transparent;
                   border-radius: 0; box-shadow: none; color: var(--tm-fg); font-family: inherit; font-size: 14px; font-weight: 400; line-height: 1.2;
                   white-space: nowrap; cursor: pointer; }
#topmenu .tm-btn:hover, #topmenu .tm-item.open .tm-btn, #topmenu .tm-item.current .tm-btn { border-bottom-color: var(--tm-accent); background: rgba(255,255,255,.1); }
#topmenu a.tm-btn { text-decoration: none; padding-right: 4px; }
#topmenu .tm-caret { display: flex; align-items: center; height: 52px; margin: 0; padding: 0 8px 0 2px; background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
                     box-shadow: none; color: var(--tm-fg); font-family: inherit; font-size: 11px; line-height: 1; cursor: pointer; opacity: .8; }
#topmenu .tm-item:hover .tm-caret, #topmenu .tm-item.open .tm-caret, #topmenu .tm-item.current .tm-caret { border-bottom-color: var(--tm-accent); background: rgba(255,255,255,.1); opacity: 1; }
#topmenu .tm-caret:focus-visible { outline: 2px solid var(--tm-accent); outline-offset: -2px; }
#topmenu .tm-item:hover .tm-btn { border-bottom-color: var(--tm-accent); background: rgba(255,255,255,.1); }
#topmenu .tm-btn:focus-visible { outline: 2px solid var(--tm-accent); outline-offset: -2px; }
#topmenu .tm-ico { font-size: 14px; line-height: 1; }
#topmenu .tm-panel { display: none; position: fixed; top: 52px; min-width: 240px; margin: 0; padding: 6px 0; background: var(--tm-panel); color: var(--tm-panel-fg);
                     border-radius: 0 0 10px 10px; box-shadow: 0 12px 28px rgba(0,0,0,.28); }
#topmenu .tm-item.open .tm-panel { display: block; }
#topmenu .tm-link { display: block; margin: 0; padding: 9px 18px; background: none; color: var(--tm-panel-fg); font-size: 14px; font-weight: 400; line-height: 1.3; text-decoration: none; }
#topmenu .tm-link:hover, #topmenu .tm-link:focus-visible { background: #eef2f7; outline: none; }
#topmenu .tm-link.current { font-weight: 700; border-left: 3px solid var(--tm-accent); padding-left: 15px; }
#topmenu .tm-who { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; margin: 0; padding: 0; font-size: 13px; line-height: 1.2; white-space: nowrap; }
#topmenu .tm-user { font-size: 13px; }
#topmenu .tm-role { margin: 0; padding: 2px 10px; background: rgba(255,255,255,.18); border-radius: 999px; font-size: 12px; text-transform: capitalize !important; }
#topmenu .tm-out { margin: 0; padding: 4px 12px; background: none; border: 1px solid currentColor; border-radius: 6px; box-shadow: none; color: var(--tm-fg);
                   font-family: inherit; font-size: 13px; font-weight: 400; line-height: 1.2; cursor: pointer; }
#topmenu .tm-out:hover { background: rgba(255,255,255,.16); }
/* Every menu must stay visible next to the user area: as the window narrows, first the email goes (it stays as the role pill's tooltip),
   then the menu icons and padding shrink. The nav scrolls sideways only as a last resort. */
@media (max-width: 1700px) { #topmenu.tm { gap: 12px; padding: 0 12px; } #topmenu .tm-btn { padding: 0 8px; } #topmenu .tm-user { display: none; } }
@media (max-width: 1500px) { #topmenu .tm-ico { display: none; } #topmenu .tm-btn { font-size: 13px; padding: 0 6px; } #topmenu .tm-caret { padding: 0 5px 0 0; } }
@media (max-width: 1100px) { #topmenu .tm-role { display: none; } }
@media (max-width: 760px) { #topmenu .tm-user { display: none; } }
@media print { #topmenu.tm, #topmenu + .tm-spacer, #tm-pagehead { display: none !important; } }

/* Pages that still carry their own old header (brand + Home link) get the shared menu instead. */
body:has(#topmenu) header.topbar { display: none; }

/* Page header: names the module and the page, in the module's colour, directly under the bar on every page. */
#tm-pagehead { display: flex; align-items: center; gap: 10px; width: 100%; height: 46px; min-height: 46px; margin: 0; padding: 0 20px; box-sizing: border-box; flex: 0 0 46px;
               background: linear-gradient(90deg, rgba(255,255,255,.16), rgba(255,255,255,.04)), var(--tm-bg, #2b2d7a); color: #fff;
               font: 400 14px/1.2 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; letter-spacing: normal; text-transform: none; border-bottom: 1px solid rgba(0,0,0,.18); }
#tm-pagehead .tm-ph-title { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
#tm-pagehead .tm-ph-ico { font-size: 16px; line-height: 1; }
#tm-pagehead .tm-ph-sep { opacity: .7; }
#tm-pagehead .tm-ph-page { font-size: 15px; font-weight: 500; }
#tm-pagehead .tm-ph-blurb { margin-left: auto; font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) { #tm-pagehead .tm-ph-blurb { display: none; } }
