/* Reports hub + categorized report list (2026-10-20, per Tim).
   .sb-rail      the list (ViewComponents/ReportsRailViewComponent): "hub" on Reports/Index,
                 "page" beside every other report page (hideable; a drawer below 1100px)
   .sb-rlayout   two-column wrapper _Layout puts around report pages
   .sb-hub*      the Reports page itself (summary hero, review counts, recently viewed)
   .sb-dash, .sb-kpi, .sb-dcard, .sb-chart*  the dashboard (phase 2) at the end of this file */

/* ---------- Report list ---------- */
.sb-rail {
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: var(--sb-radius);
  box-shadow: var(--sb-shadow);
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.sb-rail__head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 14px 16px;
  background: var(--sb-navy-800);
  color: #fff;
  border-radius: calc(var(--sb-radius) - 1px) calc(var(--sb-radius) - 1px) 0 0;
}

.sb-rail__title {
  flex: 1;
  font-family: var(--sb-font-display);
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.01em;
}

.sb-rail__title::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 9px;
  border-radius: 2px;
  background: var(--sb-accent-600);
  vertical-align: 2px;
}

.sb-rail__icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 0;
}
.sb-rail__icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.sb-rail__close { display: none; }

.sb-rail svg,
.sb-rail-show svg,
.sb-rail-open svg,
.sb-hub-stat__icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* "Reports Home" at the top of the list on report pages (per Tim 2026-10-20) */
.sb-rail__home {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--sb-border);
  background: var(--sb-navy-50);
  color: var(--sb-navy-800);
  font-weight: 700;
  text-decoration: none;
}
.sb-rail__home:hover { background: var(--sb-accent-100); color: var(--sb-navy-900); }
.sb-rail__home-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--sb-accent-600);
  color: #fff;
}
.sb-rail__home:hover .sb-rail__home-icon { background: var(--sb-accent-500); }
.sb-rail__home-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sb-rail__home-sub {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--sb-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sb-rail__nav { padding: 8px 8px 12px; }
.sb-rail__cat + .sb-rail__cat { margin-top: 2px; }

.sb-rail__cat > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
  font-family: var(--sb-font-display);
  font-weight: 800;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sb-navy-800);
}
.sb-rail__cat > summary::-webkit-details-marker { display: none; }
.sb-rail__cat > summary:hover { background: var(--sb-navy-50); }
.sb-rail__cat-title { flex: 1; }

.sb-rail__count {
  font-family: var(--sb-font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--sb-navy-600);
  background: var(--sb-navy-100);
  border-radius: 999px;
  padding: 1px 8px;
}

.sb-rail .sb-rail__chev {
  width: 14px;
  height: 14px;
  color: var(--sb-text-muted);
  transform: rotate(-90deg);
  transition: transform 0.15s ease;
}
.sb-rail__cat[open] > summary .sb-rail__chev { transform: none; }

.sb-rail__sub {
  margin: 8px 10px 2px 24px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sb-text-muted);
}

.sb-rail__cat ul {
  list-style: none;
  margin: 0 0 6px 13px;
  padding: 0 0 0 10px;
  border-left: 2px solid var(--sb-navy-100);
}

.sb-rail__cat li a {
  position: relative;
  display: block;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--sb-text);
  text-decoration: none;
  font-size: 0.9rem;
  line-height: 1.3;
}
.sb-rail__cat li a:hover { background: var(--sb-navy-50); color: var(--sb-navy-700); }
.sb-rail__cat li a.is-active {
  background: var(--sb-accent-100);
  color: var(--sb-navy-900);
  font-weight: 700;
}
.sb-rail__cat li a.is-active::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 5px;
  bottom: 5px;
  width: 3px;
  border-radius: 3px;
  background: var(--sb-accent-600);
}

.sb-rail a:focus-visible,
.sb-rail summary:focus-visible,
.sb-rail button:focus-visible,
.sb-rail-show:focus-visible,
.sb-rail-open:focus-visible,
.sb-hub-stat:focus-visible,
.sb-hub-recent a:focus-visible {
  outline: 2px solid var(--sb-accent-600);
  outline-offset: 2px;
}

/* ---------- Report pages: list beside the page ---------- */
.sb-main--rail { max-width: 1600px; }

.sb-rlayout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.sb-rlayout:not(:has(.sb-rail)) { display: block; }
.sb-rlayout__main { min-width: 0; }

.sb-rail-show,
.sb-rail-open,
.sb-rail-backdrop { display: none; }

.sb-rlayout.is-rail-hidden { grid-template-columns: 44px minmax(0, 1fr); }
.sb-rlayout.is-rail-hidden > .sb-rail { display: none; }
.sb-rlayout.is-rail-hidden > .sb-rail-show {
  position: sticky;
  top: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 44px;
  padding: 14px 0;
  border: 0;
  border-radius: var(--sb-radius);
  background: var(--sb-navy-800);
  color: #fff;
  box-shadow: var(--sb-shadow);
  cursor: pointer;
  font: 800 0.74rem var(--sb-font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sb-rlayout.is-rail-hidden > .sb-rail-show:hover { background: var(--sb-navy-700); }
.sb-rail-show span { writing-mode: vertical-rl; transform: rotate(180deg); }

/* Below 1100px the list becomes a slide-in drawer opened by the "All Reports" button. */
@media (max-width: 1099.98px) {
  .sb-rlayout,
  .sb-rlayout.is-rail-hidden { display: block; }

  .sb-rlayout > .sb-rail--page,
  .sb-rlayout.is-rail-hidden > .sb-rail--page {
    display: block;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 88vw);
    max-height: none;
    border-radius: 0;
    z-index: 1101;
    visibility: hidden;
    transform: translateX(-105%);
    transition: transform 0.2s ease, visibility 0s linear 0.2s;
  }
  .sb-rlayout > .sb-rail--page.is-open {
    visibility: visible;
    transform: none;
    transition: transform 0.2s ease, visibility 0s;
  }
  .sb-rail--page .sb-rail__head { border-radius: 0; }
  .sb-rail--page .sb-rail__hide { display: none; }
  .sb-rail--page .sb-rail__close { display: inline-flex; }
  .sb-rlayout > .sb-rail-show,
  .sb-rlayout.is-rail-hidden > .sb-rail-show { display: none; }

  .sb-rail--page.is-open ~ .sb-rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(7, 26, 44, 0.5);
  }

  .sb-rlayout:has(.sb-rail) .sb-rail-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0 0 16px;
    padding: 8px 16px;
    border: 1px solid var(--sb-border);
    border-radius: 999px;
    background: var(--sb-surface);
    color: var(--sb-navy-800);
    box-shadow: var(--sb-shadow);
    font: 700 0.9rem var(--sb-font-body);
    cursor: pointer;
  }
  .sb-rail-open svg { width: 18px; height: 18px; color: var(--sb-accent-600); }

  body.sb-rail-drawer-open { overflow: hidden; }
}

/* ---------- The Reports page ---------- */
.sb-hub {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  grid-template-areas:
    "rail top"
    "rail dash"
    "rail more";
  grid-template-rows: auto auto 1fr;
  gap: 8px 28px;
  align-items: start;
}
.sb-hub > .sb-rail { grid-area: rail; }
.sb-hub__top { grid-area: top; min-width: 0; }
.sb-hub__more { grid-area: more; min-width: 0; margin-top: 16px; }
.sb-hub:not(:has(.sb-rail)) {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "top" "dash" "more";
}

.sb-hub-hero {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 30px;
  border-radius: 14px;
  color: #fff;
  box-shadow: var(--sb-shadow);
  background-color: var(--sb-navy-800);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 420 120'%3E%3Cpolyline fill='none' stroke='rgba(255,255,255,0.13)' stroke-width='3' stroke-linejoin='round' stroke-linecap='round' points='0,78 70,78 92,42 112,104 136,18 158,78 236,78 254,58 272,92 290,68 420,68'/%3E%3C/svg%3E"),
    radial-gradient(circle at 96% -20%, rgba(232, 98, 44, 0.6), transparent 45%),
    linear-gradient(135deg, var(--sb-navy-800) 0%, var(--sb-navy-600) 100%);
  background-repeat: no-repeat;
  background-position: right 12px bottom 8px, 0 0, 0 0;
  background-size: 400px auto, auto, auto;
}

/* Super Users' group picker sits where the pulse line would be -- leave the line out. */
.sb-hub-hero--picker {
  background-image:
    radial-gradient(circle at 96% -20%, rgba(232, 98, 44, 0.6), transparent 45%),
    linear-gradient(135deg, var(--sb-navy-800) 0%, var(--sb-navy-600) 100%);
  background-position: 0 0, 0 0;
  background-size: auto, auto;
}

.sb-hub-hero__eyebrow {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--sb-accent-400);
}
.sb-hub-hero h1 {
  margin: 4px 0 0;
  color: #fff;
  font-weight: 800;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  line-height: 1.15;
}
.sb-hub-hero__meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.13);
  font-size: 0.85rem;
  font-weight: 600;
}
.sb-hub-hero__meta[hidden] { display: none; }
.sb-hub-hero__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3ddc97;
  box-shadow: 0 0 0 3px rgba(61, 220, 151, 0.25);
}
.sb-hub-hero__group {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 260px;
}
.sb-hub-hero__group label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.78);
}
.sb-hub-hero__group .sb-input { background: #fff; color: var(--sb-text); }

.sb-hub-intro {
  margin: 16px 2px 24px;
  max-width: 72ch;
  color: var(--sb-text-muted);
}
.sb-hub-empty { margin-top: 20px; }

.sb-hub-h2 {
  margin: 0 0 12px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sb-navy-700);
}

/* "Needs attention" cards: number fetched after load; amber when something is waiting,
   green when nothing is. */
.sb-hub-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}

.sb-hub-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "num icon"
    "label label"
    "meta meta"
    "go go";
  align-content: start;
  gap: 4px 12px;
  padding: 18px 20px 16px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-top: 4px solid var(--sb-navy-100);
  border-radius: 12px;
  box-shadow: var(--sb-shadow);
  color: var(--sb-text);
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.sb-hub-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(7, 26, 44, 0.08), 0 12px 28px rgba(7, 26, 44, 0.12);
}

.sb-hub-stat__icon {
  grid-area: icon;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: var(--sb-navy-50);
  color: var(--sb-navy-700);
}
.sb-hub-stat__icon svg { width: 20px; height: 20px; }

.sb-hub-stat__num {
  grid-area: num;
  justify-self: start;
  min-width: 1ch;
  font-family: var(--sb-font-display);
  font-weight: 800;
  font-size: 2.3rem;
  line-height: 1;
  color: var(--sb-navy-900);
}
.sb-hub-stat__label {
  grid-area: label;
  margin-top: 8px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--sb-navy-900);
}
.sb-hub-stat__meta { grid-area: meta; font-size: 0.82rem; color: var(--sb-text-muted); }
.sb-hub-stat__go {
  grid-area: go;
  margin-top: 10px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--sb-navy-600);
}
.sb-hub-stat__go::after { content: " \2192"; }

/* (2026-10-20) review counts are informational only - no due/clear colouring, per Tim */


.sb-hub-stat.is-loading .sb-hub-stat__num {
  width: 64px;
  border-radius: 8px;
  color: transparent;
  background: linear-gradient(90deg, var(--sb-navy-50) 0%, var(--sb-navy-100) 50%, var(--sb-navy-50) 100%);
  background-size: 200% 100%;
  animation: sb-hub-shimmer 1.2s linear infinite;
}
.sb-hub-stat.is-loading .sb-hub-stat__go { visibility: hidden; }
@keyframes sb-hub-shimmer { to { background-position: -200% 0; } }

/* Recently viewed */
.sb-hub-h2--spaced { margin-top: 28px; }
.sb-hub-recent {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: 12px;
  box-shadow: var(--sb-shadow);
}
.sb-hub-recent:empty { display: none; }
.sb-hub-recent li + li { border-top: 1px solid var(--sb-border); }
.sb-hub-recent a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  color: var(--sb-text);
  text-decoration: none;
}
.sb-hub-recent a:hover { background: var(--sb-navy-50); }
.sb-hub-recent a:hover .sb-hub-recent__title { color: var(--sb-accent-600); }
.sb-hub-recent__title { font-weight: 700; color: var(--sb-navy-800); }
.sb-hub-recent__meta { font-size: 0.82rem; color: var(--sb-text-muted); text-align: right; }
.sb-hub-recent__empty { margin: 0; }
.sb-hub-recent__empty[hidden] { display: none; }

@media (max-width: 1099.98px) {
  .sb-hub {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "top"
      "rail"
      "dash"
      "more";
    grid-template-rows: none;
  }
  .sb-hub > .sb-rail { position: static; max-height: none; }
  .sb-hub > .sb-rail .sb-rail__head { position: static; }
}

@media (max-width: 600px) {
  .sb-hub-hero { padding: 22px 20px; }
  .sb-hub-hero:not(.sb-hub-hero--picker) { background-size: 300px auto, auto, auto; }
  .sb-hub-hero__group { min-width: 0; width: 100%; }
  .sb-hub-stats { grid-template-columns: minmax(0, 1fr); }
  .sb-hub-recent a { flex-direction: column; align-items: flex-start; gap: 2px; }
  .sb-hub-recent__meta { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .sb-rail .sb-rail__chev,
  .sb-hub-stat,
  .sb-rlayout > .sb-rail--page { transition: none; }
  .sb-hub-stat:hover { transform: none; }
  .sb-hub-stat.is-loading .sb-hub-stat__num { animation: none; }
}

/* ---------- Dashboard (phase 2, 2026-10-20) - js/reports-dashboard.js ---------- */
.sb-dash { grid-area: dash; min-width: 0; margin-top: 8px; }
.sb-dash[hidden] { display: none; }

.sb-dash__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 14px;
}
.sb-dash__head .sb-hub-h2 { margin: 0 0 12px; }
.sb-dash__filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.sb-dash__field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.sb-dash__field label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sb-text-muted);
}
.sb-dash__field .sb-input { min-height: 42px; }
.sb-dash__field--site .sb-input { min-width: 220px; max-width: 320px; }

.sb-dash__note {
  margin: 0 0 14px;
  padding: 10px 14px;
  border: 1px solid var(--sb-border);
  border-left: 4px solid var(--sb-navy-500);
  border-radius: 10px;
  background: var(--sb-surface);
  color: var(--sb-navy-700);
  font-size: 0.88rem;
}
.sb-dash.is-error .sb-dash__note { border-left-color: var(--sb-danger); }
.sb-dash__note[hidden] { display: none; }

/* KPI tiles */
.sb-dash__kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}
.sb-kpi {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  padding: 16px 18px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-top: 4px solid var(--sb-navy-600);
  border-radius: 12px;
  box-shadow: var(--sb-shadow);
}
#kpiForms { border-top-color: var(--sb-accent-600); }
#kpiCompletion { border-top-color: var(--sb-success); }
#kpiAe { border-top-color: var(--sb-navy-800); }
.sb-kpi__label {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--sb-text-muted);
}
.sb-kpi__value {
  font-family: var(--sb-font-display);
  font-weight: 800;
  font-size: clamp(1.5rem, 2.3vw, 2.05rem);
  line-height: 1.1;
  color: var(--sb-navy-900);
}
.sb-kpi__sub { font-size: 0.82rem; color: var(--sb-text-muted); }
.sb-kpi__go {
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--sb-navy-600);
  text-decoration: none;
}
.sb-kpi__go::after { content: " \2192"; }
.sb-kpi__go:hover { color: var(--sb-accent-600); }
.sb-kpi__go[hidden] { display: none; }
.sb-kpi.is-loading .sb-kpi__value {
  width: 70%;
  border-radius: 8px;
  color: transparent;
  background: linear-gradient(90deg, var(--sb-navy-50) 0%, var(--sb-navy-100) 50%, var(--sb-navy-50) 100%);
  background-size: 200% 100%;
  animation: sb-hub-shimmer 1.2s linear infinite;
}
.sb-kpi.is-loading .sb-kpi__sub,
.sb-kpi.is-loading .sb-kpi__go { visibility: hidden; }

/* Cards */
.sb-dash__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.sb-dcard {
  min-width: 0;
  padding: 18px 20px;
  background: var(--sb-surface);
  border: 1px solid var(--sb-border);
  border-radius: 12px;
  box-shadow: var(--sb-shadow);
}
.sb-dcard--wide { grid-column: 1 / -1; }
.sb-dcard[hidden] { display: none; }
.sb-dcard__head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.sb-dcard__head h3 { margin: 0; font-size: 1rem; font-weight: 800; color: var(--sb-navy-900); }
.sb-dcard__link {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--sb-navy-600);
  text-decoration: none;
  white-space: nowrap;
}
.sb-dcard__link::after { content: " \2192"; }
.sb-dcard__link:hover { color: var(--sb-accent-600); }
.sb-dcard__link[hidden] { display: none; }
.sb-dcard__hint { font-size: 0.78rem; color: var(--sb-text-muted); white-space: nowrap; }
.sb-dcard__foot { margin: 14px 0 0; font-size: 0.82rem; color: var(--sb-text-muted); }
.sb-dcard__empty { margin: 6px 0; color: var(--sb-text-muted); }
.sb-dcard__more { margin-top: 6px; }
.sb-dcard__more[hidden] { display: none; }

/* Charts (SVG drawn at the container's pixel width) */
.sb-chart { width: 100%; min-height: 240px; transition: opacity 0.2s ease; }
.sb-dash.is-loading .sb-chart { opacity: 0.45; }
.sb-chart__svg { display: block; overflow: visible; }
.sb-chart__grid { stroke: var(--sb-border); stroke-width: 1; }
.sb-chart__axis { font: 600 11px var(--sb-font-body); fill: var(--sb-text-muted); }
.sb-chart__axis--year { font-weight: 700; fill: var(--sb-navy-700); }
.sb-chart__bar--billed { fill: var(--sb-navy-600); }
.sb-chart__bar--forms { fill: var(--sb-accent-600); }
g.is-after .sb-chart__bar { opacity: 0.3; }
.sb-chart__hit { fill: transparent; }
.sb-chart__hit:hover { fill: rgba(11, 41, 66, 0.05); }
.sb-chart__line { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.sb-chart__line--rate { stroke: var(--sb-accent-600); }
.sb-chart__line--bench { stroke: var(--sb-navy-500); stroke-width: 2; stroke-dasharray: 6 5; }
.sb-chart__dot { fill: #fff; stroke: var(--sb-accent-600); stroke-width: 2; pointer-events: none; }

.sb-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 0.82rem; color: var(--sb-text-muted); }
.sb-legend > span { display: inline-flex; align-items: center; gap: 7px; }
.sb-legend > span[hidden] { display: none; }
.sb-legend__sw { display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.sb-legend__sw--billed { background: var(--sb-navy-600); }
.sb-legend__sw--forms { background: var(--sb-accent-600); }
.sb-legend__sw--rate { height: 3px; width: 18px; background: var(--sb-accent-600); }
.sb-legend__sw--bench { height: 0; width: 18px; border-radius: 0; border-top: 2px dashed var(--sb-navy-500); }

/* Form completion by site */
.sb-sitebars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sb-sitebar[hidden] { display: none; }
.sb-sitebar a { display: block; padding: 8px 10px; border-radius: 8px; color: inherit; text-decoration: none; }
.sb-sitebar a:hover { background: var(--sb-navy-50); }
.sb-sitebar__top { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; font-weight: 700; color: var(--sb-navy-900); }
.sb-sitebar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-sitebar__value { flex: none; }
.sb-sitebar__bar { display: block; height: 8px; margin: 6px 0 4px; overflow: hidden; border-radius: 999px; background: var(--sb-navy-100); }
.sb-sitebar__bar i { display: block; height: 100%; border-radius: inherit; background: var(--sb-success); }
.sb-sitebar.is-low .sb-sitebar__bar i { background: var(--sb-accent-600); }
.sb-sitebar.is-low .sb-sitebar__value { color: var(--sb-accent-600); }
.sb-sitebar__sub { font-size: 0.78rem; color: var(--sb-text-muted); }

/* Most common adverse events */
.sb-events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sb-events__top { display: flex; justify-content: space-between; gap: 10px; font-size: 0.9rem; font-weight: 600; color: var(--sb-navy-900); }
.sb-events__count { flex: none; font-weight: 800; }
.sb-events__bar { display: block; height: 6px; margin-top: 5px; overflow: hidden; border-radius: 999px; background: var(--sb-navy-100); }
.sb-events__bar i { display: block; height: 100%; border-radius: inherit; background: var(--sb-navy-600); }
.sb-events__none { color: var(--sb-text-muted); }
.sb-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  vertical-align: 1px;
}
.sb-badge--critical { background: #fde8eb; color: var(--sb-danger); }

/* MIPS */
.sb-mips { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 28px; }
.sb-mips__label { display: flex; flex-direction: column; }
.sb-mips__code { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sb-accent-600); }
.sb-mips__name { font-size: 0.92rem; font-weight: 700; color: var(--sb-navy-900); }
.sb-mips__meter { display: flex; align-items: center; gap: 10px; margin: 8px 0 4px; }
.sb-mips__bar { flex: 1; height: 10px; overflow: hidden; border-radius: 999px; background: var(--sb-navy-100); }
.sb-mips__bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--sb-navy-600), var(--sb-navy-500)); }
.sb-mips__value { min-width: 58px; text-align: right; font-family: var(--sb-font-display); font-weight: 800; color: var(--sb-navy-900); }
.sb-mips__sub { font-size: 0.78rem; color: var(--sb-text-muted); }

@media (max-width: 1300px) {
  .sb-dash__kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .sb-dash__grid { grid-template-columns: minmax(0, 1fr); }
  .sb-dash__filters { width: 100%; }
  .sb-dash__field { flex: 1 1 140px; }
  .sb-dash__field--site { flex-basis: 100%; }
  .sb-dash__field--site .sb-input { min-width: 0; max-width: none; }
  #dashApply { flex: 1 1 100%; }
}
@media (max-width: 420px) {
  .sb-dash__kpis { gap: 10px; }
  .sb-kpi { padding: 12px 14px; }
  .sb-dcard { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .sb-kpi.is-loading .sb-kpi__value { animation: none; }
  .sb-chart { transition: none; }
}

/* ---------- Data Assistant (Claude chat, TRIAL, 2026-10-20) - js/data-assistant.js ---------- */
.sb-trial-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--sb-accent-100);
  color: var(--sb-accent-600);
  border: 1px solid rgba(232, 98, 44, 0.35);
  font: 800 0.64rem var(--sb-font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  vertical-align: 2px;
}

.sb-rail__assist {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px 12px 16px;
  border: 0;
  border-bottom: 1px solid var(--sb-border);
  background: linear-gradient(135deg, #fff 0%, var(--sb-accent-100) 100%);
  color: var(--sb-navy-900);
  font: 700 0.95rem var(--sb-font-body);
  text-align: left;
  cursor: pointer;
}
.sb-rail__assist:hover { background: var(--sb-accent-100); }
.sb-rail__assist-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--sb-navy-800);
  color: #fff;
}
.sb-rail__assist-text { flex: 1; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sb-rail__assist-sub { font-size: 0.76rem; font-weight: 600; color: var(--sb-text-muted); }
.sb-rail__assist:focus-visible { outline: 2px solid var(--sb-accent-600); outline-offset: -2px; }

/* panel: a drawer on the right; full screen on phones */
.sb-da[hidden] { display: none; }
.sb-da { position: fixed; inset: 0; z-index: 1200; }
.sb-da__backdrop { position: absolute; inset: 0; background: rgba(7, 26, 44, 0.35); }
.sb-da__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(520px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--sb-bg, #f3f6f9);
  box-shadow: -12px 0 40px rgba(7, 26, 44, 0.25);
}
body.sb-da-open { overflow: hidden; }

.sb-da__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 14px 18px;
  background: var(--sb-navy-800);
  color: #fff;
}
.sb-da__logo, .sb-da__icon-btn {
  flex: none;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
}
.sb-da__logo { background: var(--sb-accent-600); }
.sb-da__titles { flex: 1; min-width: 0; }
.sb-da__titles h2 { margin: 0; color: #fff; font-size: 1.05rem; font-weight: 800; }
.sb-da__group { display: block; font-size: 0.78rem; color: rgba(255, 255, 255, 0.75); }
.sb-da__icon-btn { border: 1px solid rgba(255, 255, 255, 0.22); background: transparent; color: #fff; cursor: pointer; padding: 0; }
.sb-da__icon-btn:hover { background: rgba(255, 255, 255, 0.12); }
.sb-da__head svg, .sb-da__send svg, .sb-rail__assist svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-da__chart svg { display: block; overflow: visible; }
.sb-da__mdtable { width: 100%; border-collapse: collapse; margin: 4px 0 8px; font-size: 0.85rem; }
.sb-da__mdtable th, .sb-da__mdtable td { padding: 4px 8px; border-bottom: 1px solid var(--sb-border); text-align: left; }
.sb-da__mdtable th { background: var(--sb-navy-50); color: var(--sb-navy-800); }

.sb-da__trial, .sb-da__unavailable { margin: 16px; padding: 18px 20px; border-radius: 12px; background: var(--sb-surface); border: 1px solid var(--sb-border); }
.sb-da__trial[hidden], .sb-da__unavailable[hidden], .sb-da__log[hidden], .sb-da__form[hidden], .sb-da__loading[hidden] { display: none; }
.sb-da__loading { margin: 24px 18px; color: var(--sb-text-muted); }
.sb-da__trial { border-top: 4px solid var(--sb-accent-600); overflow-y: auto; }
.sb-da__trial h3 { margin: 0 0 10px; font-size: 1.05rem; }
.sb-da__trial ul { margin: 0 0 16px; padding-left: 18px; color: var(--sb-text); font-size: 0.9rem; line-height: 1.5; }
.sb-da__trial li + li { margin-top: 6px; }

.sb-da__log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.sb-da__msg { display: flex; flex-direction: column; gap: 8px; max-width: 100%; }
.sb-da__msg--user { align-items: flex-end; }
.sb-da__bubble { padding: 10px 14px; border-radius: 14px; font-size: 0.92rem; line-height: 1.5; overflow-wrap: anywhere; }
.sb-da__msg--user .sb-da__bubble { background: var(--sb-navy-800); color: #fff; border-bottom-right-radius: 4px; max-width: 88%; white-space: pre-wrap; }
.sb-da__msg--assistant .sb-da__bubble { background: var(--sb-surface); border: 1px solid var(--sb-border); border-bottom-left-radius: 4px; }
.sb-da__msg--blocked_phi .sb-da__bubble, .sb-da__msg--error .sb-da__bubble, .sb-da__msg--limit .sb-da__bubble { border-color: rgba(232, 98, 44, 0.5); background: var(--sb-accent-100); }
.sb-da__bubble p { margin: 0 0 8px; }
.sb-da__bubble p:last-child, .sb-da__bubble ul:last-child, .sb-da__bubble ol:last-child { margin-bottom: 0; }
.sb-da__bubble ul, .sb-da__bubble ol { margin: 0 0 8px; padding-left: 20px; }
.sb-da__h { font-weight: 800; color: var(--sb-navy-900); }

.sb-da__dots { display: inline-flex; gap: 4px; margin-right: 10px; vertical-align: middle; }
.sb-da__dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--sb-navy-400, #6b8bab); animation: sb-da-dot 1.2s infinite ease-in-out; }
.sb-da__dots i:nth-child(2) { animation-delay: 0.15s; }
.sb-da__dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes sb-da-dot { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.sb-da__waittext { color: var(--sb-text-muted); font-size: 0.86rem; }

.sb-da__welcome { padding: 4px 2px; }
.sb-da__hello { margin: 0 0 12px; color: var(--sb-text); }
.sb-da__chips { display: flex; flex-direction: column; gap: 8px; }
.sb-da__chip {
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--sb-border);
  background: var(--sb-surface);
  color: var(--sb-navy-800);
  font: 600 0.88rem var(--sb-font-body);
  cursor: pointer;
}
.sb-da__chip:hover { border-color: var(--sb-accent-600); background: var(--sb-accent-100); }

.sb-da__art { background: var(--sb-surface); border: 1px solid var(--sb-border); border-radius: 12px; padding: 12px 14px; }
.sb-da__art-title { font-weight: 800; color: var(--sb-navy-900); font-size: 0.9rem; margin-bottom: 8px; }
.sb-da__art--link { padding: 0; border: 0; background: none; }
.sb-da__link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--sb-border);
  border-left: 4px solid var(--sb-navy-600);
  background: var(--sb-surface);
  color: var(--sb-navy-700);
  text-decoration: none;
}
.sb-da__link:hover { border-left-color: var(--sb-accent-600); }
.sb-da__link-title { font-weight: 700; font-size: 0.88rem; }
.sb-da__link-title::after { content: " \2197"; }
.sb-da__link-note { font-size: 0.78rem; color: var(--sb-text-muted); }
.sb-da__chart { width: 100%; }
.sb-da__grid { stroke: var(--sb-border); stroke-width: 1; }
.sb-da__axis { font: 600 10.5px var(--sb-font-body); fill: var(--sb-text-muted); }
.sb-da__legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 6px; font-size: 0.78rem; color: var(--sb-text-muted); }
.sb-da__legend span { display: inline-flex; align-items: center; gap: 6px; }
.sb-da__legend i { width: 12px; height: 8px; border-radius: 2px; display: inline-block; }
.sb-da__tablewrap { overflow-x: auto; max-height: 340px; overflow-y: auto; }
.sb-da__table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.sb-da__table th, .sb-da__table td { padding: 5px 8px; border-bottom: 1px solid var(--sb-border); text-align: left; white-space: nowrap; }
.sb-da__table th { position: sticky; top: 0; background: var(--sb-navy-50); color: var(--sb-navy-800); font-weight: 700; }
.sb-da__table .is-num { text-align: right; }
.sb-da__table tr.is-total td { font-weight: 800; background: var(--sb-navy-50); }
.sb-da__art-foot { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 8px; font-size: 0.8rem; color: var(--sb-text-muted); }
.sb-da__art-foot a { font-weight: 700; color: var(--sb-navy-600); }

.sb-da__form { display: flex; gap: 8px; padding: 12px 14px 6px; border-top: 1px solid var(--sb-border); background: var(--sb-surface); }
.sb-da__form textarea {
  flex: 1;
  resize: none;
  min-height: 46px;
  max-height: 140px;
  padding: 11px 12px;
  border: 1px solid var(--sb-border);
  border-radius: 10px;
  font: 16px/1.4 var(--sb-font-body);   /* 16px: no zoom-on-focus on iPhone */
  color: var(--sb-text);
}
.sb-da__form textarea:focus { outline: 2px solid var(--sb-accent-600); outline-offset: 0; border-color: transparent; }
.sb-da__send {
  flex: none;
  width: 46px;
  border: 0;
  border-radius: 10px;
  background: var(--sb-accent-600);
  color: #fff;
  cursor: pointer;
}
.sb-da__send:disabled { opacity: 0.5; cursor: wait; }
.sb-da__foot { margin: 0; padding: 4px 16px 12px; background: var(--sb-surface); font-size: 0.74rem; color: var(--sb-text-muted); }

@media (max-width: 600px) {
  .sb-da__panel { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) {
  .sb-da__dots i { animation: none; }
}
