/* BBB Techs palette (docs/BRANDING.md). --accent fills primary buttons;
   --ink is the brand colour for text, lines and highlights (navy on light,
   white on dark, where navy would disappear). */
:root {
  --navy: #001E5C;
  --navy-2: #001747;
  --navy-dark: #001033;
  --near-black: #000A1F;
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --fg: #1A1A1A;
  --muted: #2E2E2E;
  --accent: var(--navy);
  --accent-hover: var(--navy-2);
  --ink: var(--navy);
  --btn-bg: rgba(255, 255, 255, 0.94);
  --btn-fg: var(--navy);
  --btn-border: #E6E6E6;
  --hover: rgba(0, 30, 92, 0.06);
  --shadow: 0 1px 4px rgba(0, 16, 51, 0.16);
  --overlay-bg: #FFFFFF;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--near-black);
    --surface: var(--navy-2);
    --fg: #FFFFFF;
    --muted: #E6E6E6;
    --ink: #FFFFFF;
    --btn-bg: rgba(0, 23, 71, 0.94);
    --btn-fg: #FFFFFF;
    --btn-border: #242424;
    --hover: rgba(255, 255, 255, 0.08);
    --shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    --overlay-bg: linear-gradient(180deg, var(--near-black), var(--navy-dark));
  }
}

/* BBB logo: navy on light backgrounds, white on dark. */
.logo-dark { display: none; }
@media (prefers-color-scheme: dark) {
  .logo-light { display: none; }
  .logo-dark { display: inline; }
}

/* Lock the outer page. The report scrolls inside its own iframe, so the
   wrapper itself never scrolls, rubber-bands, or pulls to refresh. */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body {
  position: fixed;   /* stops iOS Safari from scrolling the body behind the iframe */
  inset: 0;
}

.report {
  position: fixed;
  inset: 0;
  /* 100dvh tracks the real visible height as mobile browser bars show/hide */
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-sizing: border-box;
}
.report iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* ---- Loading / error overlay -------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: var(--overlay-bg);
  transition: opacity 0.25s ease, visibility 0.25s;
}
.overlay.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.overlay p {
  margin: 0;
  max-width: 34em;
  color: var(--muted);
}
.splash-logo { line-height: 0; margin-bottom: 10px; }
.splash-logo img { width: min(200px, 52vw); height: auto; }
.splash-logo[hidden] { display: none; }
.overlay.is-error .spinner { display: none; }
.brand-logo {
  max-width: min(220px, 60vw);
  max-height: 72px;
  object-fit: contain;
  margin-bottom: 6px;
}
.menu-logo {
  display: block;
  max-width: 180px;
  max-height: 44px;
  object-fit: contain;
  margin-bottom: 8px;
  padding: 4px 6px;
  border-radius: 6px;
  background: #FFFFFF;
}
.overlay.is-error p { color: var(--fg); }

.spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--btn-border);
  border-top-color: var(--ink);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
}

/* Author display rules (flex) would otherwise override the hidden attribute. */
[hidden] { display: none !important; }

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
.overlay-actions button {
  min-height: 44px;           /* comfortable touch target */
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.overlay-actions button:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.overlay-actions button.secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--ink);
}
.overlay-actions button.secondary:hover { background: var(--hover); }

/* ---- Floating buttons (bottom right) ------------------------------------ */
/* Stacked from the bottom: the menu button always first, then the layout
   switch, then the AI assistant on top. --dock-lift raises the stack above
   any page navigation bar so the buttons only cover the report itself. */
:root { --fab-size: 51px; --dock-lift: 0px; }
body.has-pagebar { --dock-lift: 52px; }        /* our page picker (mobile layout) */
body.has-pagetabs { --dock-lift: 44px; }       /* Power BI's own page tabs */
.dock {
  position: fixed;
  z-index: 7;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(var(--dock-lift, 0px) + 10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 8px;
  pointer-events: none;        /* only the buttons themselves take taps */
}
.dock > * { pointer-events: auto; }
.assistant-slot:empty { display: none; }

.fab {
  position: relative;
  width: var(--fab-size);
  height: var(--fab-size);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0.6;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
/* Bigger invisible hit area so the small button is still easy to tap. */
.fab::after {
  content: "";
  position: absolute;
  inset: -4px;
}
.fab svg { width: 27px; height: 27px; }
.fab:hover, .fab:focus-visible, .fab[aria-expanded="true"] { opacity: 1; }

/* ---- Page picker (mobile layout) ---------------------------------------- */
/* Power BI shows no page tabs in the mobile layout, so a slim bar at the
   bottom offers a page drop-down. The report is shortened so nothing is
   covered, and the layout toggle sits inside the bar. */
body.has-pagebar .report {
  padding-bottom: calc(52px + env(safe-area-inset-bottom));
}
.pagebar {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  bottom: 0;
  height: 52px;
  box-sizing: content-box;
  padding: 0 calc(10px + env(safe-area-inset-right)) env(safe-area-inset-bottom)
           calc(10px + env(safe-area-inset-left));
  display: flex;
  align-items: center;
  background: var(--bg);
  border-top: 1px solid var(--btn-border);
}
.pagebar label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.pagebar select {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 34px 0 12px;
  border-radius: 8px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font: inherit;
  font-size: 16px;            /* 16px stops iOS zooming on focus */
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236b6f76' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
/* The buttons float above the page bar, not inside it. */
body.has-pagebar .fab, body.has-pagetabs .fab { opacity: 1; }

/* ---- Menu dropdown ------------------------------------------------------- */
/* A small card that opens just above the menu button: current customer
   (a switcher for staff), then Install, Settings and Sign out. */
.menu {
  position: fixed;
  inset: 0;
  z-index: 20;
}
.menu-backdrop { position: absolute; inset: 0; }
.menu-pop {
  position: absolute;
  right: calc(10px + env(safe-area-inset-right));
  bottom: calc(var(--dock-lift, 0px) + var(--fab-size) + 18px + env(safe-area-inset-bottom));
  width: max-content;
  min-width: 220px;
  max-width: calc(100vw - 20px);
  box-sizing: border-box;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: 0 8px 24px rgba(0, 16, 51, 0.18), 0 1px 3px rgba(0, 16, 51, 0.12);
}
.menu-customer {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.menu-logo { max-height: 24px; max-width: 80px; object-fit: contain; }
.menu-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-select {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 32px 0 10px;
  border-radius: 8px;
  border: 1px solid var(--btn-border);
  background-color: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23808898' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.menu-select:focus { outline: none; border-color: var(--ink); }
.menu-user {
  margin: 4px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0.8;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-icons {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--btn-border);
}
.menu-icon {
  flex: 1;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  text-decoration: none;
  cursor: pointer;
}
.menu-icon[hidden] { display: none; }
.menu-icon:hover { background: var(--hover); }
.menu-icon:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.menu-tip { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); max-width: 240px; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Link styled as a button on the error screen ("Contact support"). */
.overlay-actions .button-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 8px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.overlay-actions .button-link:hover { background: var(--hover); }


/* ---- Customer picker (staff landing page) ---------------------------------- */
.picker {
  position: fixed;
  inset: 0;
  z-index: 12;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--overlay-bg);
  color: var(--fg);
}
.picker-bar {
  position: sticky;
  top: 0;
  z-index: 2;   /* keep cards (position: relative) scrolling underneath */
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) 12px
           calc(20px + env(safe-area-inset-left));
  background: var(--navy-dark);
  color: #FFFFFF;
}
.picker-bar img { width: 40px; height: auto; }
.picker-brand { font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; font-size: 15px; }
.picker-user {
  margin-left: auto;
  font-size: 13px;
  color: #E6E6E6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.picker-body {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px calc(20px + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom))
           calc(20px + env(safe-area-inset-left));
}
.picker-title { margin: 0 0 6px; font-size: 24px; font-weight: 700; color: var(--ink); }
.picker-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.picker-search { margin-bottom: 16px; }
.picker-search label {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.picker-search input {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--btn-border);
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 16px;
}
.picker-search input:focus { outline: none; border-color: var(--ink); }
.picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));   /* 2 on phones, 3 on tablets, 4 on desktop */
  gap: 12px;
}
@media (min-width: 640px) { .picker-list { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .picker-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; } }
.picker-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  height: 100%;
  box-sizing: border-box;
  padding: 18px 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--fg);
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.picker-card:hover, .picker-card:focus-visible {
  border-color: var(--ink);
  outline: none;
}
.picker-card.is-off { opacity: 0.6; }
.picker-mono {
  flex: none;
  width: 100%;
  max-width: 140px;
  height: 56px;
  box-sizing: border-box;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.02em;
}
/* Logos sit on white in both themes so dark logos stay visible. */
.picker-mono.has-logo {
  padding: 6px 8px;
  border: 1px solid #E6E6E6;
  background: #FFFFFF;
}
.picker-mono img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.picker-text { display: flex; flex-direction: column; min-width: 0; width: 100%; }
.picker-name { font-weight: 600; font-size: 15px; overflow-wrap: anywhere; }
.picker-meta {
  font-size: 12.5px;
  color: var(--muted);
  opacity: 0.85;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-pill {
  flex: none;
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--btn-border);
  font-size: 11.5px;
  color: var(--muted);
}
.picker-empty { color: var(--muted); }
.picker-icon {
  flex: none;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #FFFFFF;
  cursor: pointer;
}
.picker-icon:hover { background: rgba(255, 255, 255, 0.12); }
.picker-icon:focus-visible { outline: 2px solid #FFFFFF; outline-offset: 1px; }
.picker-icon[hidden] { display: none; }
.picker-user + .picker-icon, .picker-user + .picker-icon[hidden] + .picker-icon { margin-left: 4px; }
@media (max-width: 480px) { .picker-brand { display: none; } .picker-bar { gap: 8px; } }
