/* ==========================================================================
   ba-ui.css — MarineUW / Bellatrix Advisors UI kit
   --------------------------------------------------------------------------
   Component styles for the pop-out window manager, taskbar, command palette,
   toasts, drawer, enhanced tables, evidence marks, chips, skeletons and the
   dark ("terminal") theme.

   This file EXTENDS templates/base.html — it never competes with it. Every
   colour comes from the base.html custom properties so the kit inherits the
   Studio palette, and the dark theme simply re-points those same properties.

   Typography contract used throughout:
     11px   uppercase, .06em tracking  — labels / column heads
     12.5px                            — body copy, controls
     13px                              — table cells
     15px                              — section titles
     20px                              — page titles
   ========================================================================== */

/* ── 0. Theme tokens ─────────────────────────────────────────────────────── */

:root {
  --ba-z-drawer: 900;
  --ba-z-window: 1000;
  --ba-z-taskbar: 1200;
  --ba-z-palette: 1400;
  --ba-z-toast: 1500;
  --ba-shadow-1: 0 1px 2px rgba(16, 24, 40, .05);
  --ba-shadow-2: 0 4px 14px rgba(16, 24, 40, .10);
  --ba-shadow-3: 0 18px 48px rgba(16, 24, 40, .22);
  --ba-radius: 10px;
  --ba-focus: 0 0 0 3px rgba(68, 114, 196, .30);
  --ba-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bax-bg: #0E1420;
  --bax-surface: #151C2B;
  --bax-surface-alt: #1A2334;
  --bax-ink: #E6EDF7;
  --bax-ink-soft: #C3CEDF;
  --bax-muted: #93A1B5;
  --bax-muted-2: #6B7A90;
  --bax-line: #223047;
  --bax-line-soft: #1C273A;
  --bax-accent: #6E9BE8;
  --bax-accent-dark: #9CBCF2;
  --bax-accent-soft: #1D2A42;
  --bax-accent-ink: #0E1420;
  /* Bellatrix pale blue, re-pointed for the dark ground: the light-theme
     value (#5B86CE) drops to ~3.2:1 on --bax-surface here, so the token moves
     up the ramp rather than the rule moving to a different colour. */
  --bax-brand-pale: #A8C4F2;
  --bax-danger: #F97066;
  --bax-danger-soft: #2A1A1C;
  --bax-success: #4ADE80;
  --bax-success-soft: #14281F;
  --bax-warn: #FBBF24;
  --bax-warn-soft: #2A2213;
  --bax-gv-green: var(--bax-accent);
  --bax-gv-green-dark: var(--bax-accent-dark);
  --bax-gv-green-soft: var(--bax-accent-soft);
  --ba-shadow-1: 0 1px 2px rgba(0, 0, 0, .40);
  --ba-shadow-2: 0 4px 14px rgba(0, 0, 0, .48);
  --ba-shadow-3: 0 18px 48px rgba(0, 0, 0, .62);
  --ba-focus: 0 0 0 3px rgba(110, 155, 232, .38);
  color-scheme: dark;
}

html[data-theme="dark"] body { background: var(--bax-bg); color: var(--bax-ink); }

/* Tailwind-CDN compatibility: a handful of hard-coded utility colours are
   baked into legacy pages. Re-point them so dark mode stays readable rather
   than rewriting every template. */
html[data-theme="dark"] .bg-white { background-color: var(--bax-surface) !important; }
html[data-theme="dark"] .bg-slate-50,
html[data-theme="dark"] .bg-slate-100 { background-color: var(--bax-surface-alt) !important; }
html[data-theme="dark"] .bg-slate-900\/50 { background-color: rgba(0, 0, 0, .66) !important; }
html[data-theme="dark"] .text-slate-900,
html[data-theme="dark"] .text-slate-800 { color: var(--bax-ink) !important; }
html[data-theme="dark"] .text-slate-700,
html[data-theme="dark"] .text-slate-600 { color: var(--bax-ink-soft) !important; }
html[data-theme="dark"] .text-slate-500,
html[data-theme="dark"] .text-slate-400 { color: var(--bax-muted) !important; }
html[data-theme="dark"] .border-slate-200,
html[data-theme="dark"] .border-slate-300,
html[data-theme="dark"] .divide-slate-100 > * { border-color: var(--bax-line) !important; }
html[data-theme="dark"] .hover\:bg-slate-50:hover { background-color: var(--bax-surface-alt) !important; }
html[data-theme="dark"] .text-emerald-700 { color: var(--bax-success) !important; }
html[data-theme="dark"] .text-amber-700 { color: var(--bax-warn) !important; }
html[data-theme="dark"] .text-red-700 { color: var(--bax-danger) !important; }
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: var(--bax-surface-alt); color: var(--bax-ink); border-color: var(--bax-line);
}
/* The BA mark is drawn in black ink on a transparent ground. Inverting it
   and rotating the hue back lifts the glyph to a light ink on the dark
   surface while keeping the counter's blue reading as blue — no second
   asset to maintain. The transparent ground stays transparent through the
   filter, so no blend mode is needed. */
html[data-theme="dark"] img.ba-brand-mark {
  filter: invert(1) hue-rotate(180deg) brightness(1.08);
}

/* ── 1. Focus & motion baseline ──────────────────────────────────────────── */

.ba-focusable:focus-visible,
.ba-btn:focus-visible,
.ba-win-btn:focus-visible,
.ba-chip:focus-visible,
.ba-tasklet:focus-visible,
.ba-pal-row:focus-visible,
[data-ba-table] th[data-ba-sortable]:focus-visible,
.ba-topsearch:focus-visible,
.ba-icon-btn:focus-visible {
  outline: none;
  box-shadow: var(--ba-focus);
  border-radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  .ba-window, .ba-toast, .ba-drawer, .ba-palette, .ba-skel::after { transition: none !important; animation: none !important; }
}

/* ── 2. Topbar additions (search / bell / theme) ─────────────────────────── */

.ba-topbar-tools { display: flex; align-items: center; gap: 8px; }

.ba-topsearch-wrap { position: relative; display: flex; align-items: center; }
/* The global search is the primary way into the workspace, so it is
   sized as a primary control rather than as a utility box: full control
   height, wide enough to read a real question back, and it grows on
   focus. It shares --ba-control-h with .btn and .ba-icon-btn so the
   whole toolbar row sits on one line. */
.ba-topsearch {
  width: 420px; height: var(--ba-control-h, 36px); box-sizing: border-box;
  padding: 0 66px 0 36px;
  border: 1px solid var(--bax-line); border-radius: 8px;
  background: var(--bax-surface-alt); color: var(--bax-ink);
  font-size: 13px; line-height: 1;
  transition: width .16s ease, border-color .12s ease,
              background .12s ease, box-shadow .12s ease;
}
.ba-topsearch:focus { width: 560px; }
@media (max-width: 1500px) {
  .ba-topsearch { width: 300px; }
  .ba-topsearch:focus { width: 420px; }
}
@media (max-width: 1200px) {
  .ba-topsearch { width: 210px; }
  .ba-topsearch:focus { width: 300px; }
}
.ba-topsearch::placeholder { color: var(--bax-muted-2); }
.ba-topsearch:hover { border-color: var(--bax-muted-2); }
.ba-topsearch:focus { outline: none; border-color: var(--bax-accent); background: var(--bax-surface); box-shadow: var(--ba-focus); }
.ba-topsearch-wrap .ba-topsearch-ico {
  position: absolute; left: 12px; width: 16px; height: 16px;
  color: var(--bax-muted); pointer-events: none;
}
.ba-topsearch:focus + .ba-kbd,
.ba-topsearch-wrap:focus-within .ba-topsearch-ico { color: var(--bax-accent); }
.ba-kbd {
  position: absolute; right: 8px; display: inline-flex; gap: 2px;
  pointer-events: none;
}
.ba-kbd kbd {
  font: 600 10px/1 var(--ba-mono);
  color: var(--bax-muted); background: var(--bax-surface);
  border: 1px solid var(--bax-line); border-bottom-width: 2px;
  border-radius: 4px; padding: 3px 4px;
}

.ba-icon-btn {
  position: relative;
  width: var(--ba-control-h, 36px); height: var(--ba-control-h, 36px);
  box-sizing: border-box; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--bax-line); background: var(--bax-surface);
  color: var(--bax-muted); cursor: pointer; padding: 0;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.ba-icon-btn svg { width: 16px; height: 16px; }
.ba-icon-btn:hover { background: var(--bax-line-soft); color: var(--bax-ink); border-color: var(--bax-muted-2); }
.ba-icon-btn:active { background: var(--bax-accent-soft); color: var(--bax-accent-dark); }
.ba-icon-btn[aria-expanded="true"] { background: var(--bax-accent-soft); color: var(--bax-accent-dark); border-color: var(--bax-accent); }
.ba-icon-btn:disabled { opacity: .5; cursor: not-allowed; }
/* The count pill.
   It used to centre its digits with line-height:16px on a box that also
   carried a 2px border — so the text was laid out against 16px of space
   inside a box only 12px tall, and a two-digit count sat proud of the
   red circle. Flex centring has no such arithmetic to get wrong, and the
   pill grows sideways for 2- and 3-digit counts instead of clipping. */
.ba-bell-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 18px; height: 18px;
  padding: 0 5px; box-sizing: border-box;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 9999px; background: var(--bax-danger); color: #fff;
  font-weight: 700; font-size: 10px; line-height: 1; font-variant-numeric: tabular-nums;
  letter-spacing: 0; white-space: nowrap;
  border: 2px solid var(--bax-surface);
}

/* ── 3. Window manager ───────────────────────────────────────────────────── */

.ba-window {
  position: fixed; z-index: var(--ba-z-window);
  display: flex; flex-direction: column;
  min-width: 320px; min-height: 180px;
  background: var(--bax-surface);
  border: 1px solid var(--bax-line);
  border-radius: 12px;
  box-shadow: var(--ba-shadow-3);
  overflow: hidden;
  transition: box-shadow .12s ease;
}
.ba-window.ba-win-focused { border-color: var(--bax-accent); }
.ba-window.ba-win-minimized { display: none; }
.ba-window.ba-win-maximized { border-radius: 0; }

.ba-win-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px;
  height: 40px; box-sizing: border-box; padding: 0 8px 0 12px;
  background: var(--bax-surface-alt);
  border-bottom: 1px solid var(--bax-line);
  cursor: grab; user-select: none;
}
.ba-win-head:active { cursor: grabbing; }
.ba-win-head .ba-win-ico {
  width: 15px; height: 15px; flex: 0 0 15px; color: var(--bax-accent);
}
.ba-win-titles { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; }
.ba-win-title {
  font-weight: 600; font-size: 12.5px; line-height: 1.2; color: var(--bax-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ba-win-sub {
  font-weight: 400; font-size: 10.5px; line-height: 1.3; color: var(--bax-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: .02em;
}
/* Drill-down breadcrumb: "opened from <parent>", click focuses the
   parent. Only rendered on windows that were opened from another one. */
.ba-win-parent {
  flex: 0 1 auto; min-width: 0; max-width: 180px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; box-sizing: border-box; padding: 0 8px;
  border: 1px solid var(--bax-line); border-radius: 999px;
  background: var(--bax-accent-soft); color: var(--bax-accent-dark);
  font-weight: 600; font-size: 10.5px; line-height: 1; letter-spacing: .01em;
  cursor: pointer; white-space: nowrap;
  transition: background .12s ease, border-color .12s ease;
}
.ba-win-parent[hidden] { display: none; }
.ba-win-parent svg { width: 11px; height: 11px; flex: 0 0 11px; opacity: .85; }
.ba-win-parent .ba-win-parent-text { overflow: hidden; text-overflow: ellipsis; }
.ba-win-parent:hover { background: var(--bax-accent); color: var(--bax-accent-ink); border-color: var(--bax-accent); }
.ba-win-parent:focus-visible { outline: none; box-shadow: var(--ba-focus); }

.ba-win-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 2px; }
.ba-win-btn {
  width: 26px; height: 26px; border-radius: 6px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--bax-muted); cursor: pointer;
  transition: background .1s ease, color .1s ease;
}
.ba-win-btn svg { width: 13px; height: 13px; }
.ba-win-btn:hover { background: var(--bax-line-soft); color: var(--bax-ink); }
.ba-win-btn:active { background: var(--bax-accent-soft); color: var(--bax-accent-dark); }
.ba-win-btn.ba-win-close:hover { background: var(--bax-danger-soft); color: var(--bax-danger); }

.ba-win-body {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  background: var(--bax-surface);
  font-size: 12.5px; color: var(--bax-ink);
  padding: 0;
}
.ba-win-body > .ba-win-pad { padding: 16px 18px; }

.ba-win-resize { position: absolute; z-index: 3; }
.ba-win-resize.n  { top: -3px; left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.ba-win-resize.s  { bottom: -3px; left: 10px; right: 10px; height: 8px; cursor: ns-resize; }
.ba-win-resize.w  { left: -3px; top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.ba-win-resize.e  { right: -3px; top: 10px; bottom: 10px; width: 8px; cursor: ew-resize; }
.ba-win-resize.nw { top: -3px; left: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.ba-win-resize.ne { top: -3px; right: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.ba-win-resize.sw { bottom: -3px; left: -3px; width: 14px; height: 14px; cursor: nesw-resize; }
.ba-win-resize.se { bottom: -3px; right: -3px; width: 14px; height: 14px; cursor: nwse-resize; }
.ba-window.ba-win-maximized .ba-win-resize { display: none; }

.ba-win-error {
  margin: 18px; padding: 16px 18px;
  border: 1px solid var(--bax-line); border-left: 3px solid var(--bax-danger);
  border-radius: var(--ba-radius); background: var(--bax-danger-soft);
}
.ba-win-error h4 { margin: 0 0 4px; font-weight: 600; font-size: 13px; line-height: 1.3; color: var(--bax-danger); }
.ba-win-error p { margin: 0 0 10px; font-size: 12.5px; color: var(--bax-ink-soft); }
.ba-win-error code { font: 11.5px var(--ba-mono); color: var(--bax-muted); word-break: break-all; }

/* Taskbar */
#ba-taskbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--ba-z-taskbar);
  display: none; align-items: center; gap: 6px;
  padding: 6px 10px; box-sizing: border-box;
  background: var(--bax-surface); border-top: 1px solid var(--bax-line);
  box-shadow: 0 -2px 12px rgba(16, 24, 40, .08);
  overflow-x: auto;
}
#ba-taskbar.ba-has-items { display: flex; }
#ba-taskbar .ba-taskbar-label {
  font-weight: 700; font-size: 10px; line-height: 1; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bax-muted-2); padding-right: 4px; flex: 0 0 auto;
}
.ba-tasklet {
  display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto;
  max-width: 260px; height: 28px; box-sizing: border-box; padding: 0 8px 0 9px;
  border: 1px solid var(--bax-line); border-radius: 7px;
  background: var(--bax-surface-alt); color: var(--bax-ink-soft);
  font-weight: 500; font-size: 12px; line-height: 1; cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.ba-tasklet:hover { background: var(--bax-accent-soft); border-color: var(--bax-accent); color: var(--bax-accent-dark); }
.ba-tasklet:active { background: var(--bax-accent); color: var(--bax-accent-ink); }
.ba-tasklet .ba-tasklet-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ba-tasklet .ba-tasklet-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--bax-accent); flex: 0 0 6px; }

/* ── 4. Command palette ──────────────────────────────────────────────────── */

.ba-palette-backdrop {
  position: fixed; inset: 0; z-index: var(--ba-z-palette);
  background: rgba(16, 24, 40, .40);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 88px 16px 16px;
  backdrop-filter: blur(2px);
}
html[data-theme="dark"] .ba-palette-backdrop { background: rgba(0, 0, 0, .62); }

.ba-palette {
  width: 100%; max-width: 860px; max-height: 70vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--bax-surface); border: 1px solid var(--bax-line);
  border-radius: 14px; box-shadow: var(--ba-shadow-3);
  animation: ba-pal-in .12s ease-out;
}
@keyframes ba-pal-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.ba-palette-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--bax-line);
}
.ba-palette-head svg { width: 16px; height: 16px; color: var(--bax-muted-2); flex: 0 0 16px; }
.ba-palette-input {
  flex: 1 1 auto; border: 0; background: transparent; color: var(--bax-ink);
  font-weight: 400; font-size: 15px; line-height: 1.4; padding: 2px 0;
}
.ba-palette-input:focus { outline: none; }
.ba-palette-input::placeholder { color: var(--bax-muted-2); }
.ba-palette-hint { font-weight: 500; font-size: 10.5px; line-height: 1; color: var(--bax-muted-2); letter-spacing: .04em; white-space: nowrap; }

.ba-palette-results { flex: 1 1 auto; overflow: auto; padding: 6px 0 8px; }
.ba-pal-group {
  padding: 10px 16px 4px;
  font-weight: 700; font-size: 10px; line-height: 1; letter-spacing: .09em; text-transform: uppercase;
  color: var(--bax-muted-2);
}
.ba-pal-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 16px; border: 0; background: transparent; cursor: pointer;
  text-align: left; color: var(--bax-ink); text-decoration: none;
  font-weight: 400; font-size: 12.5px; line-height: 1.35;
}
.ba-pal-row .ba-pal-ico {
  width: 22px; height: 22px; flex: 0 0 22px; border-radius: 6px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bax-accent-soft); color: var(--bax-accent-dark);
  font-weight: 700; font-size: 10px; line-height: 1;
}
.ba-pal-row .ba-pal-main { min-width: 0; flex: 1 1 auto; }
.ba-pal-row .ba-pal-title { display: block; font-weight: 600; color: var(--bax-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ba-pal-row .ba-pal-sub { display: block; font-size: 11px; color: var(--bax-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.ba-pal-row .ba-pal-kind { font-weight: 600; font-size: 10px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; color: var(--bax-muted-2); }
.ba-pal-row:hover { background: var(--bax-line-soft); }
.ba-pal-row.ba-pal-active { background: var(--bax-accent-soft); }
.ba-pal-row.ba-pal-active .ba-pal-title { color: var(--bax-accent-dark); }
.ba-palette-empty { padding: 30px 16px; text-align: center; color: var(--bax-muted); font-size: 12.5px; }
.ba-palette-foot {
  flex: 0 0 auto; display: flex; gap: 14px; align-items: center;
  padding: 8px 16px; border-top: 1px solid var(--bax-line-soft);
  background: var(--bax-surface-alt);
  font-weight: 500; font-size: 10.5px; line-height: 1; color: var(--bax-muted-2); letter-spacing: .03em;
}

/* ── 5. Toasts ───────────────────────────────────────────────────────────── */

#ba-toasts {
  position: fixed; top: 14px; right: 14px; z-index: var(--ba-z-toast);
  display: flex; flex-direction: column; gap: 8px;
  width: 340px; max-width: calc(100vw - 28px);
  pointer-events: none;
}
.ba-toast {
  position: relative; overflow: hidden; pointer-events: auto; cursor: pointer;
  background: var(--bax-surface); border: 1px solid var(--bax-line);
  border-left: 3px solid var(--bax-accent);
  border-radius: var(--ba-radius); box-shadow: var(--ba-shadow-2);
  padding: 10px 12px 11px;
  animation: ba-toast-in .16s ease-out;
}
@keyframes ba-toast-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.ba-toast.ba-toast-out { opacity: 0; transform: translateX(12px); transition: opacity .16s ease, transform .16s ease; }
.ba-toast .ba-toast-msg { font-weight: 500; font-size: 12.5px; line-height: 1.45; color: var(--bax-ink); }
.ba-toast .ba-toast-kind {
  font-weight: 700; font-size: 9.5px; line-height: 1; letter-spacing: .09em; text-transform: uppercase;
  color: var(--bax-muted-2); margin-bottom: 3px; display: block;
}
.ba-toast .ba-toast-bar { position: absolute; left: 0; bottom: 0; height: 2px; background: var(--bax-accent); width: 100%; }
.ba-toast.ba-success { border-left-color: var(--bax-success); }
.ba-toast.ba-success .ba-toast-bar { background: var(--bax-success); }
.ba-toast.ba-warn { border-left-color: var(--bax-warn); }
.ba-toast.ba-warn .ba-toast-bar { background: var(--bax-warn); }
.ba-toast.ba-danger { border-left-color: var(--bax-danger); }
.ba-toast.ba-danger .ba-toast-bar { background: var(--bax-danger); }

/* ── 6. Drawer ───────────────────────────────────────────────────────────── */

.ba-drawer-backdrop {
  position: fixed; inset: 0; z-index: var(--ba-z-drawer);
  background: rgba(16, 24, 40, .34);
}
html[data-theme="dark"] .ba-drawer-backdrop { background: rgba(0, 0, 0, .58); }
.ba-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: calc(var(--ba-z-drawer) + 1);
  width: 420px; max-width: 94vw;
  display: flex; flex-direction: column;
  background: var(--bax-surface); border-left: 1px solid var(--bax-line);
  box-shadow: var(--ba-shadow-3);
  animation: ba-drawer-in .16s ease-out;
}
@keyframes ba-drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.ba-drawer-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 10px;
  height: 56px; box-sizing: border-box; padding: 0 12px 0 18px;
  border-bottom: 1px solid var(--bax-line);
}
.ba-drawer-title { flex: 1 1 auto; font-weight: 600; font-size: 15px; line-height: 1.2; color: var(--bax-ink); }
.ba-drawer-body { flex: 1 1 auto; overflow: auto; padding: 14px 18px 22px; }
.ba-drawer-foot {
  flex: 0 0 auto; padding: 10px 18px; border-top: 1px solid var(--bax-line-soft);
  background: var(--bax-surface-alt); display: flex; gap: 8px; justify-content: flex-end;
}

/* Notification list inside the drawer */
.ba-note {
  display: block; text-decoration: none; color: inherit;
  padding: 10px 12px; margin-bottom: 8px;
  border: 1px solid var(--bax-line); border-left: 3px solid var(--bax-muted-2);
  border-radius: var(--ba-radius); background: var(--bax-surface-alt);
  transition: border-color .12s ease, background .12s ease;
}
.ba-note:hover { background: var(--bax-accent-soft); border-color: var(--bax-accent); }
.ba-note .ba-note-title { font-weight: 600; font-size: 12.5px; line-height: 1.35; color: var(--bax-ink); }
.ba-note .ba-note-detail { font-size: 11.5px; color: var(--bax-muted); margin-top: 2px; line-height: 1.45; }
.ba-note .ba-note-ts { font: 500 10.5px/1 var(--ba-mono); color: var(--bax-muted-2); margin-top: 6px; display: block; }
.ba-note.sev-warn { border-left-color: var(--bax-warn); }
.ba-note.sev-danger, .ba-note.sev-critical { border-left-color: var(--bax-danger); }
.ba-note.sev-success { border-left-color: var(--bax-success); }
.ba-note.sev-info { border-left-color: var(--bax-accent); }

/* ── 7. Enhanced tables ──────────────────────────────────────────────────── */

.ba-table-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 12px; border-bottom: 1px solid var(--bax-line-soft);
}
.ba-filter-input {
  height: 32px; box-sizing: border-box; width: 260px; max-width: 100%;
  padding: 0 10px; border: 1px solid var(--bax-line); border-radius: 8px;
  background: var(--bax-surface); color: var(--bax-ink); font-size: 12.5px; line-height: 1;
  transition: border-color .12s ease, box-shadow .12s ease;
}
.ba-filter-input::placeholder { color: var(--bax-muted-2); }
.ba-filter-input:hover { border-color: var(--bax-muted-2); }
.ba-filter-input:focus { outline: none; border-color: var(--bax-accent); box-shadow: var(--ba-focus); }

.ba-count-badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px;
  border-radius: 9999px; background: var(--bax-line-soft); color: var(--bax-muted);
  font-weight: 600; font-size: 11px; line-height: 1; letter-spacing: .03em; white-space: nowrap;
}

.ba-btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; box-sizing: border-box; padding: 0 12px;
  border: 1px solid var(--bax-line); border-radius: 8px;
  background: var(--bax-surface); color: var(--bax-ink-soft);
  font-weight: 600; font-size: 12px; line-height: 1; cursor: pointer; text-decoration: none;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.ba-btn svg { width: 13px; height: 13px; }
.ba-btn:hover { background: var(--bax-line-soft); color: var(--bax-ink); border-color: var(--bax-muted-2); }
.ba-btn:active { background: var(--bax-accent-soft); color: var(--bax-accent-dark); border-color: var(--bax-accent); }
.ba-btn:disabled { opacity: .5; cursor: not-allowed; }
.ba-btn-accent { background: var(--bax-accent); border-color: var(--bax-accent); color: var(--bax-accent-ink); }
.ba-btn-accent:hover { background: var(--bax-accent-dark); border-color: var(--bax-accent-dark); color: var(--bax-accent-ink); }

table[data-ba-table] { border-collapse: separate; border-spacing: 0; width: 100%; }
table[data-ba-table] th { position: relative; }
table[data-ba-table] thead th.ba-sticky {
  position: sticky; top: 0; z-index: 5; background: var(--bax-surface-alt);
}
table[data-ba-table] th[data-ba-sortable] {
  cursor: pointer; user-select: none; white-space: nowrap;
  transition: color .12s ease, background .12s ease;
}
table[data-ba-table] th[data-ba-sortable]:hover { color: var(--bax-accent-dark); background: var(--bax-accent-soft); }
table[data-ba-table] th .ba-sort-ind {
  display: inline-block; margin-left: 5px; width: 8px;
  font-size: 9px; color: var(--bax-muted-2); vertical-align: middle;
}
table[data-ba-table] th[aria-sort="ascending"] .ba-sort-ind,
table[data-ba-table] th[aria-sort="descending"] .ba-sort-ind { color: var(--bax-accent); }
table[data-ba-table] th[aria-sort="ascending"],
table[data-ba-table] th[aria-sort="descending"] { color: var(--bax-accent-dark); }

table[data-ba-table] .ba-col-grip {
  position: absolute; top: 0; right: -3px; width: 7px; height: 100%;
  cursor: col-resize; z-index: 6;
}
table[data-ba-table] .ba-col-grip:hover { background: linear-gradient(to right, transparent 2px, var(--bax-accent) 2px, var(--bax-accent) 4px, transparent 4px); }

table[data-ba-table] tbody tr.ba-row-zebra { background: var(--bax-surface-alt); }
table[data-ba-table] tbody tr:hover { background: var(--bax-accent-soft); }
table[data-ba-table] tbody tr.ba-row-cursor {
  background: var(--bax-accent-soft);
  box-shadow: inset 3px 0 0 var(--bax-accent);
}
table[data-ba-table] tbody tr.ba-row-hidden { display: none; }

.ba-table-empty {
  padding: 40px 16px; text-align: center; color: var(--bax-muted); font-size: 12.5px;
}
.ba-table-empty .ba-empty-title { font-weight: 600; font-size: 13px; line-height: 1.4; color: var(--bax-ink-soft); margin-bottom: 4px; }

/* Generic empty state card, reusable on any page */
.ba-empty {
  padding: 48px 24px; text-align: center;
  border: 1px dashed var(--bax-line); border-radius: 12px;
  background: var(--bax-surface-alt);
}
.ba-empty svg { width: 30px; height: 30px; color: var(--bax-muted-2); margin-bottom: 10px; }
.ba-empty h4 { margin: 0 0 4px; font-weight: 600; font-size: 15px; line-height: 1.3; color: var(--bax-ink); }
.ba-empty p { margin: 0 0 14px; font-size: 12.5px; color: var(--bax-muted); }

/* ── 8. Chips: evidence, record, tag ─────────────────────────────────────── */

.ev-chip {
  display: inline-flex; align-items: center; gap: 5px;
  max-width: 300px; padding: 2px 8px; margin: 2px 4px 2px 0;
  border: 1px solid var(--bax-line); border-radius: 9999px;
  background: var(--bax-surface-alt); color: var(--bax-ink-soft);
  font: 500 11px/1.6 var(--ba-mono); text-decoration: none;
  vertical-align: middle;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.ev-chip::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--bax-accent); flex: 0 0 5px;
}
.ev-chip .ev-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ev-chip:hover { background: var(--bax-accent-soft); border-color: var(--bax-accent); color: var(--bax-accent-dark); }
.ev-chip:active { background: var(--bax-accent); color: var(--bax-accent-ink); }
.ev-chip:focus-visible { outline: none; box-shadow: var(--ba-focus); }

.rec-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; margin: 0 6px 6px 0;
  border: 1px solid var(--bax-line); border-radius: 8px;
  background: var(--bax-surface); color: var(--bax-ink-soft);
  font-weight: 500; font-size: 12px; line-height: 1.4; text-decoration: none;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.rec-chip .rec-kind {
  font-weight: 700; font-size: 9.5px; line-height: 1; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bax-muted-2);
}
.rec-chip:hover { background: var(--bax-accent-soft); border-color: var(--bax-accent); color: var(--bax-accent-dark); }
.rec-chip:hover .rec-kind { color: var(--bax-accent); }
.rec-chip:focus-visible { outline: none; box-shadow: var(--ba-focus); }

.ba-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 9999px;
  border: 1px solid var(--bax-line); background: var(--bax-surface-alt);
  color: var(--bax-muted); font-weight: 600; font-size: 11px; line-height: 1.7; letter-spacing: .02em;
}

/* ── 9. Evidence marks in the document viewer ────────────────────────────── */

mark.ev-span {
  background: rgba(68, 114, 196, .13);
  border-bottom: 1px solid rgba(68, 114, 196, .45);
  color: inherit; padding: 1px 0; border-radius: 2px;
  cursor: pointer; scroll-margin: 120px;
  transition: background .15s ease, box-shadow .15s ease;
}
mark.ev-span:hover { background: rgba(68, 114, 196, .26); }
mark.ev-field { background: rgba(19, 138, 71, .13); border-bottom-color: rgba(19, 138, 71, .5); }
mark.ev-field:hover { background: rgba(19, 138, 71, .26); }
mark.ev-finding { background: rgba(180, 35, 24, .12); border-bottom-color: rgba(180, 35, 24, .5); }
mark.ev-finding:hover { background: rgba(180, 35, 24, .24); }
mark.ev-classification { background: rgba(179, 107, 0, .14); border-bottom-color: rgba(179, 107, 0, .5); }
mark.ev-classification:hover { background: rgba(179, 107, 0, .26); }
mark.ev-focus,
mark.ev-span.ev-focus {
  background: #FDE68A; color: #1A1A1A;
  box-shadow: 0 0 0 2px rgba(179, 107, 0, .55);
  border-radius: 3px;
}
html[data-theme="dark"] mark.ev-focus,
html[data-theme="dark"] mark.ev-span.ev-focus { background: #8A6D1F; color: #FFF8E1; }
mark.ba-find-hit { background: rgba(110, 155, 232, .35); border-radius: 2px; }
mark.ba-find-hit.ba-find-current { background: #FDE68A; box-shadow: 0 0 0 2px rgba(179, 107, 0, .6); }
@keyframes ba-flash {
  0%   { box-shadow: 0 0 0 2px rgba(179, 107, 0, .0); }
  25%  { box-shadow: 0 0 0 5px rgba(179, 107, 0, .70); }
  100% { box-shadow: 0 0 0 2px rgba(179, 107, 0, .55); }
}
mark.ba-flash { animation: ba-flash .9s ease-out 2; }

/* ── 10. Skeletons ───────────────────────────────────────────────────────── */

.ba-skel {
  position: relative; overflow: hidden;
  background: var(--bax-line-soft); border-radius: 6px;
  height: 12px; margin-bottom: 8px;
}
.ba-skel::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .62), transparent);
  transform: translateX(-100%);
  animation: ba-shimmer 1.25s infinite;
}
html[data-theme="dark"] .ba-skel::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .09), transparent);
}
@keyframes ba-shimmer { 100% { transform: translateX(100%); } }
.ba-skel-title { height: 16px; width: 42%; }
.ba-skel-line-80 { width: 80%; }
.ba-skel-line-60 { width: 60%; }
.ba-skel-block { height: 74px; border-radius: 10px; }
.ba-skel-wrap { padding: 18px 20px; }

/* ── 11. Tabs enhancement ────────────────────────────────────────────────── */

[data-ba-tabs] { display: flex; gap: 2px; }
[data-ba-tabs] [role="tab"] { cursor: pointer; }
[data-ba-tabs] [role="tab"]:focus-visible { outline: none; box-shadow: var(--ba-focus); border-radius: 6px 6px 0 0; }

/* ── 12. Inline two-step confirmation ────────────────────────────────────── */

.ba-confirm-armed {
  background: var(--bax-danger) !important; border-color: var(--bax-danger) !important;
  color: #fff !important;
}
.ba-confirm-armed:hover { background: #8C1B12 !important; }

/* ── 13. Document viewer ─────────────────────────────────────────────────── */

.doc-shell { display: flex; flex-direction: column; min-height: 0; }
.doc-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  padding: 14px 18px; border: 1px solid var(--bax-line);
  border-radius: 12px; background: var(--bax-surface); margin-bottom: 12px;
}
.doc-head .doc-idents { min-width: 0; flex: 1 1 340px; }
.doc-filename {
  font-weight: 600; font-size: 15px; line-height: 1.3; color: var(--bax-ink);
  word-break: break-all; margin: 0 0 5px;
}
.doc-head .doc-meta {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: center;
  font-size: 11.5px; color: var(--bax-muted);
}
.doc-head .doc-meta b { font: 600 11.5px/1 var(--ba-mono); color: var(--bax-ink-soft); }
.doc-head .doc-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.doc-stats { display: flex; gap: 0; flex-wrap: wrap; margin-top: 10px; width: 100%; }
.doc-stat {
  padding: 6px 18px 6px 0; margin-right: 18px;
  border-right: 1px solid var(--bax-line-soft);
}
.doc-stat:last-child { border-right: 0; }
.doc-stat .k {
  font-weight: 700; font-size: 10px; line-height: 1.4; letter-spacing: .07em; text-transform: uppercase;
  color: var(--bax-muted-2);
}
.doc-stat .v { font: 600 13px/1.4 var(--ba-mono); color: var(--bax-ink); }

.doc-body { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 12px; align-items: start; }
@media (max-width: 1180px) { .doc-body { grid-template-columns: minmax(0, 1fr); } }

.doc-pane {
  border: 1px solid var(--bax-line); border-radius: 12px;
  background: var(--bax-surface); overflow: hidden;
  display: flex; flex-direction: column; min-height: 0;
}
.doc-toolbar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; border-bottom: 1px solid var(--bax-line-soft);
  background: var(--bax-surface-alt);
}
.doc-find-wrap { position: relative; display: flex; align-items: center; gap: 6px; }
.doc-find-count { font: 600 11px/1 var(--ba-mono); color: var(--bax-muted); min-width: 44px; }
.doc-toolbar .sep { width: 1px; height: 18px; background: var(--bax-line); margin: 0 2px; }

.doc-page {
  flex: 1 1 auto; min-height: 340px; max-height: calc(100vh - 330px); overflow: auto;
  padding: 22px 26px;
  font: 12.75px/1.95 var(--ba-mono);
  color: var(--bax-ink); background: var(--bax-surface);
  white-space: normal; word-break: break-word;
}
.ba-window .doc-page { max-height: none; }
.doc-page.doc-nowrap { white-space: pre; overflow-x: auto; word-break: normal; }
.doc-page.fs-1 { font-size: 11px; line-height: 1.85; }
.doc-page.fs-2 { font-size: 12.75px; }
.doc-page.fs-3 { font-size: 14.5px; line-height: 2.05; }
.doc-page.fs-4 { font-size: 16.5px; line-height: 2.1; }

.doc-rail { display: flex; flex-direction: column; min-height: 0; }
.doc-rail-head {
  padding: 10px 14px; border-bottom: 1px solid var(--bax-line-soft);
  background: var(--bax-surface-alt);
  display: flex; align-items: center; gap: 8px;
}
.doc-rail-head h3 {
  margin: 0; font-weight: 700; font-size: 11px; line-height: 1.4; letter-spacing: .07em;
  text-transform: uppercase; color: var(--bax-muted);
}
.doc-rail-body { overflow: auto; max-height: calc(100vh - 330px); padding: 6px 0 10px; }
.ba-window .doc-rail-body { max-height: none; }
.doc-rail-group {
  padding: 12px 14px 4px;
  font-weight: 700; font-size: 10px; line-height: 1; letter-spacing: .09em; text-transform: uppercase;
  color: var(--bax-muted-2);
}
.span-card {
  display: block; text-decoration: none; color: inherit;
  margin: 0 10px 6px; padding: 8px 10px;
  border: 1px solid var(--bax-line); border-left: 3px solid var(--bax-accent);
  border-radius: 8px; background: var(--bax-surface-alt);
  transition: background .12s ease, border-color .12s ease;
  cursor: pointer;
}
.span-card:hover { background: var(--bax-accent-soft); border-color: var(--bax-accent); }
.span-card:focus-visible { outline: none; box-shadow: var(--ba-focus); }
.span-card.kind-field { border-left-color: var(--bax-success); }
.span-card.kind-finding { border-left-color: var(--bax-danger); }
.span-card.kind-classification { border-left-color: var(--bax-warn); }
.span-card .sc-label { font-weight: 600; font-size: 12px; line-height: 1.35; color: var(--bax-ink); }
.span-card .sc-quote {
  font: 11.5px/1.55 var(--ba-mono); color: var(--bax-ink-soft);
  margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--bax-line);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.span-card .sc-meta {
  margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  font-weight: 500; font-size: 10.5px; line-height: 1; color: var(--bax-muted-2); letter-spacing: .03em;
}
.span-card .sc-meta .sc-agent { font-family: var(--ba-mono); color: var(--bax-muted); }

.doc-notice {
  margin: 18px; padding: 20px 22px; text-align: center;
  border: 1px dashed var(--bax-line); border-radius: 12px; background: var(--bax-surface-alt);
}
.doc-notice h4 { margin: 0 0 6px; font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--bax-ink); }
.doc-notice p { margin: 0 0 12px; font-size: 12.5px; color: var(--bax-muted); line-height: 1.6; }

/* 404 / error card shared by the document routes */
.ba-error-card {
  max-width: 560px; margin: 60px auto; padding: 28px 30px; text-align: center;
  border: 1px solid var(--bax-line); border-top: 3px solid var(--bax-danger);
  border-radius: 12px; background: var(--bax-surface); box-shadow: var(--ba-shadow-1);
}
.ba-error-card .code {
  font-weight: 700; font-size: 11px; line-height: 1; letter-spacing: .1em; text-transform: uppercase; color: var(--bax-danger);
}
.ba-error-card h2 { margin: 8px 0 6px; font-weight: 600; font-size: 20px; line-height: 1.25; color: var(--bax-ink); }
.ba-error-card p { margin: 0 0 18px; font-size: 12.5px; color: var(--bax-muted); line-height: 1.6; }

/* ── 14. Case / claim detail additions ───────────────────────────────────── */

.ba-statstrip {
  display: flex; flex-wrap: wrap; gap: 0;
  border: 1px solid var(--bax-line); border-radius: 12px; background: var(--bax-surface);
  padding: 4px 0; margin-bottom: 14px; overflow: hidden;
}
.ba-statstrip .ba-stat {
  flex: 1 1 132px; min-width: 132px; padding: 10px 16px;
  border-right: 1px solid var(--bax-line-soft);
  text-decoration: none; color: inherit; display: block;
  transition: background .12s ease;
}
.ba-statstrip .ba-stat:last-child { border-right: 0; }
.ba-statstrip a.ba-stat:hover { background: var(--bax-accent-soft); }
.ba-statstrip a.ba-stat:focus-visible { outline: none; box-shadow: var(--ba-focus); }
.ba-statstrip .ba-stat .k {
  font-weight: 700; font-size: 10px; line-height: 1.35; letter-spacing: .07em; text-transform: uppercase;
  color: var(--bax-muted-2);
  /* Labels wrap rather than truncate — an underwriter reading
     "TECHNICAL PREMIUM" must not be shown "TECHNICAL …". */
  white-space: normal; overflow-wrap: break-word; min-height: 2.7em;
}
.ba-statstrip .ba-stat .v {
  font-weight: 600; font-size: 15px; line-height: 1.35; color: var(--bax-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ba-statstrip .ba-stat .v.mono { font-family: var(--ba-mono); font-size: 13.5px; }
.ba-statstrip .ba-stat.is-danger .v { color: var(--bax-danger); }
.ba-statstrip .ba-stat.is-warn .v { color: var(--bax-warn); }
.ba-statstrip .ba-stat.is-success .v { color: var(--bax-success); }

.ba-rail {
  border: 1px solid var(--bax-line); border-radius: 12px; background: var(--bax-surface);
  padding: 14px 16px; margin-bottom: 14px;
}
.ba-rail h4 {
  margin: 0 0 10px; font-weight: 700; font-size: 11px; line-height: 1.4; letter-spacing: .07em;
  text-transform: uppercase; color: var(--bax-muted);
}
.ba-rail .ba-rail-items { display: flex; flex-wrap: wrap; }

.ba-evrow { margin-top: 6px; display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.ba-evrow .ba-evlabel {
  font-weight: 700; font-size: 9.5px; line-height: 1.7; letter-spacing: .08em; text-transform: uppercase;
  color: var(--bax-muted-2); margin-right: 6px;
}

.ba-lazy-pane { min-height: 120px; }
.ba-lazy-error {
  padding: 18px 20px; border: 1px solid var(--bax-line); border-left: 3px solid var(--bax-warn);
  border-radius: 10px; background: var(--bax-warn-soft);
  font-size: 12.5px; color: var(--bax-ink-soft); line-height: 1.6;
}
.ba-lazy-error b { color: var(--bax-ink); }

/* ── 15. Small shared utilities ──────────────────────────────────────────── */

.ba-label {
  font-weight: 700; font-size: 11px; line-height: 1.5; letter-spacing: .07em; text-transform: uppercase;
  color: var(--bax-muted);
}
.ba-mono { font-family: var(--ba-mono); }
.ba-muted { color: var(--bax-muted); }
.ba-sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ba-hr { height: 1px; background: var(--bax-line-soft); border: 0; margin: 14px 0; }

/* Body padding so neither the taskbar nor the AI Activity lid that
   stacks on top of it can ever hide page content. --ba-ai-tab-reserve is
   declared in base.html and already folds in --ba-taskbar-h. */
body.ba-taskbar-open { padding-bottom: var(--ba-ai-tab-reserve, 46px); }


/* ── Palette answer pane ─────────────────────────────────────────────────
   The answer sits ABOVE the ranked rows because the operator asked a
   question, and a question deserves a sentence before it deserves a
   list. The rows below it become citations rather than output. */
.ba-pal-answer {
  margin: 8px 10px 10px; padding: 12px 14px;
  border: 1px solid var(--bax-accent); border-radius: 10px;
  background: var(--bax-accent-soft);
}
.ba-pal-answer.thinking { border-color: var(--bax-line); background: var(--bax-surface-alt); }
.ba-pal-answer-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
  flex-wrap: wrap;
}
.ba-pal-answer-label {
  font-weight: 700; font-size: 9px; line-height: 1; letter-spacing: .12em; text-transform: uppercase;
  color: var(--bax-accent-dark);
}
.ba-pal-answer-chip {
  font-weight: 700; font-size: 9px; line-height: 1; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 999px;
  background: var(--bax-surface); color: var(--bax-muted); border: 1px solid var(--bax-line);
}
.ba-pal-answer-chip[data-conf="high"] { color: var(--bax-success); border-color: var(--bax-success); }
.ba-pal-answer-chip[data-conf="low"], .ba-pal-answer-chip[data-conf="none"] { color: var(--bax-warn); border-color: var(--bax-warn); }
.ba-pal-answer-chip.exact { color: var(--bax-accent-dark); border-color: var(--bax-accent); background: var(--bax-surface); }
.ba-pal-answer-model {
  margin-left: auto; font: 500 10px/1 var(--ba-mono, ui-monospace, Menlo, monospace);
  color: var(--bax-muted-2); white-space: nowrap;
}
.ba-pal-answer-body {
  font-size: 13px; line-height: 1.6; color: var(--bax-ink);
}
.ba-pal-answer-understood {
  margin-top: 6px; font-size: 10.5px; color: var(--bax-muted); line-height: 1.5;
}
.ba-pal-cites { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.ba-pal-cite {
  font-weight: 600; font-size: 11px; line-height: 1; max-width: 300px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
  padding: 5px 9px; border-radius: 7px; cursor: pointer;
  background: var(--bax-surface); color: var(--bax-accent-dark);
  border: 1px solid var(--bax-line);
}
.ba-pal-cite:hover { border-color: var(--bax-accent); background: var(--bax-accent-soft); }
.ba-pal-cite:focus-visible { outline: none; box-shadow: var(--ba-focus); }

/* The palette itself is taller now that it leads with an answer. */
.ba-palette { max-height: min(78vh, 760px); }


/* ── Document preview ────────────────────────────────────────────────────
   The viewer shows a file as itself: a picture as a picture, a PDF as
   pages, a workbook as tables. The extracted text sits behind a tab
   beside it rather than replacing it. */
.doc-viewtabs {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 0 10px; border-bottom: 1px solid var(--bax-line-soft);
  margin-bottom: 10px;
}
.doc-viewtab {
  font-weight: 600; font-size: 11.5px; padding: 5px 11px; border-radius: 7px;
  border: 1px solid var(--bax-line); background: var(--bax-surface);
  color: var(--bax-muted); cursor: pointer; white-space: nowrap;
}
.doc-viewtab:hover { color: var(--bax-ink); border-color: var(--bax-muted-2); }
.doc-viewtab.is-on {
  background: var(--bax-accent-soft); color: var(--bax-accent-dark);
  border-color: var(--bax-accent);
}
.doc-viewtab-sp { flex: 1 1 auto; }

.doc-img-wrap {
  background: var(--bax-surface-alt); border: 1px solid var(--bax-line-soft);
  border-radius: 10px; padding: 10px; overflow: auto;
  max-height: 72vh; text-align: center;
}
.ba-window .doc-img-wrap { max-height: none; }
.doc-img {
  max-width: 100%; height: auto; display: inline-block;
  border-radius: 6px; transform-origin: top center;
  transition: width .12s ease;
}

.doc-pdf {
  width: 100%; height: 72vh; min-height: 460px;
  border: 1px solid var(--bax-line-soft); border-radius: 10px;
  background: var(--bax-surface-alt); display: block;
}
.ba-window .doc-pdf { height: 100%; min-height: 380px; }

.doc-sheettabs { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 9px; }
.doc-sheettab {
  font-weight: 600; font-size: 11px; padding: 4px 10px; border-radius: 6px;
  border: 1px solid var(--bax-line); background: var(--bax-surface);
  color: var(--bax-muted); cursor: pointer;
}
.doc-sheettab.is-on {
  background: var(--bax-accent-soft); color: var(--bax-accent-dark);
  border-color: var(--bax-accent);
}
.doc-sheet { overflow: auto; max-height: 68vh;
             border: 1px solid var(--bax-line-soft); border-radius: 10px; }
.ba-window .doc-sheet { max-height: none; }
.doc-sheet-table {
  width: 100%; border-collapse: collapse;
  font: 11.5px/1.5 var(--ba-mono, ui-monospace, Menlo, monospace);
  font-variant-numeric: tabular-nums;
}
.doc-sheet-table th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bax-surface-alt); color: var(--bax-ink);
  text-align: left; font-weight: 700; white-space: nowrap;
  padding: 7px 10px; border-bottom: 1px solid var(--bax-line);
}
.doc-sheet-table td {
  padding: 6px 10px; border-bottom: 1px solid var(--bax-line-soft);
  color: var(--bax-ink-soft); white-space: nowrap;
}
.doc-sheet-table tr:hover td { background: var(--bax-line-soft); }
.doc-sheet-note {
  margin: 8px 2px 0; font-size: 11px; color: var(--bax-muted);
}
