:root {
  /* Colors: BCI's original palette (BCI Brand Guidelines, April 2019) --
     Deep Green (Pantone 567 C, RGB 23/63/53) + Off White (RGB 250/250/250)
     are the brand colors; the greys are tints of that same green family.
     2026-10-16: restored under the Apple-style UI (shapes, type, spacing,
     shadows stay Apple-style; only the colors went back), per direction.
     The status pairs (review/unmatched/ok/info) carry meaning, not brand.

     Token roles (every screen's CSS uses these names):
       --ink / --accent  Deep Green -- text, buttons, selection, focus
       --page            the page behind the cards (a step darker than them)
       --paper           cards / surfaces (Off White)
       --paper2          subtle fill;  --paper3 secondary buttons, pressed
       --rule / --hairline   borders */
  --accent: #173F35;
  --accent-hover: #0F2C25;
  --accent-tint: rgba(23, 63, 53, 0.10);
  --accent-text: var(--accent);  /* links / text in the accent color -- lighter in dark mode */
  --ink: var(--accent);

  --text: #173F35;
  --text-secondary: color-mix(in srgb, #173F35 70%, #FAFAFA);
  --muted: var(--text-secondary);

  --page: #F0F2F0;
  --paper: #FAFAFA;
  --paper2: #F0F2F0;
  --paper3: #E4E8E5;
  --paper3-hover: #D8DED9;  /* secondary-button hover */
  --rule: #C7D1CC;
  --hairline: rgba(23, 63, 53, 0.14);
  --glass: rgba(250, 250, 250, 0.82);  /* frosted bars: top bar, toasts, account button */

  --review: #A8790A;
  --review-bg: #F2E4BE;
  --unmatched: #8C3B2E;
  --unmatched-bg: #EED9D2;
  --ok: #3F6C51;
  --ok-bg: #DCE6DC;
  --info: #2E5C8A;
  --info-bg: #DCE6F0;

  /* System font: San Francisco on Apple devices, Segoe UI on Windows. */
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue",
               "Segoe UI", Roboto, Arial, sans-serif;
  /* Type scale (2026-11-02): every font-size in the app's CSS is one of these. */
  --fs-2xs: 0.62rem;
  --fs-xs: 0.68rem;
  --fs-sm: 0.75rem;
  --fs-md: 0.82rem;
  --fs-base: 0.88rem;
  --fs-lg: 1.0rem;
  --fs-xl: 1.15rem;
  --fs-2xl: 1.3rem;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-pill: 980px;

  /* System Health heatmap, no failures -> every attempt failed (2026-11-02,
     moved here from admin/settings.css so dark mode has its own). */
  --heat-1: #1a7a1a; --heat-2: #5a9c1f; --heat-3: #d99a1f; --heat-4: #d9600a; --heat-5: #a61c1c;
  --shadow-sm: 0 1px 2px rgba(23, 63, 53, 0.08);
  --shadow: 0 1px 3px rgba(23, 63, 53, 0.08), 0 8px 24px rgba(23, 63, 53, 0.08);
  --shadow-lg: 0 24px 64px rgba(23, 63, 53, 0.20);
  --focus-ring: 0 0 0 4px rgba(23, 63, 53, 0.18);
  color-scheme: light;

  /* Page gutter (2026-10-15): the space every screen keeps between its
     content and the window edge -- see "Page gutter" below. */
  --gutter: 1.5rem;
}

/* ---------- Dark mode (2026-10-15) ----------
   Switched by the "Dark mode" toggle in the account menu (js/whoami.js),
   which sets <html data-theme="dark"> and remembers the choice in this
   browser; index.html / login.html apply it before the page draws. Same
   token names as the light theme above, so every screen follows. A dark
   version of the same green family, with Deep Green lifted so it still
   reads on a dark background. */
:root[data-theme="dark"] {
  --accent: #2F7A61;
  --accent-hover: #388C70;
  --accent-tint: rgba(111, 191, 156, 0.16);
  --accent-text: #7CC7A6;

  --text: #E6EEEA;
  --text-secondary: #9DB3AA;

  --page: #0C1714;
  --paper: #13221D;
  --paper2: #192B25;
  --paper3: #24392F;
  --paper3-hover: #2E463B;
  --rule: #34493F;
  --hairline: rgba(230, 238, 234, 0.12);
  --glass: rgba(19, 34, 29, 0.78);

  --review: #D9A532;
  --review-bg: rgba(217, 165, 50, 0.16);
  --unmatched: #E0806C;
  --unmatched-bg: rgba(224, 128, 108, 0.18);
  --ok: #74C08F;
  --ok-bg: rgba(116, 192, 143, 0.16);
  --info: #7FAEDC;
  --info-bg: rgba(127, 174, 220, 0.18);

  --heat-1: #3f9d4a; --heat-2: #8bbd3c; --heat-3: #e2b13f; --heat-4: #ec7d3d; --heat-5: #e0564e;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 4px rgba(124, 199, 166, 0.35);
  color-scheme: dark;
}
/* The BCI logo is green; dark mode uses its white version. */
:root[data-theme="dark"] img[src$="bci-logo-green.svg"] { content: url("../images/bci-logo-white.svg"); }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}
/* .mono marks data (codes, numbers, ids) across the app. In the Apple
   theme it's the same system font with fixed-width digits, so numbers
   still line up in columns -- a real monospace is only for code. */
.mono { font-family: var(--font-sans); font-variant-numeric: tabular-nums; }
.display { font-family: var(--font-sans); letter-spacing: -0.02em; }
code, pre, kbd { font-family: var(--font-mono); }

/* ---------- Form controls (Apple theme baseline) ----------
   :where() keeps these at zero specificity, so any screen's own rule for
   a control still wins -- this only fills in what a screen didn't set. */
:where(button, input, select, textarea) { font-family: inherit; color: inherit; }
:where(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), select, textarea) {
  border-radius: var(--radius-sm);
}
:where(input, select, textarea, button):focus-visible {
  outline: none; box-shadow: var(--focus-ring); border-color: var(--accent);
}
:where(a) { color: var(--accent-text); }
::selection { background: var(--accent-tint); }

/* ---------- Screen visibility ---------- */
.screen { display: none; }
.screen.active { display: block; }

/* ---------- Page gutter (2026-10-15) ----------
   Every screen keeps --gutter between its content and the window edge, so
   nothing -- including anything added later -- can sit flush against it.
   Full-width bands (a background or divider meant to run edge to edge)
   step back out over the gutter and pad their own content by the same
   amount, so their text still lines up with everything else. Only bands
   that are a screen's DIRECT children do this; a .status-bar or
   .download-strip inside a card stays inside it. Add a new page-wide band
   to this list rather than giving it its own side padding. */
.screen { padding-inline: var(--gutter); }
.screen > .topbar,
.screen > .upload-bar {
  margin-inline: calc(-1 * var(--gutter));
  padding-inline: var(--gutter);
}
@media (max-width: 640px) { :root { --gutter: 1rem; } }

/* ---------- Login page landing (login.html, css/login.css) ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-block: 4rem;
}
/* Fixed rem width keeps this in scale with the rest of this rem-sized
   layout; height:auto preserves the source file's own aspect ratio. */
.brand-logo { width: 28rem; height: auto; margin: 0 0 1.2rem; }
.eyebrow {
  font-size: var(--fs-md); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-secondary); margin-bottom: 1.6rem;
}
h1.title { font-size: 2.6rem; font-weight: 700; margin: 0 0 2.5rem; letter-spacing: -0.03em; line-height: 1.1; }

/* ---------- Screen header (every screen's .topbar) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.25rem 1rem;
  padding: 0.85rem 1.5rem; border-bottom: 1px solid var(--hairline);
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
}
.topbar h1 { font-size: var(--fs-2xl); margin: 0; display: flex; align-items: center; gap: 0.5rem; font-weight: 600; letter-spacing: -0.02em; }
.topbar-left { display: flex; align-items: center; gap: 0.8rem; }
/* The section name above the title, and the section's screens as tabs
   under it (js/nav.js). */
.nav-heading { display: flex; flex-direction: column; gap: 0.1rem; }
.nav-crumb { font-size: var(--fs-sm); color: var(--text-secondary); }
.topbar.has-tabs { padding-bottom: 0; }
.nav-tabs { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 0 1.5rem; margin-top: 0.35rem; }
.nav-tabs[hidden] { display: none; }
.nav-tab {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.55rem 0.1rem;
  font-size: var(--fs-base); font-weight: 500; text-decoration: none; color: var(--text-secondary);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav-tab:hover { color: var(--text); }
.nav-tab.on { color: var(--text); font-weight: 600; border-bottom-color: var(--accent-text); }
.nav-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-xs); }
/* A count beside a screen's name: tabs, the rail's flyout, Home. */
.nav-count {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.35rem; height: 1.2rem; padding: 0 0.4rem;
  border-radius: var(--radius-pill); background: var(--unmatched); color: #fff;
  font-size: var(--fs-xs); font-weight: 600; font-variant-numeric: tabular-nums;
}

/* ---------- Navigation rail + flyout (js/nav.js, 2026-11-02) ----------
   A fixed icon rail on the left of every screen; a section with several
   screens opens a flyout panel beside it. On a phone the rail is a bar
   along the bottom and the flyout rises above it. */
body.has-rail { --rail-w: 76px; --rail-h: 0px; padding-left: var(--rail-w); }
#appRail {
  position: fixed; top: 0; bottom: 0; left: 0; width: var(--rail-w); z-index: 1500;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem; padding: 0.9rem 0.75rem;
  background: var(--paper); border-right: 1px solid var(--hairline);
}
.rail-logo { background: none; border: none; padding: 0.35rem; margin-bottom: 0.5rem; cursor: pointer; line-height: 0; border-radius: var(--radius-sm); }
.rail-logo img { display: block; width: 34px; height: auto; }
.rail-logo:hover { opacity: 0.75; }
.rail-btn {
  position: relative; width: 52px; min-height: 52px; padding: 0.4rem 0; border: none; border-radius: var(--radius);
  background: transparent; color: var(--text); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font: inherit; font-size: var(--fs-2xs); font-weight: 600;
}
.rail-btn[hidden] { display: none; }
.rail-btn:hover { background: var(--paper2); }
.rail-btn.cur { background: var(--accent-tint); color: var(--accent-text); }
.rail-btn.open { background: var(--accent); color: #fff; }
.rail-dot {
  position: absolute; top: 6px; right: 9px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--unmatched); border: 2px solid var(--paper);
}
.rail-dot[hidden] { display: none; }
.rail-bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 0.35rem; }
.rail-scrim { position: fixed; inset: 0; left: var(--rail-w); z-index: 1490; background: rgba(23, 63, 53, 0.08); }
.rail-scrim[hidden], .rail-flyout[hidden] { display: none; }
.rail-flyout {
  position: fixed; top: 0; bottom: 0; left: var(--rail-w); width: 270px; z-index: 1495; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px; padding: 1.3rem 0.75rem;
  background: var(--paper); box-shadow: var(--shadow-lg);
}
.rail-flyout-head { display: flex; align-items: center; gap: 0.5rem; padding: 0 0.25rem 0.25rem 0.75rem; }
.rail-flyout-head h2 { flex: 1; margin: 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.02em; }
.rail-flyout-close {
  width: 32px; height: 32px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.rail-flyout-close:hover { background: var(--paper2); color: var(--text); }
.rail-flyout-desc { margin: 0; padding: 0 0.75rem 0.9rem; font-size: var(--fs-sm); line-height: 1.45; color: var(--text-secondary); }
.rail-flyout-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; padding: 0.65rem 0.75rem; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text); font: inherit; font-size: var(--fs-base); text-align: left; cursor: pointer;
}
.rail-flyout-item .nav-count { margin-left: auto; }
.rail-flyout-item:hover { background: var(--paper2); }
.rail-flyout-item.on { background: var(--accent-tint); font-weight: 600; }
/* A sub-heading over a group of a section's screens (nav.js's `group`,
   e.g. Reports -> Sales Insights) -- in the flyout and on Home. */
.nav-group-label {
  padding: 0.5rem 0.75rem 0.2rem; font-size: var(--fs-xs); font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary);
}
.home-card-links .nav-group-label { padding-inline: 0.15rem; }
@media (max-width: 640px) {
  body.has-rail { --rail-w: 0px; --rail-h: 62px; padding-left: 0; padding-bottom: calc(var(--rail-h) + env(safe-area-inset-bottom, 0px)); }
  #appRail {
    top: auto; right: 0; width: auto; height: calc(var(--rail-h) + env(safe-area-inset-bottom, 0px));
    flex-direction: row; justify-content: space-around; gap: 0; padding: 0.3rem 0.5rem env(safe-area-inset-bottom, 0px);
    border-right: none; border-top: 1px solid var(--hairline);
  }
  .rail-logo { display: none; }
  .rail-bottom { display: contents; }
  .rail-btn { min-height: 50px; }
  .rail-scrim { left: 0; bottom: var(--rail-h); }
  .rail-flyout {
    top: auto; left: 0; right: 0; bottom: calc(var(--rail-h) + env(safe-area-inset-bottom, 0px)); width: auto; max-height: 70vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  /* The help chat and toasts sit above the bar. */
  body.has-rail #chatbotRoot { bottom: calc(var(--rail-h) + 0.75rem); }
  body.has-rail .toast-stack { bottom: calc(var(--rail-h) + 0.75rem); }
  /* ...except while a flyout is open, which it would cover. */
  body.rail-flyout-open #chatbotRoot { display: none; }
}

/* ---------- Home (index.html's #home, filled in by js/nav.js) ---------- */
.home-sections {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr)); gap: 1.25rem;
  max-width: 1100px; padding-block: 1.75rem 3rem;
}
.home-card {
  display: flex; flex-direction: column; gap: 0.6rem; padding: 1.25rem;
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
}
.home-card-head { display: flex; align-items: center; gap: 0.6rem; }
.home-card-head h2 { flex: 1; margin: 0; font-size: var(--fs-lg); font-weight: 600; letter-spacing: -0.02em; }
.home-card-icon {
  width: 36px; height: 36px; flex: none; border-radius: var(--radius-sm); background: var(--accent-tint); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center;
}
.home-card p { margin: 0; font-size: var(--fs-md); line-height: 1.45; color: var(--text-secondary); }
.home-card-links { display: flex; flex-direction: column; gap: 0.3rem; margin-top: auto; padding-top: 0.4rem; }
.home-link {
  display: flex; align-items: center; gap: 0.5rem; width: 100%; padding: 0.6rem 0.75rem; border: none; border-radius: var(--radius-sm);
  background: var(--paper2); color: var(--text); font: inherit; font-size: var(--fs-base); text-align: left; cursor: pointer;
}
.home-link .nav-count { margin-left: auto; }
.home-link > span[aria-hidden] { margin-left: auto; color: var(--text-secondary); }
.home-link .nav-count + span[aria-hidden] { margin-left: 0; }
.home-link:hover { background: var(--paper3); }

/* ---------- Search bar row (the History screens: Sales PO, Logistics, Buy
   Sheet) -- 2026-10-15: back here, shared, after the Logistics overhaul
   (2026-08-31) deleted it from process-vendor-invoice.css while all three
   History screens still used it. ---------- */
.search-row { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; }

/* ---------- Generic empty/placeholder state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4rem 1.5rem; color: var(--text-secondary); gap: 0.6rem; }
.empty-state p { font-size: var(--fs-md); max-width: 360px; margin: 0; }
.empty-state code { font-family: var(--font-mono); background: var(--paper2); padding: 1px 4px; border-radius: var(--radius-xs); }

/* ---------- Account button + menu (whoami.js) -- at the foot of the rail (js/nav.js) ---------- */
#whoamiRoot { position: relative; font-size: var(--fs-md); }
#whoamiRoot .whoami-trigger {
  width: 52px; height: 52px; border: none; border-radius: var(--radius); background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font: inherit;
}
#whoamiRoot .whoami-trigger:hover, #whoamiRoot .whoami-trigger[aria-expanded="true"] { background: var(--paper2); }
.whoami-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--paper3); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-xs); font-weight: 600;
}
#whoamiRoot .whoami-menu {
  position: absolute; bottom: 0; left: calc(100% + 12px); min-width: 220px; z-index: 1600;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--paper); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 0.35rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
#whoamiRoot .whoami-menu[hidden] { display: none; }
.whoami-menu-who { display: flex; flex-direction: column; gap: 0.1rem; padding: 0.45rem 0.6rem 0.55rem; border-bottom: 1px solid var(--hairline); margin-bottom: 0.2rem; }
.whoami-menu-who span { font-size: var(--fs-sm); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 640px) {
  #whoamiRoot .whoami-menu { left: auto; right: 0; bottom: calc(100% + 8px); }
}
#whoamiRoot .whoami-menu-item {
  display: block; color: var(--text); text-decoration: none; opacity: 0.85;
  padding: 0.4rem 0.6rem; border-radius: var(--radius-sm); white-space: nowrap;
}
#whoamiRoot .whoami-menu-item:hover { opacity: 1; background: var(--paper2); }
/* Dark-mode row: a menu item with an on/off switch (whoami.js). */
#whoamiRoot .whoami-theme {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  width: 100%; background: none; border: none; font: inherit; text-align: left; cursor: pointer;
}
.whoami-switch {
  position: relative; flex: none; width: 32px; height: 19px; border-radius: var(--radius-pill);
  background: var(--paper3); transition: background 0.2s ease;
}
.whoami-switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s ease;
}
.whoami-theme[aria-checked="true"] .whoami-switch { background: var(--accent); }
.whoami-theme[aria-checked="true"] .whoami-switch::after { transform: translateX(13px); }

/* ---------- Help-guide modal (whoami.js) -- opens the Sales PO/Logistics
   quick reference PDF in-app instead of a new tab; greys out and blocks the
   rest of the screen (backdrop has no pointer-events passthrough) until closed. ---------- */
#whoamiHelpModal {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 2rem;
}
#whoamiHelpModal[hidden] { display: none; }
.whoami-help-modal-box {
  background: var(--paper); border: none; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 900px; height: 100%; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.whoami-help-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.8rem 1.1rem; border-bottom: 1px solid var(--hairline); flex: none;
}
.whoami-help-modal-header h2 { font-size: var(--fs-base); margin: 0; font-weight: 600; }
.whoami-help-modal-close {
  background: none; border: none; font: inherit; color: var(--text); cursor: pointer;
  font-size: var(--fs-xl); line-height: 1; padding: 4px 8px; border-radius: var(--radius-sm); opacity: 0.7;
}
.whoami-help-modal-close:hover { opacity: 1; background: var(--paper2); }

/* Presence-lock badge (static/js/presence.js) -- "someone else has this
   open" indicator shared by the Sales PO and Logistics screens. --presence-
   color is set inline per-user by presenceBadgeHtml(). */
.presence-badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  font-size: var(--fs-xs); font-weight: 600; color: var(--presence-color, var(--ink));
  background: var(--paper2); border: 1px solid var(--presence-color, var(--rule));
  border-radius: var(--radius-pill); padding: 0.15rem 0.55rem;
  white-space: nowrap;
}
.presence-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--presence-color, var(--ink));
  flex: none;
}
.presence-force-unlock {
  font-size: var(--fs-xs); background: none; border: 1px solid var(--rule); color: var(--text);
  border-radius: var(--radius-sm); padding: 0.1rem 0.4rem; cursor: pointer; opacity: 0.75;
}
.presence-force-unlock:hover { opacity: 1; background: var(--paper2); }
.presence-lock-banner {
  display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap;
  font-size: var(--fs-md); background: var(--review-bg); color: var(--text); border: none;
  border-radius: var(--radius); padding: 0.6rem 0.85rem; margin: 0.5rem 0 0.8rem;
}
.whoami-help-modal-box iframe { flex: 1; width: 100%; border: none; }

/* ======================================================================
   Messages, app-wide (2026-10-13). Three kinds, one look everywhere:
   - Toasts (js/toast.js): what just happened -- an action's result or a
     failure. Errors / warnings stay until closed; the rest fade.
   - Dialogs (js/dialog.js): a question that needs an answer before going
     on (confirmDialog() / alertDialog()), replacing the browser's own
     confirm() / alert() boxes.
   - .status-bar: a message about the screen's CURRENT state that stays
     while it's true ("Loading…", "No GPO export uploaded yet") -- never
     for an action's result, which is a toast.
   Screen-specific message styles stay in that screen's own CSS.
   ====================================================================== */

/* ---------- Status bar (was in sales-po/exceptions.css / admin/settings.css) ---------- */
.status-bar { padding: 0.6rem 0.9rem; font-size: var(--fs-md); border-radius: var(--radius-sm); }
.status-bar.error { background: var(--unmatched-bg); color: var(--unmatched); }
.status-bar.warning { background: var(--review-bg); color: var(--review); }
.status-bar.ok { background: var(--ok-bg); color: var(--ok); }
.status-bar.info { color: var(--text-secondary); }

/* ---------- Toasts (js/toast.js) ---------- */
/* Left of the help chat's round button (css/chatbot.css: 52px wide, 1.25rem
   from the right) with a 10px gap, so a toast never sits behind it. */
.toast-stack {
  --toast-right: calc(1.25rem + 52px + 10px);
  position: fixed; right: var(--toast-right); bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); z-index: 9990;
  width: min(380px, calc(100vw - var(--toast-right) - 1rem)); max-height: calc(100vh - 2.5rem); overflow-y: auto;
  display: flex; flex-direction: column; align-items: stretch;
  pointer-events: none;
}
.toast-stack > * { pointer-events: auto; }
.toast-clear-all {
  align-self: flex-end; margin-bottom: 0.1rem; font: inherit; font-size: var(--fs-sm); cursor: pointer;
  background: var(--glass); color: var(--text); border: 1px solid var(--hairline); border-radius: var(--radius-pill); padding: 0.25rem 0.75rem;
  box-shadow: var(--shadow-sm);
}
.toast-clear-all:hover { background: var(--paper); }
.toast {
  --toast-color: var(--info); --toast-bg: var(--info-bg);
  display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 0.6rem; align-items: start;
  margin-top: 0.5rem; padding: 0.8rem 0.7rem 0.8rem 0.9rem; overflow: hidden;
  background: var(--glass); color: var(--text); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  font-family: var(--font-sans); font-size: var(--fs-md); line-height: 1.4;
  animation: toastIn 0.22s ease-out;
  transition: opacity 0.18s ease, transform 0.18s ease, height 0.22s ease, margin 0.22s ease, padding 0.22s ease, border-width 0.22s ease;
}
.toast-error { --toast-color: var(--unmatched); --toast-bg: var(--unmatched-bg); }
.toast-warning { --toast-color: var(--review); --toast-bg: var(--review-bg); }
.toast-success { --toast-color: var(--ok); --toast-bg: var(--ok-bg); }
.toast-icon {
  width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; background: var(--toast-bg); color: var(--toast-color);
}
.toast-progress .toast-icon { background: transparent; border: 2px solid var(--toast-bg); border-top-color: var(--toast-color); animation: toastSpin 0.8s linear infinite; }
.toast-body { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }
.toast-title { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; color: var(--toast-color); }
.toast-count { font-family: var(--font-sans); font-variant-numeric: tabular-nums; font-size: var(--fs-xs); font-weight: 500; background: var(--toast-bg); padding: 0 0.35rem; border-radius: var(--radius-xs); }
.toast-msg { overflow-wrap: anywhere; }
.toast-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.35rem; }
.toast-action {
  font: inherit; font-size: var(--fs-sm); font-weight: 500; cursor: pointer; padding: 0.25rem 0.75rem; border-radius: var(--radius-pill);
  border: none; background: var(--toast-bg); color: var(--toast-color);
}
.toast-action:hover { filter: brightness(0.96); }
.toast-x {
  font: inherit; font-size: var(--fs-xl); line-height: 1; cursor: pointer; color: var(--text); opacity: 0.62;
  background: none; border: none; border-radius: var(--radius-sm); padding: 0.1rem 0.35rem; margin-top: -0.15rem;
}
.toast-x:hover, .toast-x:focus-visible { opacity: 1; background: var(--paper2); }
.toast.toast-bump { animation: toastBump 0.3s ease; }
/* Closing: fade + slide right, then collapse so the toasts above drop down. */
.toast.leaving { opacity: 0; transform: translateX(16px); }
.toast.collapsing { height: 0 !important; margin-top: 0; padding-top: 0; padding-bottom: 0; border-width: 0; box-shadow: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toastBump { 50% { transform: scale(1.02); } }
@keyframes toastSpin { to { transform: rotate(360deg); } }
@media (max-width: 480px) { .toast-stack { left: 1rem; width: auto; } }

/* ---------- Dialogs (js/dialog.js) ---------- */
.dlg-backdrop {
  position: fixed; inset: 0; z-index: 9995; background: rgba(0, 0, 0, 0.32);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: dlgFade 0.15s ease-out;
}
.dlg {
  background: var(--paper); color: var(--text); border: none; border-radius: var(--radius-lg);
  padding: 1.5rem 1.5rem 1.3rem; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto;
  box-shadow: var(--shadow-lg); font-size: var(--fs-base); line-height: 1.45;
}
.dlg-wide { max-width: 760px; }
.dlg-title { margin: 0 0 0.6rem; font-size: var(--fs-xl); font-weight: 600; letter-spacing: -0.02em; }
.dlg-danger .dlg-title { color: var(--unmatched); }
.dlg-msg { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.dlg-input {
  display: block; width: 100%; margin-top: 0.8rem; padding: 0.55rem 0.7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--rule); background: var(--paper); color: var(--text);
  font-family: var(--font-sans); font-size: var(--fs-md);
}
.dlg-input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.dlg-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }
.dlg-actions button {
  font: inherit; font-size: var(--fs-md); font-weight: 500; padding: 0.5rem 1.15rem; border-radius: var(--radius-pill); cursor: pointer;
  border: none; background: var(--paper3); color: var(--text);
}
.dlg-actions button:hover { background: var(--paper3-hover); }
.dlg-actions .dlg-go { background: var(--accent); color: #fff; }
.dlg-actions .dlg-go:hover { background: var(--accent-hover); }
.dlg-danger .dlg-actions .dlg-go { background: var(--unmatched); }
@keyframes dlgFade { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .toast, .toast.leaving, .dlg-backdrop { animation: none; transform: none; transition: opacity 0.15s linear; }
  .toast-progress .toast-icon { animation: none; }
}

/* ---------- Active users widget (js/active-users.js, 2026-11-17) ----------
   Admins only: a pill fixed in the top right (over the empty right end of
   every screen's top bar), opening a panel of who's using the app. */
#activeUsersRoot {
  position: fixed; top: 0.75rem; right: 1.25rem; z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem;
  font-family: var(--font-sans);
}
.au-pill {
  display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.4rem 0.8rem;
  border: 1px solid var(--hairline); border-radius: var(--radius-pill);
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  color: var(--text); font-size: var(--fs-sm); font-weight: 500; cursor: pointer; box-shadow: var(--shadow-sm);
}
.au-pill:hover { background: var(--paper3); }
.au-pill:focus-visible, .au-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.au-dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.au-count { font-weight: 600; font-variant-numeric: tabular-nums; }
#activeUsersRoot.open .au-pill { background: var(--paper3); }
.au-panel {
  width: 320px; max-height: min(70vh, 480px); display: flex; flex-direction: column;
  background: var(--paper); color: var(--text); border: 1px solid var(--hairline);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.au-panel[hidden] { display: none; }
.au-head { display: flex; align-items: center; gap: 0.25rem; padding: 0.6rem 0.6rem 0.6rem 0.9rem; border-bottom: 1px solid var(--hairline); }
.au-title { flex: 1; font-size: var(--fs-base); font-weight: 600; }
.au-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 1.9rem; height: 1.9rem;
  border: 0; border-radius: 50%; background: transparent; color: var(--text-secondary); cursor: pointer;
}
.au-icon-btn:hover:not(:disabled) { background: var(--paper3); color: var(--text); }
.au-icon-btn:disabled { cursor: default; }
.au-refresh.spinning svg { animation: au-spin 0.9s linear infinite; }
@keyframes au-spin { to { transform: rotate(360deg); } }
.au-body { overflow-y: auto; }
.au-list { list-style: none; margin: 0; padding: 0.3rem 0; }
.au-user { display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.9rem; }
.au-avatar {
  flex: none; width: 2rem; height: 2rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-tint); color: var(--accent-text); font-size: var(--fs-xs); font-weight: 600;
}
.au-who { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.au-name { font-size: var(--fs-md); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-you {
  display: inline-block; margin-left: 0.3rem; padding: 0 0.4rem; border-radius: var(--radius-pill);
  background: var(--ok-bg); color: var(--ok); font-size: var(--fs-2xs); font-weight: 600; vertical-align: 1px;
}
.au-email { font-size: var(--fs-xs); color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-when { flex: none; display: flex; flex-direction: column; align-items: flex-end; }
.au-seen { font-size: var(--fs-xs); font-weight: 500; }
.au-since { font-size: var(--fs-2xs); color: var(--text-secondary); }
.au-empty { margin: 0; padding: 1rem 0.9rem; font-size: var(--fs-sm); color: var(--text-secondary); }
.au-note { margin: 0; padding: 0.55rem 0.9rem; border-top: 1px solid var(--hairline); font-size: var(--fs-2xs); color: var(--text-secondary); }
@media (max-width: 640px) {
  #activeUsersRoot { top: 0.5rem; right: 0.5rem; }
  .au-label { display: none; }
  .au-panel { width: calc(100vw - 1rem); }
}
@media (prefers-reduced-motion: reduce) { .au-refresh.spinning svg { animation: none; } }
