/* =====================================================================
   SWITCHBOARD CHROME: chrome.css (owner: shell)
   The topbar, its menus, the nav alert lamp, the mini operator, the user and Sign out, the footer
   line and the #tip host. Loaded by EVERY internal page: rebuilt pages (with sb.css) and legacy
   pages (with the frozen style.css), so the nav is the same everywhere from day one.

   Rules of this file:
   * Selectors start with header.site-header, footer.site-footer or #tip, and nothing else, so the
     chrome can never restyle a page body (legacy or rebuilt).
   * Colors come ONLY from this file's own --ch-* tokens, set on header.site-header,
     footer.site-footer and #tip below (light values, then the night-operator values under
     prefers-color-scheme: dark and data-theme="dark", the same switch sb.css uses). No var() here
     reads another file's token: style.css defines --bg --ink --muted --line with other values and
     sb.css's tokens exist only on rebuilt pages, so the chrome looks the same on a legacy page
     (style.css) and a rebuilt one (sb.css). The header, its menus and #tip carry their own
     backgrounds and switch with the theme on every page. The footer has no background of its own,
     so its night values apply only on rebuilt pages (html[data-ui="switchboard"]): a legacy page's
     body stays light (style.css is frozen) and the footer keeps the light values there.
   * header.site-header ... beats style.css's .site-header / .navmenu rules by specificity, and this
     file loads after style.css.
   * CSP default-src 'self': no inline style anywhere; the "/" key and focus-leave are shell.js,
     the menus' outside-click / Esc / one-at-a-time are records.js (details.navmenu).

   MARKUP CONTRACT (base.html, PLAN 5.2; part B writes it, this file styles exactly this):

   <header class="site-header">                                   exact class string, nothing added
     <a class="sb-brand" href="/" aria-label="Records home">
       <span class="brand-dial" id="brandDial">{{ ui.dial_svg(38, 'dial-brand') }}</span>
       <span class="sb-wordmark"><b>1-800-MARKETER</b><small>records · back office switchboard</small></span>
     </a>
     <nav class="sb-nav" aria-label="Main">
       <a href="/" class="nav-on" aria-current="page">Home</a>          current item: .nav-on + aria-current
       <a href="/answers">Answers</a>
       <a href="/orders">Orders</a>
       <details class="navmenu [nav-on]"><summary>Backorders</summary>
         <div class="sb-menu-pop">
           <a href="/backorders">All backorders</a> ... <span class="sb-menu-div" role="separator"></span> ...
         </div></details>
       <a href="/releases">Releases<span class="sb-nav-alert" title="2 customers answered ...">
         <i aria-hidden="true"></i>2</span></a>                         only when shell_alerts().n > 0
       <details class="navmenu">Numbers ...</details>
       <details class="navmenu">Network ...</details>
       <details class="navmenu sb-menu-end">Settings ...</details>      sb-menu-end: panel opens leftwards
       <span class="sb-nav-div" aria-hidden="true"></span>
       <details class="navmenu sb-menu-end"><summary>Blog</summary><div class="sb-menu-pop">
         <a class="ext" href="https://..." target="_blank" rel="noopener">Blog admin</a> ...</div></details>
       <form class="sb-qmini" method="post" action="/search" role="search">   not on Home or /search
         <label class="sb-vh" for="qmini">Search all records</label>
         <input id="qmini" name="q" type="search" maxlength="120" autocomplete="off" spellcheck="false"
                placeholder="Dial… /"></form>
       <span class="nav-user" id="navUser"><i class="sb-user-lamp" aria-hidden="true"></i>Bill</span>
       <form class="sb-out" method="post" action="/logout"><button type="submit">Sign out</button></form>
     </nav>
   </header>
   Signed out on /login: the <a class="sb-brand"> only. Elsewhere signed out: no header content.

   <footer class="site-footer">                                   exact class string
     {% block footer_dial %}  <nav class="sb-speed" ...>  (index pages only, styled by sb.css)
     <div class="sb-foot">
       <span class="sb-foot-who">records.1800marketer.com · Bill and Hope only · days are Central time</span>
       <span class="sb-asof" id="sbAsOf"></span>                    panels.js / shell.js write it
       <span class="sb-foot-links"><a href="/answers">Answers book</a><a href="/activity">Daily summary</a>
         <a href="#top">Back to top</a></span>
     </div>
   </footer>
   <div class="tip" id="tip" role="tooltip" hidden></div>
   ===================================================================== */

/* ---------------------------------------------------------------- the topbar */
header.site-header {
  --ch-bg: #0E3B43;           /* the bar (teal deep) */
  --ch-ink: #E9E1CF;          /* nav text */
  --ch-cream: #F6EFE0;        /* wordmark */
  --ch-hi: #E2B458;           /* brass high: current item, focus ring, Sign out */
  --ch-rule: #C99234;         /* brass rule under the bar, dial ring */
  --ch-rule-lo: #8A5A0C;      /* the rule's shadow */
  --ch-pop: #FCF8EF;          /* menu panel */
  --ch-pop-2: #F5EEDF;        /* menu item hover */
  --ch-pop-line: #D3C29F;     /* menu border, divider */
  --ch-pop-ink: #435053;      /* menu text, the open mini operator's text */
  --ch-pop-hi: #00697A;       /* menu item hover / current text */
  --ch-pop-kick: #9A6510;     /* menu group label */
  --ch-red: #C4302B;          /* alert lamp, current-item tick, the open mini operator's ring */
  --ch-field: #FFFDF8;        /* the open mini operator */
  --ch-field-hint: #7E847D;   /* its placeholder */
  position: relative; z-index: 60;
  display: flex; align-items: center; gap: 22px; height: 56px; margin: 0; padding: 0 22px;
  background: var(--ch-bg);
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(0, 0, 0, .12));
  border-bottom: 3px solid var(--ch-rule);
  box-shadow: 0 1px 0 var(--ch-rule-lo);
  color: var(--ch-cream);
  font: 14px/1.3 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
header.site-header:empty { display: none; }
header.site-header *, header.site-header *::before, header.site-header *::after { box-sizing: border-box; }
header.site-header [hidden] { display: none !important; }
/* a customer answered an approval request (the home sets .has-alert on <body>; the line turns red) */
.has-alert header.site-header { border-bottom-color: var(--ch-red); }

/* brand: the dial and the wordmark */
header.site-header .sb-brand { display: flex; align-items: center; gap: 11px; flex: none; color: var(--ch-cream); text-decoration: none; }
header.site-header .sb-brand:hover { text-decoration: none; }
header.site-header .brand-dial { display: flex; }
header.site-header .brand-dial svg { display: block; }
header.site-header .sb-wordmark { display: flex; flex-direction: column; line-height: 1.05; }
header.site-header .sb-wordmark b {
  font: 700 21px "Bahnschrift Condensed", "Bahnschrift SemiCondensed", "DIN Condensed", "Avenir Next Condensed", "Arial Narrow", sans-serif;
  letter-spacing: .04em; color: var(--ch-cream);
}
header.site-header .sb-wordmark small {
  font: 500 10px "Segoe UI", -apple-system, Arial, sans-serif; letter-spacing: .14em; text-transform: uppercase;
  color: var(--ch-hi); opacity: .92; white-space: nowrap;
}
/* the rotary dial drawn inline (the same classes sb.css gives every dial; repeated here for legacy pages) */
header.site-header .dl-ring { fill: var(--ch-rule); }
header.site-header .dl-face { fill: #F3EAD6; }
header.site-header .dl-hole { fill: var(--ch-bg); }
header.site-header .dl-cap { fill: var(--ch-red); }
header.site-header .dl-stop { stroke: #C0C4BE; stroke-width: 3; stroke-linecap: round; }
header.site-header .dl-wheel { transform-origin: 32px 32px; transition: transform .45s cubic-bezier(.3, 1.4, .5, 1); }
header.site-header .sb-brand:hover .dl-wheel { transform: rotate(-60deg); }

/* ---------------------------------------------------------------- the nav */
header.site-header .sb-nav { display: flex; align-items: center; gap: 1px; height: 100%; margin-left: auto; min-width: 0; }
header.site-header .sb-nav > a,
header.site-header details.navmenu > summary,
header.site-header .sb-out button {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; margin: 0;
  border: 0; border-radius: 8px; background: none; cursor: pointer;
  color: var(--ch-ink); font-weight: 500; font-size: 14px; line-height: 1; font-family: inherit; white-space: nowrap; text-decoration: none;
  list-style: none; user-select: none;
}
header.site-header .sb-nav > a:hover,
header.site-header details.navmenu > summary:hover,
header.site-header details.navmenu[open] > summary,
header.site-header .sb-out button:hover { background: rgba(255, 255, 255, .09); color: #fff; text-decoration: none; }
header.site-header .sb-nav > a:focus-visible,
header.site-header details.navmenu > summary:focus-visible,
header.site-header .sb-out button:focus-visible { outline: 2px solid var(--ch-hi); outline-offset: 1px; }
/* the page you are on: brass underline */
header.site-header .sb-nav > a.nav-on,
header.site-header .sb-nav > a[aria-current="page"],
header.site-header details.navmenu.nav-on > summary { color: #fff; box-shadow: inset 0 -2px 0 var(--ch-hi); border-radius: 8px 8px 0 0; }

/* menus: <details class="navmenu"> (records.js closes them; never also .menu) */
header.site-header details.navmenu { position: relative; display: inline-flex; height: 100%; align-items: center; }
header.site-header details.navmenu > summary::-webkit-details-marker { display: none; }
header.site-header details.navmenu > summary::marker { content: ""; }
header.site-header details.navmenu > summary::after {
  content: ""; width: 0; height: 0; margin: 0 0 0 1px; opacity: .75;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-top: 5px solid currentColor;
}
header.site-header details.navmenu[open] > summary::after { border-top: 0; border-bottom: 5px solid currentColor; }
header.site-header .sb-menu-pop {
  position: absolute; top: calc(100% - 4px); left: 0; z-index: 70; min-width: 210px; padding: 6px;
  display: flex; flex-direction: column;
  background: var(--ch-pop); border: 1px solid var(--ch-pop-line); border-radius: 12px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, .45);
}
header.site-header details.navmenu.sb-menu-end .sb-menu-pop { left: auto; right: 0; }
header.site-header .sb-menu-pop a {
  display: block; padding: 8px 12px; border-radius: 8px; color: var(--ch-pop-ink); font-weight: 500; font-size: 14px; line-height: 1.3; font-family: inherit; text-decoration: none; white-space: nowrap;
}
header.site-header .sb-menu-pop a:hover, header.site-header .sb-menu-pop a:focus-visible { background: var(--ch-pop-2); color: var(--ch-pop-hi); outline: none; }
header.site-header .sb-menu-pop a[aria-current="page"] { color: var(--ch-pop-hi); font-weight: 650; box-shadow: inset 3px 0 0 var(--ch-red); }
header.site-header .sb-menu-pop a.ext::after { content: " ↗"; font-size: .85em; opacity: .65; }
header.site-header .sb-menu-pop .sb-menu-div { display: block; height: 1px; margin: 5px 8px; background: var(--ch-pop-line); }
header.site-header .sb-menu-pop small { display: block; padding: 6px 12px 2px; font-weight: 700; font-size: 10px; font-family: inherit; letter-spacing: .14em; text-transform: uppercase; color: var(--ch-pop-kick); }
header.site-header .sb-nav-div { flex: none; width: 1px; height: 24px; margin: 0 8px; background: rgba(255, 255, 255, .22); }

/* the Releases alert lamp: customers answered an approval request and nobody has acted (not on Home) */
header.site-header .sb-nav-alert {
  display: inline-flex; align-items: center; gap: 5px; height: 19px; margin-left: 2px; padding: 0 7px 0 5px;
  border-radius: 999px; background: var(--ch-red); color: #fff; font-weight: 700; font-size: 11.5px; line-height: 1; font-family: inherit;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .25), 0 0 12px rgba(229, 83, 75, .55);
}
header.site-header .sb-nav-alert i {
  width: 8px; height: 8px; border-radius: 50%; background: #FFE08A; box-shadow: 0 0 6px #FFE08A;
  animation: sb-chrome-blink 1.1s steps(2, start) infinite;
}
@keyframes sb-chrome-blink { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) { header.site-header .sb-nav-alert i { animation: none; } }

/* the mini operator: 140 px until it has focus, then 360 px laid over the nav (CSS only, no reflow) */
header.site-header .sb-qmini { position: relative; flex: none; width: 140px; height: 34px; margin: 0 6px 0 8px; }
header.site-header .sb-qmini input {
  position: absolute; right: 0; top: 0; width: 140px; height: 34px; padding: 0 10px; margin: 0;
  border: 1px solid rgba(255, 255, 255, .2); border-radius: 9px; background: rgba(255, 255, 255, .08);
  color: #fff; font-weight: 600; font-size: 13.5px; line-height: 1; font-family: inherit; letter-spacing: .01em; outline: none;
  transition: width .16s ease, background .16s, border-color .16s;
  -webkit-appearance: none; appearance: none;
}
header.site-header .sb-qmini input::placeholder { color: rgba(233, 225, 207, .72); font-weight: 500; }
header.site-header .sb-qmini input::-webkit-search-cancel-button { display: none; }
header.site-header .sb-qmini:focus-within input {
  width: 360px; z-index: 5; background: var(--ch-field); color: var(--ch-pop-ink);
  border-color: var(--ch-red); box-shadow: 0 0 0 3px rgba(196, 48, 43, .28), 0 12px 28px -12px rgba(0, 0, 0, .55);
}
header.site-header .sb-qmini:focus-within input::placeholder { color: var(--ch-field-hint); }
header.site-header .sb-vh {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* who is signed in, and Sign out (the desk greeting reads #navUser's first word) */
header.site-header .nav-user {
  display: inline-flex; align-items: center; gap: 7px; padding: 0 4px 0 10px; flex: none;
  color: #fff; font-weight: 600; font-size: 14px; line-height: 1; font-family: inherit; white-space: nowrap;
}
header.site-header .nav-user .sb-user-lamp, header.site-header .nav-user .lamp {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, .85) 0 14%, #4FBF72 46%, #2E8B4F 100%);
  box-shadow: 0 0 8px rgba(79, 191, 114, .6);
}
header.site-header .sb-out { display: inline-flex; margin: 0; }
header.site-header .sb-out button { color: var(--ch-hi); font-weight: 600; }

/* a narrower desktop (1440): the same nine items, a little tighter, the wordmark's second line goes */
@media (max-width: 1560px) {
  header.site-header { gap: 14px; padding: 0 16px; }
  header.site-header .sb-wordmark small { display: none; }
  header.site-header .sb-nav > a,
  header.site-header details.navmenu > summary,
  header.site-header .sb-out button { padding: 0 8px; font-size: 13.5px; }
  header.site-header .sb-qmini { width: 124px; margin: 0 4px 0 6px; }
  header.site-header .sb-qmini input { width: 124px; }
  header.site-header .sb-nav-div { margin: 0 5px; }
}

/* ---------------------------------------------------------------- the footer: one quiet line */
footer.site-footer {
  --ch-foot-ink: #66706B;     /* the line */
  --ch-foot-faint: #7E847D;   /* who it is for */
  --ch-foot-rule: #D3C29F;    /* the rule above it */
  --ch-foot-strong: #435053;  /* "Data as of ..." */
  --ch-foot-link: #00697A;    /* links */
  margin: 36px 0 0; padding: 0 28px 26px; color: var(--ch-foot-ink);
  font: 12.5px/1.45 "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}
footer.site-footer:empty { display: none; }
footer.site-footer [hidden] { display: none !important; }
footer.site-footer .sb-foot {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; max-width: 1824px; margin: 0 auto;
  padding-top: 14px; border-top: 2px solid var(--ch-foot-rule);
}
footer.site-footer .sb-foot-who { color: var(--ch-foot-faint); }
footer.site-footer .sb-asof:empty { display: none; }
footer.site-footer .sb-asof { color: var(--ch-foot-strong); font-weight: 600; }
footer.site-footer .sb-foot-links { display: flex; gap: 18px; margin-left: auto; }
footer.site-footer a { color: var(--ch-foot-link); font-weight: 600; text-decoration: none; }
footer.site-footer a:hover { text-decoration: underline; }
footer.site-footer .sb-speed { max-width: 1824px; margin: 0 auto 4px; }

/* ---------------------------------------------------------------- the tooltip host (charts.js fills it) */
#tip {
  --ch-tip-bg: #13262B;
  --ch-tip-ink: #F6EFE0;
  position: fixed; z-index: 200; left: 0; top: 0; pointer-events: none; max-width: 360px; padding: 9px 11px; border-radius: 10px;
  background: var(--ch-tip-bg); color: var(--ch-tip-ink); font-size: 12px; line-height: 1.4;
  font-family: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  box-shadow: 0 14px 30px -10px rgba(0, 0, 0, .5); border: 1px solid rgba(255, 255, 255, .06);
}
#tip[hidden] { display: none !important; }

/* ---------------------------------------------------------------- night operator (sb.css's dark switch) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) header.site-header {
    --ch-bg: #08171A; --ch-pop: #132529; --ch-pop-2: #172C31; --ch-pop-line: #2E4C4B; --ch-pop-ink: #CFC6B3;
    --ch-pop-hi: #5CC2CF; --ch-pop-kick: #DDA94A; --ch-red: #E5534B; --ch-field: #0F2024; --ch-field-hint: #87918C;
  }
  :root:not([data-theme="light"]) #tip { --ch-tip-bg: #F1E9D8; --ch-tip-ink: #13262B; }
  :root[data-ui="switchboard"]:not([data-theme="light"]) footer.site-footer {
    --ch-foot-ink: #9EA8A2; --ch-foot-faint: #87918C; --ch-foot-rule: #2E4C4B; --ch-foot-strong: #CFC6B3; --ch-foot-link: #5CC2CF;
  }
}
:root[data-theme="dark"] header.site-header {
  --ch-bg: #08171A; --ch-pop: #132529; --ch-pop-2: #172C31; --ch-pop-line: #2E4C4B; --ch-pop-ink: #CFC6B3;
  --ch-pop-hi: #5CC2CF; --ch-pop-kick: #DDA94A; --ch-red: #E5534B; --ch-field: #0F2024; --ch-field-hint: #87918C;
}
:root[data-theme="dark"] #tip { --ch-tip-bg: #F1E9D8; --ch-tip-ink: #13262B; }
:root[data-ui="switchboard"][data-theme="dark"] footer.site-footer {
  --ch-foot-ink: #9EA8A2; --ch-foot-faint: #87918C; --ch-foot-rule: #2E4C4B; --ch-foot-strong: #CFC6B3; --ch-foot-link: #5CC2CF;
}

/* ---------------------------------------------------------------- print: no chrome on paper */
@media print {
  header.site-header, footer.site-footer, #tip { display: none !important; }
}
