/* ============================================================
   Whisper · v3 work surfaces — craft pass W2 (BRAND.md §5–§7)
   Sources · Worksheets · Whisper Chat · Dashboards
   Global .w3-* components (also used inside modals) + view-scoped layout.
   Shared tokens / .btn / .dtable / .menu live in styles.css.
   ============================================================ */

:root {
  --w3-ease: var(--ease, cubic-bezier(.2, .8, .2, 1));
  --w3-ring: var(--signal-ring, rgba(31, 79, 216, .35));
  --w3-c1: var(--chart-1, #1F4FD8); --w3-c2: var(--chart-2, #0F8B7E); --w3-c3: var(--chart-3, #B7791F); --w3-c4: var(--chart-4, #C2413A);
  --w3-c5: var(--chart-5, #5B6B85); --w3-c6: var(--chart-6, #2B8FBF); --w3-c7: var(--chart-7, #6B8E23); --w3-c8: var(--chart-8, #8A5A9E);
  --w3-hl-band: rgba(31, 79, 216, .045);
  --w3-sel: rgba(31, 79, 216, .22);
  --tk-kw: var(--accent); --tk-fn: var(--text); --tk-str: #4F6F60; --tk-num: var(--text-2); --tk-com: var(--text-3); --tk-id: var(--text);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --w3-c1: var(--chart-1, #6E9BFF); --w3-c2: var(--chart-2, #3FB5A7); --w3-c3: var(--chart-3, #D9A04A); --w3-c4: var(--chart-4, #E5736B);
    --w3-c5: var(--chart-5, #8C9AB2); --w3-c6: var(--chart-6, #5BB0DB); --w3-c7: var(--chart-7, #94B54A); --w3-c8: var(--chart-8, #B08AC2);
    --w3-hl-band: rgba(110, 155, 255, .06);
    --w3-sel: rgba(110, 155, 255, .30);
    --tk-kw: var(--accent); --tk-fn: var(--text); --tk-str: #8FB3A0; --tk-num: var(--text-2); --tk-com: var(--text-3); --tk-id: var(--text);
  }
}
:root[data-theme="dark"] {
  --w3-c1: var(--chart-1, #6E9BFF); --w3-c2: var(--chart-2, #3FB5A7); --w3-c3: var(--chart-3, #D9A04A); --w3-c4: var(--chart-4, #E5736B);
  --w3-c5: var(--chart-5, #8C9AB2); --w3-c6: var(--chart-6, #5BB0DB); --w3-c7: var(--chart-7, #94B54A); --w3-c8: var(--chart-8, #B08AC2);
  --w3-hl-band: rgba(110, 155, 255, .06);
  --w3-sel: rgba(110, 155, 255, .30);
  --tk-kw: var(--accent); --tk-fn: var(--text); --tk-str: #8FB3A0; --tk-num: var(--text-2); --tk-com: var(--text-3); --tk-id: var(--text);
}

@keyframes w3-shimmer { to { background-position: -200% 0; } }
@keyframes w3-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes w3-spin { to { transform: rotate(360deg); } }

@keyframes w3-think-sheen { to { background-position: -200% 0; } }
@keyframes w3-breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }

/* ============================================================
   GLOBAL COMPONENTS (prefixed .w3-*)
   ============================================================ */

/* ---- skeletons ---- */
.w3-sk {
  display: inline-block; flex: 0 0 auto; vertical-align: middle; border-radius: 4px; max-width: 100%;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: w3-shimmer 1.2s linear infinite;
}
.w3-sk-ico { border-radius: 6px; }
.w3-sk-ctl { border-radius: 8px; }
.w3-skel-list { display: flex; flex-direction: column; padding: 6px 0; }
.w3-skel-row { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; }
.w3-skel-tree { height: 28px; padding-left: 38px; }
.w3-skel-lines { display: flex; flex-direction: column; gap: 7px; flex: 1 1 auto; min-width: 0; }
.w3-skel-table td, .w3-skel-table th { pointer-events: none; }
.w3-skel-table th .w3-sk { opacity: .7; }
.w3-skel-chart { display: flex; align-items: flex-end; gap: 6%; height: 100%; min-height: 180px; padding: 12px 4px 26px 40px;
  background: repeating-linear-gradient(to bottom, transparent 0 calc(25% - 1px), var(--line) calc(25% - 1px) 25%); }
.w3-skel-bar { flex: 1 1 0; border-radius: 4px 4px 0 0; }
.w3-skel-num { display: flex; flex-direction: column; justify-content: center; gap: 12px; height: 100%; min-height: 80px; }

/* ---- error block with retry ---- */
.w3-errbox {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 12px 12px 14px; border-radius: 8px;
  background: var(--surface); border: 1px solid color-mix(in srgb, var(--err) 30%, var(--line)); color: var(--text);
  animation: w3-fade-in .16s var(--w3-ease);
}
.w3-errbox-ico { color: var(--err); display: inline-flex; margin-top: 1px; flex: 0 0 auto; }
.w3-errbox-text { flex: 1 1 auto; min-width: 0; }
.w3-errbox-title { font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text); line-height: 20px; }
.w3-errbox-msg { font-size: var(--fs-13); color: var(--text-2); line-height: 18px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--mono); font-size: var(--fs-12); margin-top: 2px; }
.w3-errbox .w3-retry { flex: 0 0 auto; background: var(--surface); }
.w3-pad { padding: 12px; }
.w3-section-gap { margin-top: 16px; }

/* ---- empty states with brand illustration ---- */
.w3-empty { gap: 6px; text-align: center; animation: w3-fade-in .16s var(--w3-ease); }
.w3-illus { display: inline-flex; color: var(--text-3); margin-bottom: 8px; }
.w3-illus svg { display: block; }
.w3-empty .empty-title { font-size: var(--fs-14); font-weight: var(--fw-strong); letter-spacing: 0; }
.w3-empty .empty-body { font-size: var(--fs-13); color: var(--text-2); line-height: 20px; max-width: 360px; margin: 0 auto; }
.w3-empty-act { margin-top: 10px; display: flex; gap: 8px; justify-content: center; }
.w3-empty-sm { padding: 24px 16px; }
.w3-empty-sm .w3-illus { margin-bottom: 4px; }

/* ---- misc atoms ---- */
.w3-dotsep { display: inline-block; width: 3px; height: 3px; border-radius: 50%; background: currentColor; opacity: .45; margin: 0 7px; vertical-align: middle; flex: 0 0 auto; }
.w3-fade { animation: w3-fade-in .16s var(--w3-ease); }
.w3-tnum, .w3-time { font-variant-numeric: tabular-nums; }
.w3-time { cursor: default; }
.w3-linkbtn { border: 0; background: none; padding: 0 2px; font: inherit; font-size: var(--fs-12); font-weight: var(--fw-med); color: var(--accent); cursor: pointer; border-radius: 4px; }
.w3-linkbtn:hover { text-decoration: underline; }

/* busy buttons: spinner replaces the leading icon, width stays stable */
.w3-bi { display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; flex: 0 0 auto; }
.icon-btn.w3-spin svg, .w3-row-menu.w3-spin svg { animation: w3-spin .8s linear infinite; }
.w3-copied { color: var(--ok) !important; }
.w3-copied svg { color: var(--ok); }

/* ---- type glyphs (columns) ---- */
.w3-tg {
  display: inline-grid; place-items: center; flex: 0 0 auto; min-width: 18px; height: 16px; padding: 0 3px; border-radius: 4px;
  font-family: var(--mono); font-size: var(--fs-11); font-weight: var(--fw-strong); letter-spacing: var(--track-display); line-height: 1;
  color: var(--text-3); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
.w3-tg-num, .w3-tg-text, .w3-tg-date, .w3-tg-bool, .w3-tg-obj { color: var(--text-3); }



.w3-tg svg { width: 10px; height: 10px; }

/* ---- engine badges ---- */
.w3-eng {
  --eng: var(--text-2);
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 20px; height: 20px;
  color: var(--text-3); background: none;
}
.w3-eng svg { width: 16px; height: 16px; }
.w3-eng-lg { width: 24px; height: 24px; }
.w3-eng-lg svg { width: 20px; height: 20px; }








@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .w3-eng-postgres { --eng: #7EA6D8; } }
:root[data-theme="dark"] .w3-eng-postgres { --eng: #7EA6D8; }

/* ---- SQL token colours (worksheet overlay, chat blocks, history) ---- */
.tk-kw { color: var(--tk-kw); font-weight: var(--fw-med); }
.tk-fn { color: var(--tk-fn); }
.tk-str { color: var(--tk-str); }
.tk-num { color: var(--tk-num); }
.tk-com { color: var(--tk-com); font-style: italic; }
.tk-id { color: var(--tk-id); }
.w3-codeblock {
  margin: 0; padding: 12px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line);
  font-family: var(--mono); font-size: var(--fs-13); line-height: 20px; white-space: pre; overflow-x: auto; color: var(--text); tab-size: 2;
}
.w3-md .w3-codeblock { margin: 4px 0 12px; }

/* ---- result grid (worksheets, previews, table tiles) ---- */
.w3-grid { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; }
.w3-grid th, .w3-grid td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.w3-grid td { height: 34px; padding: 0 14px; font-variant-numeric: tabular-nums; font-size: var(--fs-13); }
.w3-grid td.num { font-family: var(--mono); font-size: var(--fs-12); }
.w3-grid th { height: 36px; padding: 0 14px; position: sticky; top: 0; z-index: 2; }
.w3-grid th:hover { background: var(--surface-3); }
.w3-grid .w3-th { display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; vertical-align: middle; }
.w3-grid th.num .w3-th { flex-direction: row-reverse; }
.w3-grid .w3-th-n { overflow: hidden; text-overflow: ellipsis; font-weight: var(--fw-strong); color: var(--text); font-size: var(--fs-12); }
.w3-grid th { position: sticky; }
.w3-col-rs { position: absolute; top: 6px; bottom: 6px; right: 0; width: 7px; cursor: col-resize; z-index: 3; }
.w3-col-rs::after { content: ""; position: absolute; top: 0; bottom: 0; right: 3px; width: 1px; background: var(--line-strong); opacity: 0; transition: opacity .12s, background .12s; }
.w3-grid th:hover .w3-col-rs::after { opacity: 1; }
.w3-col-rs:hover::after, .w3-col-rs.active::after { opacity: 1; background: var(--accent); width: 2px; right: 2px; }
body.w3-col-resizing, body.w3-col-resizing * { cursor: col-resize !important; user-select: none !important; }
.w3-grid .w3-rn {
  width: 1%; min-width: 44px; color: var(--text-3); text-align: right; font-size: var(--fs-11); font-family: var(--mono);
  padding: 0 10px 0 8px !important; background: var(--surface); position: sticky; left: 0; z-index: 1; border-right: 1px solid var(--line);
}
.w3-grid th.w3-rn { background: var(--surface-2); z-index: 3; }
.w3-grid tbody tr:hover td { background: var(--row-hover); }
.w3-grid tbody tr:hover td.w3-rn { color: var(--text-2); }
.w3-grid .null-val { color: var(--text-3); font-style: italic; font-family: var(--mono); font-size: var(--fs-12); }
.w3-grid-wrap { flex: 1 1 auto; min-height: 0; }

/* ---- charts ---- */
.w3-chart { position: relative; flex: 1 1 auto; width: 100%; height: 100%; min-height: 200px; overflow: hidden; touch-action: pan-y; }
.w3-chart > svg { position: absolute; left: 0; top: 0; display: block; overflow: visible; }
.w3-cg { stroke: var(--line); stroke-width: 1; shape-rendering: crispEdges; }
.w3-cg0 { stroke: var(--line-strong); }
.w3-ct { fill: var(--text-3); font-family: var(--font); font-size: var(--fs-11); font-variant-numeric: tabular-nums; }
.w3-bar { transition: opacity .12s var(--w3-ease); }
.w3-chart.w3-hovering .w3-bar:not(.on) { opacity: .42; }
.w3-hband { fill: var(--text); opacity: 0; transition: opacity .12s; }
.w3-chart-bar.w3-hovering .w3-hband { opacity: .035; }
.w3-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.w3-pt { stroke-width: 1.5; }
.w3-hx { stroke: var(--line-strong); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; }
.w3-hdot { opacity: 0; stroke: var(--surface); stroke-width: 2.5; transition: opacity .1s; }
.w3-chart.w3-hovering .w3-hx, .w3-chart.w3-hovering .w3-hdot { opacity: 1; }
.w3-chart-tip {
  position: absolute; z-index: 4; pointer-events: none; display: flex; flex-direction: column; gap: 2px; min-width: 96px; max-width: 240px;
  padding: 7px 10px; border-radius: 8px; background: var(--ink-900, #0B1220); color: #fff; box-shadow: var(--shadow-pop);
  font-size: var(--fs-12); line-height: 16px; white-space: nowrap;
}
.w3-chart-tip[hidden] { display: none; }
.w3-tip-l { color: rgba(255, 255, 255, .64); font-size: var(--fs-11); overflow: hidden; text-overflow: ellipsis; }
.w3-tip-v { display: flex; align-items: center; gap: 6px; }
.w3-tip-v i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.w3-tip-k { color: rgba(255, 255, 255, .8); overflow: hidden; text-overflow: ellipsis; }
.w3-tip-v b { margin-left: auto; padding-left: 10px; font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; }
.w3-chart-note, .chart-note.w3-chart-note { font-size: var(--fs-12); color: var(--text-3); padding-top: 6px; text-align: right; }

/* ---- number tile ---- */
.w3-num { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; height: 100%; min-width: 0; text-align: left; }
.w3-num-v {
  font-size: var(--fs-28); line-height: 36px; font-weight: var(--fw-strong); letter-spacing: var(--track-display); color: var(--text);
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.w3-num-empty { color: var(--text-3); }
.w3-num-l { font-size: var(--fs-12); line-height: 18px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- tile footer (also in the tile preview modal) ---- */
.w3-tile-foot {
  display: flex; align-items: center; gap: 0; min-height: 34px; padding: 0 16px; border-top: 1px solid var(--line);
  font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden;
}
.w3-tile-foot:empty { display: none; }
.w3-tile-run { display: inline-flex; align-items: center; gap: 0; }
.w3-tile-run .spinner { width: 10px; height: 10px; border-width: 1.5px; margin-right: 7px; }
.w3-grow { flex: 1 1 auto; }

/* ---- tile preview inside the Add/Edit tile modal ---- */
.w3-tile-preview { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; padding: 0; min-height: 0; }
.w3-prev-idle { display: flex; align-items: center; justify-content: center; gap: 8px; height: 64px; font-size: var(--fs-13); color: var(--text-3); }
.w3-prev-body { display: flex; flex-direction: column; height: 260px; padding: 14px 16px 10px; }
.w3-prev-body.w3-tile-number { height: 140px; }
.w3-prev-body.w3-tile-table { padding: 0; height: auto; max-height: 320px; overflow: auto; }
.w3-prev-body .dtable-wrap { border: 0; border-radius: 0; }
.w3-tile-preview > .w3-errbox { margin: 12px; }

/* ---- logomark + live arcs ---- */
.w3-mark { display: block; flex: 0 0 auto; }




/* ---- scope menu (chat) ---- */
.menu.w3-scope-menu { min-width: 220px; }
.w3-menu-eyebrow { font-size: var(--fs-12); font-weight: var(--fw-med); letter-spacing: 0; text-transform: none; color: var(--text-3); }
.menu.w3-scope-menu .menu-item { position: relative; padding-right: 32px; }
.w3-menu-sel { color: var(--text); font-weight: var(--fw-strong); }
.w3-menu-check { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); display: inline-flex; color: var(--accent); }

/* ============================================================
   SHARED VIEW BITS
   ============================================================ */
#view-sources .w3-muted, #view-worksheets .w3-muted, #view-chat .w3-muted, #view-dashboards .w3-muted { color: var(--text-3); }
#view-sources .w3-err, #view-worksheets .w3-err { color: var(--err); }
#view-worksheets .w3-ok { color: var(--ok); }
#view-sources .w3-count, #view-dashboards .w3-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 999px;
  font-size: var(--fs-11); font-weight: var(--fw-strong); color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); font-variant-numeric: tabular-nums;
}
#view-sources .w3-count:empty { display: none; }

/* pane head: 48px everywhere so adjacent panes line up */
#view-sources .w3-phead { height: 48px; min-height: 48px; flex: 0 0 48px; padding: 0 12px 0 16px; gap: 8px; border-bottom: 1px solid var(--line); }
#view-sources .w3-phead .pane-title { font-size: var(--fs-13); font-weight: var(--fw-strong); }

/* status dots */
.w3-sdot { display: inline-block; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: transparent; box-shadow: inset 0 0 0 1px var(--text-3); }
.w3-sdot-ok { background: var(--ok); box-shadow: none; }
.w3-sdot-info { background: var(--info); box-shadow: none; }
.w3-sdot-warn { background: var(--warn); box-shadow: none; }
.w3-sdot-err { background: var(--err); box-shadow: none; }

/* filter input with leading icon (pane tops) */
#view-sources .w3-filter, #view-worksheets .w3-filter, #view-dashboards .w3-filter, #view-chat .w3-filter {
  position: relative; display: flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 10px 12px; border-bottom: 1px solid var(--line); min-width: 0;
}
#view-dashboards .w3-filter-inline { padding: 0; border: 0; width: 280px; max-width: 100%; }
#view-sources .w3-filter-ico, #view-worksheets .w3-filter-ico, #view-dashboards .w3-filter-ico, #view-chat .w3-filter-ico {
  position: absolute; left: 22px; top: 50%; transform: translateY(-50%); color: var(--text-3); display: inline-flex; pointer-events: none;
}
#view-dashboards .w3-filter-inline .w3-filter-ico { left: 10px; }
#view-sources .w3-filter input, #view-worksheets .w3-filter input, #view-dashboards .w3-filter input, #view-chat .w3-filter input {
  flex: 1 1 auto; width: 100%; height: 32px; padding-left: 30px; font-size: var(--fs-13); border-radius: 8px;
}
#view-worksheets .w3-filter-btn { width: 32px; height: 32px; flex: 0 0 32px; }

/* row hover-action button (⋯ / trash / re-run) */
#view-sources .w3-row-menu, #view-worksheets .w3-row-menu, #view-dashboards .w3-row-menu {
  display: inline-grid; place-items: center; flex: 0 0 auto; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px;
  background: transparent; color: var(--text-3); opacity: 0; cursor: pointer;
  transition: opacity .12s var(--w3-ease), background .12s var(--w3-ease), color .12s var(--w3-ease), transform .12s var(--w3-ease);
}
#view-sources .w3-row-menu:hover, #view-worksheets .w3-row-menu:hover, #view-dashboards .w3-row-menu:hover { background: var(--surface-3); color: var(--text); }
#view-sources .w3-row-menu:active, #view-worksheets .w3-row-menu:active, #view-dashboards .w3-row-menu:active { transform: scale(.98); }
#view-sources .w3-row-menu:focus-visible, #view-worksheets .w3-row-menu:focus-visible, #view-dashboards .w3-row-menu:focus-visible { opacity: 1; outline: none; box-shadow: var(--ring); }
#view-worksheets .ws-del:hover, #view-dashboards .dash-del:hover { color: var(--err); background: var(--err-soft); }
#view-sources .w3-src-row:hover .w3-row-menu, #view-sources .w3-src-row.selected .w3-row-menu, #view-sources .w3-src-row:focus-within .w3-row-menu,
#view-worksheets .w3-ws-item:hover .w3-row-menu, #view-worksheets .w3-ws-item.selected .w3-row-menu, #view-worksheets .w3-ws-item:focus-within .w3-row-menu,
#view-dashboards tr:hover .w3-row-menu, #view-dashboards tr:focus-within .w3-row-menu,
#view-dashboards .w3-tile:hover .w3-row-menu, #view-dashboards .w3-tile:focus-within .w3-row-menu, #view-dashboards .w3-row-menu.w3-spin { opacity: 1; }
@media (hover: none) {
  #view-sources .w3-row-menu, #view-worksheets .w3-row-menu, #view-dashboards .w3-row-menu { opacity: 1; }
}

/* chevrons */
.w3-chev {
  display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 16px; height: 16px; color: var(--text-3);
  transition: transform .18s var(--w3-ease), color .12s;
}
.w3-chev.open { transform: rotate(90deg); }

/* eyebrow / crumbs above titles */
#view-sources .w3-eyebrow, #view-dashboards .w3-eyebrow {
  display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); line-height: 18px; color: var(--text-3); margin-bottom: 2px; min-width: 0;
}
#view-sources .w3-crumb, #view-dashboards .w3-crumb {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; border: 0; background: transparent; padding: 0 4px; margin-left: -4px;
  font: inherit; font-size: var(--fs-12); color: var(--text-2); cursor: pointer; border-radius: 4px; transition: color .12s, background .12s;
}
#view-sources .w3-crumb:hover, #view-dashboards .w3-crumb:hover { color: var(--accent); background: var(--accent-soft); }
#view-sources .w3-crumb-sep { color: var(--line-strong); }

/* clickable table rows */
#view-sources .w3-cell-ico, #view-dashboards .w3-dash-ico { display: inline-grid; place-items: center; width: 16px; height: 16px; vertical-align: middle; margin-right: 10px; color: var(--text-3); background: none; }
#view-sources .w3-link, #view-dashboards .w3-link { color: var(--text); font-weight: var(--fw-med); vertical-align: middle; }
#view-sources .w3-click-table td, #view-dashboards .w3-click-table td { height: 44px; }
#view-sources tr.clickable, #view-dashboards tr.clickable { cursor: pointer; }
#view-sources tr.clickable:hover .w3-link, #view-dashboards tr.clickable:hover .w3-link { color: var(--accent); }
#view-sources tr.clickable:hover .w3-cell-ico, #view-dashboards tr.clickable:hover .w3-dash-ico { color: var(--text-2); }
#view-sources .w3-act-col, #view-dashboards .w3-act-col { width: 1%; text-align: right; white-space: nowrap; padding-right: 10px !important; }
#view-sources .w3-act-col > *, #view-dashboards .w3-act-col > * { vertical-align: middle; }
.w3-row-go { display: inline-flex; color: var(--text-3); opacity: 0; transform: translateX(-4px); transition: opacity .12s, transform .12s var(--w3-ease); margin-left: 4px; }
tr:hover > td > .w3-row-go, tr:focus-visible > td > .w3-row-go { opacity: 1; transform: none; color: var(--accent); }

/* ============================================================
   SOURCES
   ============================================================ */
#view-sources .w3-src { flex: 1 1 auto; min-height: 0; }
#view-sources .w3-src-left { flex: 0 0 288px; width: 288px; background: var(--surface); }
#view-sources .w3-src-list { padding: 6px 0 16px; }
#view-sources .w3-src-detail { background: var(--bg); }

/* source rows */
#view-sources .w3-src-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 6px 8px 6px 8px; border: 0;
  background: transparent; color: var(--text); cursor: pointer; text-align: left; position: relative; box-shadow: none; border-radius: 0;
  transition: background .12s var(--w3-ease);
}
#view-sources .w3-src-row:hover { background: var(--surface-2); }
#view-sources .w3-src-row:active { background: var(--surface-3); }
#view-sources .w3-src-row.selected { background: var(--accent-soft); }
#view-sources .w3-src-row.selected::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 0 2px 2px 0; background: var(--accent); }
#view-sources .w3-src-row:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-sources .w3-src-row.selected .w3-chev { color: var(--accent); }
#view-sources .w3-src-text { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
#view-sources .w3-src-name { font-size: var(--fs-13); font-weight: var(--fw-strong); line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-sources .w3-src-meta { font-size: var(--fs-12); color: var(--text-3); line-height: 16px; font-variant-numeric: tabular-nums; }

/* inline object tree with indent guides */
#view-sources .w3-tree { padding: 2px 0 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
#view-sources .w3-tree-inner, #view-worksheets .w3-tree-inner { padding: 0; font-size: var(--fs-13); }
#view-sources .w3-tnode, #view-worksheets .w3-tnode {
  display: flex; align-items: center; gap: 6px; width: 100%; height: 30px; padding: 0 12px 0 26px;
  border: 0; border-radius: 0; background-color: transparent; color: var(--text); text-align: left;
  font-family: var(--font); font-size: var(--fs-13); font-weight: 400; cursor: pointer; min-width: 0; position: relative;
  background-repeat: no-repeat; transition: background-color .12s var(--w3-ease);
}
#view-sources button.w3-tnode:hover, #view-worksheets button.w3-tnode:hover { background-color: var(--surface-2); }
#view-sources button.w3-tnode:active, #view-worksheets button.w3-tnode:active { background-color: var(--surface-3); }
#view-sources button.w3-tnode:focus-visible, #view-worksheets button.w3-tnode:focus-visible, #view-worksheets .w3-ins:focus-visible, #view-worksheets .w3-chev-btn:focus-visible {
  outline: none; box-shadow: var(--ring-inset);
}
.w3-tico { display: inline-flex; color: var(--text-3); flex: 0 0 auto; }
#view-sources .w3-tname, #view-worksheets .w3-tname { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-sources .w3-tnode .rowcount, #view-worksheets .w3-tnode .rowcount {
  margin-left: auto; padding-left: 8px; color: var(--text-3); font-size: var(--fs-11); font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
#view-sources .w3-tschema { color: var(--text-2); font-weight: var(--fw-med); }
#view-sources .w3-ttable {
  padding-left: 40px;
  background-image: linear-gradient(var(--line-strong), var(--line-strong)); background-size: 1px 100%; background-position: 33px 0;
}
#view-sources .tree-table.selected { background-color: var(--accent-soft); color: var(--accent); font-weight: var(--fw-strong); }
#view-sources .tree-table.selected .w3-tico, #view-sources .tree-table.selected .rowcount, #view-sources .tree-table.selected .w3-chev { color: var(--accent); }
#view-sources .w3-tcol, #view-worksheets .w3-tcol {
  cursor: default; height: 26px; padding-left: 62px; font-family: var(--mono); font-size: var(--fs-12); color: var(--text-2); gap: 8px;
  background-image: linear-gradient(var(--line-strong), var(--line-strong)), linear-gradient(var(--line), var(--line));
  background-size: 1px 100%, 1px 100%; background-position: 33px 0, 49px 0;
}
#view-sources .w3-tcol.w3-last { background-size: 1px 100%, 1px 50%; }
#view-sources .w3-ttype, #view-worksheets .w3-ttype { margin-left: auto; color: var(--text-3); font-size: var(--fs-11); flex: 0 0 auto; padding-left: 8px; }
#view-sources .w3-tree-note, #view-worksheets .w3-tree-note { display: flex; align-items: center; gap: 6px; padding: 7px 12px 7px 40px; font-size: var(--fs-12); color: var(--text-3); }
#view-sources .w3-ind2 { padding-left: 56px; }

/* detail pane */
#view-sources .w3-detail-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; animation: w3-fade-in .16s var(--w3-ease); }
#view-sources .w3-detail-empty { display: flex; align-items: center; justify-content: center; padding: 24px; }
#view-sources .w3-page { padding: 24px 32px 40px; max-width: 1120px; }
#view-sources .w3-dhead { display: flex; align-items: center; gap: 14px; padding: 0; margin-bottom: 24px; }
#view-sources .w3-dhead .page-head-text { flex: 1 1 auto; min-width: 0; }
#view-sources .w3-page .page-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-20); line-height: var(--lh-20); letter-spacing: var(--track-display); }
#view-sources .page-sub { display: flex; align-items: center; flex-wrap: wrap; white-space: normal; font-size: var(--fs-13); color: var(--text-2); margin-top: 2px; }
#view-sources .w3-section { margin-bottom: 28px; min-width: 0; }
#view-sources .w3-h2 { font-size: var(--fs-14); line-height: 22px; font-weight: var(--fw-strong); color: var(--text); margin: 0 0 10px; }
#view-sources .w3-sec-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
#view-sources .w3-sec-head .w3-h2 { margin: 0; }
#view-sources .w3-mstrip { margin-bottom: 28px; }
#view-sources .w3-mstrip .metric-value { min-height: 30px; display: flex; align-items: center; }
#view-sources .w3-mstrip .w3-mv-sm { font-size: var(--fs-16); font-weight: var(--fw-strong); }
#view-sources .w3-kv {
  grid-template-columns: 160px minmax(0, 1fr); padding: 4px 16px; margin: 0; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05)); column-gap: 16px; row-gap: 0;
}
#view-sources .w3-kv dt, #view-sources .w3-kv dd { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: 0; padding: 6px 0; border-bottom: 1px solid var(--line); }
#view-sources .w3-kv dt { font-size: var(--fs-13); color: var(--text-2); }
#view-sources .w3-kv dd { font-size: var(--fs-13); color: var(--text); min-width: 0; }
#view-sources .w3-kv dt:nth-last-of-type(1), #view-sources .w3-kv dd:last-of-type { border-bottom: 0; }
#view-sources .w3-kv dd > svg { color: var(--ok); flex: 0 0 auto; }
#view-sources .w3-kv code { font-size: var(--fs-12); background: var(--surface-2); padding: 2px 6px; border-radius: 6px; color: var(--text); overflow-wrap: anywhere; }
#view-sources .w3-kv-eng { display: inline-flex; align-items: center; gap: 8px; }
#view-sources .w3-kv-eng .w3-eng { width: 22px; height: 22px; border-radius: 6px; }
#view-sources .w3-kv-copy { width: 28px; height: 28px; margin-left: 2px; color: var(--text-3); }
#view-sources .w3-kv-copy:hover { color: var(--text); }
#view-sources .w3-break code { word-break: break-all; }
#view-sources .w3-st { display: inline-flex; align-items: center; gap: 7px; font-weight: var(--fw-med); color: var(--text); }
#view-sources .w3-tag {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; margin-left: 8px; border-radius: 6px;
  font-size: var(--fs-11); font-weight: var(--fw-strong); letter-spacing: var(--track-code); color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line);
}
#view-sources .w3-danger-ico:hover, #view-dashboards .w3-danger-ico:hover { color: var(--err); background: var(--err-soft); border-color: color-mix(in srgb, var(--err) 30%, var(--line-strong)); }
#view-sources .w3-section > .empty { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; max-width: none; }

/* upload (uploads source overview only) */
#view-sources .w3-upload-wrap { padding: 0; border: 0; }
#view-sources .w3-upload-zone {
  background: var(--surface); padding: 16px; border-radius: 8px; border: 1px dashed var(--line-strong);
  transition: border-color .12s, background .12s; cursor: pointer;
}
#view-sources .w3-upload-zone:hover, #view-sources .w3-upload-zone.drag { border-color: var(--accent); background: var(--surface-2); }
#view-sources .w3-upload-zone:focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--accent); }
#view-sources .w3-upload-zone.w3-uploading { opacity: .7; pointer-events: none; }
#view-sources .w3-upload-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; color: var(--text-3); flex: 0 0 auto; }
#view-sources .w3-upload-zone:hover .w3-upload-ico, #view-sources .w3-upload-zone.drag .w3-upload-ico { color: var(--accent); }
#view-sources .upload-row .text-input { height: 32px; max-width: 420px; border-radius: 8px; }
#view-sources .w3-upl-prog { display: flex; align-items: center; gap: 0; font-size: var(--fs-13); color: var(--text-2); margin-top: 10px; }

/* table detail: fixed head + tabs, scrolling body */
#view-sources .w3-tdetail { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; background: var(--bg); animation: w3-fade-in .16s var(--w3-ease); }
#view-sources .w3-thead { flex: 0 0 auto; padding: 20px 32px 0; margin: 0 0 12px; align-items: center; }
#view-sources .w3-thead .page-title { font-size: var(--fs-20); line-height: 28px; letter-spacing: var(--track-heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-sources .w3-mono-title { font-family: var(--mono); font-weight: var(--fw-strong); }
#view-sources .w3-tbadge { display: inline-grid; place-items: center; width: 24px; height: 24px; flex: 0 0 auto; color: var(--text-3); background: none; }
#view-sources .w3-ptabs { padding: 0 28px; margin: 0; flex: 0 0 auto; }
#view-sources .w3-tabn { display: inline-grid; place-items: center; min-width: 18px; height: 16px; margin-left: 6px; font-size: var(--fs-11); font-weight: var(--fw-strong); color: var(--text-2); background: var(--surface-2); border-radius: 999px; padding: 0 5px; font-variant-numeric: tabular-nums; }
#view-sources .ptab.active .w3-tabn { color: var(--text); background: var(--surface-3); }
#view-sources .w3-tabn:empty { display: none; }
#view-sources .w3-tbody { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 20px 32px 32px; display: flex; flex-direction: column; }
#view-sources .w3-tbody > .dtable-wrap, #view-sources #src-preview { min-height: 0; }
#view-sources #src-preview { display: flex; flex-direction: column; flex: 1 1 auto; }
#view-sources #src-preview > .w3-fade { display: flex; flex-direction: column; min-height: 0; flex: 0 1 auto; }
#view-sources #src-preview .dtable-wrap { flex: 0 1 auto; min-height: 0; overflow: auto; }
#view-sources .w3-ident { font-family: var(--mono); font-size: var(--fs-13); background: transparent; padding: 0; color: var(--text); }
#view-sources .w3-colname { display: inline-flex; align-items: center; gap: 10px; }
#view-sources .w3-cols-table td { height: 40px; }
#view-sources .w3-type { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; font-family: var(--mono); font-size: var(--fs-12); color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
#view-sources .w3-meta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0; min-height: 20px; font-size: var(--fs-12); color: var(--text-2); margin-bottom: 12px; font-variant-numeric: tabular-nums; }
#view-sources .w3-meta-row strong { color: var(--text); font-weight: var(--fw-strong); }

/* knowledge list */
#view-sources .w3-kb-list { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05)); }
#view-sources .w3-kb-row {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; color: var(--text); cursor: pointer; font: inherit; transition: background .12s;
}
#view-sources .w3-kb-row:last-child { border-bottom: 0; }
#view-sources .w3-kb-row:hover { background: var(--surface-2); }
#view-sources .w3-kb-row:active { background: var(--surface-3); }
#view-sources .w3-kb-row:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-sources .w3-kb-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; color: var(--text-3); flex: 0 0 auto; }
#view-sources .w3-kb-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }
#view-sources .w3-kb-title { font-weight: var(--fw-strong); font-size: var(--fs-13); line-height: 20px; }
#view-sources .w3-kb-snip { font-size: var(--fs-13); line-height: 18px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-sources .w3-kb-meta { display: flex; align-items: center; flex-wrap: wrap; font-size: var(--fs-12); line-height: 16px; color: var(--text-3); margin-top: 2px; }
#view-sources .w3-kb-go { color: var(--text-3); flex: 0 0 auto; padding-top: 6px; opacity: 0; transition: opacity .12s; }
#view-sources .w3-kb-row:hover .w3-kb-go, #view-sources .w3-kb-row:focus-visible .w3-kb-go { opacity: 1; color: var(--accent); }

/* ============================================================
   WORKSHEETS
   ============================================================ */
#view-worksheets .w3-ws { flex: 1 1 auto; min-height: 0; }
#view-worksheets .w3-ws-left { flex: 0 0 264px; width: 264px; background: var(--surface); }
#view-worksheets .w3-ws-ltabs { flex: 0 0 48px; height: 48px; padding: 0 8px; margin: 0; align-items: stretch; }
#view-worksheets .w3-ws-ltabs > button { height: 48px; flex: 1 1 0; justify-content: center; }
#view-worksheets .w3-lbody { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#view-worksheets .w3-lbody[hidden] { display: none; }
#view-worksheets .w3-lbody .pane-body { padding: 6px 0 16px; }
#view-worksheets .w3-obj-hint { font-size: var(--fs-12); color: var(--text-3); padding: 8px 14px 2px; }

#view-worksheets .w3-ws-item {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 8px 6px 14px; border: 0; cursor: pointer; position: relative;
  transition: background .12s var(--w3-ease);
}
#view-worksheets .w3-ws-item:hover { background: var(--surface-2); }
#view-worksheets .w3-ws-item:active { background: var(--surface-3); }
#view-worksheets .w3-ws-item.selected { background: var(--accent-soft); box-shadow: none; }
#view-worksheets .w3-ws-item.selected::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px; border-radius: 0 2px 2px 0; background: var(--accent); }
#view-worksheets .w3-ws-item:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-worksheets .w3-ws-ico { display: inline-grid; place-items: center; width: 20px; height: 20px; color: var(--text-3); background: none; flex: 0 0 auto; }
#view-worksheets .w3-ws-item.selected .w3-ws-ico { color: var(--text-2); background: none; }
#view-worksheets .ws-item-body { display: flex; flex-direction: column; min-width: 0; flex: 1 1 auto; }
#view-worksheets .ws-item-name { font-size: var(--fs-13); font-weight: var(--fw-med); line-height: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
#view-worksheets .ws-item-meta { display: flex; align-items: center; font-size: var(--fs-12); line-height: 16px; color: var(--text-3); white-space: nowrap; overflow: hidden; }

/* object browser */
#view-worksheets .w3-tsrc { padding-left: 10px; font-weight: var(--fw-strong); height: 34px; gap: 8px; }
#view-worksheets .w3-tsrc .w3-eng { width: 20px; height: 20px; border-radius: 6px; }
#view-worksheets .w3-tsrc .w3-eng svg { width: 12px; height: 12px; }
#view-worksheets .w3-tsrc .w3-sdot { margin-left: auto; }
#view-worksheets .w3-dim { color: var(--text-3); }
#view-worksheets .w3-tschema.w3-ind1 { padding-left: 26px; color: var(--text-2);
  background-image: linear-gradient(var(--line), var(--line)); background-size: 1px 100%; background-position: 17px 0; }
#view-worksheets div.w3-ind1 { padding-left: 26px; }
#view-worksheets .w3-ttable.w3-ind2 { padding: 0 8px 0 36px; gap: 2px; cursor: default;
  background-image: linear-gradient(var(--line), var(--line)), linear-gradient(var(--line-strong), var(--line-strong));
  background-size: 1px 100%, 1px 100%; background-position: 17px 0, 33px 0; }
#view-worksheets .w3-chev-btn {
  display: inline-grid; place-items: center; width: 20px; height: 24px; padding: 0; border: 0; background: transparent; border-radius: 4px; cursor: pointer; flex: 0 0 auto;
}
#view-worksheets .w3-chev-btn:hover { background: var(--surface-3); }
#view-worksheets .w3-ins {
  display: flex; align-items: center; gap: 6px; flex: 1 1 auto; min-width: 0; height: 26px; padding: 0 6px; border: 0; border-radius: 6px;
  background: transparent; color: var(--text); font: inherit; font-size: var(--fs-13); cursor: copy; text-align: left; transition: background .12s, color .12s;
}
#view-worksheets .w3-ins:hover { background: var(--accent-soft); color: var(--accent); }
#view-worksheets .w3-ins:hover .w3-tico { color: var(--accent); }
#view-worksheets .w3-ins:active { background: var(--surface-3); transform: none; }
#view-worksheets .w3-tcol.w3-ind3 { padding-left: 62px; cursor: copy; height: 26px; border-radius: 0;
  background-image: linear-gradient(var(--line), var(--line)), linear-gradient(var(--line-strong), var(--line-strong)), linear-gradient(var(--line), var(--line));
  background-size: 1px 100%, 1px 100%, 1px 100%; background-position: 17px 0, 33px 0, 49px 0; }
#view-worksheets .w3-tcol.w3-ins:hover { background-color: var(--accent-soft); }
#view-worksheets .w3-tree-note.w3-ind1 { padding-left: 40px; }

/* main: toolbar + editor/results */
#view-worksheets .w3-ws-main { background: var(--surface); }
#view-worksheets .w3-ws-bar { flex: 0 0 48px; height: 48px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--line); flex-wrap: nowrap; gap: 8px; min-height: 48px; }
#view-worksheets .w3-ws-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; flex: 0 1 auto; font-size: var(--fs-14); font-weight: var(--fw-strong); color: var(--text); }
#view-worksheets .w3-ws-name-ico { display: inline-flex; color: var(--text-3); }
#view-worksheets #ws-cur-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
#view-worksheets .w3-dirty { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
#view-worksheets .w3-src-pick { position: relative; display: inline-flex; align-items: center; flex: 0 1 auto; min-width: 0; margin-left: 4px; color: var(--text-3); }
#view-worksheets .w3-src-pick > svg { position: absolute; left: 10px; pointer-events: none; }
#view-worksheets .w3-src-pick select { padding-left: 30px; max-width: 220px; height: 32px; border-radius: 8px; font-weight: var(--fw-med); }
#view-worksheets .w3-ws-status { display: inline-flex; align-items: center; gap: 5px; font-size: var(--fs-12); color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
#view-worksheets .w3-ws-status .spinner { width: 11px; height: 11px; border-width: 1.5px; margin-right: 3px; }
#view-worksheets .w3-ws-status svg { vertical-align: -2px; }
#view-worksheets .w3-ws-status .w3-err, #view-worksheets .w3-ws-status .w3-ok { display: inline-flex; align-items: center; gap: 3px; }
#view-worksheets .w3-run { min-width: 76px; }
#view-worksheets .w3-ws-v { flex: 1 1 auto; min-height: 0; }

/* editor: highlighted <pre> under a transparent textarea */
#view-worksheets .w3-editor { display: flex; flex: 0 0 42%; min-height: 80px; background: var(--surface); overflow: hidden; position: relative; }
#view-worksheets .w3-lines {
  flex: 0 0 auto; min-width: 52px; padding: 12px 0; overflow: hidden; user-select: none;
  font-family: var(--mono); font-size: var(--fs-12); line-height: 20px; color: var(--text-3); background: var(--surface-2); border-right: 1px solid var(--line);
}
#view-worksheets .w3-lines > div { height: 20px; padding: 0 14px 0 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-3); }
#view-worksheets .w3-editor.w3-focus .w3-lines > div.on { color: var(--text); opacity: 1; font-weight: var(--fw-strong); }
#view-worksheets .w3-code { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; }
#view-worksheets .w3-activeline {
  position: absolute; left: 0; right: 0; top: 0; height: 20px; background: var(--w3-hl-band); pointer-events: none; opacity: 0; transition: opacity .12s;
  box-shadow: none;
}
#view-worksheets .w3-editor.w3-focus .w3-activeline { opacity: 1; }
#view-worksheets .w3-hl, #view-worksheets .w3-sql {
  font-family: var(--mono); font-size: var(--fs-13); line-height: 20px; tab-size: 2; letter-spacing: 0; font-variant-ligatures: none;
  padding: 12px 16px 24px; margin: 0; border: 0; white-space: pre; word-wrap: normal;
}
#view-worksheets .w3-hl {
  position: absolute; left: 0; top: 0; min-width: 100%; pointer-events: none; color: var(--text); background: transparent; overflow: visible; border-radius: 0;
}
#view-worksheets .w3-hl code { font: inherit; background: none; padding: 0; color: inherit; }
#view-worksheets .w3-sql {
  position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border-radius: 0; box-shadow: none; outline: none;
  color: transparent; background: transparent; caret-color: var(--text); overflow: auto; z-index: 1;
}
#view-worksheets .w3-sql::selection { background: var(--w3-sel); color: transparent; }
#view-worksheets .w3-sql::placeholder { color: var(--text-3); opacity: 1; }
#view-worksheets .w3-sql:focus { outline: none; box-shadow: none; border: 0; }
#view-worksheets .gutter { flex: 0 0 7px; height: 7px; background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); cursor: row-resize; position: relative; transition: background .12s; }
#view-worksheets .gutter::after { content: ""; position: absolute; left: 50%; top: 2px; width: 32px; height: 1px; margin-left: -16px; border-radius: 1px; background: var(--line-strong); box-shadow: 0 2px 0 var(--line-strong); opacity: .9; top: 1px; }
#view-worksheets .gutter:hover, #view-worksheets .gutter.dragging { background: var(--accent-soft); }
#view-worksheets .gutter:focus-visible { outline: none; box-shadow: var(--ring-inset); }

#view-worksheets .w3-res { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 120px; background: var(--surface); }
#view-worksheets .w3-res-head { display: flex; align-items: center; gap: 10px; flex: 0 0 40px; height: 40px; padding: 0 12px 0 0; border-bottom: 1px solid var(--line); }
#view-worksheets .w3-res-tabs { padding: 0 8px; margin: 0; border-bottom: 0; align-self: stretch; align-items: stretch; }
#view-worksheets .w3-res-tabs > button { height: 40px; }
#view-worksheets .w3-res-meta { font-size: var(--fs-12); color: var(--text-2); display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums; }
#view-worksheets #ws-error:not(:empty) { padding: 12px 12px 0; }
#view-worksheets .w3-res-body { flex: 1 1 auto; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
#view-worksheets .w3-res-body[hidden] { display: none; }
#view-worksheets .w3-res-fill { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#view-worksheets .w3-res-body .dtable-wrap { border: 0; border-radius: 0; flex: 1 1 auto; min-height: 0; overflow: auto; }
#view-worksheets .w3-res-body .dtable th { border-radius: 0; }
#view-worksheets .w3-res-body > .empty, #view-worksheets .w3-res-fill > .empty { margin: auto; }
#view-worksheets .w3-hist { display: flex; flex-direction: column; }
#view-worksheets .w3-hist-row {
  display: grid; grid-template-columns: 8px minmax(0, 1fr); column-gap: 12px; row-gap: 2px; align-items: center; padding: 10px 16px;
  border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; color: var(--text); font: inherit; transition: background .12s;
}
#view-worksheets .w3-hist-row:hover { background: var(--surface-2); }
#view-worksheets .w3-hist-row:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-worksheets .w3-hist-row .h-sql { font-family: var(--mono); font-size: var(--fs-12); line-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
#view-worksheets .w3-hist-row .h-meta { grid-column: 2; display: flex; align-items: center; font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; }
#view-worksheets .w3-statusline {
  display: flex; align-items: center; gap: 10px; flex: 0 0 28px; height: 28px; padding: 0 14px; border-top: 1px solid var(--line);
  font-size: var(--fs-12); color: var(--text-3); background: var(--surface); white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums;
}
#view-worksheets .w3-statusline > span { display: inline-flex; align-items: center; gap: 5px; }
#view-worksheets .w3-statusline svg { color: var(--ok); }
#view-worksheets .w3-sl-sep { width: 1px; height: 12px; background: var(--line-strong); }
#view-worksheets #ws-eng:empty + * , #view-worksheets #ws-eng:empty { display: none; }

/* ============================================================
   WHISPER CHAT
   ============================================================ */
#view-chat .w3-chat { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; background: var(--bg); position: relative; }
#view-chat .w3-chat-head {
  display: flex; align-items: center; gap: 10px; flex: 0 0 48px; height: 48px; padding: 0 12px 0 20px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
#view-chat .w3-chat-title { display: inline-flex; align-items: center; gap: 10px; font-size: var(--fs-14); font-weight: var(--fw-strong); letter-spacing: 0; color: var(--text); }
#view-chat .w3-chat-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 6px; font-size: var(--fs-12); font-weight: var(--fw-med);
  color: var(--text-2); background: var(--surface); border: 1px solid var(--line); cursor: default;
}
#view-chat .w3-chat-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }
#view-chat .w3-chat-col { max-width: 800px; margin: 0 auto; padding: 32px 24px 40px; display: flex; flex-direction: column; gap: 24px; min-height: 100%; }
#view-chat .w3-chat-col-empty { justify-content: center; }
#view-chat .w3-chat-errwrap { margin: auto 0; }

/* empty state */
#view-chat .w3-chat-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 0 24px; animation: w3-fade-in .24s var(--w3-ease); }
#view-chat .w3-hero-mark { display: inline-flex; }
#view-chat .w3-chat-hero { font-size: var(--fs-22); line-height: 28px; font-weight: var(--fw-strong); letter-spacing: var(--track-display); color: var(--text); margin: 16px 0 6px; }
#view-chat .w3-chat-lede { font-size: var(--fs-13); line-height: 20px; color: var(--text-2); max-width: 520px; margin: 0 0 24px; }
#view-chat .w3-suggest-label { align-self: flex-start; font-size: var(--fs-12); font-weight: var(--fw-med); letter-spacing: 0; text-transform: none; color: var(--text-3); margin-bottom: 10px; }
#view-chat .w3-suggest { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
#view-chat .w3-suggest-card {
  display: flex; align-items: flex-start; gap: 12px; min-height: 64px; padding: 12px 12px 12px 14px; text-align: left; position: relative;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05));
  font: inherit; font-size: var(--fs-13); line-height: 20px; cursor: pointer;
  transition: border-color .12s var(--w3-ease), box-shadow .12s var(--w3-ease), transform .12s var(--w3-ease);
}
#view-chat .w3-suggest-card:hover { border-color: var(--line-hover); background: var(--surface-2); }

#view-chat .w3-suggest-card:hover .w3-suggest-ico { color: var(--text-2); }
#view-chat .w3-suggest-card:focus-visible { outline: none; box-shadow: var(--ring); }
#view-chat .w3-suggest-ico { display: inline-grid; place-items: center; width: 16px; height: 20px; color: var(--text-3); flex: 0 0 auto; }
#view-chat .w3-suggest-text { padding-top: 0; min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
#view-chat .w3-suggest-go { display: inline-flex; color: var(--text-3); opacity: 0; transform: rotate(45deg) translate(-2px, 2px); padding-top: 2px; transition: opacity .12s; }
#view-chat .w3-suggest-card:hover .w3-suggest-go, #view-chat .w3-suggest-card:focus-visible .w3-suggest-go { opacity: 1; transform: rotate(45deg); }
#view-chat .w3-suggest-sk { cursor: default; align-items: center; }

/* messages */
#view-chat .w3-msg-user { align-self: flex-end; max-width: 78%; display: flex; }
#view-chat .w3-user-bubble {
  background: var(--surface); border: 1px solid var(--line); color: var(--text); border-radius: 8px 8px 4px 8px;
  padding: 10px 14px; font-size: var(--fs-14); line-height: 22px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05));
}
#view-chat .w3-fresh-user { animation: w3-fade-in .12s var(--w3-ease); }
#view-chat .w3-msg-bot { display: flex; gap: 14px; align-self: stretch; max-width: 100%; }
#view-chat .w3-msg-bot > .w3-mark { margin-top: 1px; }
#view-chat .w3-bot-body { flex: 1 1 auto; min-width: 0; padding-top: 3px; font-size: var(--fs-14); line-height: 24px; color: var(--text); }
#view-chat .w3-md p { margin: 0 0 12px; }
#view-chat .w3-md p:last-child { margin-bottom: 0; }
#view-chat .w3-md ul, #view-chat .w3-md ol { margin: 0 0 12px; padding-left: 22px; }
#view-chat .w3-md li { margin: 2px 0; padding-left: 2px; }
#view-chat .w3-md li::marker { color: var(--text-3); }
#view-chat .w3-md code { font-family: var(--mono); font-size: var(--fs-13); background: var(--surface-2); padding: 1px 5px; border-radius: 5px; box-shadow: inset 0 0 0 1px var(--line); }
#view-chat .w3-md .w3-codeblock code { box-shadow: none; padding: 0; background: none; }
#view-chat .w3-md strong { font-weight: var(--fw-strong); }
#view-chat .w3-md > p:first-child > strong:only-child { font-size: var(--fs-14); letter-spacing: 0; }

/* streaming-like reveal of a fresh answer */

/* thinking indicator */
#view-chat .w3-msg-think .w3-bot-body { padding-top: 4px; }
#view-chat .w3-think {
  display: inline-block; font-size: var(--fs-14); font-weight: var(--fw-med); line-height: 20px;
  color: var(--text-3);
}
#view-chat .w3-think::after { content: "…"; }
#view-chat .w3-think-in { animation: w3-fade-in .2s var(--w3-ease); }
#view-chat .w3-think-lines { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; max-width: 520px; opacity: .8; }

/* SQL block */
#view-chat .w3-sql-block { margin-top: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05)); }
#view-chat .w3-sql-block > summary {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 6px 0 10px; cursor: pointer; list-style: none;
  font-size: var(--fs-13); font-weight: var(--fw-strong); color: var(--text); user-select: none; transition: background .12s;
}
#view-chat .w3-sql-block > summary::-webkit-details-marker { display: none; }
#view-chat .w3-sql-block > summary:hover { background: var(--surface-2); }
#view-chat .w3-sql-block > summary:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-chat .w3-sql-block[open] > summary .w3-chev { transform: rotate(90deg); }
#view-chat .w3-sql-lbl { display: inline-flex; align-items: center; gap: 6px; }
#view-chat .w3-sql-lbl svg { color: var(--text-3); }
#view-chat .w3-sql-n { font-weight: 400; font-size: var(--fs-12); }
#view-chat .w3-sql-block > summary .btn { font-weight: var(--fw-med); height: 28px; }
#view-chat .w3-sql-block .w3-codeblock { border: 0; border-top: 1px solid var(--line); border-radius: 0; white-space: pre-wrap; word-break: break-word; }
#view-chat .w3-show-sm { display: none; }

/* citations */
#view-chat .w3-cites { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 14px; }
#view-chat .w3-cites-label { font-size: var(--fs-12); color: var(--text-3); margin-right: 4px; }
#view-chat .w3-cite {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 26px; max-width: 280px; padding: 0 10px 0 3px; border-radius: 999px;
  font-size: var(--fs-12); font-weight: var(--fw-med); color: var(--text-2); background: var(--surface); border: 1px solid var(--line); cursor: default;
  transition: border-color .12s, color .12s, background .12s;
}
#view-chat .chip-link.w3-cite { cursor: pointer; }
#view-chat .w3-cite .cite-n {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin: 0; padding: 0 5px; border-radius: 999px;
  font-size: var(--fs-11); font-weight: var(--fw-strong); font-variant-numeric: tabular-nums; color: var(--accent); background: var(--accent-soft);
}
#view-chat .w3-cite-src { color: var(--text-3); font-weight: var(--fw-med); }
#view-chat .w3-cite-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
#view-chat .w3-cite:hover, #view-chat .w3-cite:focus-visible { border-color: var(--line-hover); outline: none; }
#view-chat .w3-cite:focus-visible { box-shadow: var(--ring); }
#view-chat .chip-link.w3-cite:hover .w3-cite-t { color: var(--accent); }
#view-chat .chip-link.w3-cite:active { transform: scale(.98); }
#view-chat .w3-cite-pop {
  position: absolute; left: -1px; bottom: calc(100% + 8px); z-index: 20; display: flex; flex-direction: column; gap: 2px; width: max-content; max-width: 300px;
  padding: 10px 12px; border-radius: 10px; background: var(--ink-900, #0B1220); color: #fff; text-align: left; white-space: normal;
  box-shadow: var(--shadow-pop); font-size: var(--fs-12); line-height: 17px; font-weight: 400;
  opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity .12s var(--w3-ease) .15s, transform .12s var(--w3-ease) .15s;
}
#view-chat .w3-cite:hover .w3-cite-pop, #view-chat .w3-cite:focus-visible .w3-cite-pop { opacity: 1; transform: none; }
#view-chat .w3-cite-pop-k { font-size: var(--fs-12); font-weight: var(--fw-med); letter-spacing: 0; text-transform: none; color: rgba(255, 255, 255, .55); }
#view-chat .w3-cite-pop-t { font-weight: var(--fw-strong); font-size: var(--fs-13); overflow-wrap: anywhere; }
#view-chat .w3-cite-pop-s { font-family: var(--mono); font-size: var(--fs-11); color: rgba(255, 255, 255, .7); overflow-wrap: anywhere; }
#view-chat .w3-cite-pop-h { display: inline-flex; align-items: center; gap: 5px; margin-top: 4px; color: #A3ADFF; font-size: var(--fs-12); }

/* answer actions + meta */
#view-chat .w3-msg-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; min-height: 28px; }
#view-chat .w3-msg-actions .icon-btn { width: 28px; height: 28px; color: var(--text-3); }
#view-chat .w3-msg-actions .icon-btn:hover { color: var(--text); background: var(--surface-2); }
#view-chat .w3-msg-meta { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: var(--fs-11); color: var(--text-3); }
#view-chat .w3-msg-meta .route-tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px; font-family: var(--mono); font-size: var(--fs-11);
  color: var(--text-2); background: var(--surface-2); border: 0; box-shadow: inset 0 0 0 1px var(--line); margin: 0;
}
#view-chat .w3-model { font-family: var(--mono); font-size: var(--fs-11); }
#view-chat .w3-msg-bot:not(:last-child) .w3-msg-actions { opacity: .0; transition: opacity .12s; }
#view-chat .w3-msg-bot:not(:last-child):hover .w3-msg-actions, #view-chat .w3-msg-bot:not(:last-child):focus-within .w3-msg-actions { opacity: 1; }

/* chat skeleton */
#view-chat .w3-chat-sk { display: flex; flex-direction: column; gap: 28px; }
#view-chat .w3-sk-bubble { width: 240px; height: 42px; border-radius: 8px 8px 4px 8px; }
#view-chat .w3-sk-bubble-sm { width: 160px; }

/* composer dock */
#view-chat .w3-chat-dock { flex: 0 0 auto; padding: 0 24px 14px; position: relative; background: var(--bg); }
#view-chat .w3-jump {
  position: absolute; left: 50%; top: -48px; margin-left: -16px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2); box-shadow: var(--shadow-sm, 0 2px 8px rgba(13, 20, 48, .08)); cursor: pointer; z-index: 2;
  animation: w3-fade-in .16s var(--w3-ease);
}
#view-chat .w3-jump[hidden] { display: none; }
#view-chat .w3-jump:hover { color: var(--accent); border-color: var(--line-strong); }
#view-chat .w3-composer {
  max-width: 800px; margin: 0 auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px 10px 16px; cursor: text;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px;
  box-shadow: none;
  transition: border-color .12s var(--w3-ease), box-shadow .18s var(--w3-ease);
}
#view-chat .w3-composer:hover { border-color: var(--line-hover); }
#view-chat .w3-composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--signal-ring);
}
#view-chat .w3-composer textarea {
  width: 100%; min-height: 24px; max-height: 200px; padding: 2px 0; border: 0; border-radius: 0; resize: none; background: transparent;
  font: inherit; font-size: var(--fs-14); line-height: 22px; color: var(--text); box-shadow: none; overflow-y: auto;
}
#view-chat .w3-composer textarea::placeholder { color: var(--text-3); }
#view-chat .w3-composer textarea:focus { outline: none; box-shadow: none; border: 0; }
#view-chat .w3-composer-bar { display: flex; align-items: center; gap: 8px; min-width: 0; cursor: default; }
#view-chat .w3-scope-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; max-width: 240px; padding: 0 8px 0 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text-2); font: inherit; font-size: var(--fs-13); font-weight: var(--fw-med); cursor: pointer;
  transition: border-color .12s, background .12s, color .12s;
}
#view-chat .w3-scope-btn:hover { border-color: var(--line-strong); color: var(--text); }
#view-chat .w3-scope-btn:active { transform: scale(.98); }
#view-chat .w3-scope-btn:focus-visible { outline: none; box-shadow: var(--ring); }
#view-chat .w3-scope-btn.w3-scoped { color: var(--text); background: var(--surface-2); border-color: var(--line-strong); }
#view-chat .w3-scope-ico { display: inline-flex; }
#view-chat .w3-scope-ico svg { width: 13px; height: 13px; }
#view-chat .w3-scope-l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#view-chat .w3-scope-caret { display: inline-flex; transform: rotate(90deg); opacity: .7; }
#view-chat .w3-composer-hint { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-12); color: var(--text-3); white-space: nowrap; }
#view-chat .w3-composer-hint kbd {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 5px; font-family: var(--font); font-size: var(--fs-11);
  color: var(--text-2); background: var(--surface-2); box-shadow: inset 0 -1px 0 var(--line-strong), inset 0 0 0 1px var(--line);
}
#view-chat .w3-send {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; border: 0; padding: 0; flex: 0 0 auto;
  background: var(--surface-3); color: var(--text-3); cursor: not-allowed; transition: background .12s var(--w3-ease), color .12s, transform .12s var(--w3-ease), box-shadow .12s;
}
#view-chat .w3-ready .w3-send:not(:disabled), #view-chat .w3-send.w3-busy {
  background: var(--accent-fill); color: var(--on-accent); cursor: pointer; box-shadow: none;
}
#view-chat .w3-ready .w3-send:not(:disabled):hover { background: var(--accent-hover, var(--accent-fill)); }
#view-chat .w3-ready .w3-send:not(:disabled):active { transform: scale(.98); }
#view-chat .w3-send .w3-bi { width: 16px; height: 16px; }
#view-chat .w3-send:focus-visible { outline: none; box-shadow: var(--ring); }
#view-chat .w3-chat-foot { max-width: 800px; margin: 8px auto 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: var(--fs-11); color: var(--text-3); text-align: center; }
#view-chat .w3-chat-foot svg { color: var(--text-3); }

/* ============================================================
   DASHBOARDS
   ============================================================ */
#view-dashboards .w3-dash-page { padding: 24px 32px 40px; }
#view-dashboards .page-head { margin-bottom: 20px; }
#view-dashboards .page-title { font-size: var(--fs-20); line-height: var(--lh-20); letter-spacing: var(--track-display); }
#view-dashboards .page-sub { display: flex; align-items: center; flex-wrap: wrap; }
#view-dashboards .w3-unsaved { color: var(--warn); font-weight: var(--fw-med); }
#view-dashboards .w3-dash-toolbar { padding: 0 0 12px; min-height: 0; gap: 12px; }
#view-dashboards .w3-empty-box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 40px 16px; box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05)); }
#view-dashboards #dash-nomatch:not(:empty) { margin-top: 12px; }
#view-dashboards .w3-dash-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
#view-dashboards .w3-dash-title > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-dashboards .w3-title-btn { width: 28px; height: 28px; border-color: transparent; background: transparent; color: var(--text-3); }
#view-dashboards .w3-title-btn:hover { background: var(--surface-2); color: var(--text); }
#view-dashboards .w3-dirty { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); flex: 0 0 auto; }
#view-dashboards .w3-dash-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
#view-dashboards .w3-dash-grid > .w3-empty-box { grid-column: 1 / -1; }
/* B-U7: tiles pack without holes (dense flow) and share their row's height; B-N2: "No access" tiles are compact
   fixed-height cards, aligned to the top of their row */
#view-dashboards .w3-dash-grid { align-items: stretch; }
#view-dashboards .w3-dash-grid.w3-dash-ro { grid-auto-flow: row dense; }
#view-dashboards .w3-tile.w2-tile-denied { min-height: 0; height: 120px; align-self: start; }
#view-dashboards .w3-tile.w2-tile-denied .w3-tile-body { flex: 1 1 auto; padding: 0 16px 14px; justify-content: flex-start; overflow: hidden; }
#view-dashboards .w2-tile-denied .w3-tile-foot { display: none; }
#view-dashboards .w2-tile-denied .w2-tile-noaccess { height: auto; justify-content: flex-start; align-items: flex-start; padding: 0; }
#view-dashboards .w2-tile-denied .w2-denied-sm { padding: 4px 0; }
@media (max-width: 719.98px) { #view-dashboards .w3-tile.w2-tile-denied { grid-column: 1 / -1; height: auto; min-height: 0; } }
#view-dashboards .w3-tile {
  display: flex; flex-direction: column; min-width: 0; min-height: 340px; border-radius: 8px; overflow: hidden;
  box-shadow: var(--shadow-xs, 0 1px 2px rgba(13, 20, 48, .05)); transition: box-shadow .18s var(--w3-ease), border-color .18s;
}
#view-dashboards .w3-tile:hover { border-color: var(--line-strong); }
#view-dashboards .w3-tile.w2 { grid-column: 1 / -1; }
#view-dashboards .w3-tile-number, #view-dashboards .w3-tile-sk:nth-child(-n+2) { min-height: 176px; }
#view-dashboards .w3-tile-head { display: flex; height: 56px; min-height: 56px; padding: 0 8px 0 16px; gap: 2px; align-items: center; border-bottom: 0; }
#view-dashboards .w3-tile-titles { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1 1 auto; }
#view-dashboards .w3-tile-titles h3 { font-size: var(--fs-14); font-weight: var(--fw-strong); line-height: 20px; letter-spacing: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-dashboards .w3-tile-meta { font-size: var(--fs-12); line-height: 16px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-dashboards .w3-tile-body { flex: 1 1 auto; min-height: 0; overflow: hidden; padding: 4px 16px 12px; display: flex; flex-direction: column; }
#view-dashboards .w3-tile-fill { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#view-dashboards .w3-tile-number .w3-tile-body { justify-content: center; padding: 0 16px 16px; }
#view-dashboards .w3-tile-table .w3-tile-body { padding: 0; overflow: auto; }
#view-dashboards .w3-tile-table .dtable-wrap { border: 0; border-radius: 0; border-top: 1px solid var(--line); }
#view-dashboards .w3-tile-table .chart-note { padding: 8px 16px; }
#view-dashboards .w3-tile-body > .w3-errbox { margin: auto 0; }
#view-dashboards .w3-tile-body > .w3-empty { margin: auto; }
#view-dashboards .w3-tile-sk { pointer-events: none; }
#view-dashboards .w3-tile-sk .w3-tile-titles { gap: 8px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1100px) {
  #view-sources .w3-src-left { flex-basis: 248px; width: 248px; }
  #view-worksheets .w3-ws-left { flex-basis: 224px; width: 224px; }
  #view-worksheets #ws-cur-name { max-width: 160px; }
  #view-sources .w3-page { padding: 20px 24px 32px; }
  #view-sources .w3-thead { padding: 18px 24px 0; }
  #view-sources .w3-ptabs { padding: 0 20px; }
  #view-sources .w3-tbody { padding: 16px 24px 24px; }
  #view-sources .w3-mstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-dashboards .w3-dash-page { padding: 20px 24px 32px; }
  #view-sources .w3-dhead { flex-wrap: wrap; }
  #view-sources .w3-dhead .page-actions { flex: 1 1 100%; margin-left: 58px; justify-content: flex-start; }
  #view-sources .w3-thead .page-actions { flex: 0 0 auto; margin-left: 0; }
}

@media (max-width: 720px) {
  #view-sources .w3-hide-sm, #view-worksheets .w3-hide-sm, #view-chat .w3-hide-sm, #view-dashboards .w3-hide-sm { display: none !important; }
  #view-chat .w3-show-sm { display: inline; }

  /* app views become a scrolling column of stacked panes */
  #view-sources.app.active, #view-worksheets.app.active { height: auto; min-height: 100%; overflow: visible; }
  #view-sources .w3-src, #view-worksheets .w3-ws { flex-direction: column; flex: 0 0 auto; }
  #view-sources .w3-src-left, #view-worksheets .w3-ws-left { flex: 0 0 auto; width: auto; border-bottom: 1px solid var(--line); }
  #view-sources .pane + .pane, #view-worksheets .pane + .pane { border-left: 0; }
  #view-sources .w3-src-list { max-height: 320px; }
  #view-sources .w3-src-detail { flex: 0 0 auto; }
  #view-sources .w3-detail-scroll { overflow: visible; }
  #view-sources .w3-page { padding: 16px; }
  #view-sources .w3-dhead { gap: 12px; }
  #view-sources .w3-dhead .page-actions { margin-left: 0; }
  #view-sources .w3-eng-lg, #view-sources .w3-tbadge { width: 36px; height: 36px; border-radius: 8px; }
  #view-sources .w3-page .page-title { font-size: var(--fs-20); }
  #view-sources .page-actions { flex-wrap: wrap; }
  #view-sources .w3-kv { grid-template-columns: minmax(0, 1fr); }
  #view-sources .w3-kv dt { min-height: 0; padding: 10px 0 0; border-bottom: 0; font-size: var(--fs-12); }
  #view-sources .w3-kv dd { min-height: 0; padding: 2px 0 10px; }
  #view-sources .w3-tdetail { flex: 0 0 auto; }
  #view-sources .w3-thead { padding: 14px 16px 0; flex-wrap: wrap; }
  #view-sources .w3-ptabs { padding: 0 8px; overflow-x: auto; }
  #view-sources .w3-tbody { padding: 12px 16px 20px; overflow: visible; }
  #view-sources #src-preview .dtable-wrap { max-height: 60vh; }

  #view-worksheets .w3-lbody .pane-body { max-height: 220px; }
  #view-worksheets .w3-ws-main { flex: 0 0 auto; }
  #view-worksheets .w3-ws-bar { flex-wrap: wrap; height: auto; padding: 8px 12px; row-gap: 8px; }
  #view-worksheets .w3-ws-name { flex: 1 1 100%; }
  #view-worksheets .w3-src-pick { flex: 1 1 auto; margin-left: 0; }
  #view-worksheets .w3-src-pick select { max-width: none; width: 100%; }
  #view-worksheets .w3-ws-status { order: 10; flex: 1 1 100%; }
  #view-worksheets .w3-ws-status:empty { display: none; }
  #view-worksheets .w3-ws-v { flex: 0 0 auto; }
  #view-worksheets .w3-editor { flex: 0 0 200px !important; height: 200px; }
  #view-worksheets .gutter { display: none; }
  #view-worksheets .w3-res { flex: 0 0 auto; min-height: 320px; border-top: 1px solid var(--line); }
  #view-worksheets .w3-res-body { max-height: 60vh; min-height: 200px; }

  #view-chat .w3-chat-head { padding: 0 8px 0 16px; }
  #view-chat .w3-chat-col { padding: 20px 16px 24px; gap: 22px; }
  #view-chat .w3-chat-dock { padding: 0 10px 10px; }
  #view-chat .w3-suggest { grid-template-columns: minmax(0, 1fr); }
  #view-chat .w3-chat-hero { font-size: var(--fs-22); line-height: 30px; }
  #view-chat .w3-msg-user { max-width: 88%; }
  #view-chat .w3-msg-bot { gap: 10px; }
  #view-chat .w3-msg-bot > .w3-mark { width: 24px; height: 24px; }
  #view-chat .w3-scope-btn { max-width: 180px; }
  #view-chat .w3-cite { max-width: 100%; }
  #view-chat .w3-cite-pop { max-width: calc(100vw - 48px); }
  #view-chat .w3-msg-bot:not(:last-child) .w3-msg-actions { opacity: 1; }

  #view-dashboards .w3-dash-page { padding: 16px; }
  #view-dashboards .page-head { flex-wrap: wrap; }
  #view-dashboards .page-actions { margin-left: 0; justify-content: flex-start; }
  #view-dashboards .w3-dash-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  #view-dashboards .w3-tile { min-height: 300px; }
  #view-dashboards .w3-tile-number { min-height: 156px; }
  #view-dashboards .w3-dash-toolbar .w3-filter-inline { flex: 1 1 auto; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .w3-sk, .w3-mark-live .w3-arc, #view-chat .w3-think, .w3-sdot-info, .w3-busy .w3-bi::before, .icon-btn.w3-spin svg, .w3-row-menu.w3-spin svg { animation-duration: 0s !important; animation-iteration-count: 1 !important; }
  .w3-fade, .w3-empty, .w3-errbox, #view-chat .w3-fresh *, #view-chat .w3-fresh-user, #view-sources .w3-detail-scroll, #view-sources .w3-tdetail { animation: none !important; }
  .w3-chev, .w3-row-go, #view-chat .w3-cite-pop { transition: none !important; }
}

/* number tile: value block vertically centred inside the fill wrapper */
.w3-tile-fill > .w3-num, .w3-prev-body > .w3-num { flex: 1 1 auto; }
#view-worksheets .w3-tschema.w3-ind1, #view-worksheets .w3-ttable.w3-ind2, #view-worksheets .w3-tcol.w3-ind3 { background-repeat: no-repeat; }
#view-chat .w3-msg-actions .icon-btn, #view-sources .w3-kv-copy { border-color: transparent; background-color: transparent; box-shadow: none; }
#view-chat .w3-msg-actions .icon-btn:hover, #view-sources .w3-kv-copy:hover { background-color: var(--surface-2); }
#view-sources .w3-src-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-chat .w3-sql-lbl, #view-chat .w3-sql-n { white-space: nowrap; }
@media (max-width: 720px) {
  #view-worksheets .w3-ws-bar { flex: 0 0 auto; }
  #view-chat .w3-sql-n { display: none; }
  #view-chat .w3-sql-block > summary { gap: 4px; }
}

/* RESTRAINT: list rows carry no dot when healthy — status shows only when it needs attention */
.w3-src-row .w3-sdot-ok, .w3-tsrc .w3-sdot-ok { display: none; }

/* voice input — neutral icon button; recording = stop control with a small red dot + elapsed time */
#view-chat .w3-mic {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; min-width: 34px; padding: 0 9px; margin-right: 6px;
  border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--text-3); cursor: pointer; font: inherit; flex: 0 0 auto;
  transition: background .12s var(--w3-ease), color .12s, border-color .12s;
}
#view-chat .w3-mic[hidden] { display: none; }
#view-chat .w3-mic:hover { background: var(--surface-2); color: var(--text); }
#view-chat .w3-mic:focus-visible { outline: none; box-shadow: var(--ring); }
#view-chat .w3-mic .w3-bi { width: 16px; height: 16px; display: inline-flex; }
#view-chat .w3-mic-rec { display: none; align-items: center; gap: 6px; font-size: var(--fs-12); font-variant-numeric: tabular-nums; color: var(--text); }
#view-chat .w3-mic-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--err); }
#view-chat .w3-mic.w3-mic-on { border-color: var(--line-strong); background: var(--surface); color: var(--text); }
#view-chat .w3-mic.w3-mic-on .w3-bi { display: none; }
#view-chat .w3-mic.w3-mic-on .w3-mic-rec { display: inline-flex; }
#view-chat .w3-mic.w3-mic-on .w3-mic-rec::after { content: ""; width: 8px; height: 8px; border-radius: 1px; background: var(--text-2); margin-left: 2px; }

/* thinking row: the ring spins (overrides the reduced-motion freeze above) */
#view-chat .w3-msg-think > .w3-mark.wr-spin { animation: wr-rot 1s linear infinite !important; animation-duration: 1s !important; animation-iteration-count: infinite !important; }
@media (prefers-reduced-motion: reduce) { #view-chat .w3-msg-think > .w3-mark.wr-spin { animation: wr-rot 2.4s linear infinite !important; } }

/* ============================================================
   R1 refinement (REFINE §A1 §A2 §C §F §G §H) — F2 core work surfaces
   ============================================================ */

/* ---- shared: errors in Inter, engine output in mono ---- */
.w3-errbox-msg { font-family: var(--font); font-size: var(--fs-13); line-height: 20px; color: var(--text-2); white-space: normal; }
.w3-errbox-detail { display: block; margin-top: 6px; font-family: var(--mono); font-size: var(--fs-12); line-height: 18px; color: var(--text-3); background: none; padding: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.w3-hint { display: flex; align-items: center; gap: 8px; font-size: var(--fs-13); line-height: 20px; color: var(--text-2); }
.w3-hint svg { color: var(--text-3); flex: 0 0 auto; }
.w3-linkbtn { border: 0; background: none; padding: 0 2px; color: var(--accent); font: inherit; font-size: inherit; cursor: pointer; text-decoration: none; }
.w3-linkbtn:hover { text-decoration: underline; }
.w3-err-t { color: var(--err); font-weight: var(--fw-med); margin-right: 6px; }
.w3-t2 { color: var(--text-2); }

/* real links in the first cell (rows stay clickable for the mouse) */
.w3-rowlink { display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%; color: var(--text); font-weight: var(--fw-med); text-decoration: none; border-radius: 4px; }
.w3-rowlink .w3-cell-ico, .w3-rowlink .w3-dash-ico { margin-right: 0 !important; }
.w3-rowlink-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.clickable:hover .w3-rowlink { color: var(--accent); }
.w3-rowlink:focus-visible { outline: none; box-shadow: var(--ring); }
.w3-name-cell { max-width: 0; width: 60%; }

/* ---- result grid: sort, selection, nulls ---- */
.w3-grid-wrap:focus-visible { outline: none; box-shadow: var(--ring-inset); }
.w3-grid th[data-sort] { cursor: pointer; user-select: none; }
.w3-grid .w3-sort { color: var(--text-3); font-size: 9px; line-height: 1; min-width: 0; }
.w3-grid .w3-sort:empty { display: none; }
.w3-grid th[aria-sort="ascending"] .w3-th-n, .w3-grid th[aria-sort="descending"] .w3-th-n { color: var(--text); }
.w3-grid td { cursor: cell; }
.w3-grid td.w3-csel, .w3-grid tbody tr:hover td.w3-csel { background: var(--w3-sel); color: var(--text); }
.w3-grid .w3-null { color: var(--text-3); font-style: italic; }

/* ---- charts (§C) ---- */
.w3-cyt { font-size: var(--fs-11); fill: var(--text-3); }
.w3-cv, .chart-val.w3-cv { fill: var(--text-2); font-family: var(--font); font-size: var(--fs-11); font-variant-numeric: tabular-nums; opacity: 1; }
.w3-ct-other { fill: var(--text-3); font-style: italic; }
.w3-cl { fill: var(--text-2); }
.w3-chart-h .w3-hband { opacity: 0; }
.w3-chart-h.w3-hovering .w3-hband { opacity: .035; }
.w3-num-v { font-size: var(--fs-32); line-height: 40px; }

/* ============ WORKSHEETS ============ */
#view-worksheets .w3-ws-listbtn { display: none; }
#view-worksheets .w3-ws-scrim { display: none; }
#view-worksheets .w3-res-acts { display: inline-flex; align-items: center; gap: 6px; }
#view-worksheets .w3-res-acts[hidden] { display: none; }
#view-worksheets .w3-splitbtn { display: inline-flex; }
#view-worksheets .w3-splitbtn > .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
#view-worksheets .w3-splitbtn > .w3-split-caret { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: -1px; padding: 0 6px; min-width: 0; }
#view-worksheets .w3-split-caret svg { transform: rotate(90deg); }
#view-worksheets .w3-show-sm { display: none; }
#view-worksheets #ws-error:not(:empty) { padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
#view-worksheets .w3-res-head .btn-sm { height: 28px; }

/* ============ DASHBOARDS ============ */
#view-dashboards .w3-dash-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
#view-dashboards .w3-span-1 { grid-column: span 1; }
#view-dashboards .w3-span-2 { grid-column: span 2; }
#view-dashboards .w3-span-4 { grid-column: 1 / -1; }
#view-dashboards .w3-tile-h { font-size: var(--fs-14); font-weight: var(--fw-strong); line-height: 20px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#view-dashboards .w3-tile:focus-visible { outline: none; box-shadow: var(--ring); }
#view-dashboards .w3-tile-number { min-height: 176px; }
#view-dashboards .w3-tile-number .w3-tile-foot { font-size: var(--fs-11); }
#view-dashboards .w3-tile-slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 176px;
  border: 1px dashed var(--line-strong); border-radius: 8px; background: transparent; color: var(--text-3); font: inherit; font-size: var(--fs-13); cursor: pointer;
  transition: border-color .12s, color .12s, background .12s;
}
#view-dashboards .w3-tile-slot:hover { border-color: var(--text-3); color: var(--text-2); background: var(--surface); }
#view-dashboards .w3-tile-slot:focus-visible { outline: none; box-shadow: var(--ring); }
#view-dashboards .dash-empty { grid-column: 1 / -1; }
/* A1: list rows are plain table rows */
@media (min-width: 720px) { #view-dashboards tr.dash-row { display: table-row; } }
.dtable.stack .w3-rowlink { display: flex; width: 100%; }
#view-dashboards .w3-dash-table td { height: 44px; vertical-align: middle; }
#view-dashboards .w3-dash-table th.num, #view-dashboards .w3-dash-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
#view-dashboards .w3-dash-table td:nth-child(3) { color: var(--text-2); font-size: var(--fs-13); }
#view-dashboards .w3-dash-table .w3-act-col { width: 48px; }
#view-dashboards .w3-dash-toolbar #dash-count:empty { display: none; }
@media (max-width: 1100px) {
  #view-dashboards .w3-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-dashboards .w3-span-2 { grid-column: 1 / -1; }
}

/* ============ SOURCES ============ */
#view-sources .w3-mback { display: none; }
#view-sources .w3-cols-table td { height: 36px; }
#view-sources .w3-cname { font-family: var(--mono); font-size: var(--fs-13); color: var(--text); }
#view-sources .w3-ctype { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-3); }
#view-sources .w3-ckey { font-size: var(--fs-12); color: var(--text-2); }
#view-sources .w3-dhead .page-title { font-family: var(--font); }
#view-sources .w3-tbody:focus-visible { outline: none; box-shadow: var(--ring-inset); }

/* ============ CHAT (§F) ============ */
#view-chat .w3-chat-wrap { display: flex; flex: 1 1 auto; min-height: 0; position: relative; }
#view-chat .w3-chat-wrap > .w3-chat { min-width: 0; }
#view-chat .w3-convs {
  flex: 0 0 260px; width: 260px; display: none; flex-direction: column; min-height: 0; background: var(--surface); border-right: 1px solid var(--line);
}
#view-chat .w3-convs-open > .w3-convs { display: flex; }
#view-chat .w3-convs-head { display: flex; align-items: center; gap: 6px; height: 48px; flex: 0 0 48px; padding: 0 8px 0 12px; border-bottom: 1px solid var(--line); }
#view-chat .w3-convs-new { flex: 1 1 auto; justify-content: flex-start; height: 32px; }
#view-chat .w3-convs .w3-filter { border-bottom: 0; }
#view-chat .w3-conv-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 4px 0 16px; }
#view-chat .w3-conv-glabel { padding: 12px 16px 4px; font-size: var(--fs-11); line-height: 16px; font-weight: var(--fw-med); color: var(--text-3); }
#view-chat .w3-conv { position: relative; display: flex; align-items: center; margin: 0 8px; border-radius: 6px; }
#view-chat .w3-conv:hover { background: var(--surface-2); }
#view-chat .w3-conv.selected { background: var(--accent-soft); }
#view-chat .w3-conv-a {
  flex: 1 1 auto; min-width: 0; display: block; padding: 7px 8px; font-size: var(--fs-13); line-height: 18px; color: var(--text); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 6px;
}
#view-chat .w3-conv.selected .w3-conv-a { font-weight: var(--fw-med); }
#view-chat .w3-conv-a:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-chat .w3-conv-menu { flex: 0 0 auto; opacity: 0; }
#view-chat .w3-conv:hover .w3-conv-menu, #view-chat .w3-conv:focus-within .w3-conv-menu, #view-chat .w3-conv.selected .w3-conv-menu { opacity: 1; }
#view-chat .w3-convs-empty { padding: 16px; font-size: var(--fs-13); color: var(--text-3); }
#view-chat .w3-convs-scrim { display: none; }
#view-chat .w3-chat-head { padding: 0 8px 0 8px; }
#view-chat .w3-chat-title { display: block; min-width: 0; margin: 0; font-size: var(--fs-14); line-height: 22px; font-weight: var(--fw-strong); letter-spacing: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-chat .w3-convs-open .w3-convs-toggle { display: none; }
#view-chat .w3-chat-scroll { scroll-padding-top: 16px; }
#view-chat .w3-chat-col { max-width: 760px; }
#view-chat .w3-md { max-width: 68ch; }
#view-chat .w3-bot-body { font-size: var(--fs-14); line-height: 22px; }
#view-chat .w3-msg-bot { gap: 12px; }
#view-chat .w3-av { flex: 0 0 auto; margin-top: 2px; }
#view-chat .w3-av-mono { display: inline-flex; width: 20px; height: 20px; color: var(--text-3); }
#view-chat .w3-av-mono svg { width: 20px; height: 20px; }
#view-chat .w3-msg-user { flex-direction: column; align-items: flex-end; scroll-margin-top: 16px; }
#view-chat .w3-user-scope { margin-top: 4px; font-size: var(--fs-11); line-height: 16px; color: var(--text-3); }
#view-chat .w3-think::after { content: none; }
#view-chat .w3-think-t { font-variant-numeric: tabular-nums; }
/* inline citation markers */
#view-chat .w3-cite-ref {
  display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; margin: 0 1px; vertical-align: 1px;
  border: 0; border-radius: 999px; background: var(--surface-2); color: var(--accent); font: inherit; font-size: var(--fs-11); line-height: 16px; font-weight: var(--fw-strong);
  font-variant-numeric: tabular-nums; cursor: pointer;
}
#view-chat .w3-cite-ref:hover { background: var(--accent-soft); }
#view-chat .w3-cite-ref:focus-visible { outline: none; box-shadow: var(--ring); }
#view-chat .w3-cite { height: 26px; padding: 0 10px 0 3px; border-radius: 6px; cursor: pointer; font: inherit; font-size: var(--fs-12); }
#view-chat .w3-cite .cite-n { border-radius: 4px; color: var(--text-2); background: var(--surface-2); }
#view-chat .w3-cite-logo { width: 14px; height: 14px; flex: 0 0 auto; display: inline-grid; place-items: center; color: var(--text-3); }
#view-chat .w3-cite.w3-hl, #view-chat .w3-cite.w3-flash { border-color: var(--accent); }
#view-chat .w3-cite.w3-hl .cite-n, #view-chat .w3-cite.w3-flash .cite-n { background: var(--accent-soft); color: var(--accent); }
#view-chat .w3-cite-more { padding: 0 10px; color: var(--text-2); }
/* actions + follow-ups */
#view-chat .w3-msg-actions { gap: 2px; flex-wrap: wrap; }
#view-chat .w3-msg-meta { margin-left: 8px; font-size: var(--fs-12); color: var(--text-3); gap: 0; flex-wrap: wrap; }
#view-chat .w3-msg-meta .w3-model { font-family: var(--mono); font-size: var(--fs-11); }
#view-chat .w3-fb.on { color: var(--accent) !important; }
#view-chat .w3-msg-bot:not(.w3-last) .w3-msg-actions { opacity: 0; transition: opacity .12s; }
#view-chat .w3-msg-bot:not(.w3-last):hover .w3-msg-actions, #view-chat .w3-msg-bot:not(.w3-last):focus-within .w3-msg-actions { opacity: 1; }
#view-chat .w3-msg-bot.w3-last .w3-msg-actions, #view-chat .w3-msg-bot:last-child .w3-msg-actions { opacity: 1; }
@media (hover: none) { #view-chat .w3-msg-bot .w3-msg-actions { opacity: 1 !important; } }
#view-chat .w3-followups { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
#view-chat .w3-fu { height: 32px; font-size: var(--fs-13); color: var(--text-2); background: transparent; }
#view-chat .w3-fu:hover { color: var(--text); }
#view-chat .w3-more-row { margin-top: 10px; }
/* compact table for list answers */
#view-chat .w3-ans-table-wrap { margin: 4px 0 12px; border: 1px solid var(--line); border-radius: 8px; overflow: auto; background: var(--surface); max-width: 100%; }
#view-chat .w3-ans-table-wrap:focus-visible { outline: none; box-shadow: var(--ring); }
#view-chat .w3-ans-table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); line-height: 20px; }
#view-chat .w3-ans-table th { position: sticky; top: 0; text-align: left; font-size: var(--fs-12); font-weight: var(--fw-med); color: var(--text-2); background: var(--surface-2); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
#view-chat .w3-ans-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
#view-chat .w3-ans-table tr:last-child td { border-bottom: 0; }
#view-chat .w3-ans-owner { white-space: nowrap; font-weight: var(--fw-med); }
#view-chat .w3-ans-due, #view-chat .w3-ans-ch { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
#view-chat .w3-ans-src { white-space: nowrap; text-align: right; }
/* send ↔ stop */
#view-chat .w3-send.w3-stop { background: var(--text); color: var(--surface); cursor: pointer; }
#view-chat .w3-send.w3-stop .w3-bi svg { width: 12px; height: 12px; }
/* composer: quiet focus (no permanent ring) */
#view-chat .w3-composer:focus-within { border-color: var(--text-3); box-shadow: var(--shadow-sm, 0 2px 8px rgba(13, 20, 48, .08)); }
#view-chat .w3-composer textarea { overflow-y: hidden; }
#view-chat .w3-composer-hint[hidden] { display: none; }
#view-chat .w3-chat-foot { gap: 0; }
@media (max-width: 1099.98px) {
  #view-chat .w3-convs { position: absolute; left: 0; top: 0; bottom: 0; z-index: 30; box-shadow: var(--shadow-pop); }
  #view-chat .w3-convs-open .w3-convs-scrim { display: block; position: absolute; inset: 0; z-index: 29; background: rgba(11, 18, 32, .28); }
  #view-chat .w3-convs-scrim[hidden] { display: none !important; }
  #view-chat .w3-convs-open .w3-convs-toggle { display: inline-grid; }
}
@media (min-width: 1100px) { #view-chat .w3-convs-close { display: inline-grid; } }

/* ============ Mobile (§H, ≤719px): push navigation, bottom sheet, sticky composer ============ */
@media (max-width: 719.98px) {
  /* Sources: master → detail */
  #view-sources .w3-src { flex-direction: column; }
  #view-sources .w3-src-left { border-bottom: 0; }
  #view-sources .w3-src-list { max-height: none; }
  #view-sources .w3-src:not(.w3-m-detail) .w3-src-detail { display: none; }
  #view-sources .w3-src.w3-m-detail .w3-src-left { display: none; }
  #view-sources .w3-src-row .w3-chev, #view-sources .w3-tree-slot, #view-sources #src-tree { display: none; }
  #view-sources .w3-mback {
    display: none; align-items: center; gap: 4px; height: 44px; margin: 0 0 4px -8px; padding: 0 8px; border: 0; background: none;
    color: var(--accent); font: inherit; font-size: var(--fs-14); cursor: pointer;
  }
  #view-sources .w3-tdetail > .w3-mback { margin: 8px 0 0 8px; }
  #view-sources .w3-dhead { flex-wrap: wrap; }
  #view-sources .w3-dhead .page-actions { flex: 1 1 100%; margin-left: 0; justify-content: flex-start; }

  /* Worksheets: editor first, list in a bottom sheet */
  #view-worksheets .w3-ws-left { display: none; }
  #view-worksheets .w3-ws-listbtn { display: inline-flex; flex: 0 0 auto; }
  #view-worksheets .w3-ws-name { flex: 1 1 auto; min-width: 0; }
  #view-worksheets .w3-sheet-open .w3-ws-left {
    display: flex; flex-direction: column; position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; width: auto; max-height: 75dvh;
    border-radius: 10px 10px 0 0; box-shadow: var(--shadow-pop); padding-bottom: env(safe-area-inset-bottom);
  }
  #view-worksheets .w3-sheet-open .w3-ws-scrim { display: block; position: fixed; inset: 0; z-index: 59; background: rgba(11, 18, 32, .28); }
  #view-worksheets .w3-sheet-open .w3-lbody .pane-body { max-height: none; overflow: auto; }
  #view-worksheets .w3-hl, #view-worksheets .w3-sql { white-space: pre-wrap; overflow-wrap: anywhere; }
  #view-worksheets .w3-lines { min-width: 28px; }
  #view-worksheets .w3-lines > div { padding: 0 6px; }
  #view-worksheets .w3-show-sm { display: inline; }
  #view-worksheets .w3-res-head { flex-wrap: wrap; height: auto; min-height: 40px; }

  /* Dashboards */
  #view-dashboards .w3-dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #view-dashboards .w3-span-1 { grid-column: span 1; }
  #view-dashboards .w3-span-2 { grid-column: 1 / -1; }
  #view-dashboards .w3-tile-number { min-height: 150px; }
  #view-dashboards .w3-tile-number .w3-num-v { font-size: var(--fs-28); line-height: 34px; }
  #view-dashboards .w3-tile-number .w3-tile-foot > span:first-child, #view-dashboards .w3-tile-number .w3-tile-foot .w3-dotsep { display: none; }
  #view-dashboards .page-actions { flex-direction: row-reverse; justify-content: flex-end; }

  /* Chat */
  #view-chat .w3-chat-head { display: flex; height: 44px; flex-basis: 44px; }
  #view-chat .w3-chat-title { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #view-chat .w3-ans-table { font-size: var(--fs-12); }
  #view-chat .w3-ans-table td, #view-chat .w3-ans-table th { padding: 6px 8px; }
  #view-chat .w3-convs { width: 86vw; flex-basis: 86vw; }
  #view-chat .w3-chat-dock { position: sticky; bottom: 0; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  #view-chat .w3-composer textarea { font-size: var(--fs-16); }
  #view-chat .w3-cites { flex-wrap: wrap; }
  #view-chat .w3-msg-meta { flex-basis: 100%; margin: 4px 0 0 6px; }
}

#view-sources .w3-kpi4 { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 28px; }
@media (max-width: 719.98px) { #view-sources .w3-kpi4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ============================================================
   R2 refinement (REFINE2 §1 §3 §5 §6 §8 §9) — F2 core work surfaces
   ============================================================ */
@keyframes w3-op { from { opacity: 0; } to { opacity: 1; } }

/* ---- charts (§5) ---- */
.w3-cl, .w3-ct.w3-cl { font-size: var(--fs-12); fill: var(--text-2); }
.w3-bar { fill-opacity: .85; }
.w3-bar.on, .w3-chart:not(.w3-hovering) .w3-bar:hover { fill-opacity: 1; }
.w3-bar-partial { fill-opacity: .4; }
.w3-line-partial { stroke-dasharray: 3 3; }
.w3-cv, .chart-val.w3-cv { font-size: var(--fs-11); fill: var(--text-2); }
#view-dashboards .w3-tile:has(.w3-chart-h) { min-height: 0; }
#view-dashboards .w3-tile-body:has(.w3-chart-h) { padding-bottom: 8px; }

/* ---- number tiles (§5): 40 → 32 → 28 auto-fit, caption only when it adds context ---- */
.w3-num-v { font-size: 40px; line-height: 48px; letter-spacing: var(--track-display); }
.w3-num-v.w3-fit-1 { font-size: 32px; line-height: 40px; }
.w3-num-v.w3-fit-2 { font-size: var(--fs-28); line-height: 34px; }
.w3-num-l { color: var(--text-2); }
#view-dashboards .w3-tile-foot:empty { display: none; }
#view-dashboards .w3-tile-foot { min-height: 32px; font-size: var(--fs-12); color: var(--text-2); white-space: normal; }

/* ---- tile drag reorder ---- */
#view-dashboards .w3-tile-head { cursor: grab; touch-action: none; }
#view-dashboards .w3-tile-head button { cursor: pointer; }
#view-dashboards .w3-tile.w3-dragging { opacity: .55; outline: 1px dashed var(--line-strong); outline-offset: 2px; }
body.w3-tile-dragging, body.w3-tile-dragging * { cursor: grabbing !important; user-select: none !important; }
@media (pointer: coarse) { #view-dashboards .w3-tile-head { touch-action: auto; cursor: default; } }

/* ---- result grid (§5 §8): 32px rows, shrink-to-fit numeric/date columns, sort buttons, keyboard selection ---- */
.w3-grid td { height: 32px; }
.w3-grid th.w3-fit, .w3-grid td.w3-fit { width: 1%; white-space: nowrap; min-width: 72px; }
.w3-grid td.w3-date { font-family: var(--mono); font-size: var(--fs-12); font-variant-numeric: normal; }
.w3-grid .w3-th-btn {
  display: inline-flex; align-items: center; gap: 7px; min-width: 0; max-width: 100%; height: 28px; margin: 0 -6px; padding: 0 6px;
  border: 0; border-radius: 6px; background: transparent; color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.w3-grid th.num .w3-th-btn { flex-direction: row-reverse; }
.w3-grid .w3-th-btn:hover { background: var(--surface-3); }
.w3-grid .w3-th-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.w3-grid th:hover { background: inherit; }
.w3-grid td.w3-cact { box-shadow: inset 0 0 0 2px var(--accent); }
.w3-col-rs:focus-visible { outline: none; }
.w3-col-rs:focus-visible::after { opacity: 1; background: var(--accent); width: 2px; right: 2px; }
@media (pointer: coarse) { .w3-col-rs { display: none; } }

/* ---- shared stacked cards (§8) for my tables ---- */
@media (max-width: 719.98px) {
  #view-dashboards .dtable.stack td.sc-menu, #view-dashboards .dtable.stack td.w3-act-col { position: absolute; top: 4px; right: 4px; width: auto; padding: 0 !important; }
  #view-dashboards .dtable.stack .w3-row-menu { width: 44px; height: 44px; opacity: 1; }
  #view-dashboards .dtable.stack .w3-rowlink-t { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}

/* ============ WORKSHEETS (§9): stacked Worksheets list + Objects tree ============ */
#view-worksheets .w3-ws-left { flex: 0 0 var(--pane-w, 280px); width: var(--pane-w, 280px); display: flex; flex-direction: column; min-height: 0; }
#view-worksheets .w3-lsec-ws { flex: 0 0 38%; min-height: 96px; display: flex; flex-direction: column; overflow: hidden; }
#view-worksheets .w3-lsec-obj { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; overflow: hidden; }
#view-worksheets .w3-lsec-ws .pane-body, #view-worksheets .w3-lsec-obj .pane-body { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 0 8px; }
#view-worksheets .w3-lsec-head { display: flex; align-items: center; gap: 8px; height: 40px; flex: 0 0 40px; padding: 0 8px 0 16px; }
#view-worksheets .w3-lsec-t { margin: 0; font-size: var(--fs-12); line-height: 18px; font-weight: var(--fw-strong); color: var(--text-2); }
#view-worksheets .w3-lsec-head .w3-filter-btn { width: 28px; height: 28px; flex: 0 0 28px; }
#view-worksheets .w3-lbody .w3-filter { padding: 0 12px 8px; border-bottom: 0; }
#view-worksheets .w3-lbody .w3-filter-ico { left: 22px; top: calc(50% - 4px); }
#view-worksheets .w3-lsplit { flex: 0 0 7px; height: 7px; cursor: row-resize; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--surface); position: relative; }
#view-worksheets .w3-lsplit::after { content: ""; position: absolute; left: 50%; top: 2px; width: 32px; height: 1px; margin-left: -16px; background: var(--line-strong); box-shadow: 0 2px 0 var(--line-strong); }
#view-worksheets .w3-lsplit:hover, #view-worksheets .w3-lsplit.dragging { background: var(--surface-2); }
#view-worksheets .w3-lsplit:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-worksheets .w3-obj-hint { flex: 0 0 auto; padding: 8px 16px; border-top: 1px solid var(--line); font-size: var(--fs-11); line-height: 16px; color: var(--text-2); }
#view-worksheets .w3-ws-unsaved { cursor: default; }
#view-worksheets .w3-ws-unsaved .ws-item-name { font-style: normal; }
#view-worksheets .w3-tnode[role="treeitem"]:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-worksheets .w3-tstate { margin-left: auto; font-size: var(--fs-11); color: var(--warn); text-transform: none; }
#view-worksheets .w3-ttable.w3-ind2.w3-ins { width: 100%; height: 28px; padding: 0 8px 0 36px; border-radius: 0; cursor: copy; }
#view-worksheets .w3-chev-hit { cursor: pointer; padding: 4px; margin: -4px; }
/* completion popup */
#view-worksheets .w3-ac {
  position: absolute; z-index: 5; width: 300px; max-height: 240px; overflow: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow-pop);
  font-family: var(--font); font-size: var(--fs-13);
}
#view-worksheets .w3-ac-item { display: flex; align-items: center; gap: 8px; height: 28px; padding: 0 8px; border-radius: 6px; cursor: pointer; color: var(--text); }
#view-worksheets .w3-ac-item.on { background: var(--accent-soft); }
#view-worksheets .w3-ac-k { display: inline-flex; color: var(--text-3); }
#view-worksheets .w3-ac-n { font-family: var(--mono); font-size: var(--fs-12); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-worksheets .w3-ac-m { margin-left: auto; font-size: var(--fs-11); color: var(--text-2); white-space: nowrap; }
#view-worksheets .w3-ac-empty { padding: 6px 8px; color: var(--text-2); }

/* ============ SOURCES (§1): all sources by category, one tree ============ */
#view-sources .w3-src-left { flex: 0 0 var(--pane-w, 280px); width: var(--pane-w, 280px); }
#view-sources .w3-src-cat {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px 0 8px; margin-top: 4px; cursor: pointer;
  font-size: var(--fs-12); line-height: 18px; font-weight: var(--fw-strong); color: var(--text-2);
}
#view-sources .w3-src-cat:hover { background: var(--surface-2); }
#view-sources .w3-src-cat:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-sources .w3-src-cat-n { margin-left: auto; font-weight: 400; color: var(--text-2); font-variant-numeric: tabular-nums; }
#view-sources .w3-src-cat .w3-chev.open { transform: rotate(90deg); }
#view-sources .w3-chev-sp { display: inline-block; width: 12px; flex: 0 0 12px; }
#view-sources .w3-src-row { padding-left: 16px; }
#view-sources .w3-src-state { font-size: var(--fs-11); color: var(--text-2); white-space: nowrap; }
#view-sources .w3-src-state.w3-st-warn { color: var(--warn); }
#view-sources .w3-src-state.w3-st-err { color: var(--err); }
#view-sources .w3-eng-logo, #view-sources .w3-eng-glyph { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: 0 0 20px; color: var(--text-3); }
#view-sources .w3-eng-logo img { width: 14px; height: 14px; }
/* one selected bar per tree: the expanded ancestor gets surface-2 only */
#view-sources .w3-src-row.selected[aria-selected="false"] { background: var(--surface-2); }
#view-sources .w3-src-row.selected[aria-selected="false"]::before { display: none; }
#view-sources .w3-src-row.selected[aria-selected="false"] .w3-chev { color: var(--text-3); }
#view-sources .w3-tnode[role="treeitem"]:focus-visible { outline: none; box-shadow: var(--ring-inset); }
#view-sources .w3-kv dt, #view-sources .w3-kv dd { min-height: 44px; }
#view-sources .w3-kv code { line-height: 20px; }
#view-sources .w3-cex { font-family: var(--mono); font-size: var(--fs-12); color: var(--text-2); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-sources .w3-cols-table td.num, #view-sources .w3-cols-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
#view-sources .w3-cols-note { margin-top: 8px; font-size: var(--fs-12); color: var(--text-2); }

/* ============ CHAT (§6) ============ */
/* one 760px column for thread, bubbles and composer; the avatar hangs outside it */
#view-chat .w3-chat-col, #view-chat .w3-composer, #view-chat .w3-chat-foot { max-width: 760px; margin-left: auto; margin-right: auto; }
#view-chat .w3-chat-col { padding-left: 24px; padding-right: 24px; box-sizing: content-box; }
#view-chat .w3-msg-bot { margin-left: -32px; gap: 12px; }
#view-chat .w3-md { max-width: none; }
#view-chat .w3-av-think .wr-ring { display: block; }
#view-chat .w3-av-think, #view-chat .w3-av-mono { display: inline-flex; width: 20px; height: 20px; flex: 0 0 20px; }
#view-chat .w3-av-mono { color: var(--text-3); }
/* one fade for the whole answer — no per-block stagger */
#view-chat .w3-fresh .w3-md > *, #view-chat .w3-fresh .w3-md li, #view-chat .w3-fresh .w3-sql-block, #view-chat .w3-fresh .w3-cites, #view-chat .w3-fresh .w3-msg-actions { animation: none !important; }
#view-chat .w3-fresh { animation: w3-op var(--t-med, 160ms) var(--ease, ease) both; }
/* citation list */
#view-chat ul.w3-cites { list-style: none; margin: 14px 0 0; padding: 0; }
#view-chat ul.w3-cites > li { display: inline-flex; }
#view-chat .w3-demo-line { margin: 6px 0 0; font-size: var(--fs-12); line-height: 16px; color: var(--text-3); }
#view-chat .w3-demo-tag { margin-left: 4px; padding: 0 5px; border-radius: 4px; font-size: var(--fs-11); line-height: 16px; color: var(--text-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
/* conversation ⋯: ghost, revealed on hover/focus/selected */
#view-chat .w3-conv-menu { border: 0 !important; background: transparent !important; box-shadow: none; color: var(--text-3); }
#view-chat .w3-conv-menu:hover, #view-chat .w3-conv-menu:focus-visible { background: var(--surface-3) !important; color: var(--text); }
#view-chat .w3-conv:not(:hover):not(:focus-within) .w3-conv-menu { opacity: 0; }
#view-chat .w3-conv.selected:not(:hover):not(:focus-within) .w3-conv-menu { opacity: 0; }
#view-chat .w3-conv-a { padding-right: 32px; }
/* R4: title ellipsised + right-aligned time meta; the ⋯ replaces the meta on hover/focus */
#view-chat .w3-conv-a { display: flex; align-items: baseline; gap: 8px; padding-right: 8px; }
#view-chat .w3-conv-t { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#view-chat .w3-conv-m { flex: none; font-size: var(--fs-12); line-height: 18px; color: var(--text-3); font-variant-numeric: tabular-nums; font-weight: var(--fw-reg, 400); }
#view-chat .w3-conv:hover .w3-conv-a, #view-chat .w3-conv:focus-within .w3-conv-a { padding-right: 32px; }
#view-chat .w3-conv:hover .w3-conv-m, #view-chat .w3-conv:focus-within .w3-conv-m { visibility: hidden; width: 0; overflow: hidden; margin-left: -8px; }
#view-chat .w3-conv-menu { position: absolute; right: 2px; }
#view-chat .w3-convs { flex-basis: var(--pane-w, 280px); width: var(--pane-w, 280px); }
/* structured rows */
#view-chat .w3-overdue { color: var(--text-2); white-space: nowrap; }
#view-chat .w3-overdue-t { color: var(--err); font-weight: var(--fw-med); font-size: var(--fs-11, 11px); }
:root[data-theme="dark"] #view-chat .w3-overdue-t { color: var(--err-display, var(--err)); }
#view-chat .w3-ans-due { min-width: 150px; }
#view-chat .w3-ans-table td.w3-ac-0 { white-space: nowrap; font-weight: var(--fw-med); }
#view-chat .w3-rows-tickets td.w3-ac-0 { font-family: var(--mono); font-size: var(--fs-12); }
/* Deepgram disclosure at every width */
#view-chat .w3-chat-foot { display: flex !important; }
/* phone: one topbar */
#chat-top-more { display: none; }
@media (max-width: 719.98px) {
  body:has(#view-chat.active) #chat-top-more { display: inline-grid; width: 44px; height: 44px; }
  body:has(#view-chat.active) #top-search { display: none !important; }
  #view-chat .w3-chat-head { display: none !important; }
  #view-chat .w3-chat-col { padding-left: 16px; padding-right: 16px; }
  #view-chat .w3-msg-bot { margin-left: 0; gap: 8px; }
  #view-chat .w3-chat-foot { margin-top: 6px; font-size: var(--fs-11); line-height: 16px; }
  /* answer tables become stacked blocks */
  #view-chat .w3-ans-table-wrap { overflow: visible; border: 0; background: none; }
  #view-chat .w3-ans-table, #view-chat .w3-ans-table tbody, #view-chat .w3-ans-table tr, #view-chat .w3-ans-table td { display: block; }
  #view-chat .w3-ans-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  #view-chat .w3-ans-table tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  #view-chat .w3-ans-table td { padding: 0; border: 0; }
  #view-chat .w3-ans-table td.w3-ac-0 { grid-column: 1; font-weight: var(--fw-strong); }
  #view-chat .w3-ans-table td[data-label="Due"], #view-chat .w3-ans-table td[data-label="Date"] { grid-column: 2; grid-row: 1; font-size: var(--fs-12); color: var(--text-2); text-align: right; }
  #view-chat .w3-ans-table td.w3-ac-1 { grid-column: 1 / -1; font-size: var(--fs-13); line-height: 20px; }
  #view-chat .w3-ans-table td[data-label="Source"], #view-chat .w3-ans-table td[data-label="Status"], #view-chat .w3-ans-table td[data-label="Owner"]:not(.w3-ac-0) { grid-column: 1; font-size: var(--fs-12); color: var(--text-2); }
  #view-chat .w3-ans-table td.w3-ans-src { grid-column: 2; text-align: right; }
  #view-dashboards .w3-num-v { font-size: var(--fs-28); line-height: 34px; }
}

.sc-only { display: none; }
@media (max-width: 719.98px) { .dtable.stack .sc-only { display: inline; } #view-dashboards .dtable.stack td[data-label="Tiles"]::before { content: none !important; } }
@media (max-width: 719.98px) {
  #view-dashboards .dtable.stack .w3-name-cell, #view-sources .dtable.stack .w3-name-cell { max-width: none; width: auto; }
  #view-worksheets .w3-ws:not(.w3-sheet-open) .w3-ws-left { display: none; }
  #view-worksheets .w3-sheet-open .w3-ws-left { width: auto; }
  #view-worksheets .w3-sheet-open .w3-lsec-ws { flex: 0 0 auto; max-height: 40dvh; }
}
@media (max-width: 719.98px) {
  #view-sources .w3-src-left { flex: 1 1 auto; width: auto; max-width: none; }
  #view-sources .w3-src-list { max-height: none; overflow: visible; }
  #view-dashboards .w3-tile-h { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  #view-dashboards .w3-tile-head { height: auto; min-height: 56px; padding-top: 10px; padding-bottom: 6px; align-items: flex-start; }
}

/* ============================================================
   R3 final pass (REFINE3) — F2 core work surfaces
   ============================================================ */

/* ---- chat: one wrapper, exact edges; edge fade above the composer; group rows ---- */
#view-chat .w3-ans-table-wrap { width: 100%; box-sizing: border-box; }
#view-chat .w3-bot-body { padding-right: 0; }
#view-chat .w3-user-bubble { margin-right: 0; }
#view-chat .w3-chat-dock::before {
  content: ""; position: absolute; left: 0; right: 0; top: -24px; height: 24px; pointer-events: none;
  background: linear-gradient(to bottom, transparent, var(--bg));
}
#view-chat .w3-ans-table tr.w3-grp th {
  padding: 8px 12px 4px; text-align: left; font-size: var(--fs-12); line-height: 18px; font-weight: var(--fw-med);
  color: var(--text-2); background: var(--surface); border-bottom: 1px solid var(--line); position: static;
}
#view-chat .w3-ans-table tr.w3-grp-over th { color: var(--err); }
#view-chat .w3-overdue, #view-chat .w3-due { white-space: nowrap; }
#view-chat .w3-ans-table td[data-label="Due"] { min-width: 150px; white-space: nowrap; }
#view-chat .w3-suggest-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 auto; }
#view-chat .w3-suggest-cat { font-size: var(--fs-11); line-height: 16px; color: var(--text-2); }
/* single 160ms fade for a new answer and the user bubble */
#view-chat .w3-fresh-user { animation: w3-op var(--t-fast, 120ms) var(--ease, ease) both; }
@media (max-width: 719.98px) {
  #view-chat .w3-ans-table tr.w3-grp { display: block; padding: 10px 0 2px; border-bottom: 0; }
  #view-chat .w3-ans-table tr.w3-grp th { display: block; padding: 0; background: none; border: 0; }
  #view-chat .w3-ans-table td[data-label="Due"] { min-width: 0; }
}

/* ---- worksheets: 48px pane heads, 8px tree gaps, phone results menu ---- */
#view-worksheets .w3-lsec-head { height: 48px; flex-basis: 48px; border-bottom: 0; }
#view-worksheets .w3-lsec-obj .w3-lsec-head { height: 40px; flex-basis: 40px; }
#view-worksheets .w3-tnode { gap: 8px; }
#view-worksheets .w3-ins { gap: 8px; }
#view-worksheets .w3-res-more { display: none; }
@media (max-width: 719.98px) {
  #view-worksheets .w3-res-acts { display: none !important; }
  #view-worksheets .w3-res-more { display: inline-grid; width: 44px; height: 44px; margin-left: auto; }
  .w3-col-rs { display: none; }
}

/* ---- grid: headers never truncated by shrink-to-fit; resize handle clipped to the header ---- */
.w3-grid th.w3-fit { min-width: max-content; max-width: none; overflow: visible; }
.w3-grid th.w3-fit .w3-th-n { overflow: visible; text-overflow: clip; }
.w3-grid th { overflow: hidden; }
.w3-grid .w3-th-btn { border: 0; background: transparent; }

/* ---- number tiles: fixed 3-row grid (title block · value · reserved caption) so values share a baseline ---- */
#view-dashboards .w3-tile-number .w3-tile-body { justify-content: flex-start; padding: 8px 16px 16px; }
.w3-tile-fill > .w3-num, .w3-prev-body > .w3-num { flex: 0 0 auto; }
.w3-num { display: grid; grid-template-rows: 48px 18px; align-content: start; justify-content: stretch; gap: 4px; height: auto; }
.w3-num-v { align-self: end; }
.w3-num-l { min-height: 18px; line-height: 18px; }
#view-dashboards .w3-tile-h { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
#view-dashboards .w3-tile-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 719.98px) {
  #view-dashboards .w3-tile-h { display: block !important; -webkit-line-clamp: unset; white-space: nowrap; }
  #view-dashboards .w3-tile-head { height: 56px; min-height: 56px; padding-top: 0; padding-bottom: 0; align-items: center; }
  .w3-num { grid-template-rows: 34px 18px; }
  /* dashboard list cards: content centred, no empty band */
  #view-dashboards .dtable.stack tr.dash-row { min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; }
}
.w3-cv-last { fill: var(--text); font-weight: var(--fw-med); }

/* ---- trees: 24px chevron hit areas without changing the visual size ---- */
#view-sources .w3-chev, #view-worksheets .w3-chev { position: relative; }
#view-sources .w3-chev::after, #view-worksheets .w3-chev::after { content: ""; position: absolute; left: 50%; top: 50%; width: 24px; height: 24px; margin: -12px 0 0 -12px; }
#view-chat .w3-msg-bot { max-width: none; width: calc(100% + 32px); }
#view-chat .w3-chat-scroll { scrollbar-gutter: stable both-edges; }
@media (max-width: 719.98px) { #view-chat .w3-msg-bot { width: auto; } #view-chat .w3-chat-scroll { scrollbar-gutter: auto; } }
#view-worksheets .w3-ttable.w3-ind2.w3-ins, #view-worksheets .w3-tcol.w3-ind3 { gap: 8px; }
.w3-grid .w3-rn { width: 1%; }

/* R4: idle assistant = filled disc + mono ring (identity, not a control) */
.wsn-assistant-disc { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); color: var(--text-3); }
/* R4 dark: greyscaled vendor glyphs stay legible at rest */
[data-theme="dark"] .v2p-help-item .v2p-mk { filter: grayscale(1) brightness(1.7) contrast(.9); opacity: .8; }
[data-theme="dark"] .v2p-help-item:hover .v2p-mk, [data-theme="dark"] .v2p-help-item.active .v2p-mk, [data-theme="dark"] .v2p-help-item[aria-current] .v2p-mk { filter: none; opacity: 1; }
/* R4 docs: prose measure */
.docs-article :is(p, li, .lede), .doc-body :is(p, li) { max-width: 68ch; }

/* R4 a11y: worksheet row = container; stretched "open" button + sibling delete button (visuals unchanged) */
#view-worksheets .ws-item-open {
  position: static; display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; padding: 0; margin: 0;
  border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
#view-worksheets .ws-item-open::after { content: ""; position: absolute; inset: 0; z-index: 0; }
#view-worksheets .ws-item-open:focus-visible { outline: none; }
#view-worksheets .ws-item-open:focus-visible::after { box-shadow: var(--ring-inset); }
#view-worksheets .w3-ws-item .ws-del { position: relative; z-index: 1; }

/* R4: number tiles — no reserved caption row; value sits under the title, tile 128px (not bottom-heavy) */
.w3-num { grid-template-rows: auto !important; }
#view-dashboards .w3-tile-number { min-height: 128px; }
#view-dashboards .w3-tile-number .w3-tile-body { justify-content: flex-start; padding: 8px 16px 16px; }

/* ==== GOLIVE F (go-live fixes) ==== */
/* F9: long usernames / display names truncate in tables instead of pushing columns off-screen */
#view-admin .adm-users td[data-label="User"] { max-width: 320px; }
#view-admin .adm-user { min-width: 0; max-width: 100%; }
#view-admin .adm-user-text { min-width: 0; max-width: 100%; overflow: hidden; }
#view-admin .adm-user-name, #view-admin .adm-user-handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
@media (max-width: 719.98px) { #view-admin .adm-users td[data-label="User"] { max-width: none; } }
/* F6: Admin › Settings — import roots + document review */
#view-admin .adm-set-next { margin-top: 28px; }
#view-admin .adm-roots { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--line); border-radius: 6px; }
#view-admin .adm-root { display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 12px; min-height: 40px; }
#view-admin .adm-root + .adm-root { border-top: 1px solid var(--line); }
#view-admin .adm-root-path { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: var(--fs-12); color: var(--text); background: none; padding: 0; }
#view-admin .adm-roots-add { display: flex; align-items: flex-end; gap: 8px; margin: 0 0 8px; }
#view-admin .adm-roots-add .field { margin: 0; min-width: 0; flex: 1 1 auto; }
#view-admin .adm-check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
#view-admin .adm-check input { margin-top: 3px; }
#view-admin .adm-check-t { display: block; font-weight: var(--fw-med); color: var(--text); }
#view-admin .adm-check .adm-small { display: block; }
/* F4: worksheet Cancel sits inline with the running status */
.w3-ws-status .w3-cancel { height: 24px; padding: 0 8px; margin-left: 6px; }
#view-admin #iroots-body code { overflow-wrap: anywhere; word-break: break-all; }
#view-admin #iroots-body .hint-line > span { min-width: 0; }
@media (max-width: 600px) { #view-admin .adm-roots-add { flex-direction: column; align-items: stretch; } }
/* F8: plain notice row (hosting over HTTP) */
.v2p-notice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin: 12px 0 16px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); border-radius: 8px; background: var(--surface); font-size: var(--fs-13); color: var(--text-2); }
.v2p-notice > svg { flex: 0 0 auto; margin-top: 2px; color: var(--warn); }
.v2p-notice > span { min-width: 0; }
.v2p-dm-card:disabled { cursor: not-allowed; }
/* F10: Admin guides list links to Help */
#view-admin li.adm-doc { padding: 0; }
#view-admin .adm-doc-link { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 8px 16px; color: var(--text); text-decoration: none; }
#view-admin .adm-doc-link:hover { background: var(--surface-2); }
#view-admin .adm-doc-link:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#view-admin .adm-audit td[data-label="User"] { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 719.98px) { #view-admin .adm-audit td[data-label="User"] { max-width: none; overflow-wrap: anywhere; white-space: normal; } }
/* BAA attestation fields (model endpoints) */
.baa-fields { margin: 4px 0 12px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.baa-fields .adm-check, .baa-check { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; font-size: var(--fs-13); color: var(--text); cursor: pointer; }
.baa-fields .form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.baa-fields .field { margin: 0; min-width: 0; }
.baa-fields .field.grow { flex: 1 1 180px; }
/* MFA key: wrap only between 4-character groups */
.mfa-secret { word-break: normal; overflow-wrap: normal; white-space: normal; }
@media (max-width: 480px) { .mfa-secret-row .mfa-secret { display: block; margin: 4px 0; } }
/* Docs on phones: the guide picker pane is full width and only as tall as its content */
@media (max-width: 719.98px) { .v2p-docs > .v2p-help-side { flex: 0 0 auto !important; width: auto !important; } }
/* Security › Outbound allowlist */
.v2p-allow { margin-top: 16px; }
.v2p-allow-list { list-style: none; margin: 0 0 12px; padding: 0; border: 1px solid var(--line); border-radius: 6px; }
.v2p-allow-row { display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 12px; min-height: 44px; }
.v2p-allow-row + .v2p-allow-row { border-top: 1px solid var(--line); }
.v2p-allow-main { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-width: 0; }
.v2p-allow-host { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.v2p-allow-add { display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; margin: 0 0 8px; }
.v2p-allow-add .field { margin: 0; min-width: 0; flex: 0 1 240px; }
.v2p-allow-add .field.grow { flex: 1 1 240px; }
@media (max-width: 600px) { .v2p-allow-add { flex-direction: column; align-items: stretch; } .v2p-allow-add .field, .v2p-allow-add .field.grow { flex: none; } }
.v2p-allow { margin-bottom: 16px; }
.v2p-dm-card:disabled:not(.on) { opacity: .55; }
.w3-upl-warn { display: flex; gap: 8px; align-items: flex-start; margin-top: 8px; padding: 8px 12px; border: 1px solid color-mix(in srgb, var(--warn) 45%, var(--line)); border-radius: 6px; font-size: var(--fs-12); color: var(--text-2); }
.w3-upl-warn > svg { flex: 0 0 auto; margin-top: 2px; color: var(--warn); }
.w3-upl-warn strong { color: var(--text); font-weight: 600; }
.w3-upl-warn ul { margin: 2px 0 0; padding-left: 16px; }
.v2p-tile-net { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: var(--fs-12); color: var(--text-3); }
.v2p-tile-net svg { flex: 0 0 auto; }
.w3-composer-count { font-size: var(--fs-12); color: var(--text-3); font-variant-numeric: tabular-nums; margin-right: 8px; white-space: nowrap; }
.w3-composer-count.w3-over { color: var(--warn); }
.v2p-sched-name, .v2p-sched-owner { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.v2p-sched-t .v2p-c-act { text-align: right; width: 1%; white-space: nowrap; }
@media (max-width: 719.98px) { .v2p-sched-t td.actions { display: block; margin-top: 8px; } .v2p-sched-t td.actions::before { content: none !important; } }

/* E2E D-1 / U-5: redacted history answer and pending-certification note */
.w2-redacted-body p { display: flex; align-items: flex-start; gap: 8px; margin: 0; color: var(--text-2); font-style: normal; }
.w2-redacted-body p > svg { flex: 0 0 auto; margin-top: 4px; color: var(--text-3); }
.w3-pending-cert { display: flex; align-items: flex-start; gap: 6px; }
.w3-pending-cert > svg { flex: 0 0 auto; margin-top: 2px; }
.w3-locked-note { display: flex; align-items: center; gap: 8px; padding: 12px 16px; font-size: var(--fs-12); color: var(--text-3); }
.w3-upl-warn.w3-upl-info { border-color: var(--line); }
.w3-upl-warn.w3-upl-info > svg { color: var(--text-3); }
/* E2E D-2: declined answers — a quiet rule on the left and a plain "Not answered" tag, no colour */
#view-chat .w3-msg-declined .w3-md { padding-left: 12px; border-left: 2px solid var(--line-strong); }
#view-chat .w3-declined-tag { font-weight: 600; color: var(--text-2); }
/* Team DQ: per-source data quality panel — text only, colour only where it is the information */
#view-sources .dq-score { font-size: var(--fs-13); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
#view-sources .dq-score .dq-of { font-weight: 400; color: var(--text-3); }
#view-sources .dq-score.dq-warn { color: var(--warn); }
#view-sources .dq-score.dq-bad { color: var(--err); }
#view-sources .dq-warn-t { color: var(--warn); font-weight: 500; }
#view-sources .dq-dd > span:first-child { min-width: 0; overflow-wrap: anywhere; }
#view-sources .dq-cadence { font: inherit; font-size: var(--fs-12); color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 2px 6px; }
#view-sources .dq-issues { list-style: none; margin: 8px 0 0; padding: 0; }
#view-sources .dq-issue { display: flex; align-items: baseline; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-13); }
#view-sources .dq-issue:last-child { border-bottom: 0; }
#view-sources .dq-issue .dq-msg { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
#view-sources .dq-issue .w3-linkbtn { flex: 0 0 auto; white-space: nowrap; }
#view-sources .dq-line { margin: 6px 0 0; font-size: var(--fs-13); }
