/* =================================================================
   DATA STUDIO - the workbench in the new frame (portal-look-and-feel.md 3.18)
   -----------------------------------------------------------------
   A TOKEN-ONLY DOOR, whole (Tests/ShellTokensOnlyTests): every colour
   reads a --theme-* / --wf-* token, so a dark, grey, sharp or pill
   tenant re-skins all of it. ONE OWNER: every ds-* class is styled
   unscoped here and nowhere else (Tests/ConversationBuilderCssOwnershipTests).

   An APP page (BlazorConventions "Page Layout Modes"): .ds-page fills the
   page area; the library is a card column of its own on the left and the
   main column (.ds-composer) scrolls on its own. Under 760px of page the
   library folds behind a toggle under the header, the main column's
   children join the page's own flow and the sheet scrolls the lot.
   Inner layouts read the main column's width (container dsmain), so a
   table stacks when ITS column is narrow, whatever the window.
   ================================================================= */

.ds-page {
    display: flex;
    flex: 1;
    gap: var(--wf-space-4);
    min-height: 0;
    min-width: 0;
    overflow: hidden;
}

/* ── The library (left column) ───────────────────────────────────── */

.ds-library {
    display: flex;
    flex-direction: column;
    flex: 0 0 280px;
    width: 280px;
    min-height: 0;
    overflow: hidden;
    background: var(--wf-card);
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-lg);
    box-shadow: var(--wf-elev-1);
}

/* ── The main column ─────────────────────────────────────────────── */

.ds-composer {
    container: dsmain / inline-size;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow-y: auto;
    /* An inner scroll box: a sticky inside it sticks to the box's top, not under the shell bar. */
    --wf-sticky-top: 0px;
    /* Room for focus rings and card shadows at the column's edges. */
    padding: 2px 6px var(--wf-space-6);
}

.ds-header.wf-page-header { margin-bottom: var(--wf-space-5); }
/* min-width 0: the actions wrap inside the header instead of widening it (a long remembered name, a long option). */
.ds-header .wf-page-actions { align-items: center; min-width: 0; }
.ds-header-select {
    width: auto;
    min-width: 11rem;
    max-width: 16rem;
}
.ds-vertical-select { min-width: 9rem; max-width: 11rem; }
.ds-iconbtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    padding-inline: 0;
}
.ds-iconbtn.btn-sm { min-width: 30px; }
.ds-iconbtn > .bi { margin: 0; }
.ds-new { white-space: nowrap; }
/* The remembered-state chip (AreaResetButton) - the page's own class; pages.css owns the chip itself. */
.ds-reset { min-width: 0; max-width: min(16rem, 100%); }

/* The phone's library toggle: hidden while the library has its own column. */
.ds-lib-toggle { display: none; }

.ds-stack { display: flex; flex-direction: column; gap: var(--wf-space-4); }
.ds-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--wf-space-4);
    align-items: start;
}
@container dsmain (max-width: 720px) {
    .ds-pair { grid-template-columns: minmax(0, 1fr); }
}

/* ── A section card (the start page, the tabs' cards, the relationship cards) ── */

.ds-sec { padding: 18px 20px; overflow: visible; }
.ds-sec-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}
.ds-sec-words { flex: 1 1 auto; min-width: 0; }
.ds-sec-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: var(--theme-text-emphasis);
    font-size: var(--wf-text-h3);
    font-weight: 650;
    line-height: 1.35;
}
.ds-sec-sub {
    margin: 2px 0 0;
    max-width: 72ch;
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
    line-height: 1.45;
}
.ds-sec-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 12px 0 0;
    color: var(--theme-text-muted);
    font-size: var(--wf-text-sm);
}

/* ── The honest states ───────────────────────────────────────────── */

.ds-failed {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
}
.ds-failed-text { flex: 1 1 auto; margin: 0; color: var(--theme-text-emphasis); font-weight: 600; }
.ds-first { overflow: visible; }
.ds-inline-failed {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 14px;
    border-radius: var(--wf-radius-md);
    background: var(--wf-inset);
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
}
.ds-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--wf-radius-md);
    background: var(--wf-inset);
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
}

/* Skeletons in the shape of what is coming. */
.ds-skel-row { height: 44px; margin-bottom: 8px; }
.ds-skel-row:last-child { margin-bottom: 0; }
.ds-skel-rows { padding-top: 4px; }
.ds-skel-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 10px; margin-top: 14px; }
.ds-skel-tile { height: 58px; }
.ds-skel-block { height: 168px; }
.ds-skel-head { display: flex; align-items: center; gap: 14px; }
.ds-skel-ic { flex: none; width: 44px; height: 44px; }
.ds-skel-lines { display: flex; flex: 1 1 auto; flex-direction: column; gap: 10px; }
.ds-skel-w40 { width: 40%; }
.ds-skel-w70 { width: 70%; }
.ds-skel-tabs { width: 60%; margin-top: 22px; margin-bottom: 14px; }

/* ── The start page ──────────────────────────────────────────────── */

.ds-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
    gap: 10px;
    margin: 0;
    padding: 0;
    list-style: none;
}
.ds-tile {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 58px;
    padding: 10px 12px;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-md);
    background: var(--wf-card);
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background var(--wf-motion), border-color var(--wf-motion), box-shadow var(--wf-motion);
}
.ds-tile:hover { background: var(--wf-card-hover); border-color: var(--wf-line-strong); box-shadow: var(--wf-elev-1); }
.ds-tile:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 2px; }
.ds-tile-words { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.ds-tile-name {
    overflow: hidden;
    color: var(--theme-text-emphasis);
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-tile-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    color: var(--theme-text-muted);
    font-size: var(--wf-text-xs);
    font-variant-numeric: tabular-nums;
}
.ds-tile-tag { display: inline-flex; align-items: center; gap: 3px; }
.ds-tile-recent { flex: none; color: var(--theme-text-muted); font-size: 14px; }

.ds-doors { display: flex; flex-direction: column; margin: 0; padding: 0; list-style: none; }
.ds-doors > li + li { border-top: 1px solid var(--wf-line); }
.ds-door {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 56px;
    padding: 10px 6px;
    border: 0;
    border-radius: var(--wf-radius-sm);
    background: none;
    color: inherit;
    font: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--wf-motion);
}
.ds-door:hover { background: var(--wf-card-hover); color: inherit; }
.ds-door:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: -2px; }
.ds-door-words { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.ds-door-title { color: var(--theme-text-emphasis); font-weight: 600; }
.ds-door-text { color: var(--theme-text-secondary); font-size: var(--wf-text-sm); line-height: 1.4; }
.ds-door-go { flex: none; color: var(--theme-text-muted); }
.ds-door:hover .ds-door-go { color: var(--wf-primary-ink); }

/* ── The open entity's card ──────────────────────────────────────── */

.ds-entity { padding: 18px 20px 0; overflow: visible; }
.ds-entity-head { display: flex; align-items: flex-start; gap: 14px; }
.ds-entity-ic { margin-top: 2px; }
.ds-entity-words { flex: 1 1 auto; min-width: 0; }
.ds-entity-title {
    margin: 0;
    color: var(--theme-text-emphasis);
    font-size: var(--wf-text-h2);
    font-weight: 650;
    letter-spacing: -0.012em;
    line-height: 1.3;
    overflow-wrap: anywhere;
}
.ds-entity-desc {
    margin: 4px 0 0;
    max-width: 72ch;
    color: var(--theme-text-secondary);
    font-size: 13.5px;
    line-height: 1.5;
}
.ds-facts {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 16px;
    margin-top: 10px;
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
}
.ds-fact { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.ds-fact > .bi { color: var(--wf-primary-ink); }
.ds-fact-code { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-fact-linked > .bi { color: var(--theme-text-muted); }
.ds-entity-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; flex: none; }
.ds-act { white-space: nowrap; }
.ds-entity-menu { min-width: 15rem; }
@container dsmain (max-width: 640px) {
    .ds-entity-head { flex-wrap: wrap; }
    .ds-entity-ic { display: none; }
    .ds-entity-actions { flex-basis: 100%; justify-content: flex-start; }
}
@container dsmain (max-width: 420px) {
    .ds-act-word { display: none; }
}

/* The tabs sit at the card's foot: a hairline above, the selected tab's underline on the card's edge. A narrow
   column scrolls them sideways inside the card (a swipe row) - the page never does. */
.wf-tabs.ds-tabs {
    flex-wrap: nowrap;
    margin: 16px -20px 0;
    padding: 0 12px;
    overflow-x: auto;
    border-top: 1px solid var(--wf-line);
    border-bottom: 0;
    scrollbar-width: none;
}
.wf-tabs.ds-tabs::-webkit-scrollbar { display: none; }
.ds-tabs > .wf-tab { flex: none; margin-bottom: 0; white-space: nowrap; }
.ds-tabs > .wf-tab > .bi { color: var(--theme-text-muted); }
.ds-tabs > .wf-tab.active > .bi { color: var(--wf-primary-ink); }

.ds-panel { margin-top: var(--wf-space-4); }
.ds-data-card { padding: 16px 18px; }
.ds-panel > .ds-sec + .ds-sec { margin-top: var(--wf-space-4); }

/* ── "Build a context for this" (the nudge; was BuildContextNudge.razor.css) ── */

.ds-nudge {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-md);
    background: var(--wf-brand-wash), var(--wf-card);
}
.ds-nudge-text { display: flex; flex: 1 1 auto; flex-direction: column; gap: 2px; min-width: 0; }
.ds-nudge-title { color: var(--theme-text-emphasis); font-weight: 600; }
.ds-nudge-body { color: var(--theme-text-secondary); font-size: var(--wf-text-sm); }
.ds-nudge-actions { display: flex; flex: none; align-items: center; gap: 4px; }
@container dsmain (max-width: 560px) {
    .ds-nudge { flex-wrap: wrap; }
    .ds-nudge-actions { flex-basis: 100%; }
}

/* ── The Properties tab ──────────────────────────────────────────── */

.ds-props { min-width: 0; }
.ds-props-card .ds-drop-zone { margin-top: 14px; }
.ds-props-head { margin-bottom: 10px; }
.ds-props-table { table-layout: fixed; width: 100%; margin: 0; }
.ds-props-table .ds-props-col-drag { width: 2rem; }
.ds-props-table .ds-props-col-type { width: 9rem; }
.ds-props-table .ds-props-col-rules { width: 15rem; }
.ds-props-table .ds-props-col-act { width: 6rem; }
/* A middling column: the declared columns give the property its room back before the table stacks at 640px. */
@container dsmain (max-width: 820px) {
    .ds-props-table .ds-props-col-type { width: 7.5rem; }
    .ds-props-table .ds-props-col-rules { width: 11rem; }
}
.ds-props-table td { vertical-align: middle; }
.ds-props-table > tbody > tr.is-drop-target > td { background: var(--wf-primary-soft); box-shadow: inset 0 2px 0 var(--wf-primary-ink); }
.ds-props-drag { color: var(--theme-text-muted); text-align: center; cursor: grab; user-select: none; }
.ds-props-cell-name { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ds-props-ic { flex: none; width: 30px; height: 30px; font-size: 14px; }
.ds-props-words { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ds-props-link {
    max-width: 100%;
    padding: 0;
    overflow: hidden;
    border: 0;
    background: none;
    color: var(--theme-text-emphasis);
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}
.ds-props-link:hover { color: var(--wf-primary-ink); text-decoration: underline; }
.ds-props-link:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 2px; border-radius: var(--wf-radius-xs); }
.ds-props-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.ds-props-code {
    max-width: 100%;
    overflow: hidden;
    color: var(--theme-text-muted);
    font: 500 11.5px var(--theme-font-mono);
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-props-mark { color: var(--wf-primary-ink); font-size: 12px; }
.ds-props-cell-rules { line-height: 1.9; }
.ds-props-cell-rules > .ds-rel-pill + .ds-rel-pill { margin-left: 4px; }
.ds-rel-pill.is-strong { color: var(--theme-text-emphasis); }
.ds-rel-pill.is-key { background: var(--wf-primary-soft); color: var(--wf-primary-ink); }
.ds-rel-pill.is-fix { background: var(--wf-warning-soft); color: var(--wf-warning-ink); }
.ds-props-remove { color: var(--wf-danger-ink); }
.ds-inline-failed.is-error { margin-top: 10px; background: var(--wf-danger-soft); color: var(--wf-danger-ink); }
/* A re-read that did not answer: the quiet line over the last good rows. */
.ds-props-stale { margin-bottom: 10px; }

@container dsmain (max-width: 640px) {
    .ds-props-table, .ds-props-table tbody { display: block; }
    .ds-props-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .ds-props-table tbody > tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "name name act" "type rules rules";
        align-items: center;
        gap: 6px 12px;
        padding: 12px 0;
        border-bottom: 1px solid var(--wf-line);
    }
    .ds-props-table tbody > tr:last-child { border-bottom: 0; }
    /* (0,1,3) - wf.css pads every .table > tbody > tr > td at the same weight; this sheet loads later. */
    .ds-props-table > tbody > tr > td { display: block; padding: 0; border: 0; }
    .ds-props-table .ds-props-drag { display: none; }
    .ds-props-table .ds-props-cell-name { display: flex; grid-area: name; }
    .ds-props-table .ds-props-cell-type { grid-area: type; }
    .ds-props-table .ds-props-cell-rules { grid-area: rules; }
    .ds-props-table .ds-props-cell-act { grid-area: act; align-self: start; }
}

.ds-drop-zone { margin: 12px 20px 0; }

.ds-drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px;
    margin-top: 8px;
    border: 1.5px dashed var(--wf-line-strong);
    border-radius: var(--wf-radius-md);
    color: var(--theme-text-muted);
    font-size: var(--wf-text-sm);
    transition: border-color var(--wf-motion), background-color var(--wf-motion), color var(--wf-motion);
}
.ds-drop-zone.active {
    border-color: var(--wf-primary-ink);
    background-color: var(--wf-primary-soft);
    color: var(--wf-primary-ink);
}

.ds-children-columns { display: flex; gap: var(--wf-space-5); }
.ds-children-column { flex: 1; min-width: 0; }
.ds-children-column-header {
    margin-bottom: 8px;
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
    font-weight: 600;
}
.ds-condition-pickers { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.ds-condition-pickers > .form-select { width: auto; max-width: 100%; }
@container dsmain (max-width: 720px) {
    .ds-children-columns { flex-direction: column; }
}

/* ── The Forms tab: a table above 640px of column, one card per form under it (3.10) ── */

.ds-forms { overflow: visible; }
.ds-forms-table { table-layout: fixed; width: 100%; margin: 0; }
.ds-forms-table .ds-col-who { width: 8rem; }
.ds-forms-table .ds-col-check { width: 9.5rem; }
.ds-forms-table .ds-col-act { width: 7.5rem; }
.ds-forms-table td { vertical-align: middle; }
.ds-cell-form { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ds-cell-form > .bi { flex: none; color: var(--wf-primary-ink); }
.ds-cell-words { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.ds-cell-title, .ds-cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-cell-title { color: var(--theme-text-emphasis); font-weight: 600; }
.ds-cell-sub { color: var(--theme-text-muted); font-size: var(--wf-text-xs); }
.ds-cell-who { color: var(--theme-text-secondary); }
.ds-form-acts { display: flex; justify-content: flex-end; gap: 4px; }
.ds-forms-table .ds-form-acts { justify-content: flex-start; }
.ds-forms-table tr.ds-row-highlighted > td { background: var(--wf-primary-soft); }

@container dsmain (max-width: 640px) {
    .ds-forms-table, .ds-forms-table tbody { display: block; }
    .ds-forms-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .ds-forms-table tbody > tr {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        grid-template-areas: "form form act" "who check check";
        gap: 4px 12px;
        padding: 12px 0;
        border-bottom: 1px solid var(--wf-line);
    }
    .ds-forms-table tbody > tr:last-child { border-bottom: 0; }
    .ds-forms-table > tbody > tr > td { display: block; padding: 0; border: 0; }
    .ds-forms-table .ds-cell-form { display: flex; grid-area: form; }
    .ds-forms-table .ds-cell-act { grid-area: act; align-self: center; }
    .ds-forms-table .ds-cell-who,
    .ds-forms-table .ds-cell-check { display: inline-flex; align-items: center; gap: 6px; font-size: var(--wf-text-xs); }
    .ds-forms-table .ds-cell-who { grid-area: who; }
    .ds-forms-table .ds-cell-check { grid-area: check; justify-self: start; }
    .ds-forms-table .ds-cell-who::before { content: attr(data-label) ":"; color: var(--theme-text-muted); }
}

/* ── The Relationships tab ───────────────────────────────────────── */

.ds-rel-container { display: flex; flex-direction: column; gap: var(--wf-space-4); }
.ds-rel-container > .ds-sec + .ds-sec { margin-top: 0; }
.ds-rel-add-btn { flex: none; white-space: nowrap; }
.ds-rel-note {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin: 12px 0 0;
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
}
.ds-rel-note > .bi { margin-top: 2px; color: var(--theme-text-muted); }
.ds-rel-list { display: flex; flex-wrap: wrap; gap: 8px; }
.ds-rel-entity-card {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    max-width: 100%;
    min-height: 40px;
    padding: 6px 12px;
    border: 1px solid var(--wf-line-strong);
    border-radius: var(--wf-radius-md);
    background: var(--wf-card);
    color: var(--theme-text);
    font: inherit;
    font-size: var(--wf-text-sm);
    text-align: left;
    cursor: pointer;
    transition: background var(--wf-motion), border-color var(--wf-motion);
}
.ds-rel-entity-card:hover { background: var(--wf-card-hover); border-color: var(--wf-primary-ink); }
.ds-rel-entity-card:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: 2px; }
.ds-rel-entity-card > .bi { color: var(--wf-primary-ink); }
.ds-rel-entity-name { color: var(--theme-text-emphasis); font-weight: 600; overflow-wrap: anywhere; }
.ds-rel-entity-muted { color: var(--theme-text-muted); }
.ds-rel-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: var(--wf-radius-pill);
    background: var(--wf-neutral-soft);
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-xs);
    font-weight: 600;
    white-space: nowrap;
}
.ds-rel-subsection-label {
    margin: 12px 0 8px;
    color: var(--theme-text-secondary);
    font-size: var(--wf-text-sm);
    font-weight: 600;
}
.ds-rel-subsection-label:first-of-type { margin-top: 0; }
.ds-rel-empty-cta {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1.5px dashed var(--wf-line-strong);
    border-radius: var(--wf-radius-md);
    background: none;
    color: var(--theme-text-secondary);
    font: inherit;
    font-size: var(--wf-text-sm);
    text-align: left;
    cursor: pointer;
}
.ds-rel-empty-cta:hover { border-color: var(--wf-primary-ink); color: var(--wf-primary-ink); background: var(--wf-primary-soft); }
.ds-rel-empty-cta > .bi { color: var(--wf-primary-ink); }
.ds-key-slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@container dsmain (max-width: 560px) {
    .ds-key-slots { grid-template-columns: minmax(0, 1fr); }
}
.ds-key-slot {
    padding: 10px 12px;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-md);
    background: var(--wf-card);
    min-width: 0;
}
.ds-key-slot.filled { border-color: color-mix(in srgb, var(--wf-primary-ink) 45%, var(--wf-line)); background: var(--wf-primary-soft); }
.ds-key-slot.empty { border-style: dashed; background: none; }
.ds-key-slot-label { color: var(--theme-text-muted); font-size: var(--wf-text-xs); font-weight: 600; }
.ds-key-slot-name { margin-top: 2px; overflow: hidden; color: var(--theme-text-emphasis); font-size: var(--wf-text-sm); font-weight: 600; text-overflow: ellipsis; }
.ds-key-slot-display { color: var(--theme-text-secondary); font-size: var(--wf-text-xs); }
.ds-key-slot-empty { margin-top: 2px; color: var(--theme-text-muted); font-size: var(--wf-text-sm); }

/* ── The library's insides (DataStudioLibrary) ───────────────────── */

.ds-lib-tabs {
    display: flex;
    flex: none;
    padding: 4px 6px 0;
    border-bottom: 1px solid var(--wf-line);
}
.ds-lib-tab {
    display: inline-flex;
    flex: 1 1 auto;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 0;
    min-height: 40px;
    margin-bottom: -1px;
    padding: 0 6px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: none;
    color: var(--theme-text-muted);
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}
.ds-lib-tab:hover { color: var(--theme-text-emphasis); }
.ds-lib-tab.active { color: var(--theme-text-emphasis); border-bottom-color: var(--wf-primary-ink); }
.ds-lib-tab:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: -2px; border-radius: var(--wf-radius-xs); }
.ds-lib-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    border-radius: var(--wf-radius-pill);
    background: var(--wf-neutral-soft);
    color: var(--theme-text-secondary);
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}
.ds-lib-tab.active .ds-lib-count { background: var(--wf-primary-soft); color: var(--wf-primary-ink); }
.ds-lib-search { position: relative; flex: none; padding: 10px 10px 8px; }
.ds-lib-search > .bi {
    position: absolute;
    top: 50%;
    left: 21px;
    transform: translateY(-40%);
    color: var(--theme-text-muted);
    font-size: 13px;
    pointer-events: none;
}
.ds-lib-search > .form-control { padding-left: 30px; background: var(--wf-inset); border-color: transparent; }
.ds-lib-search > .form-control:focus { background: var(--wf-card); border-color: var(--wf-primary-ink); }
.ds-lib-items { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 2px 6px 8px; }
.ds-lib-items.is-split { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.ds-lib-item {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 4px 8px;
    border-radius: var(--wf-radius-sm);
    color: var(--theme-text);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--wf-motion);
}
.ds-lib-item[draggable="true"] { cursor: grab; }
.ds-lib-item:hover { background: var(--wf-card-hover); }
.ds-lib-item:focus-visible { outline: 2px solid var(--wf-primary-ink); outline-offset: -2px; }
.ds-lib-item.active {
    background: var(--wf-primary-soft);
    color: var(--theme-text-emphasis);
    font-weight: 600;
    box-shadow: inset 3px 0 0 var(--wf-primary-ink);
}
.ds-lib-ic { flex: none; width: 1rem; color: var(--theme-text-muted); font-size: 13px; text-align: center; }
.ds-lib-item.active .ds-lib-ic { color: var(--wf-primary-ink); }
.ds-lib-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ds-lib-pill {
    flex: none;
    max-width: 7rem;
    overflow: hidden;
    padding: 1px 7px;
    border-radius: var(--wf-radius-pill);
    background: var(--wf-neutral-soft);
    color: var(--theme-text-secondary);
    font-size: 11px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ds-lib-tr { flex: none; font-size: 11px; }
.ds-lib-tr.is-done { color: var(--wf-success-ink); }
.ds-lib-tr.is-missing { color: var(--wf-warning-ink); }
.ds-lib-linked { flex: none; color: var(--theme-text-muted); font-size: 12px; }
.ds-lib-del {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: var(--wf-radius-sm);
    background: none;
    color: var(--wf-danger-ink);
    font-size: 12px;
    opacity: 0;
    cursor: pointer;
    transition: opacity var(--wf-motion), background var(--wf-motion);
}
.ds-lib-item:hover .ds-lib-del,
.ds-lib-item:focus-within .ds-lib-del,
.ds-lib-del:focus-visible { opacity: 1; }
.ds-lib-del:hover { background: var(--wf-danger-soft); }
/* A row's own non-destructive act (start a conversation from a view): the delete button's shape, a neutral ink and hover. */
.ds-lib-act {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: var(--wf-radius-sm);
    background: none;
    color: var(--wf-primary-ink);
    font-size: 12px;
    opacity: 0;
    cursor: pointer;
    transition: opacity var(--wf-motion), background var(--wf-motion);
}
.ds-lib-item:hover .ds-lib-act,
.ds-lib-item:focus-within .ds-lib-act,
.ds-lib-act:focus-visible { opacity: 1; }
.ds-lib-act:hover { background: var(--wf-primary-soft); }
.ds-lib-note {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 14px;
    color: var(--theme-text-muted);
    font-size: var(--wf-text-sm);
    line-height: 1.45;
    text-align: center;
}
.ds-lib-note > .bi { font-size: 18px; }
.ds-lib-done { color: var(--wf-success-ink); }
.ds-lib-skel { display: flex; flex-direction: column; gap: 12px; padding: 12px 8px; }
.ds-lib-split { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.ds-lib-split-section { display: flex; flex: 1 1 0; flex-direction: column; min-height: 0; }
.ds-lib-split-section + .ds-lib-split-section { border-top: 1px solid var(--wf-line); }
.ds-lib-split-header {
    display: flex;
    flex: none;
    align-items: center;
    gap: 6px;
    padding: 10px 14px 6px;
    color: var(--theme-text-secondary);
    font-size: 12.5px;
    font-weight: 600;
}
.ds-lib-split-header > .bi { color: var(--theme-text-muted); }
.ds-lib-split-body { flex: 1 1 0; min-height: 0; overflow-y: auto; padding: 0 6px 8px; }
.ds-lib-footer {
    display: flex;
    flex: none;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    border-top: 1px solid var(--wf-line);
}
.ds-lib-footer > .btn { justify-content: center; }

/* The check glyph a saved view or report wears (its shape and its words carry the meaning). */
.ds-check-glyph { flex: none; font-size: 12px; cursor: help; }
.ds-check-glyph.is-ok { color: var(--wf-success-ink); }
.ds-check-glyph.is-warn { color: var(--wf-warning-ink); }
.ds-check-glyph.is-error { color: var(--wf-danger-ink); }

/* The catalog tab */
.ds-catalog-category { margin-bottom: 2px; }
.ds-catalog-category-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    min-height: 32px;
    margin: 4px 0 2px;
    padding: 0 8px;
    border: 0;
    border-radius: var(--wf-radius-sm);
    background: var(--wf-inset);
    color: var(--theme-text-secondary);
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}
.ds-catalog-category-header:hover { background: var(--wf-card-hover); color: var(--theme-text-emphasis); }
.ds-catalog-category-header > .ds-lib-count { margin-left: auto; }
.ds-catalog-chevron { flex: none; font-size: 10px; color: var(--theme-text-muted); }
.ds-catalog-item { padding-right: 4px; }
.ds-catalog-entity + .ds-catalog-entity { border-top: 1px solid var(--wf-line); }
.ds-catalog-import-btn {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--wf-line-strong);
    border-radius: var(--wf-radius-sm);
    background: var(--wf-card);
    color: var(--wf-primary-ink);
    font-size: 12px;
    cursor: pointer;
}
.ds-catalog-import-btn:hover { background: var(--wf-primary-soft); border-color: var(--wf-primary-ink); }
.ds-catalog-import-btn:disabled { opacity: .55; cursor: not-allowed; }
.ds-catalog-desc { padding: 2px 10px 6px 36px; color: var(--theme-text-muted); font-size: 12px; line-height: 1.4; }
.ds-catalog-preview { padding: 0 6px 8px 28px; }
.ds-catalog-preview-item { display: flex; align-items: center; gap: 6px; min-height: 26px; padding: 0 6px; color: var(--theme-text-secondary); font-size: 12px; }
.ds-catalog-preview-item.is-note { color: var(--theme-text-muted); font-style: italic; }

/* ── A phone, and a touch screen ─────────────────────────────────── */

/* Under 760px of page the library folds behind the toggle (open: above the main column's content), the main column
   joins the page's flow (display: contents - the header stays first) and the sheet scrolls everything. A box that is
   display: contents is no container, so the page itself becomes dsmain here: the tables still stack by their column. */
@container page (max-width: 760px) {
    .ds-page { container: dsmain / inline-size; flex-direction: column; flex: 1 0 auto; gap: 12px; overflow: visible; padding-bottom: 16px; }
    .ds-composer { display: contents; container: none; }
    .ds-composer > .ds-header { order: 0; margin-bottom: 0; }
    /* The actions take their own row under the words (root.css does this by the window under 768px; here by the page). */
    .ds-header .wf-page-actions { flex-basis: 100%; margin-left: 0; }
    .ds-lib-toggle { display: inline-flex; order: 1; align-self: flex-start; }
    .ds-library { display: none; order: 2; flex: none; width: auto; max-height: 70vh; }
    .ds-page.is-lib-open .ds-library { display: flex; }
    .ds-composer > :not(.ds-header):not(.ds-lib-toggle) { order: 3; min-width: 0; }
    /* min-width 0: a select is as wide as its longest option otherwise, and a long entity name would push the page sideways. */
    .ds-header-select, .ds-vertical-select { flex: 1 1 12rem; min-width: 0; max-width: none; }
}

/* 44px targets and 16px inputs on a coarse pointer (3.17). */
@media (pointer: coarse) {
    .ds-page .btn-sm,
    .ds-page .ds-iconbtn,
    .ds-page .ds-iconbtn.btn-sm { min-width: 44px; min-height: 44px; }
    .ds-page .form-control,
    .ds-page .form-select { min-height: 44px; font-size: 16px; }
    .ds-lib-tab { min-height: 44px; }
    .ds-lib-item { min-height: 44px; }
    .ds-lib-del,
    .ds-lib-act,
    .ds-catalog-import-btn { width: 44px; height: 44px; opacity: 1; }
    .ds-catalog-category-header { min-height: 44px; }
    .ds-rel-entity-card { min-height: 44px; }
    .ds-tile { min-height: 60px; }
    .ds-reset { min-height: 44px; }
    .ds-page .wf-action-menu-item { min-height: 44px; }
    /* The fix round's touch-target pass (targets.sh, a real coarse pointer at 390px): the shared pieces this page
       wears, raised here by the page (the Job Center's and the Answer Center's way) - the entity card's tabs, the
       remembered-state chip's clear, a child entity block's two buttons, the property names in the Properties table,
       the data browser's small selects and the Query console's SQL panel. */
    .ds-page .wf-tab { min-height: 44px; }
    .ds-reset.area-remember-chip { padding-block: 0; padding-right: 0; }
    .ds-reset > .area-remember-clear { align-self: stretch; min-width: 44px; min-height: 44px; padding: 0; }
    .ds-page .wf-canvas-action { min-width: 44px; min-height: 44px; }
    .ds-props-link { display: inline-flex; align-items: center; min-height: 44px; }
    .ds-page .form-select.form-select-sm,
    .ds-page .form-control.form-control-sm { min-height: 44px; font-size: 16px; }
    .ds-sql-query-panel .btn-sm { min-height: 44px; }
    .ds-sql-query-panel .form-select-sm { min-height: 44px; font-size: 16px; }
}

/* Reduced motion: nothing slides or fades. */
@media (prefers-reduced-motion: reduce) {
    .ds-tile, .ds-door, .ds-lib-item, .ds-lib-del, .ds-lib-act, .ds-drop-zone { transition: none; }
}

/* ── Data Browser ─────────────────────────────────────── */

.ds-data-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.6rem;
    margin-bottom: 0.75rem;
}

/* Toolbar clusters — related controls grouped with a tight inner gap,
   divided by thin separators so the bar reads as labeled sections. */
.ds-tb-group {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
}
.ds-tb-sep {
    width: 1px;
    height: 1.4rem;
    background: var(--theme-border);
    flex-shrink: 0;
}
/* Button text label sitting next to its icon (Filters / Columns / Export …). */
.ds-tb-label {
    font-size: 0.78rem;
}
/* The Group picker and the page-size picker (they wore inline styles; the coarse block lifts them to 16px / 44px). */
.ds-tb-groupby { max-width: 160px; font-size: 0.8rem; }
.ds-db-pagesize { width: auto; font-size: 0.8rem; }
/* Unsaved-view nudge — amber dot on the Save button when the user has shaped
   the view (filters / grouping / named keys) but not saved it. */
.ds-tb-save {
    position: relative;
}
.ds-tb-dot {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--theme-warning);
    border: 1.5px solid var(--theme-background-raised);
}

.ds-data-toolbar .form-control {
    max-width: 280px;
}

.ds-data-toolbar .ds-data-count {
    font-size: 0.72rem;
    color: var(--theme-text-secondary);
    margin-left: auto;
    background: var(--theme-background);
    border: 1px solid var(--theme-border);
    border-radius: 999px;
    padding: 0.12rem 0.6rem;
    white-space: nowrap;
}

/* The grid is a spreadsheet: it scrolls inside its own box (both ways) with a sticky head, so a long page of rows
   keeps its column names in sight and a wide one never pushes the page sideways (3.10 - the Answer Center's
   Explorer rule). */
.ds-data-table {
    max-height: min(72vh, 56rem);
    overflow: auto;
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-md);
    background: var(--wf-card);
}

.ds-data-table table {
    font-size: 0.82rem;
}

/* Drag to scroll (2026-11-24 - Kirk's mock-up): the open hand over the grid's body wherever a drag would move it
   (modules/dragscroll.js marks the box ds-can-drag on hover), the closed hand everywhere in the box while it pans
   (ds-grabbing). Links, buttons, fields and pictures keep their own cursors; an edit cell never pans. */
[data-drag-scroll].ds-can-drag tbody td:not(.ds-edit-cell) {
    cursor: grab;
}

[data-drag-scroll].ds-grabbing,
[data-drag-scroll].ds-grabbing * {
    cursor: grabbing !important;
    user-select: none;
}

.ds-data-table th {
    cursor: pointer;
    /* Allow header text to wrap so long labels ("SERVICE LOCATION / ACCESS
       INSTRUCTIONS") don't force the column wider than its data. But cap
       visually at 2 lines so an ultra-narrow column doesn't stack the
       header text into a disruptive 4-line tower.

       DO NOT use `display:-webkit-box` + `-webkit-line-clamp` here — that
       property requires block display, which removes the th from table-
       cell layout and causes every th to stack vertically in the first
       column (headers become a left-side tower, data rows flow below).
       Use line-height + max-height as a soft clamp instead; keeps the th
       as display:table-cell. No ellipsis on line 2, but clipped cleanly. */
    white-space: normal;
    line-height: 1.2;
    max-height: 2.4em;
    overflow: hidden;
    vertical-align: bottom;
    user-select: none;
    /* The header per 3.10: on the card, 12.5/600 muted, SENTENCE case, one hairline under it - and sticky inside
       the grid's own scroller. */
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 0.5rem 0.75rem;
    background-color: var(--wf-card);
    border-bottom: 1px solid var(--wf-line);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--theme-text-muted);
}

/* The sticky head needs a solid fill (wf.css paints thead.table-light transparent, !important). */
.ds-data-table thead.table-light th,
.ds-data-table thead th {
    background-color: var(--wf-card) !important;
}

.ds-data-table th:hover {
    background-color: var(--wf-card-hover);
    color: var(--theme-text-secondary);
}

/* Row hover — quiet highlight so the eye tracks across a dense row. */
.ds-data-table tbody tr:hover {
    background-color: var(--wf-card-hover);
}

.ds-data-cell {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ds-data-pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    font-size: 0.85rem;
}

.ds-data-detail {
    background: var(--theme-background-subtle);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 1rem;
    margin-top: 0.75rem;
}

.ds-data-detail dt {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--theme-text-muted);
}

.ds-data-detail dd {
    margin-bottom: 0.5rem;
    word-break: break-all;
}

.ds-data-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--theme-text-muted);
}

.ds-data-empty i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

/* ── Import Wizard ────────────────────────────────────── */

.ds-import-steps {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.ds-import-step {
    flex: 1;
    text-align: center;
    padding: 0.4rem 0;
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom: 3px solid var(--theme-border);
    color: var(--theme-text-muted);
}

.ds-import-step.active {
    border-bottom-color: var(--theme-primary);
    color: var(--theme-primary);
}

.ds-import-step.done {
    border-bottom-color: var(--theme-success);
    color: var(--theme-success);
}

.ds-import-mapping {
    max-height: 400px;
    overflow-y: auto;
}

.ds-import-mapping table td {
    vertical-align: middle;
}

.ds-import-preview {
    max-height: 300px;
    overflow: auto;
    font-size: 0.8rem;
}

.ds-import-results {
    text-align: center;
    padding: 1.5rem;
}

.ds-import-results .ds-result-number {
    font-size: 1.75rem;
    font-weight: 700;
}

.ds-import-results .ds-result-label {
    font-size: 0.8rem;
    color: var(--theme-text-muted);
}

.ds-import-dropzone {
    border: 2px dashed var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.ds-import-dropzone:hover {
    border-color: var(--theme-primary);
    background: var(--theme-background-subtle);
}

/* ── View Selector ───────────────────────────────────── */

.ds-view-select {
    max-width: 200px;
    font-size: 0.8rem;
}

.ds-toolbar-spacer {
    flex: 1;
}

/* ── Column Picker ───────────────────────────────────── */

.ds-column-picker {
    background: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.ds-column-picker-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.ds-column-picker-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.ds-column-picker-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
}

.ds-column-picker-item input[type="checkbox"] {
    margin: 0;
}

/* ── Advanced Filter Builder ──────────────────────────── */

.ds-filter-builder {
    background: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 0.75rem;
    margin-bottom: 0.75rem;
}

.ds-filter-builder-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.ds-filter-rule {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.35rem;
}

/* Incomplete rule (empty / whitespace value) — visible flag instead of
   silent drop. Mirror of FormFilterBar's .ef-filterbar-rule.is-incomplete
   styling. Red-tinted left border + flag icon make it clear the rule
   exists but won't apply until the user enters a value. */
.ds-filter-rule.is-incomplete {
    border-left: 3px solid var(--theme-danger);
    padding-left: 0.375rem;
    background-color: var(--wf-danger-soft);
    border-radius: var(--wf-radius-sm);
}

.ds-filter-rule-flag {
    color: var(--theme-danger);
    font-size: 0.85rem;
    flex-shrink: 0;
    cursor: help;
}

.ds-filter-conj {
    width: 70px;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.ds-filter-conj-label {
    width: 70px;
    flex-shrink: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    text-align: center;
}

.ds-filter-field {
    width: 140px;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.ds-filter-op {
    width: 110px;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.ds-filter-value {
    flex: 1;
    min-width: 100px;
    font-size: 0.8rem;
}

.ds-filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* ── Top-level Match pill (AND / OR) ─────────────────────
   SSMS-grade compact toggle. Visible only when meaningful
   (≥2 groups OR top-level rule + group). Pre-PR-322 the
   filter UI had no top-level combinator at all — flat
   AND/OR per-rule was the only option.
   Mirrors the .ds-report-match-* pattern in the Report
   Builder so the two surfaces feel consistent without
   sharing component code. */

.ds-filter-toplevel {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--wf-primary-soft);
    border: 1px solid var(--wf-line);
    border-radius: var(--wf-radius-sm);
    font-size: 0.8rem;
}

.ds-filter-toplevel-label {
    font-weight: 600;
    color: var(--theme-text-muted);
    flex-shrink: 0;
}

.ds-filter-toplevel-hint {
    font-style: italic;
    color: var(--theme-text-muted);
    font-size: 0.75rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Two-button pill — the active button picks up the info
   color, inactive button stays neutral. Tighter padding
   than a regular .btn-sm so the chip stays compact. */
.ds-filter-pill {
    display: inline-flex;
    border: 1px solid var(--theme-border);
    border-radius: var(--wf-radius-pill);
    overflow: hidden;
    flex-shrink: 0;
}

.ds-filter-pill-btn {
    background: transparent;
    border: none;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    cursor: pointer;
    transition: background-color 0.1s ease, color 0.1s ease;
}

.ds-filter-pill-btn:hover {
    background: var(--theme-background-hover);
    color: var(--theme-text);
}

.ds-filter-pill-btn.active {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
}

.ds-filter-pill-btn.active:hover {
    background: var(--theme-primary-hover);
    color: var(--theme-text-on-primary);
}

/* ── Indented sub-group container ─────────────────────────
   Vertical accent bar on the left + soft indented padding
   makes nested groups visually distinct from top-level
   rules. The header carries the group's AND/OR logic
   selector + Ungroup + ✕ controls. */

.ds-filter-group {
    border-left: 3px solid var(--wf-primary-ink);
    background: var(--theme-background-subtle);
    border-radius: 0 var(--wf-radius-sm) var(--wf-radius-sm) 0;
    padding: 0.4rem 0.5rem 0.4rem 0.6rem;
    margin: 0.4rem 0 0.4rem 0.5rem;
}

.ds-filter-group-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.35rem;
    font-size: 0.8rem;
}

.ds-filter-group-label {
    font-weight: 600;
    color: var(--theme-text-muted);
    font-size: 0.7rem;
}

.ds-filter-group-logic {
    width: 70px;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.ds-filter-group-actions {
    margin-top: 0.35rem;
}

/* In-group rule rows — slightly tighter than top-level so
   the visual hierarchy stays clear (top-level rules are
   the "outer scope"; in-group rules are nested children). */
.ds-filter-rule-in-group {
    margin-bottom: 0.25rem;
}

.ds-filter-rule-in-group .ds-filter-conj-label {
    color: var(--wf-primary-ink);
    text-transform: lowercase;
    font-style: italic;
}

/* ── Saved-sort builder ─────────────────────────────────────
   Sits inside the filter builder panel, separated by a
   subtle border. Visual style mirrors the filter rules so
   the two view-definition surfaces feel like peer controls.
   Order top-down = priority; the leading number badge makes
   priority obvious at a glance. */

.ds-sort-builder {
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--theme-border);
}

.ds-sort-builder-header {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.ds-sort-builder-hint {
    font-style: italic;
    color: var(--theme-text-muted);
    font-size: 0.7rem;
    margin-left: 0.25rem;
}

.ds-sort-rule {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.3rem;
}

.ds-sort-rule.is-incomplete {
    border-left: 3px solid var(--theme-danger);
    padding-left: 0.375rem;
    background-color: var(--wf-danger-soft);
    border-radius: var(--wf-radius-sm);
}

/* Priority badge — leading element so the user sees
   "1, 2, 3..." going down. Compact + colored like the info
   chip pattern. */
.ds-sort-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    font-size: 0.7rem;
    font-weight: 700;
    cursor: help;
}

.ds-sort-reorder {
    display: inline-flex;
    flex-direction: column;
    gap: 0.05rem;
    flex-shrink: 0;
}

.ds-sort-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

/* ── Date Filters ────────────────────────────────────── */

.ds-date-filters {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--theme-warning-muted);
    border: 1px solid var(--theme-warning);
    border-radius: var(--theme-radius);
    font-size: 0.8rem;
}

.ds-history-badge {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    background: var(--wf-warning-soft);
    color: var(--wf-warning-ink);
}

/* ── Group Bar ───────────────────────────────────────── */

.ds-group-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.ds-group-header-row {
    background: var(--theme-background-subtle) !important;
}

.ds-group-header-row td {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.85rem;
    border-top: 2px solid var(--theme-border);
}

.ds-group-summary {
    font-weight: 400;
    color: var(--theme-text-muted);
    margin-left: 0.75rem;
    font-size: 0.8rem;
}

/* ── Export Dropdown ──────────────────────────────────── */

.ds-export-group {
    position: relative;
}

.ds-export-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 1050;
    min-width: 160px;
    background: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    box-shadow: var(--wf-elev-3);
    padding: 0.25rem 0;
    margin-top: 0.25rem;
}

.ds-export-option {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    border: none;
    background: none;
    color: var(--theme-text);
    cursor: pointer;
    transition: background-color 120ms ease;
}

.ds-export-option:hover {
    background: var(--theme-background-hover);
}

/* ── Views Tab Items ─────────────────────────────────── */

/* ── Inline Edit Cells ───────────────────────────────── */

.ds-edit-cell {
    padding: 0.1rem 0.15rem !important;
}

.ds-edit-input {
    width: 100%;
    border: 1px solid var(--theme-border);
    border-radius: 3px;
    padding: 0.15rem 0.35rem;
    font-size: 0.8rem;
    background: var(--theme-background-raised);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.ds-edit-input:focus {
    border-color: var(--theme-primary);
    box-shadow: var(--theme-focus-ring);
    outline: none;
}

/* ── "Seed now" button for date/time/datetime edit cells ───────────
   The <input type="date|time|datetime-local"> widgets are annoying
   to populate from scratch (step buttons, spinner, no keyboard
   autocomplete for today/now). A small clock button sitting flush
   to the right of the input fills the current value and saves in
   one click. Wrapping div holds input + button side by side so the
   input stretches to fill remaining cell width while the button
   stays a fixed size. tabindex="-1" on the button keeps Tab-order
   clean — users keyboarding through the row skip past the seed
   shortcut and land on the next input, same as if the button
   weren't there. */
.ds-edit-cell-wrap {
    display: flex;
    align-items: stretch;
    gap: 2px;
    width: 100%;
}

.ds-edit-cell-wrap > .ds-edit-input,
.ds-edit-cell-wrap > .ds-card-input {
    flex: 1 1 auto;
    min-width: 0; /* lets the input shrink below its content size */
}

.ds-edit-seed-btn {
    flex: 0 0 auto;
    width: 1.5rem;
    padding: 0;
    border: 1px solid var(--theme-border);
    border-radius: 3px;
    background: var(--theme-background-subtle);
    color: var(--theme-text-muted);
    font-size: 0.7rem;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}

.ds-edit-seed-btn:hover {
    background: var(--theme-primary-muted);
    color: var(--theme-primary);
    border-color: var(--theme-primary);
}

.ds-edit-seed-btn:active {
    transform: translateY(1px);
}

/* Save feedback animations */
.ds-row-saving {
    opacity: 0.7;
}

.ds-row-saved {
    animation: ds-flash-green 1.5s ease-out;
}

@keyframes ds-flash-green {
    0% { background-color: var(--wf-success-soft); }
    100% { background-color: transparent; }
}

/* ── SOURCE-REMOVED whisper ──────────────────────────────
   The source system deleted its copy; ours is deliberately KEPT
   (jobs / answers / history keep working). Quiet by design: a
   faded row, a soft left accent, a small slash icon. Never red —
   nothing is wrong here, we just KNOW something. */
.ds-row-source-removed > td {
    opacity: 0.62;
}
.ds-row-source-removed > td:first-child {
    border-left: 3px solid color-mix(in srgb, var(--theme-text) 30%, transparent);
}
.ds-card-source-removed {
    opacity: 0.68;
    border-left: 3px solid color-mix(in srgb, var(--theme-text) 30%, transparent);
}
.ds-source-removed-ico {
    color: var(--theme-text);
    opacity: 0.55;
    margin-left: 0.35rem;
    font-size: 0.85em;
}
.ds-source-removed-chip {
    background: color-mix(in srgb, var(--theme-text) 12%, transparent);
    color: var(--theme-text);
    font-weight: 500;
}

/* ── Card View ───────────────────────────────────────── */

.ds-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ds-card {
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    background: var(--theme-background-raised);
    overflow: hidden;
    transition: box-shadow 150ms ease;
}

.ds-card:hover {
    box-shadow: var(--wf-elev-2);
}

.ds-card-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--theme-background-subtle);
    border-bottom: 1px solid var(--theme-border);
    font-size: 0.85rem;
}

.ds-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem;
    padding: 0.75rem;
}

.ds-card-field {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.ds-card-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--theme-text-muted);
}

.ds-card-value {
    font-size: 0.85rem;
    color: var(--theme-text);
    min-height: 1.5em;
}

.ds-card-input {
    font-size: 0.85rem;
}

/* ── Report Builder ──────────────────────────────────────────────── */

.ds-report-builder {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ds-report-section {
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--theme-surface);
}

.ds-report-section-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    margin-bottom: 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* Accordion: each numbered section is now a <details>/<summary>. The chevron is a pure
   CSS triangle before the step pill — rotates 90° when the section is open.
   `.ds-report-runbar` opts out of accordion styling: it's always a plain <div>. */
.ds-report-accordion > summary.ds-report-section-label {
    cursor: pointer;
    list-style: none;   /* hide default Firefox/Safari marker */
    user-select: none;
    margin-bottom: 0;   /* tighter when collapsed */
}
.ds-report-accordion > summary.ds-report-section-label::-webkit-details-marker {
    display: none;       /* hide default Chrome/Edge triangle */
}
.ds-report-accordion > summary.ds-report-section-label::before {
    content: "";
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--theme-text-muted);
    border-bottom: 2px solid var(--theme-text-muted);
    transform: rotate(-45deg);
    margin-right: 0.25rem;
    transition: transform 0.15s ease;
    flex-shrink: 0;
}
.ds-report-accordion[open] > summary.ds-report-section-label {
    margin-bottom: 0.6rem;
}
.ds-report-accordion[open] > summary.ds-report-section-label::before {
    transform: rotate(45deg);
}
.ds-report-accordion > summary.ds-report-section-label:hover::before {
    border-color: var(--theme-primary);
}

/* Summary info — the "3 rules · Match All" preview text next to the section title.
   Muted, mixed-case, non-semibold so it reads as status not as another header label. */
.ds-report-section-summary {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.78rem;
    color: var(--theme-text);
    opacity: 0.8;
    margin-left: 0.5rem;
    /* Truncate aggressively when space is tight — the full state is visible when expanded. */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex-shrink: 1;
}
.ds-report-section-summary.text-danger {
    opacity: 1;
    font-weight: 600;
}

/* Run bar — no accordion affordance. Visually identical to the old section. */
.ds-report-runbar > .ds-report-section-label {
    margin-bottom: 0.6rem;
}

/* AND/OR match toggle — appears when 2+ filter rules exist.
   Segmented pill style: subtle resting state, theme-primary accent when selected. */
.ds-report-match-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.3rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--theme-primary) 6%, transparent);
    border: 1px solid color-mix(in srgb, var(--theme-primary) 18%, transparent);
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    font-size: 0.7rem;
}
.ds-report-match-label {
    color: var(--theme-text-muted);
    padding-left: 0.35rem;
}
.ds-report-match-btn {
    border: 0;
    padding: 0.15rem 0.7rem;
    border-radius: 999px;
    background: transparent;
    color: var(--theme-text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, transform 0.08s ease;
}
.ds-report-match-btn:hover {
    color: var(--theme-text);
    background: color-mix(in srgb, var(--theme-primary) 8%, transparent);
}
.ds-report-match-btn:active {
    transform: scale(0.97);
}
.ds-report-match-btn.active {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--theme-primary) 40%, transparent);
}

.ds-report-step {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Entity rows */
.ds-report-entity-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.1rem;
    padding: 0.15rem 0;
}

.ds-report-entity-role {
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 54px;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    text-align: center;
    flex-shrink: 0;
}

.ds-report-entity-role.joined {
    background: var(--wf-primary-soft);
    color: var(--wf-primary-ink);
}

.ds-report-entity-role.add {
    background: transparent;
    border: 1px dashed var(--theme-primary);
    color: var(--theme-primary);
}

.ds-report-entity-select {
    max-width: 240px;
    flex: 1;
}

.ds-report-entity-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--theme-text);
}

.ds-report-entity-remove {
    padding: 0.15rem 0.4rem;
    line-height: 1;
}

.ds-report-add-join {
    margin-top: 0.25rem;
}

/* Column picker */
.ds-report-col-toggle {
    font-size: 0.7rem !important;
}

.ds-report-col-group {
    margin-bottom: 0.5rem;
}

.ds-report-col-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--theme-text-muted);
    padding: 0.2rem 0.5rem;
    background: var(--theme-background-subtle);
    border-radius: 3px;
    margin-bottom: 0.35rem;
    display: inline-block;
}

.ds-report-col-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.2rem 0.5rem;
    padding-left: 0.25rem;
}

.ds-report-col-item {
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    border: 1px solid transparent;
    transition: background 0.1s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--theme-text-muted);
}

.ds-report-col-item.selected {
    color: var(--theme-text);
    background: var(--theme-background-subtle);
    border-color: var(--theme-border);
}

.ds-report-col-item:hover {
    background: var(--theme-background-subtle);
    border-color: var(--theme-border);
}

/* Filter rows */
.ds-report-filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    flex-wrap: wrap;
}

/* Incomplete report-filter rule — same red-tinted treatment as
   ds-filter-rule.is-incomplete and ef-filterbar-rule.is-incomplete.
   "Incomplete" envelope is broader for reports: missing entity,
   missing property, OR (when op needs it) missing value all qualify. */
.ds-report-filter-row.is-incomplete {
    border-left: 3px solid var(--theme-danger);
    padding-left: 0.375rem;
    background-color: var(--wf-danger-soft);
    border-radius: var(--wf-radius-sm);
}

.ds-report-filter-flag {
    color: var(--theme-danger);
    font-size: 0.85rem;
    flex-shrink: 0;
    cursor: help;
    margin-left: 0.25rem;
}

/* PR #326 — Report Builder sibling-group filter UX. Each group is a
   paren-wrapped set of rules — visualized as an indented panel with a
   label header + per-rule rows. Groups combine via the outer match
   toggle (top of the Filters section). */
.ds-report-filter-group {
    border-left: 3px solid var(--wf-primary-ink);
    padding: 0.5rem 0.75rem;
    margin: 0.5rem 0;
    background: var(--wf-primary-soft);
    border-radius: var(--wf-radius-sm);
}

.ds-report-filter-group-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}

.ds-report-filter-group-label {
    font-weight: 600;
    color: var(--wf-primary-ink);
}

.ds-report-filter-grouped-row {
    margin-left: 0.5rem;
}

/* PR #326 — Report Builder multi-column sort UX. Mirrors ds-sort-rule
   but adds an entity dropdown + priority chip styled like the GroupBy
   rows so the visual rhythm of the Report Builder stays consistent. */
.ds-report-sort-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    flex-wrap: wrap;
}

.ds-report-sort-row.is-incomplete {
    border-left: 3px solid var(--theme-danger);
    padding-left: 0.375rem;
    background-color: var(--wf-danger-soft);
    border-radius: var(--wf-radius-sm);
}

.ds-report-sort-priority {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.4rem;
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
    cursor: help;
}

.ds-report-sort-dir {
    min-width: 4.25rem;
    flex: 0 0 auto;
}

.ds-report-sort-reorder {
    display: inline-flex;
    gap: 0.125rem;
    flex-shrink: 0;
}

.ds-report-filter-entity {
    max-width: 140px;
    flex: 0 0 auto;
}

.ds-report-filter-entity-label {
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 80px;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    text-align: center;
    flex-shrink: 0;
}

.ds-report-filter-field {
    max-width: 180px;
    flex: 1 1 auto;
}

.ds-report-filter-op {
    max-width: 150px;
    flex: 0 0 auto;
}

.ds-report-filter-value {
    max-width: 200px;
    flex: 1 1 auto;
}

.ds-report-filter-value-placeholder {
    flex: 1 1 auto;
    max-width: 200px;
}

/* ═══════════════════════════════════════════════════════════════════
   Report Builder — Phase D polish (parent hint, chip picker, join mode)
   ═══════════════════════════════════════════════════════════════════ */

.ds-report-parent-hint {
    padding: 0.4rem 0.6rem;
    margin: 0.35rem 0;
    background: var(--wf-primary-soft);
    border-left: 3px solid var(--wf-primary-ink);
    border-radius: 4px;
    font-size: 0.8rem;
}

.ds-report-add-related {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: var(--wf-inset);
    border-radius: 5px;
}

.ds-report-add-related-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    margin-bottom: 0.4rem;
}

.ds-report-related-chips {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.ds-report-related-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.3rem 0.6rem;
    border: 1px solid var(--wf-primary-ink);
    border-radius: 999px;
    background: var(--wf-card);
    color: var(--theme-text);
    font-size: 0.825rem;
    cursor: pointer;
    transition: background-color 120ms, transform 80ms;
}

.ds-report-related-chip:hover {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    transform: translateY(-1px);
}

.ds-report-related-chip:hover i.text-primary {
    color: var(--theme-text-on-primary) !important;
}

.ds-report-joinmode {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    padding: 0.4rem 0.6rem;
    background: var(--wf-inset);
    border-radius: 5px;
    flex-wrap: wrap;
}

.ds-report-joinmode-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--theme-text);
}

/* Phase G: chained joins in Report Builder */
.ds-report-related-group {
    margin-bottom: 0.5rem;
}

.ds-report-related-group:last-child {
    margin-bottom: 0;
}

.ds-report-related-group-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--theme-text-muted);
    margin-bottom: 0.25rem;
    padding-left: 0.1rem;
}

.ds-report-entity-via {
    font-size: 0.75rem;
    margin-left: 0.25rem;
}

/* =================================================================
   Phase P2 — Variance / Time-Travel styling
   ================================================================= */

/* Section wrapper gets a subtle clock-themed accent when variance is on */
.ds-variance-section {
    border-left: 3px solid var(--wf-primary-ink);
    padding-left: 0.75rem;
    transition: border-color 120ms ease-in-out;
}

/* Cells flagged as CHANGED — warm yellow tint, strongest signal */
.ds-variance-cell-changed {
    background-color: var(--wf-warning-soft) !important;
    border-left: 2px solid var(--wf-warning-ink) !important;
    font-weight: 500;
    cursor: help;
}

/* Cells flagged as ADDED — fresh green tint */
.ds-variance-cell-added {
    background-color: var(--wf-success-soft) !important;
    border-left: 2px solid var(--wf-success-ink) !important;
    cursor: help;
}

/* Cells flagged as REMOVED — muted red tint */
.ds-variance-cell-removed {
    background-color: var(--wf-danger-soft) !important;
    border-left: 2px solid var(--wf-danger-ink) !important;
    color: var(--theme-text-muted);
    text-decoration: line-through;
    cursor: help;
}

/* Whole-row accent when _rowStatus = "added" (new leaf pair in this snapshot) */
.ds-variance-row-added > td:first-child {
    box-shadow: inset 3px 0 0 var(--wf-success-ink);
}

/* Badges used in the legend reuse cell styling for consistency */
.badge.ds-variance-cell-changed,
.badge.ds-variance-cell-added,
.badge.ds-variance-cell-removed {
    font-size: 0.7rem;
    padding: 0.18rem 0.45rem;
    border-radius: 0.25rem;
}

/* ── Status column badges (variance report "added" / "changed" / etc.) ──
   Theme-variable driven so they remain readable on light AND dark themes.
   The previous Bootstrap subtle/emphasis pair inverted poorly on some themes
   and rendered white-on-white in the status column. Solid colored text on
   the theme-muted bg + a faint border lets the badge read as a pill-shape
   even when the row behind it is tinted. */
.ds-status-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    background: var(--theme-surface);
    color: var(--theme-text);
    border: 1px solid var(--theme-border);
}
.ds-status-added {
    background: var(--theme-success-muted);
    color: var(--theme-success);
    border-color: var(--theme-success);
}
.ds-status-changed {
    background: var(--theme-warning-muted);
    color: var(--theme-warning);
    border-color: var(--theme-warning);
}
.ds-status-removed {
    background: var(--theme-danger-muted);
    color: var(--theme-danger);
    border-color: var(--theme-danger);
}
.ds-status-unchanged {
    background: var(--theme-surface);
    color: var(--theme-text-muted);
    border-color: var(--theme-border);
}

/* ── Report Viewer cell display modes — compact (default) vs wrap ──
   Compact: truncate long values with ellipsis + show full value in the
   title tooltip. Wrap: multi-line cells reveal everything without hover.
   Headers get resize:horizontal so the user can drag a column header wider
   for a little extra breathing room — native CSS, no JS; affects only the
   header but gives a visible handle the user can grip. */
/* !important needed to beat the base .ds-data-cell { white-space: nowrap } that
   ships from the original data-browser styling — without it, the base rule
   applied even when the parent class was .ds-data-table-wrap because of an
   unrelated rule's higher source-order position. Explicit override keeps the
   toggle predictable: wrap mode always wraps, compact always truncates. */
.ds-data-table-compact .ds-data-cell {
    max-width: 260px;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ds-data-table-wrap .ds-data-cell {
    white-space: normal !important;
    word-break: break-word;
    max-width: none;
    text-overflow: clip;
    overflow: visible;
}
/* Column resize — real drag-to-resize via JSResizableColumnsService. Native CSS
   `resize: horizontal` on a <th> doesn't propagate to the column (table-layout:auto
   overrides it). The JS module flips table-layout to fixed and appends a
   .ds-col-resize-grip to each <th> that dispatches mousedown/move/up to update
   th.style.width. Grip positioned absolute at the right edge. */
.ds-data-table-compact > thead th,
.ds-data-table-wrap    > thead th {
    position: relative;
    min-width: 90px;
    overflow: hidden;
}

/* Subtle vertical separator between columns — indicates where column boundaries are
   so the user can target the resize grip. Uses the theme border variable so it stays
   visible in both light and dark themes. Right-edge placement keeps the last column
   clean (no trailing divider). */
.ds-data-table-compact > thead > tr > th:not(:last-child),
.ds-data-table-wrap    > thead > tr > th:not(:last-child),
.ds-data-table-compact > tbody > tr > td:not(:last-child),
.ds-data-table-wrap    > tbody > tr > td:not(:last-child) {
    border-right: 1px solid var(--theme-border);
}

.ds-col-resize-grip {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    background: transparent;
    transition: background-color 0.1s ease;
    z-index: 2;
}
.ds-col-resize-grip:hover {
    background: var(--theme-primary);
    opacity: 0.45;
}
.ds-col-resize-grip:active {
    background: var(--theme-primary);
    opacity: 0.8;
}

/* Property chip picker — drives the per-property filter above the snapshot grid.
   "Drifted" chips (properties that actually changed) get the primary theme accent so the
   user's eye lands on them; "stable" chips are dimmer. Selected chips invert. */
.ds-variance-chips {
    padding: 0.5rem 0.75rem;
    background: color-mix(in srgb, var(--theme-primary) 3%, transparent);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
}
.ds-variance-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--theme-primary) 30%, transparent);
    background: var(--theme-surface);
    color: var(--theme-text);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease, transform 0.08s ease;
}
.ds-variance-chip:hover {
    border-color: var(--theme-primary);
    background: color-mix(in srgb, var(--theme-primary) 6%, transparent);
}
.ds-variance-chip:active {
    transform: scale(0.97);
}
.ds-variance-chip.selected {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
    border-color: var(--theme-primary);
    box-shadow: 0 1px 3px color-mix(in srgb, var(--theme-primary) 30%, transparent);
}
.ds-variance-chip.stable {
    opacity: 0.55;
    border-style: dashed;
}
.ds-variance-chip.stable:hover {
    opacity: 1;
}
.ds-variance-chip-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.3rem;
    height: 1.15rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: color-mix(in srgb, currentColor 15%, transparent);
    color: inherit;
    font-size: 0.7rem;
    font-weight: 700;
}
.ds-variance-chip-range {
    font-size: 0.7rem;
    font-weight: 500;
    color: color-mix(in srgb, currentColor 65%, transparent);
    font-family: var(--theme-font-mono);
}
.ds-variance-quick {
    font-size: 0.78rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
}

/* Phase P2.2 — per-row action cell in EntityDataBrowser grid. Narrow column with a
   subtle hover state so the time-travel button reads as "available but not shouty". */
.ds-row-actions {
    width: 60px;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
}

/* Ghost ADD row — the buffered new-row editor at the bottom of the grid. */
.ds-ghost-row {
    background: var(--theme-background-subtle);
}

.ds-ghost-row .ds-edit-input::placeholder {
    font-size: 0.72rem;
    opacity: 0.65;
}

.ds-ghost-missing {
    border-color: var(--theme-danger) !important;
}

.ds-ghost-error-row td {
    color: var(--theme-danger);
    font-size: 0.78rem;
    padding: 0.25rem 0.5rem;
    background: var(--wf-danger-soft);
}

.ds-row-actions .btn {
    opacity: 0.55;
    transition: opacity 120ms ease-in-out;
}

.ds-row-actions .btn:hover,
.ds-row-actions .btn:focus {
    opacity: 1;
}

/* Phase P2.2 — VarianceView modal table styling. The property-×-snapshot grid can get
   wide quickly; this pin strategy keeps the property name column visible while the user
   scrolls snapshots horizontally inside the .table-responsive wrapper. */
.modal-dialog-scrollable .table thead.sticky-top th {
    position: sticky;
    top: 0;
    background-color: var(--wf-card);
    z-index: 2;
}

.modal-dialog-scrollable .table tbody th[scope="row"] {
    position: sticky;
    left: 0;
    background-color: var(--wf-card);
    z-index: 1;
    min-width: 180px;
}

/* =================================================================
   Phase P2.3 — Group By & Aggregate section polish
   ================================================================= */

/* Section accent — subtle coloured left border ties it visually to the help text. */
.ds-groupby-section {
    border-left: 3px solid var(--wf-primary-soft);
    padding-left: 0.75rem;
}

/* Inline help block shown when the section is empty — builds the mental model. */
.ds-groupby-help {
    padding: 0.5rem 0.75rem;
    background-color: var(--wf-inset);
    border-radius: 0.375rem;
}

/* Subhead label between dimension rows and measure rows. */
.ds-groupby-subhead {
    padding-left: 0.25rem;
    letter-spacing: 0.02em;
}

/* Dimension rows — primary (blue) accent on left edge. */
.ds-groupby-dim-row {
    border-left: 3px solid var(--wf-primary-ink);
    padding-left: 0.5rem;
    background-color: var(--wf-primary-soft);
    border-radius: 0.25rem;
}

/* Measure rows — success (green) accent. Different colour than dimensions so the
   eye instantly distinguishes "what groups the rows" from "what gets computed." */
.ds-groupby-measure-row {
    border-left: 3px solid var(--wf-success-ink);
    padding-left: 0.5rem;
    background-color: var(--wf-success-soft);
    border-radius: 0.25rem;
}

/* Error state — warning border when the row has an incomplete or invalid config. */
.ds-groupby-row-error {
    border-left-color: var(--wf-warning-ink) !important;
    background-color: var(--wf-warning-soft) !important;
}

/* Up/down reorder buttons — compact, muted, only active colour on hover. */
.ds-groupby-move {
    width: 1.25rem;
    opacity: 0.5;
    transition: opacity 120ms ease-in-out;
}

.ds-groupby-move:hover,
.ds-groupby-move:focus {
    opacity: 1;
}

.ds-groupby-move:disabled {
    opacity: 0.15;
    cursor: default;
}

/* Aggregate-kind dropdown width (was inline style — moving to class for consistency). */
.ds-groupby-kind {
    max-width: 8rem;
}

.ds-groupby-alias {
    max-width: 12rem;
}

/* Dialog entity picker — scrollable list of selectable entities */
.ds-add-rel-picker {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    background: var(--theme-background);
}

.ds-add-rel-picker-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.4rem 0.75rem;
    border: 0;
    background: transparent;
    text-align: left;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--theme-border-subtle);
    cursor: pointer;
}

.ds-add-rel-picker-item:last-child {
    border-bottom: 0;
}

.ds-add-rel-picker-item:hover {
    background: var(--theme-background-subtle);
}

.ds-add-rel-picker-item.selected {
    background: var(--theme-primary);
    color: var(--theme-text-on-primary);
}

.ds-add-rel-picker-item.selected .text-muted {
    color: var(--theme-text-on-primary) !important;
    opacity: 0.8;
}

.ds-add-rel-name {
    font-weight: 600;
}

/* Cardinality radios as tile-cards */
.ds-add-rel-cardinality {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.ds-add-rel-card {
    display: flex;
    flex-direction: column;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    cursor: pointer;
    transition: background-color 0.1s, border-color 0.1s;
}

.ds-add-rel-card:hover {
    background: var(--theme-background-subtle);
}

.ds-add-rel-card.selected {
    border-color: var(--theme-primary);
    background: var(--wf-primary-soft);
}

.ds-add-rel-card input[type=radio] {
    display: none;
}

.ds-add-rel-card-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.ds-add-rel-card-hint {
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    margin-top: 0.15rem;
}

/* ── Forms tab (Phase 2c.2) ──────────────────────────────────────────── */

/* Deep-link highlight — flashes a row that was just landed via
   ?formId=X / ?reportId=X / ?viewId=X so the user's eye lands on the
   target immediately. Animation runs once; the CSS class is removed
   by the page's consume-once logic after the flash completes. Works
   on any .ds-*-row — re-used for forms, reports, views lists. */
.ds-row-highlighted {
    animation: ds-row-flash 2.5s ease-in-out;
    background-color: var(--wf-primary-soft);
    box-shadow: inset 3px 0 0 var(--wf-primary-ink);
}

/* A settle, never a flash of the brand's full fill (a grey or pale primary would swallow the row's words). */
@keyframes ds-row-flash {
    0%   { background-color: color-mix(in srgb, var(--theme-primary) 34%, var(--wf-card)); }
    25%  { background-color: color-mix(in srgb, var(--theme-primary) 34%, var(--wf-card)); }
    100% { background-color: var(--wf-primary-soft); }
}

@media (prefers-reduced-motion: reduce) {
    .ds-row-highlighted { animation: none; }
}

/* =================================================================
   Phase 3.4 binary-cell rendering — thumbnails + click-to-zoom
   -----------------------------------------------------------------
   Tokens that drive sizing (default values below; override on a
   container for photo-focused reports):
     --ds-thumb-max-h   max thumbnail height — KEEPS ROWS COMPACT
     --ds-thumb-max-w   max thumbnail width
     --ds-thumb-radius  corner rounding
   A tenant with a "Fleet Photos of the Day" report can set
   .photo-report { --ds-thumb-max-h: 240px; --ds-thumb-max-w: 320px; }
   on their report container and suddenly every binary column becomes
   a full-bleed photo grid without touching this file.
   ================================================================= */

.ds-thumb {
    max-height: var(--ds-thumb-max-h, 40px);
    max-width:  var(--ds-thumb-max-w, 80px);
    border-radius: var(--ds-thumb-radius, 4px);
    object-fit: contain;
    cursor: zoom-in;
    display: inline-block;
    vertical-align: middle;
    background-color: var(--theme-background-subtle);
    transition: transform 80ms ease, box-shadow 120ms ease;
}
.ds-thumb:hover {
    transform: scale(1.04);
    box-shadow: 0 0 0 2px var(--theme-primary-muted);
}

.ds-file-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--theme-primary);
    text-decoration: none;
    font-size: var(--theme-font-size-sm);
    max-width: 100%;
    min-width: 0;
}
.ds-file-link:hover {
    text-decoration: underline;
}
.ds-file-link .bi {
    flex-shrink: 0;
    font-size: 1rem;
}
.ds-file-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

/* ── Fullscreen zoom overlay ─────────────────────────────────────
   Rendered only when a thumbnail is clicked. Fixed-position with
   generous z-index so it sits over every dialog / modal the Portal
   can throw at it. Click the dim backdrop to close — the image
   itself stops propagation so clicking on the image doesn't dismiss.
   ================================================================= */

.ds-zoom-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: color-mix(in srgb, black 82%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    cursor: zoom-out;
    animation: ds-zoom-fade-in 140ms ease-out;
}

@keyframes ds-zoom-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ds-zoom-image {
    max-width: 96vw;
    max-height: 88vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 16px 48px color-mix(in srgb, black 60%, transparent);
    cursor: default;
    background-color: color-mix(in srgb, white 100%, transparent);
}

.ds-zoom-caption {
    margin-top: 1rem;
    color: color-mix(in srgb, white 85%, transparent);
    font-size: var(--theme-font-size-sm);
    max-width: 90vw;
    text-align: center;
    cursor: default;
    text-shadow: 0 1px 3px color-mix(in srgb, black 60%, transparent);
}

.ds-zoom-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    border: none;
    background: color-mix(in srgb, white 15%, transparent);
    color: color-mix(in srgb, white 100%, transparent);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 120ms ease;
}
.ds-zoom-close:hover {
    background: color-mix(in srgb, white 25%, transparent);
}

/* ── Print media — clamp thumbnails further + hide zoom UI ───────
   Print mode is where "no matter what they hand us" most bites.
   A grid with 10 photo columns can easily blow a page apart. We
   clamp to a page-safe size by default; photo-focused reports
   with .photo-report can still override via their own @media print.
   The zoom overlay gets hidden regardless — it's a UI affordance,
   not content. If the print column is too narrow to show a usable
   thumbnail, the filename-only file-icon path still works.
   ================================================================= */

@media print {
    .ds-thumb {
        max-height: var(--ds-thumb-print-max-h, 60px);
        max-width:  var(--ds-thumb-print-max-w, 100px);
        cursor: default;
        box-shadow: none;
    }
    .ds-thumb:hover {
        transform: none;
        box-shadow: none;
    }
    .ds-zoom-overlay,
    .ds-zoom-close,
    .ds-zoom-image,
    .ds-zoom-caption {
        display: none !important;
    }
    .ds-file-link {
        color: color-mix(in srgb, black 100%, transparent);
        text-decoration: none;
    }
}

/* ────────────────────────────────────────────────────────────────────
   SQL Query tab — Logic.SqlConverter playground
   Two-column layout: SQL textarea on the left, JSON output on the right.
   On narrow viewports they stack vertically.
   ──────────────────────────────────────────────────────────────────── */
.ds-sql-query-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
}

.ds-sql-query-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.ds-sql-query-eyebrow {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: .7rem;
    color: var(--theme-text-muted);
    margin-right: auto;
}

.ds-sql-query-context {
    font-size: .8rem;
    color: var(--theme-text);
    background: var(--wf-inset);
    padding: .2rem .55rem;
    border-radius: 999px;
    border: 1px solid var(--theme-border);
}

.ds-sql-query-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    /* Compact authoring area — leaves room for the results grid below.
       Previously was 60vh which pushed Run results below the fold; the
       editor + JSON pane don't need that much height to be useful. */
    min-height: 14rem;
}

@media (max-width: 980px) {
    .ds-sql-query-grid {
        grid-template-columns: 1fr;
    }
}

.ds-sql-query-input,
.ds-sql-query-output {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    min-height: 0;
}

.ds-sql-query-label {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: .7rem;
    color: var(--theme-text-muted);
}

.ds-sql-query-textarea {
    flex: 1;
    min-height: 12rem;
    font-family: 'DM Mono', ui-monospace, Consolas, monospace;
    font-size: .85rem;
    line-height: 1.55;
    padding: 1rem;
    background: var(--wf-inset);
    color: var(--theme-text-emphasis);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    resize: vertical;
    tab-size: 2;
}

.ds-sql-query-textarea:focus {
    outline: 2px solid var(--theme-accent);
    outline-offset: -2px;
}

.ds-sql-query-hint {
    font-size: .75rem;
    color: var(--theme-text-muted);
}

.ds-sql-query-placeholder {
    flex: 1;
    display: grid;
    place-items: center;
    border: 1px dashed var(--theme-border);
    border-radius: 6px;
    font-size: .9rem;
    padding: 2rem;
    text-align: center;
}

.ds-sql-query-issues {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    margin-bottom: .25rem;
}

.ds-sql-query-issue {
    font-size: .82rem;
    padding: .45rem .65rem;
    border-radius: 4px;
    border: 1px solid var(--theme-border);
    background: var(--wf-inset);
}

.ds-sql-query-issue strong {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: .68rem;
    letter-spacing: .12em;
    margin-right: .35rem;
}

.ds-sql-query-issue-error {
    border-color: var(--theme-danger);
    background: var(--wf-danger-soft);
}

.ds-sql-query-issue-warning {
    border-color: var(--theme-warning);
    background: var(--wf-warning-soft);
}

.ds-sql-query-issue-info {
    border-color: var(--wf-primary-ink);
    background: var(--wf-primary-soft);
}

.ds-sql-query-issue-pos {
    font-family: 'DM Mono', ui-monospace, monospace;
    font-size: .7rem;
    color: var(--theme-text-muted);
}

.ds-sql-query-json {
    flex: 1;
    margin: 0;
    padding: 1rem;
    font-family: 'DM Mono', ui-monospace, Consolas, monospace;
    font-size: .8rem;
    line-height: 1.55;
    background: var(--wf-inset);
    color: var(--theme-text-emphasis);
    border: 1px solid var(--theme-border);
    border-radius: 6px;
    overflow: auto;
    white-space: pre;
    max-height: 18rem;
}

.ds-sql-query-actions {
    display: flex;
    gap: .5rem;
    flex-wrap: wrap;
    margin-top: .5rem;
}

/* Per-pane action row — Convert buttons sit immediately under their
   own textarea (right edge of SQL pane, left edge of JSON pane) so the
   button is in the logical place for what it acts on. */
.ds-sql-query-pane-actions {
    display: flex;
    margin-top: .35rem;
}
.ds-sql-query-input  .ds-sql-query-pane-actions { justify-content: flex-end; }
.ds-sql-query-output .ds-sql-query-pane-actions { justify-content: flex-start; }

/* Load dropdown — compact + sits next to the Sample button. */
.ds-sql-query-load {
    max-width: 18rem;
    margin-right: .5rem;
}

/* JSON textarea variant — same monospace + dark background as SQL but
   shorter (no need for full editor real-estate; users mostly paste). */
.ds-sql-query-textarea-json {
    min-height: 10rem;
}

/* ── Multi-select cell chips — one pill per selection (GOAL-WINGMAN-MULTI-100) ── */
.ds-chip {
    display: inline-block;
    padding: 0.1rem 0.55rem;
    margin: 0.1rem 0.25rem 0.1rem 0;
    border-radius: 999px;
    background: var(--wf-primary-soft);
    color: var(--theme-text);
    font-size: 0.78rem;
    line-height: 1.35;
    white-space: nowrap;
}

/* =================================================================
   THE REPORTS TAB'S CHROME (folded in from report-builder.css, 2026-10-03 - one stylesheet per center):
   the chip toolbar + the docked panel + the always-visible preview of the Data Studio Reports tab. The
   section CONTENT uses the .ds-report-* classes above.
   ================================================================= */

.ds-rb {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ds-rb-empty {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 2rem;
    color: var(--theme-text-muted);
    font-size: var(--theme-font-size-sm);
    border: 1px dashed var(--theme-border);
    border-radius: var(--theme-radius);
}
.ds-rb-empty i { font-size: 1.4rem; opacity: 0.7; }

/* ── Toolbar: chips + actions (sticky so Run is always reachable) ──── */
.ds-rb-bar {
    position: sticky;
    top: 0;
    z-index: 6;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
    background: var(--theme-background-subtle);
    border-bottom: 1px solid var(--theme-border);
}
.ds-rb-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    flex: 1;
    min-width: 0;
}
.ds-rb-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}
.ds-rb-loaded {
    max-width: 12rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    align-self: center;
}

.ds-rb-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    max-width: 20rem;
    padding: 0.35rem 0.7rem;
    background: var(--theme-background);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-button);
    color: var(--theme-text-secondary);
    font-size: var(--theme-font-size-sm);
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.ds-rb-chip:hover {
    border-color: var(--theme-border-subtle);
    color: var(--theme-text);
}
.ds-rb-chip > i:first-child { font-size: 0.95rem; opacity: 0.75; }
.ds-rb-chip-label { font-weight: 600; }
.ds-rb-chip-sum {
    font-size: var(--theme-font-size-xs);
    color: var(--theme-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 12rem;
}
/* Section has non-default content — subtle primary edge. */
.ds-rb-chip.is-set {
    border-color: color-mix(in srgb, var(--theme-primary) 40%, var(--theme-border));
}
.ds-rb-chip.is-set .ds-rb-chip-sum { color: var(--theme-text-secondary); }
/* Active (its panel is open). */
.ds-rb-chip.active {
    background: var(--theme-primary-muted);
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}
.ds-rb-chip.active > i:first-child { opacity: 1; }
.ds-rb-chip.active .ds-rb-chip-sum { color: var(--theme-primary); }
/* Validation error (Group By). */
.ds-rb-chip.has-error { border-color: var(--theme-warning); }
.ds-rb-chip-warn { color: var(--theme-warning); font-size: 0.8rem; }

/* ── Body: docked panel + preview ─────────────────────────────────── */
.ds-rb-body {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
}

.ds-rb-panel {
    flex: 0 0 360px;
    width: 360px;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
    background: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    box-shadow: var(--theme-shadow-lg);
    animation: ds-rb-panel-in 140ms ease-out;
}
@keyframes ds-rb-panel-in {
    from { opacity: 0; transform: translateX(-6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.ds-rb-panel-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-background-subtle);
    border-radius: var(--theme-radius) var(--theme-radius) 0 0;
    flex-shrink: 0;
}
.ds-rb-panel-head > i:first-child { color: var(--theme-primary); font-size: 1rem; }
.ds-rb-panel-title { font-weight: 600; font-size: var(--theme-font-size-sm); }
.ds-rb-panel-hint { font-size: var(--theme-font-size-xs); color: var(--theme-text-muted); }
.ds-rb-panel-close {
    margin-left: auto;
    border: none;
    background: transparent;
    color: var(--theme-text-muted);
    cursor: pointer;
    padding: 0.15rem 0.4rem;
    border-radius: var(--theme-radius-button);
    font-size: 0.8rem;
    line-height: 1;
}
.ds-rb-panel-close:hover { background: var(--theme-background-hover); color: var(--theme-text); }

.ds-rb-panel-body {
    padding: 0.8rem;
    overflow-y: auto;
    min-height: 0;
}

.ds-rb-preview {
    flex: 1;
    min-width: 0;
}

/* ── Responsive — stack the panel above the preview on narrow viewports ── */
@media (max-width: 991.98px) {
    .ds-rb-body { flex-direction: column; }
    .ds-rb-panel {
        flex-basis: auto;
        width: 100%;
        max-height: none;
    }
    .ds-rb-chip-sum { display: none; }
}
