:root {
  /* BCI Brand Guidelines (April 2019): Deep Green (Pantone 567 C, RGB
     23/63/53) + Off White (digital: RGB 250/250/250) are the only two brand
     colors -- --ink/--paper are those exact values; --paper2/--paper3/--rule
     are surface/border tints derived from that same green-gray family
     instead of the previous unrelated warm cream/tan palette. The three
     status pairs below (review/unmatched/ok) encode verified/flagged/
     unmatched meaning, not brand identity -- the guide doesn't address them,
     so their hues are unchanged (--ok already sits in the same green family
     as the brand color, so it needed no adjustment for cohesion). */
  --ink: #173F35;
  --paper: #FAFAFA;
  --paper2: #F0F2F0;
  --paper3: #E4E8E5;
  --rule: #C7D1CC;
  --review: #A8790A;
  --review-bg: #F2E4BE;
  --unmatched: #8C3B2E;
  --unmatched-bg: #EED9D2;
  --ok: #3F6C51;
  --ok-bg: #DCE6DC;
  /* Graphik is BCI's brand sans (headlines/captions/details/body per the
     guide) -- a paid commercial font with no file in this repo, so this
     uses the guide's own documented fallback ("Arial is an adequate
     substitute for Graphik") rather than fetching/embedding anything.
     Louize (the brand's serif) is deliberately not used anywhere in this
     app: it has no natural "editorial body copy" role in a dense
     operational tool, and .display below is used on every screen's page
     title (not one hero moment), so serif there would be a much bigger
     typographic shift than a straightforward brand-color/font alignment. */
  --font-sans: 'Graphik', Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  min-height: 100vh;
}
.mono { font-family: 'IBM Plex Mono', monospace; }
.display { font-family: var(--font-sans); }

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

/* ---------- Home / hub-style landing screens ---------- */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 1.5rem;
}
/* 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: 1rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  opacity: 0.55;
  margin-bottom: 2.5rem;
}
h1.title { font-size: 1.8rem; font-weight: 600; margin: 0 0 2.5rem; letter-spacing: 0.02em; }
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.5rem; width: 100%; max-width: 760px; }
.tile {
  position: relative;
  text-align: left;
  background: var(--paper2);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 1.6rem 1.2rem 1.2rem;
  cursor: pointer;
  transform: rotate(-1.2deg);
  transition: transform 0.15s ease;
  font: inherit;
  color: inherit;
}
.tile:hover { transform: rotate(0deg) translateY(-2px); }
.tile:disabled { opacity: 0.45; cursor: not-allowed; transform: rotate(0.6deg); border-style: dashed; }
.tile .grommet {
  position: absolute; top: -10px; left: 20px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--paper); border: 2px solid var(--ink);
}
.tile:disabled .grommet { border-color: var(--rule); }
.tile .badge {
  position: absolute; top: -12px; right: -10px; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600;
  background: var(--unmatched-bg); border: 2px solid var(--unmatched); color: var(--unmatched);
}
.tile h2 { font-size: 1rem; margin: 0.6rem 0 0.3rem; font-weight: 600; }
.tile p { font-size: 0.78rem; opacity: 0.65; margin: 0; line-height: 1.4; }
.tile .go { display: inline-flex; align-items: center; gap: 4px; font-size: 0.78rem; margin-top: 0.9rem; }

/* ---------- Shared sub-screen topbar (used by any screen with a back button) ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1rem;
  padding: 1rem 1.5rem; border-bottom: 1px solid var(--rule);
}
.topbar h1 { font-size: 1.15rem; margin: 0; display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.back-btn { background: none; border: none; font: inherit; color: var(--ink); cursor: pointer; display: flex; align-items: center; gap: 4px; font-size: 0.85rem; padding: 4px 6px; }
.back-btn:hover { opacity: 0.7; }
.topbar-left { display: flex; align-items: center; gap: 0.8rem; }
.topbar-divider { width: 1px; height: 20px; background: var(--rule); }
/* Home icon (see js/router.js's addHomeIcon()) -- prepended to every
   screen's .topbar-left except home itself. Reuses the same BCI logo SVG
   as the home screen's own large .brand-logo, just rendered small. */
.home-icon-btn { background: none; border: none; padding: 2px; margin: 0; cursor: pointer; display: flex; align-items: center; line-height: 0; }
.home-icon-btn:hover { opacity: 0.7; }
.home-icon-btn img { display: block; width: 26px; height: 16px; }
.counts { font-size: 0.78rem; opacity: 0.75; display: flex; gap: 0.75rem; }

/* ---------- Generic empty/placeholder state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4rem 1.5rem; opacity: 0.7; gap: 0.6rem; }
.empty-state code { font-family: 'IBM Plex Mono', monospace; background: var(--paper2); padding: 1px 4px; border-radius: 3px; }

/* ---------- Signed-in indicator + expanding menu (whoami.js) — fixed top-right, every screen ---------- */
#whoamiRoot { position: fixed; top: 0.9rem; right: 1.25rem; z-index: 9998; font-size: 0.72rem; }
#whoamiRoot .whoami-trigger {
  display: flex; align-items: center; gap: 0.5rem; font: inherit; color: var(--ink); cursor: pointer;
  background: var(--paper2); border: 1px solid var(--rule); border-radius: 20px; padding: 0.3rem 0.7rem;
}
#whoamiRoot .whoami-trigger:hover { opacity: 0.85; }
#whoamiRoot .whoami-email { opacity: 0.75; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#whoamiRoot .whoami-caret { width: 10px; height: 10px; flex: none; opacity: 0.6; transition: transform 0.15s ease; }
#whoamiRoot .whoami-trigger[aria-expanded="true"] .whoami-caret { transform: rotate(180deg); }
#whoamiRoot .whoami-menu {
  position: absolute; top: calc(100% + 6px); right: 0; min-width: 170px;
  display: flex; flex-direction: column; gap: 2px;
  background: var(--paper2); border: 1px solid var(--rule); border-radius: 10px; padding: 0.35rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
#whoamiRoot .whoami-menu[hidden] { display: none; }
#whoamiRoot .whoami-menu-item {
  display: block; color: var(--ink); text-decoration: none; opacity: 0.85;
  padding: 0.4rem 0.6rem; border-radius: 6px; white-space: nowrap;
}
#whoamiRoot .whoami-menu-item:hover { opacity: 1; background: var(--paper); }

/* ---------- 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.5);
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
}
#whoamiHelpModal[hidden] { display: none; }
.whoami-help-modal-box {
  background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  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.7rem 1rem; border-bottom: 1px solid var(--rule); flex: none;
}
.whoami-help-modal-header h2 { font-size: 0.9rem; margin: 0; font-weight: 600; }
.whoami-help-modal-close {
  background: none; border: none; font: inherit; color: var(--ink); cursor: pointer;
  font-size: 1.1rem; line-height: 1; padding: 4px 8px; border-radius: 6px; 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: 0.7rem; font-weight: 600; color: var(--presence-color, var(--ink));
  background: var(--paper2); border: 1px solid var(--presence-color, var(--rule));
  border-radius: 20px; 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: 0.68rem; background: none; border: 1px solid var(--rule); color: var(--ink);
  border-radius: 6px; 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: 0.8rem; background: var(--paper2); border: 1px solid var(--rule);
  border-radius: 8px; padding: 0.5rem 0.7rem; margin: 0.5rem 0 0.8rem;
}
.whoami-help-modal-box iframe { flex: 1; width: 100%; border: none; }
