html, body {
    font-family: 'Segoe UI Variable', 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    height: 100%;
}

/* ---- App shell (top-tab layout) ---- */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--neutral-layer-2);
}

.app-topbar {
    flex: 0 0 auto;
    height: 58px;
    display: flex;
    align-items: center;
    gap: clamp(1rem, 3vw, 2rem);
    padding: 0 clamp(1rem, 3vw, 2rem);
    background: #ffffff;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
    box-shadow: 0 1px 3px rgba(3, 45, 96, 0.05);
    z-index: 20;
}

.app-brand { display: inline-flex; align-items: center; gap: 0.55rem; font-weight: 700; color: var(--neutral-foreground-rest); text-decoration: none; }
.app-brand-mark {
    width: 30px; height: 30px; border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-fill-rest) 0%, #032d60 100%);
    color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 0.85rem;
}

.app-tabs { display: flex; gap: 0.25rem; align-self: stretch; }
.app-tab {
    display: inline-flex; align-items: center; padding: 0 1rem;
    color: var(--neutral-foreground-hint); font-weight: 600; text-decoration: none;
    border-bottom: 2px solid transparent;
}
.app-tab:hover { color: var(--neutral-foreground-rest); }
.app-tab.active { color: var(--accent-fill-rest); border-bottom-color: var(--accent-fill-rest); }
.app-tab-disabled,
.app-tab-disabled:hover {
    color: var(--neutral-foreground-hint);
    opacity: 0.48;
    cursor: not-allowed;
    border-bottom-color: transparent;
}

.tools-connection-note {
    color: var(--neutral-foreground-hint);
    font-size: 0.9rem;
}

.salesforce-connection-notice { margin-bottom: 1rem; }
.salesforce-connection-notice-dismissed .salesforce-connection-notice { display: none; }
.salesforce-connection-notice-close {
    margin-left: auto;
    padding: 0.1rem 0.35rem;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
}
.salesforce-connection-notice-close:hover { background: rgba(0, 0, 0, 0.08); }
.salesforce-connection-notice-close:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 2px;
}

.app-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }

/* Administration section: tab strip shared by every /admin page (AdminTabs.razor). */
.admin-tabs {
    display: flex; gap: 0.25rem; flex-wrap: wrap;
    margin: 1rem 0 1.25rem;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest, #e0e0e0);
}
.admin-tab {
    display: inline-flex; align-items: center; padding: 0.45rem 0.9rem;
    color: var(--neutral-foreground-hint); font-weight: 600; font-size: 0.9rem; text-decoration: none;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.admin-tab:hover { color: var(--neutral-foreground-rest); }
.admin-tab.active { color: var(--accent-fill-rest); border-bottom-color: var(--accent-fill-rest); }
.di-tabs .admin-tab {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.05rem;
}
.di-tab-subtitle {
    color: var(--neutral-foreground-hint);
    font-size: 0.74rem;
    font-weight: 500;
}

/* Inline toolbar controls (admin list cards): content-sized, no stray margins, vertically centered. */
.toolbar-input, .toolbar-select {
    box-sizing: border-box; padding: 0.45rem 0.7rem; margin: 0;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px;
    font-family: inherit; font-size: 0.9rem; color: var(--neutral-foreground-rest); background: #fff;
}
.toolbar-input:focus, .toolbar-select:focus { outline: none; border-color: var(--accent-fill-rest); }
.toolbar-select { width: auto; min-width: 220px; }

/* Searchable combobox (replaces long native <select> lists).
   Default min-width is 2× the original toolbar-select so labels like "— pick a column —"
   and typical field names aren't cramped. */
.ss-root {
    position: relative;
    display: inline-block;
    min-width: 220px;
    max-width: 100%;
    vertical-align: bottom;
}
.ss-root.ss-block { display: block; width: 100%; }
.ss-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
    width: 100%;
    text-align: left;
    cursor: pointer;
    appearance: none;
}
.ss-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}
.ss-trigger-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ss-trigger-caret {
    flex-shrink: 0;
    color: var(--neutral-foreground-hint);
    font-size: 0.75rem;
    line-height: 1;
}
.ss-backdrop {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: transparent;
}
.ss-panel {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    top: calc(100% + 3px);
    min-width: 100%;
    max-width: min(840px, 92vw);
    background: #fff;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}
/* Opens above the trigger when there is no room below (mapping-table scroller bottom). */
.ss-panel-up {
    top: auto;
    bottom: calc(100% + 3px);
}
.ss-filter {
    box-sizing: border-box;
    width: 100%;
    margin: 0;
    padding: 0.5rem 0.7rem;
    border: none;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
    font: inherit;
    font-size: 0.88rem;
    color: var(--neutral-foreground-rest);
    background: var(--neutral-layer-2);
}
/* Keyboard focus must stay visible: keyboard-driven mapping relies on knowing where you are.
   The mouse-driven :focus fallback keeps the ring off plain clicks (focus-visible handles it). */
.ss-filter:focus { outline: none; }
.ss-filter:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: -2px;
}
.ss-list {
    max-height: 240px;
    overflow-y: auto;
    padding: 0.25rem;
}
.ss-option {
    display: block;
    width: 100%;
    box-sizing: border-box;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 6px;
    padding: 0.4rem 0.55rem;
    font: inherit;
    font-size: 0.88rem;
    color: var(--neutral-foreground-rest);
    cursor: pointer;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ss-option:hover {
    background: var(--neutral-layer-2);
}
.ss-option:focus-visible {
    background: var(--neutral-layer-2);
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: -2px;
}
.ss-trigger:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 1px;
}
.ss-option.selected {
    background: color-mix(in srgb, var(--accent-fill-rest) 14%, transparent);
    color: var(--accent-fill-rest);
    font-weight: 600;
}
.ss-option.highlighted {
    background: var(--neutral-layer-2);
}
.ss-empty {
    padding: 0.65rem 0.55rem;
    color: var(--neutral-foreground-hint);
    font-size: 0.84rem;
}

.app-main { flex: 1; min-height: 0; overflow-y: auto; }
.app-content { max-width: 1180px; margin: 0 auto; padding: 1.75rem clamp(1rem, 4vw, 2.25rem); }

/* Full-width view: only widens routes the layout marks ".widenable" (Ask & Dashboard). */
html.view-full .app-content.widenable { max-width: none; }

/* Top-bar full-width toggle (shown only on Ask & Dashboard). */
.view-toggle {
    display: inline-flex; align-items: center; gap: 0.4rem;
    height: 34px; padding: 0 0.7rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 8px;
    background: var(--neutral-layer-1);
    color: var(--neutral-foreground-rest);
    font-weight: 600; font-size: 0.85rem; line-height: 1;
    cursor: pointer;
}
.view-toggle:hover { background: var(--neutral-layer-2); }
.view-toggle svg { flex: 0 0 auto; }

/* The button shows one state at a time, driven by the global view-full class (no JS needed to swap). */
.view-toggle .vt-state { display: inline-flex; align-items: center; gap: 0.4rem; }
html.view-full .view-toggle .vt-fixed { display: none; }
html:not(.view-full) .view-toggle .vt-full { display: none; }

@media (max-width: 720px) {
    .view-toggle-label { display: none; }
    .view-toggle { padding: 0 0.55rem; }
}

/* ---- User menu (avatar dropdown) ---- */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.3rem; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%; background: var(--accent-fill-rest); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.8rem;
}
.user-caret { color: var(--neutral-foreground-hint); font-size: 0.65rem; }
.user-pop {
    position: absolute; right: 0; top: 46px; min-width: 230px; background: #fff;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 10px;
    box-shadow: 0 16px 44px -16px rgba(3, 45, 96, 0.4); padding: 0.4rem; z-index: 100;
}
.user-pop-email { padding: 0.5rem 0.65rem; color: var(--neutral-foreground-hint); font-size: 0.82rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest); margin-bottom: 0.3rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-pop-item { display: block; width: 100%; text-align: left; padding: 0.5rem 0.65rem; border-radius: 7px; color: var(--neutral-foreground-rest); font-size: 0.9rem; background: none; border: none; cursor: pointer; text-decoration: none; font-family: inherit; }
.user-pop-item:hover { background: var(--neutral-layer-2); }
.user-pop-sep { height: 1px; background: var(--neutral-stroke-divider-rest); margin: 0.3rem 0; }
.user-pop-form { margin: 0; }
.user-pop-signout { color: #ba0517; }

/* ---- Auth shell (login / register) ---- */
.auth-shell { display: flex; flex-direction: column; min-height: 100vh; background: var(--neutral-layer-2); }
.auth-shell-top { padding: 1.25rem clamp(1rem, 4vw, 2rem); }
.auth-shell-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; }
.auth-shell-foot { display: flex; gap: 1.5rem; justify-content: center; padding: 1.5rem; color: var(--neutral-foreground-hint); }
.auth-shell-foot a { color: var(--neutral-foreground-hint); text-decoration: none; }
.auth-shell-foot a:hover { color: var(--accent-fill-rest); }

/* ---- Surfaces ---- */
.surface-card {
    background: var(--neutral-layer-1);
    border: calc(var(--stroke-width) * 1px) solid var(--neutral-stroke-divider-rest);
    border-radius: calc(var(--layer-corner-radius) * 1px);
    padding: 1.5rem;
    box-shadow: var(--elevation-shadow-card-rest);
}

.hero {
    background: linear-gradient(135deg, var(--accent-fill-rest) 0%, #032d60 100%);
    color: #ffffff;
    border-radius: calc(var(--layer-corner-radius) * 1px);
    padding: 2.5rem;
    margin-bottom: 1.75rem;
}

.hero h1 { margin: 0 0 0.5rem 0; font-size: clamp(1.6rem, 3vw, 2.4rem); }
.hero p { margin: 0; opacity: 0.94; max-width: 60ch; }

.soql-code {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.9rem;
}

.auth-card {
    max-width: 440px;
    margin: 2.5rem auto;
}

.full-width { width: 100%; }

/* ---- Schema sync status (settings) ---- */
.schema-status { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; color: var(--neutral-foreground-rest); }
.schema-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; background: var(--neutral-foreground-hint); }
.schema-dot.ok { background: #2e844a; }
.schema-dot.busy { background: #b67d10; }
.schema-dot.err { background: #ba0517; }

/* ---- Admin: SOQL system-prompt version history ---- */
.prompt-history { display: flex; flex-direction: column; gap: 0.6rem; }

.prompt-version {
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 8px;
    padding: 0.6rem 0.75rem;
    background: var(--neutral-layer-1);
}

.prompt-version.active {
    border-color: var(--accent-fill-rest);
    background: var(--neutral-layer-2);
}

.prompt-version-head { display: flex; align-items: center; gap: 0.6rem; }

.prompt-version-when { font-weight: 600; }

.prompt-version-badge {
    font-size: 0.72rem;
    font-weight: 600;
    color: #ffffff;
    background: var(--accent-fill-rest);
    border-radius: 10px;
    padding: 0.05rem 0.5rem;
}

.prompt-version-meta { font-size: 0.85rem; color: var(--neutral-foreground-hint); }

.prompt-version-body { margin-top: 0.45rem; }

.prompt-version-body > summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--accent-fill-rest);
}

.prompt-version-pre {
    margin: 0.5rem 0 0 0;
    padding: 0.6rem 0.75rem;
    background: var(--neutral-layer-3);
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 6px;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow-y: auto;
}

/* ---- Admin: activity log ---- */
.activity-periods { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.activity-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}
.activity-stat {
    background: var(--neutral-layer-1);
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 10px;
    padding: 0.75rem 0.9rem;
}
.activity-stat-value { font-size: 1.4rem; font-weight: 700; line-height: 1.1; }
.activity-stat-label { font-size: 0.8rem; color: var(--neutral-foreground-hint); margin-top: 0.2rem; }

.activity-chart { height: 260px; position: relative; }

.activity-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.75rem; }
.activity-filters .objects-search { min-width: 150px; }

.activity-table-wrap { overflow-x: auto; border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px; }
.activity-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.activity-table thead th {
    text-align: left; position: sticky; top: 0;
    background: var(--neutral-layer-2);
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
    padding: 0.5rem 0.6rem; font-weight: 600; white-space: nowrap;
}
.activity-table tbody td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest); vertical-align: top; }
.activity-table tbody tr:hover { background: var(--neutral-layer-1); }
.activity-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.activity-table .nowrap { white-space: nowrap; }
.activity-table .act-detail { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-ok { color: #2e844a; font-weight: 700; }
.act-fail { color: #ba0517; font-weight: 700; }

.activity-pager { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.75rem; font-size: 0.85rem; color: var(--neutral-foreground-hint); }

/* ---- Dashboard widget grid (self-contained 12-column) ---- */
.widget-grid {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 1rem;
    align-items: stretch;
}
.widget-cell {
    grid-column: span var(--span, 4);
    min-width: 0; /* let tables/charts shrink instead of blowing out the track */
}
/* "Start a new row": pin the start line to column 1 (keeping the same span) so auto-flow wraps this cell
   onto a fresh row at its full configured width, leaving an intentional gap on the previous row. The whole
   shorthand must be set — the base `span N` lives on grid-column-START, so overriding only the start would
   drop the span and collapse the cell to a single column. */
.widget-cell.row-break {
    grid-column: 1 / span var(--span, 4);
}
@media (max-width: 720px) {
    .widget-grid { grid-template-columns: 1fr; }
    .widget-cell,
    .widget-cell.row-break { grid-column: auto; }
}

/* ---- Dashboard tabs (one tab per dashboard for the engine, + add / settings controls) ---- */
.dashboard-tabs {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.25rem;
    margin: 0.25rem 0 1.1rem;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}
.dashboard-tab {
    border: none; background: none; cursor: pointer;
    padding: 0.45rem 0.85rem; border-radius: 8px 8px 0 0;
    font-family: inherit; font-size: 0.9rem; font-weight: 600;
    color: var(--neutral-foreground-hint);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.dashboard-tab:hover { color: var(--neutral-foreground-rest); background: var(--neutral-layer-2); }
.dashboard-tab.active { color: var(--accent-fill-rest); border-bottom-color: var(--accent-fill-rest); }
.dashboard-tab-icon {
    margin-left: 0.35rem; width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid var(--neutral-stroke-divider-rest); background: var(--neutral-layer-2);
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1rem; line-height: 1; color: var(--neutral-foreground-rest);
}
.dashboard-tab-icon:hover { border-color: var(--accent-fill-rest); color: var(--accent-fill-rest); }

/* ---- Pin-to-dashboard picker (shown when a user already has at least one dashboard) ---- */
.pin-picker-list { display: flex; flex-direction: column; gap: 0.4rem; }
.pin-picker-item {
    text-align: left; border: 1px solid var(--neutral-stroke-divider-rest); background: var(--neutral-layer-1);
    border-radius: 8px; padding: 0.6rem 0.8rem; cursor: pointer;
    font-family: inherit; font-size: 0.92rem; font-weight: 600; color: var(--neutral-foreground-rest);
}
.pin-picker-item:hover { border-color: var(--accent-fill-rest); color: var(--accent-fill-rest); }
.pin-picker-new {
    margin-top: 0.8rem; width: 100%; border: 1px dashed var(--neutral-stroke-divider-rest); background: none;
    border-radius: 8px; padding: 0.55rem 0.8rem; cursor: pointer;
    font-family: inherit; font-size: 0.9rem; font-weight: 600; color: var(--accent-fill-rest);
}
.pin-picker-new:hover { border-color: var(--accent-fill-rest); background: var(--neutral-layer-2); }

/* ---- Widget settings modal ---- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(3, 45, 96, 0.35);
    display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 1rem;
}
.modal-panel {
    background: #fff; border-radius: 14px; width: 100%; max-width: 440px;
    box-shadow: 0 30px 70px -20px rgba(3, 45, 96, 0.5);
    display: flex; flex-direction: column; max-height: 90vh; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest); }
.modal-close { border: none; background: none; cursor: pointer; font-size: 1rem; color: var(--neutral-foreground-hint); line-height: 1; }
.modal-close:hover { color: var(--neutral-foreground-rest); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-title-input { width: 100%; box-sizing: border-box; padding: 0.5rem 0.7rem; border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px; font-family: inherit; font-size: 0.95rem; font-weight: 600; color: var(--neutral-foreground-rest); }
.modal-title-input:focus { outline: none; border-color: var(--accent-fill-rest); }
.modal-section { margin-bottom: 1.25rem; }
.modal-section.modal-danger { margin-bottom: 0; }
.modal-label { font-weight: 600; font-size: 0.85rem; margin-bottom: 0.5rem; }
.modal-label-hint { font-weight: 400; color: var(--neutral-foreground-hint); }
/* Segmented fill bar: a 12-column track you fill like a slider. The filled
   portion mirrors the proportion of the dashboard row the widget will occupy. */
.width-bar { display: flex; flex-direction: row-reverse; gap: 3px; padding: 4px; background: var(--neutral-layer-2); border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 9px; }
.width-seg { flex: 1 1 0; height: 38px; display: flex; align-items: center; justify-content: center; border: none; border-radius: 4px; background: #fff; cursor: pointer; color: var(--neutral-foreground-hint); font-size: 0.72rem; font-weight: 600; transition: background 0.08s ease, color 0.08s ease; }
.width-seg-num { pointer-events: none; }
/* Committed selection — only while the bar is not being hovered. */
.width-bar:not(:hover) .width-seg.fill { background: var(--accent-fill-rest); color: #fff; }
/* Hover preview — fill the hovered segment plus every segment to its left
   (its later DOM siblings, since the bar is rendered reversed). */
.width-bar:hover .width-seg:hover,
.width-bar:hover .width-seg:hover ~ .width-seg { background: var(--accent-fill-rest); color: #fff; }
.width-presets { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.7rem; }
.width-preset { border: 1px solid var(--neutral-stroke-divider-rest); background: var(--neutral-layer-2); border-radius: 999px; padding: 0.32rem 0.8rem; cursor: pointer; font-size: 0.8rem; color: var(--neutral-foreground-rest); }
.width-preset:hover { border-color: var(--accent-fill-rest); color: var(--accent-fill-rest); }
.modal-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--neutral-stroke-divider-rest); display: flex; justify-content: flex-end; }

/* ---- Data Import value-mapping modal (source value → accepted value rows) ---- */
.di-valuemap-modal { max-width: 760px; width: 92vw; }

/* ---- Widget query-detail modal (query text + plain-English explanation) ---- */
.query-modal { max-width: 640px; }
.query-modal pre.soql-code {
    background: var(--neutral-layer-3);
    border: 1px solid var(--neutral-stroke-divider-rest);
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}
.query-explain-loading { display: flex; align-items: center; gap: 0.5rem; color: var(--neutral-foreground-hint); }

/* ---- Chart configuration controls (widget settings modal) ---- */
.chart-select {
    width: 100%; box-sizing: border-box; padding: 0.45rem 0.6rem;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px;
    font-family: inherit; font-size: 0.9rem; color: var(--neutral-foreground-rest); background: #fff;
}
.chart-select:focus { outline: none; border-color: var(--accent-fill-rest); }
.chart-series-list {
    display: flex; flex-direction: column; gap: 0.35rem;
    max-height: 180px; overflow-y: auto;
    padding: 0.55rem 0.7rem; border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 8px; background: var(--neutral-layer-2);
}
.chart-series-item { display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; cursor: pointer; }
.chart-series-item input { cursor: pointer; }

/* ---- Result table column picker ---- */
.result-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.column-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 6px;
    background: var(--neutral-layer-2);
}

/* ---- Result table: sortable headers + per-column filters ---- */
.result-table-wrap { overflow-x: auto; border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px; }
.result-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; min-width: 420px; }
.result-table td { padding: 0.45rem 0.7rem; border-top: 1px solid var(--neutral-stroke-divider-rest); overflow-wrap: anywhere; vertical-align: top; }
.result-table tbody tr:hover { background: var(--neutral-layer-2); }
.result-table-head th { background: var(--neutral-layer-2); padding: 0; }
.rt-sort { display: flex; align-items: center; justify-content: space-between; gap: 0.4rem; width: 100%; border: none; background: none; cursor: pointer; padding: 0.5rem 0.7rem; font: inherit; font-weight: 600; color: var(--neutral-foreground-rest); }
.rt-sort:hover { color: var(--accent-fill-rest); }
.rt-col { overflow-wrap: anywhere; text-align: left; }
.rt-arrow { flex: 0 0 auto; color: var(--neutral-foreground-hint); font-size: 0.72rem; }
.rt-sort:hover .rt-arrow { color: var(--accent-fill-rest); }
.result-table-filters th { background: var(--neutral-layer-2); padding: 0 0.4rem 0.4rem; }
.rt-filter { width: 100%; box-sizing: border-box; padding: 0.28rem 0.45rem; border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 6px; font-family: inherit; font-size: 0.78rem; color: var(--neutral-foreground-rest); background: #fff; }
.rt-filter:focus { outline: none; border-color: var(--accent-fill-rest); }
.rt-empty { padding: 1rem 0.7rem; color: var(--neutral-foreground-hint); text-align: center; }
.rt-footer { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.4rem; color: var(--neutral-foreground-hint); font-size: 0.78rem; }

/* ---- Data Sync object list ---- */
.sync-list {
    max-height: 60vh;
    overflow-y: auto;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 6px;
}

.sync-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0.6rem;
    border-bottom: 1px solid var(--neutral-stroke-divider-rest);
}

.sync-row:last-child {
    border-bottom: none;
}

.sync-name {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.82rem;
    font-weight: 600;
}

.sync-label {
    color: var(--neutral-foreground-hint);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 38%;
}

.sync-count {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.76rem;
    color: var(--neutral-foreground-hint);
    white-space: nowrap;
}

.sync-status {
    font-size: 0.76rem;
    white-space: nowrap;
}

.sync-status.ok { color: #2e844a; }
.sync-status.err { color: #ba0517; cursor: help; }

/* ---- Charts ---- */
.chart-host {
    position: relative;
    width: 100%;
    height: 260px;
}

.viz-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 0.35rem;
    margin-bottom: 0.5rem;
}

/* ---- Dashboard widget ---- */
.width-badge {
    font-family: 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.72rem;
    color: var(--neutral-foreground-hint);
    min-width: 2.6rem;
    text-align: center;
    white-space: nowrap;
}

/* Hero widgets have no white card — the gradient tile fills the whole grid cell. */
.widget-hero-cell { display: flex; }
.widget-hero-cell > .stat-hero { flex: 1; }

.stat-hero {
    background: linear-gradient(135deg, var(--accent-fill-rest) 0%, #032d60 100%);
    color: #ffffff;
    border-radius: calc(var(--layer-corner-radius) * 1px);
    box-shadow: var(--elevation-shadow-card-rest);
    padding: 1.5rem 1rem 0.6rem;
    text-align: center;
    height: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

/* KPI title + value centered in the space left under the action row. */
.stat-hero-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Action icons sit in the bottom-right of the colored tile, in white for contrast. */
.widget-actions-hero {
    width: 100%;
    margin: 0.3rem 0 0 0;
    justify-content: flex-end;
}
.widget-actions-hero .widget-icon { color: rgba(255, 255, 255, 0.82); }
.widget-actions-hero .widget-icon:hover,
.widget-actions-hero .widget-icon:focus-visible { color: #fff; }
.widget-actions-hero .widget-icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.widget-actions-hero .widget-icon-btn:disabled { color: rgba(255, 255, 255, 0.5); background: none; }

.stat-hero-title {
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    opacity: 0.92;
    margin-bottom: 0.65rem;
    overflow-wrap: anywhere;
}

.stat-hero-value {
    font-size: clamp(1.4rem, 2.8vw, 2rem);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: -0.01em;
    overflow-wrap: anywhere;
}

.stat-hero-caption {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.9;
}

/* "Refresh all" rides on the right edge of the dashboard tab strip. */
.dashboard-tabs-refresh {
    margin-left: auto;
    flex: 0 0 auto;
}

.widget-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

/* margin-left:auto pins the controls to the right edge regardless of the title (or lack of one). */
.widget-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
    margin-left: auto;
    flex: 0 0 auto;
}

/* Unified widget controls: query (info span) + refresh/settings (buttons), all inline-SVG
   so color is fully controllable via currentColor (works on white cards and dark hero tiles). */
.widget-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    color: var(--neutral-foreground-hint);
    background: none;
    border: none;
    padding: 0;
}
.widget-icon:hover { color: var(--accent-fill-rest); }
.widget-icon:focus-visible { color: var(--accent-fill-rest); outline: 2px solid currentColor; outline-offset: 1px; }
.query-icon { cursor: pointer; }
.widget-icon-btn { cursor: pointer; }
.widget-icon-btn:hover { background: rgba(3, 45, 96, 0.08); }
.widget-icon-btn:disabled { opacity: 0.35; cursor: default; color: var(--neutral-foreground-hint); background: none; }

/* Drag-to-reorder: grip handle + dragged/drop-target feedback. */
.widget-drag-handle { cursor: grab; touch-action: none; }
.widget-drag-handle:active { cursor: grabbing; }
.widget-cell.widget-dragging { opacity: 0.45; }
.widget-cell.widget-drag-over { outline: 2px dashed var(--accent-fill-rest); outline-offset: 3px; border-radius: 12px; }

/* ---- Ask (chat with conversation sidebar) ---- */
.ask-layout {
    display: flex;
    gap: 1.1rem;
    height: calc(100vh - 58px - 3.5rem);
    min-height: 420px;
}

.ask-sidebar {
    width: 264px;
    flex: 0 0 264px;
    display: flex;
    flex-direction: column;
    background: var(--neutral-layer-1);
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 12px;
    overflow: hidden;
}

.ask-sidebar-head { padding: 0.75rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest); }
.ask-sidebar-list { flex: 1; overflow-y: auto; padding: 0.4rem; }

.ask-conv {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 0.6rem; border-radius: 8px; cursor: pointer;
}
.ask-conv:hover { background: var(--neutral-layer-2); }
.ask-conv.active { background: #e6f1fb; }
.ask-conv-title { flex: 1; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ask-conv-del { border: none; background: none; cursor: pointer; color: var(--neutral-foreground-hint); opacity: 0; font-size: 0.85rem; padding: 0 0.2rem; line-height: 1; }
.ask-conv:hover .ask-conv-del { opacity: 1; }
.ask-conv-del:hover { color: #ba0517; }
.ask-empty { padding: 1.25rem 0.6rem; color: var(--neutral-foreground-hint); font-size: 0.85rem; text-align: center; }

.ask-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---- Ask tools (above the question field) + object/field browsers ---- */
.chat-tools { display: flex; gap: 0.45rem; padding: 0.4rem 0 0.5rem; flex: 0 0 auto; }
.ask-icon-btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    border: 1px solid var(--neutral-stroke-divider-rest); background: var(--neutral-layer-1);
    border-radius: 8px; padding: 0.35rem 0.7rem; cursor: pointer;
    color: var(--neutral-foreground-rest); font-size: 0.82rem; font-weight: 600;
}
.ask-icon-btn:hover:not(:disabled) { border-color: var(--accent-fill-rest); color: var(--accent-fill-rest); }
.ask-icon-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ask-icon-btn-label { line-height: 1; }

.objects-panel { max-width: 480px; }
.objects-search {
    width: 100%; box-sizing: border-box; padding: 0.5rem 0.7rem; margin-bottom: 0.7rem;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px;
    font-family: inherit; font-size: 0.9rem; color: var(--neutral-foreground-rest);
}
.objects-search:focus { outline: none; border-color: var(--accent-fill-rest); }
.objects-count { font-size: 0.75rem; color: var(--neutral-foreground-hint); margin-bottom: 0.4rem; }
.objects-state { display: flex; align-items: center; gap: 0.6rem; padding: 1.25rem 0.25rem; color: var(--neutral-foreground-hint); font-size: 0.88rem; }
.objects-state.error { color: #ba0517; }
.objects-list { display: flex; flex-direction: column; gap: 0.3rem; max-height: 48vh; overflow-y: auto; }
.objects-row {
    display: flex; flex-direction: column; align-items: flex-start; gap: 0.1rem;
    width: 100%; text-align: left; padding: 0.5rem 0.65rem; border-radius: 8px;
    border: 1px solid transparent; background: var(--neutral-layer-2); cursor: pointer;
    flex: 0 0 auto; /* don't let the flex column crush rows when the list is long */
}
.objects-row:hover { border-color: var(--accent-fill-rest); background: #eef5fd; }
.objects-api { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.85rem; font-weight: 600; color: var(--neutral-foreground-rest); overflow-wrap: anywhere; }
.objects-label { font-size: 0.78rem; color: var(--neutral-foreground-hint); }

/* ---- Tables & fields accordion ---- */
/* flex:0 0 auto is required: overflow:hidden makes a flex item's auto min-size 0,
   so without it the rows collapse to thin lines in a long list. */
.field-obj { border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px; overflow: hidden; flex: 0 0 auto; }
.field-obj-head {
    display: flex; align-items: center; gap: 0.5rem; width: 100%; text-align: left;
    padding: 0.5rem 0.65rem; border: none; background: var(--neutral-layer-2); cursor: pointer;
}
.field-obj-head:hover { background: #eef5fd; }
.field-caret { flex: 0 0 auto; color: var(--neutral-foreground-hint); font-size: 0.7rem; width: 0.8rem; }
.field-badge { flex: 0 0 auto; font-size: 0.62rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--accent-fill-rest); background: #e6f1fb; border-radius: 999px; padding: 0.08rem 0.4rem; }
.field-list { display: flex; flex-direction: column; max-height: 30vh; overflow-y: auto; border-top: 1px solid var(--neutral-stroke-divider-rest); background: #fff; }
.field-row {
    display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
    width: 100%; text-align: left; padding: 0.34rem 0.7rem 0.34rem 1.6rem;
    border: none; border-bottom: 1px solid var(--neutral-stroke-divider-rest); background: none; cursor: pointer;
}
.field-row:last-child { border-bottom: none; }
.field-row:hover { background: #eef5fd; }
.field-name { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.8rem; color: var(--neutral-foreground-rest); overflow-wrap: anywhere; }
.field-type { flex: 0 0 auto; font-size: 0.72rem; color: var(--neutral-foreground-hint); }

/* ---- Guidance modal (object definitions + term guidance) ---- */
.guid-panel { max-width: 620px; }
.guid-tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest); margin-bottom: 1rem; }
.guid-tab {
    border: none; background: none; cursor: pointer; padding: 0.5rem 0.85rem;
    font-size: 0.85rem; font-weight: 600; color: var(--neutral-foreground-hint);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.guid-tab:hover { color: var(--neutral-foreground-rest); }
.guid-tab.active { color: var(--accent-fill-rest); border-bottom-color: var(--accent-fill-rest); }
.guid-add-head { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--neutral-foreground-hint); margin: 1.1rem 0 0.5rem; }
.guid-empty { color: var(--neutral-foreground-hint); font-size: 0.88rem; padding: 0.5rem 0 0.75rem; }
.guid-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 42vh; overflow-y: auto; margin-bottom: 0.5rem; }
.guid-item { border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px; padding: 0.6rem 0.7rem; background: var(--neutral-layer-2); }
.guid-item-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.3rem; }
.guid-item-subject { font-weight: 700; font-size: 0.9rem; color: var(--neutral-foreground-rest); overflow-wrap: anywhere; }
.guid-item-detail { font-size: 0.82rem; color: var(--neutral-foreground-hint); white-space: pre-wrap; overflow-wrap: anywhere; }
.guid-item-actions { display: flex; gap: 0.6rem; flex: 0 0 auto; }
.guid-link { border: none; background: none; cursor: pointer; padding: 0; font-size: 0.78rem; font-weight: 600; color: var(--accent-fill-rest); }
.guid-link:hover { text-decoration: underline; }
.guid-link.danger { color: #ba0517; }
/* Demo custom-field showcase (Guidance panel) */
.guid-cf-group { border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px; padding: 0.6rem 0.7rem; background: var(--neutral-layer-2); }
.guid-cf-object { display: flex; align-items: center; gap: 0.45rem; font-weight: 700; font-size: 0.9rem; color: var(--neutral-foreground-rest); margin-bottom: 0.45rem; }
.guid-cf-count { font-size: 0.72rem; font-weight: 700; color: var(--neutral-foreground-hint); background: var(--neutral-stroke-divider-rest); border-radius: 999px; padding: 0.05rem 0.45rem; }
.guid-cf-fields { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.guid-cf-chip {
    display: inline-flex; align-items: center; padding: 0.2rem 0.55rem; border-radius: 999px;
    background: rgba(1, 118, 211, 0.1); border: 1px solid rgba(1, 118, 211, 0.22); color: #015fb0;
    font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.78rem; font-weight: 600;
}

.guid-editor { border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 10px; padding: 0.85rem; background: var(--neutral-layer-1); margin-bottom: 0.75rem; }
.guid-editor-title { margin-bottom: 0.5rem; }
.guid-editor-actions { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.7rem; }

/* FieldLookupTextArea: anchor for its "/" popover. The popover lives inside the Guidance modal's
   scroll area (overflow:hidden/auto), which would clip a tall list — so js/fieldlookup.js promotes it
   to position:fixed and sets its coordinates. The high z-index keeps it above the modal overlay (1000);
   the absolute fallback below applies only for the brief moment before the JS runs. */
.fl-field { position: relative; }
/* Compound selector so it beats the later `.slash-menu { z-index: 50 }` rule and sits above the modal. */
.slash-menu.fl-menu { top: calc(100% + 6px); bottom: auto; z-index: 1100; }
.fl-menu .slash-list { max-height: 240px; }

.ask-welcome { text-align: center; max-width: 560px; margin: clamp(1.5rem, 8vh, 5rem) auto 0; color: var(--neutral-foreground-hint); }
.ask-welcome h2 { color: var(--neutral-foreground-rest); margin: 0 0 0.35rem; font-size: 1.5rem; }
.ask-welcome p { margin: 0; }

/* ---- AI Query chat ---- */
.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.25rem 0.5rem 1rem 0;
}

.chat-row {
    display: flex;
    margin-bottom: 1rem;
}

.chat-row.user { justify-content: flex-end; }
.chat-row.assistant { justify-content: flex-start; }

.chat-bubble {
    max-width: 82%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    line-height: 1.45;
}

.chat-row.user .chat-bubble {
    background: var(--accent-fill-rest);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-row.assistant .chat-bubble {
    background: var(--neutral-layer-1);
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-bottom-left-radius: 4px;
}

.chat-bubble.error {
    background: var(--error-color, #fdf3f4);
    border-color: #ba0517;
}

.ai-step { margin-bottom: 0.85rem; }

/* Step header: "Ran SOQL" on the left, "Pin to dashboard" pinned to the top-right. Plain flexbox
   (not FluentStack) so the layout never depends on FluentUI's scoped-CSS delivery. */
.ai-step-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.4rem;
}
.ai-step-ran { font-weight: 600; }

/* Left side of the step header: "Ran SOQL" sits beside the "View query" toggle, so
   "Pin to dashboard" still floats to the far right. */
.ai-step-head-left { display: inline-flex; align-items: center; gap: 0.55rem; }

/* "View query" pill: the query text is hidden by default (it can be long) and opened in a
   modal on click, keeping each answer compact. Mirrors the dashboard's "view query" affordance. */
.ai-step-query-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    background: var(--neutral-layer-2);
    border-radius: 999px;
    padding: 0.2rem 0.6rem;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--neutral-foreground-hint);
    line-height: 1;
}
.ai-step-query-btn:hover { border-color: var(--accent-fill-rest); color: var(--accent-fill-rest); }
.ai-step-query-btn svg { flex: 0 0 auto; }

/* "Show data" affordance for reloaded turns (results are never stored, only the query). */
.step-rerun { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; }
.step-rerun-note {
    display: inline-flex; align-items: center; gap: 0.35rem;
    font-size: 0.8rem; color: var(--neutral-foreground-hint); max-width: 46ch;
}
.step-rerun-note svg { flex: 0 0 auto; opacity: 0.8; }
.step-rerun-loading {
    display: flex; align-items: center; gap: 0.5rem;
    color: var(--neutral-foreground-hint); font-size: 0.85rem;
}

.ai-answer {
    white-space: pre-wrap;
    margin-top: 0.6rem;
}

/* Result-bearing answers take the full chat width so the table and its top-right
   "Pin to dashboard" button (level with "Ran SOQL") use the available real estate. */
.chat-row.assistant .chat-bubble.wide { max-width: 100%; width: 100%; }

/* Related-question suggestions offered when a query returns no data. */
.chat-suggest { margin-top: 0.75rem; }
.chat-suggest-head { font-weight: 600; margin-bottom: 0.5rem; }
.chat-suggest-list { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chat-suggest-loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    color: var(--neutral-foreground-hint);
}

/* Clarification questions asked when a request is too broad. */
.clarify {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0.4rem;
}

.clarify-preamble {
    white-space: pre-wrap;
    color: var(--neutral-foreground-rest);
}

.clarify-hint {
    font-size: 0.85rem;
    color: var(--neutral-foreground-hint);
    margin-top: -0.35rem;
}

.clarify-q {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.clarify-q-text {
    font-weight: 600;
}

.clarify-text {
    margin-top: 0.15rem;
}

.clarify-text-input {
    width: 100%; box-sizing: border-box; padding: 0.45rem 0.7rem;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px;
    font-family: inherit; font-size: 0.9rem; color: var(--neutral-foreground-rest);
    background: #fff;
}
.clarify-text-input:focus { outline: none; border-color: var(--accent-fill-rest); }

.chat-input {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
    padding-top: 0.75rem;
    border-top: 1px solid var(--neutral-stroke-divider-rest);
    position: relative; /* anchor for the "/" lookup popover */
}

.chat-input-field { flex: 1; min-width: 0; }

/* Native textarea used for the chat/guidance inputs (see the markup comments in AiQueryChat /
   FieldLookupTextArea for why these are not FluentTextArea). Styled to sit alongside the Fluent
   controls: same border/focus treatment as .objects-search / .modal-title-input. */
.chat-textarea {
    width: 100%; box-sizing: border-box; display: block; resize: none;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 8px;
    font-family: inherit; font-size: 0.9rem; line-height: 1.45;
    color: var(--neutral-foreground-rest);
    background: #fff;
}
.chat-textarea::placeholder { color: var(--neutral-foreground-hint); }
.chat-textarea:focus { outline: none; border-color: var(--accent-fill-rest); box-shadow: 0 0 0 1px var(--accent-fill-rest) inset; }
.chat-textarea:disabled { opacity: 0.55; cursor: not-allowed; background: var(--neutral-layer-2); }

/* ---- "/" inline lookup popover (anchored above the input) ---- */
.slash-menu {
    position: absolute;
    left: 0; right: 0; bottom: calc(100% + 6px);
    background: #fff;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 10px;
    box-shadow: 0 18px 40px -16px rgba(3, 45, 96, 0.45);
    z-index: 50;
    overflow: hidden;
}
.slash-head {
    display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest);
    background: var(--neutral-layer-2); font-size: 0.8rem; color: var(--neutral-foreground-rest);
}
.slash-hint { color: var(--neutral-foreground-hint); font-size: 0.72rem; }
.slash-state { display: flex; align-items: center; gap: 0.5rem; padding: 0.7rem; color: var(--neutral-foreground-hint); font-size: 0.85rem; }
.slash-state.error { color: #ba0517; }
.slash-list { max-height: 280px; overflow-y: auto; padding: 0.25rem; display: flex; flex-direction: column; gap: 0.1rem; }
.slash-item {
    display: flex; align-items: baseline; gap: 0.5rem; width: 100%; text-align: left;
    padding: 0.4rem 0.55rem; border: none; border-radius: 7px; background: none; cursor: pointer; flex: 0 0 auto;
}
.slash-item.active { background: #e6f1fb; }
.slash-item-main { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: 0.84rem; font-weight: 600; color: var(--neutral-foreground-rest); overflow-wrap: anywhere; }
.slash-item-sec { margin-left: auto; flex: 0 0 auto; font-size: 0.74rem; color: var(--neutral-foreground-hint); }

/* Send button ~90% of the textarea height, vertically centered. */
.chat-input fluent-button { align-self: center; height: 90%; }
.chat-input fluent-button::part(control) { height: 100%; }

/* ---- Blazor default error UI ---- */
#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

    #blazor-error-ui .dismiss {
        cursor: pointer;
        position: absolute;
        right: 0.75rem;
        top: 0.5rem;
    }

.blazor-error-boundary {
    background: #ba0517;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred.";
    }

/* ---- Login page: two clearly-separated sign-in sections with an "or" divider ---- */
.login-section {
    padding: 1.1rem 1.15rem 1.2rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 10px;
    background: rgba(3, 45, 96, 0.018);
}

.login-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--neutral-foreground-hint);
    margin-bottom: 0.8rem;
}

.login-or {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin: 1.15rem 0;
    color: var(--neutral-foreground-hint);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

    .login-or::before,
    .login-or::after {
        content: "";
        flex: 1 1 auto;
        height: 1px;
        background: var(--neutral-stroke-divider-rest);
    }

/* ---- Branded "Continue with Salesforce" button (the production sign-in path) ---- */
.sf-login-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    width: 100%;
    min-height: 48px;
    padding: 0.7rem 1.2rem;
    border: none;
    border-radius: 8px;
    background: linear-gradient(135deg, #0176d3 0%, #032d60 100%);
    color: #ffffff;
    font-size: 1.02rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 5px 16px rgba(1, 118, 211, 0.35);
    transition: box-shadow 140ms ease, transform 120ms ease, filter 140ms ease;
}

    .sf-login-btn:hover {
        filter: brightness(1.06);
        box-shadow: 0 8px 22px rgba(1, 118, 211, 0.45);
        transform: translateY(-1px);
    }

    .sf-login-btn:active {
        transform: translateY(0);
        box-shadow: 0 4px 12px rgba(1, 118, 211, 0.35);
    }

    .sf-login-btn .sf-login-icon {
        flex: 0 0 auto;
    }


/* ---------- Data Import module ---------- */

/* Top-level cards keep a readable fixed width by default, and fill the content area when the
   top-bar full-width toggle is on (the module's routes are marked .widenable in MainLayout). */
.di-panel { max-width: 1100px; }
html.view-full .di-panel { max-width: none; }

.di-workflow {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.9rem;
}
.di-workflow-step {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 999px;
    background: var(--neutral-layer-1);
    color: var(--neutral-foreground-hint);
    font-size: 0.82rem;
    font-weight: 600;
}
.di-workflow-step strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--neutral-layer-3);
    color: var(--neutral-foreground-rest);
    font-size: 0.72rem;
}
/* Steps 1–2 are links to their routes — keep the pill look, add a hover/focus affordance. */
a.di-workflow-step {
    text-decoration: none;
    cursor: pointer;
}
a.di-workflow-step:hover {
    border-color: color-mix(in srgb, var(--accent-fill-rest) 45%, var(--neutral-stroke-divider-rest));
    color: var(--neutral-foreground-rest);
}
a.di-workflow-step:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 1px;
}
.di-workflow-step.active {
    border-color: color-mix(in srgb, var(--accent-fill-rest) 45%, var(--neutral-stroke-divider-rest));
    color: var(--neutral-foreground-rest);
}
.di-workflow-step.active strong {
    background: var(--accent-fill-rest);
    color: #fff;
}

.di-stepper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.5rem 0 1rem;
}
.di-stepper-step {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--neutral-foreground-hint);
    font-size: 0.84rem;
    font-weight: 600;
}
.di-stepper-step::before {
    content: "";
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--neutral-stroke-divider-rest);
}
.di-stepper-step.active { color: var(--accent-fill-rest); }
.di-stepper-step.complete { color: var(--neutral-foreground-rest); }
.di-stepper-step.active::before { background: var(--accent-fill-rest); }
.di-stepper-step.complete::before { background: #2e844a; }

/* New data import wizard: prominent current-step indicator. */
.di-create-stepper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.2rem;
    margin: 0.65rem 0 0.45rem;
}
.di-create-step {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.4rem 0.75rem 0.4rem 0.4rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 999px;
    background: var(--neutral-layer-1);
    color: var(--neutral-foreground-hint);
    font-size: 0.84rem;
    font-weight: 600;
}
.di-create-step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--neutral-layer-3);
    color: var(--neutral-foreground-rest);
    font-size: 0.78rem;
    font-weight: 700;
}
.di-create-step.active {
    border-color: var(--accent-fill-rest);
    background: color-mix(in srgb, var(--accent-fill-rest) 12%, var(--neutral-layer-1));
    color: var(--neutral-foreground-rest);
    box-shadow: 0 0 0 1px var(--accent-fill-rest);
}
.di-create-step.active .di-create-step-num {
    background: var(--accent-fill-rest);
    color: #fff;
}
.di-create-step.complete {
    border-color: color-mix(in srgb, #2e844a 45%, var(--neutral-stroke-divider-rest));
    color: var(--neutral-foreground-rest);
}
.di-create-step.complete .di-create-step-num {
    background: #2e844a;
    color: #fff;
}
.di-create-step-connector {
    width: 1.1rem;
    height: 2px;
    background: var(--neutral-stroke-divider-rest);
    flex-shrink: 0;
}
.di-create-step-connector.done {
    background: #2e844a;
}
.di-create-step-status {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    color: var(--neutral-foreground-hint);
}
.di-create-step-status strong {
    color: var(--accent-fill-rest);
    font-weight: 700;
}

/* New data import wizard: end-to-end process diagram + source-type cards. */
.di-how-it-works {
    margin: 0.35rem 0 0.25rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 10px;
    background: var(--neutral-layer-2);
}
.di-flow-diagram {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.35rem 0.25rem;
}
.di-flow-node {
    flex: 1 1 7.5rem;
    min-width: 7rem;
    max-width: 11rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 0.65rem 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--neutral-stroke-divider-rest);
    background: var(--neutral-layer-1);
}
.di-flow-node-end {
    border-color: color-mix(in srgb, var(--accent-fill-rest) 40%, var(--neutral-stroke-divider-rest));
}
.di-flow-tag {
    display: inline-flex;
    align-self: flex-start;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: var(--neutral-layer-3);
    color: var(--neutral-foreground-hint);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}
.di-flow-node-now {
    border-color: color-mix(in srgb, var(--accent-fill-rest) 40%, var(--neutral-stroke-divider-rest));
    background: color-mix(in srgb, var(--accent-fill-rest) 6%, var(--neutral-layer-1));
}
.di-flow-node-now .di-flow-tag {
    background: var(--accent-fill-rest);
    color: #fff;
}
.di-flow-node strong {
    font-size: 0.88rem;
    color: var(--neutral-foreground-rest);
}
.di-flow-node span:last-child {
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--neutral-foreground-hint);
}
.di-flow-arrow {
    align-self: center;
    padding: 0 0.15rem;
    color: var(--neutral-foreground-hint);
    font-weight: 700;
    font-size: 1.1rem;
}
@media (max-width: 720px) {
    .di-flow-arrow { display: none; }
    .di-flow-node { max-width: none; }
}

.di-mode-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 0.75rem;
}
.di-mode-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
    text-align: left;
    padding: 1rem 1.05rem;
    border: 1.5px solid var(--neutral-stroke-divider-rest);
    border-radius: 10px;
    background: var(--neutral-layer-1);
    color: var(--neutral-foreground-rest);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.di-mode-card:hover:not(:disabled) {
    border-color: color-mix(in srgb, var(--accent-fill-rest) 45%, var(--neutral-stroke-divider-rest));
}
.di-mode-card:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.di-mode-card.selected {
    border-color: var(--accent-fill-rest);
    box-shadow: 0 0 0 1px var(--accent-fill-rest);
    background: color-mix(in srgb, var(--accent-fill-rest) 6%, var(--neutral-layer-1));
}
.di-mode-card strong {
    font-size: 1rem;
}
.di-mode-card > span {
    font-size: 0.86rem;
    line-height: 1.4;
    color: var(--neutral-foreground-hint);
}
.di-mode-card-meta {
    margin-top: 0.25rem;
    font-size: 0.78rem !important;
    font-weight: 600;
    color: var(--accent-fill-rest) !important;
}
/* Mini source-path diagram inside a template-source card. */
.di-mode-card-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem 0.25rem;
    margin-top: 0.2rem;
}
.di-mode-card-flow > span {
    padding: 0.16rem 0.55rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 999px;
    background: var(--neutral-layer-2);
    color: var(--neutral-foreground-rest);
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.25;
    white-space: nowrap;
}
.di-mode-card-flow > .di-mode-card-flow-arrow {
    padding: 0;
    border: none;
    background: none;
    color: var(--neutral-foreground-hint);
    font-size: 0.85rem;
}
/* The node that highlights the template coming from a real org table. */
.di-mode-card-flow > .di-mode-card-flow-live {
    border-color: color-mix(in srgb, var(--accent-fill-rest) 45%, var(--neutral-stroke-divider-rest));
    background: color-mix(in srgb, var(--accent-fill-rest) 8%, var(--neutral-layer-1));
    color: var(--accent-fill-rest);
}

.di-action-summary {
    position: sticky;
    top: 0;
    z-index: 8;
    margin-bottom: 1.25rem;
}
/* Leave room under the sticky readiness bar when scrolling to preview/export. */
#di-preview-panel,
#di-export-panel {
    scroll-margin-top: 7rem;
}
.di-action-copy {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 210px;
}
.di-action-copy span {
    color: var(--neutral-foreground-hint);
    font-size: 0.84rem;
}

.di-readiness {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.di-readiness-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.28rem;
}
.di-readiness-list li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem 0.5rem;
    font-size: 0.86rem;
}
.di-ready-mark {
    font-weight: 700;
    width: 1.1rem;
    text-align: center;
    flex-shrink: 0;
}
.di-ready-ok { color: #2e844a; }
.di-ready-todo { color: var(--neutral-foreground-hint); }
.di-ready-warn { color: #8c4b02; }
.di-ready-link {
    border: none;
    background: none;
    color: var(--accent-fill-rest);
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.di-ready-link:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.di-match-stats {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.di-match-stat {
    padding: 0.55rem 0.7rem;
    border-radius: 6px;
    border: 1px solid var(--neutral-stroke-divider-rest);
    background: var(--neutral-layer-2);
    font-size: 0.88rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.di-match-stat strong { font-weight: 700; }
.di-match-stat-ok { border-color: #2e844a55; background: #2e844a12; }
.di-match-stat-warn { border-color: #dd7a0155; background: #dd7a0112; }
.di-match-stat-bad { border-color: #ba051755; background: #ba051712; }

.di-filterbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.75rem;
}
.di-inline-editor {
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.75rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    background: var(--neutral-layer-2);
}
.di-condition-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
    margin-top: 0.65rem;
}
.di-condition-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}
.di-condition-joiner {
    min-width: 42px;
    color: var(--neutral-foreground-hint);
    font-size: 0.86rem;
}

.di-condition-operator {
    min-width: 185px;
    max-width: 230px;
}

.di-condition-value {
    width: 205px;
}

.di-condition-no-value {
    min-width: 205px;
    color: var(--neutral-foreground-hint);
    font-size: 0.86rem;
}

.di-inline-error {
    margin-top: 0.25rem;
    color: var(--error, #b42318);
    font-size: 0.82rem;
}
.di-filter {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 999px;
    background: var(--neutral-layer-1);
    color: var(--neutral-foreground-rest);
    cursor: pointer;
    font: inherit;
    font-size: 0.84rem;
    font-weight: 600;
}
.di-filter:hover { background: var(--neutral-layer-2); }
.di-filter.active {
    border-color: var(--accent-fill-rest);
    color: var(--accent-fill-rest);
}
.di-filter span {
    color: var(--neutral-foreground-hint);
    font-size: 0.78rem;
}
.di-empty {
    color: var(--neutral-foreground-hint);
    text-align: center;
    padding: 1rem !important;
}

/* Dense data tables (template rows, mappings, preview). */
.di-table {
    border-collapse: collapse;
    width: 100%;
    font-size: 0.88rem;
}
.di-table th {
    text-align: left; font-weight: 600; color: var(--neutral-foreground-hint);
    padding: 0.45rem 0.6rem; border-bottom: 2px solid var(--neutral-stroke-divider-rest);
    white-space: nowrap; position: sticky; top: 0; z-index: 2;
    background: var(--neutral-layer-1);
}
.di-table td {
    padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--neutral-stroke-divider-rest);
    vertical-align: top;
}

.di-row-count {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.di-row-count-meta {
    display: block;
    margin-top: 0.1rem;
    color: var(--neutral-foreground-hint);
    font-size: 0.76rem;
}

.di-row-count-unavailable {
    color: var(--neutral-foreground-hint);
    font-size: 0.8rem;
    cursor: help;
}

.di-selection-summary {
    min-width: 220px;
    max-width: 360px;
    color: var(--neutral-foreground-hint);
    line-height: 1.35;
}

/* Mapping table: sticky header must sit above in-cell combobox panels while the list scrolls
   (SearchableSelect .ss-panel defaults to a high z-index for page-level dropdowns). */
.di-map-scroll {
    overflow: auto;
    max-height: 60vh;
    /* Contain absolute dropdowns so they don't paint outside the scroller. */
    position: relative;
}
.di-map-table thead th {
    z-index: 6;
    background: var(--neutral-layer-1);
    box-shadow: 0 1px 0 var(--neutral-stroke-divider-rest);
}
.di-map-table tbody .ss-root {
    z-index: 0;
}
/* An OPEN select must rise above its sibling rows' selects: equal-z sibling stacking contexts
   paint in DOM order, so a later row's closed trigger would otherwise draw (and steal clicks)
   on top of an earlier row's open panel. 7 also clears the sticky thead (6) — the panel is a
   position:fixed portal that may legitimately overlap the header block when it opens upward —
   while staying under the page readiness bar (8). */
.di-map-table tbody .ss-root.ss-open {
    z-index: 7;
}
/* The panel must stack ABOVE the fixed click-outside backdrop (matching the base rules:
   panel 40 over backdrop 39) or option clicks land on the backdrop and just close the list.
   .ss-root creates the stacking context, so both stay under the sticky thead (z-index 6)
   and the page readiness bar (z-index 8) regardless of these inner values. */
.di-map-table tbody .ss-panel {
    z-index: 5;
}
.di-map-table tbody .ss-backdrop {
    z-index: 4;
}
.di-cell { white-space: nowrap; max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.di-cell-error { background: #fdeded; color: #ba0517; text-align: center; cursor: help; }
.di-cell-error span:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 1px;
}

/* Stale preview: kept visible for before/after comparison, visibly out of date. */
.di-preview-stale { opacity: 0.55; }

/* Sortable list headers: keep the th typography, add a click affordance. */
.di-th-sort {
    border: none;
    background: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    white-space: nowrap;
}
.di-th-sort:hover { color: var(--neutral-foreground-rest); }
.di-th-sort:focus-visible {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 2px;
}

/* Icon-only row actions in the imports list: shrink the fluent-button hit target to the glyph
   (stealth buttons otherwise reserve a text-sized min-width + horizontal padding). */
fluent-button.di-action-btn { min-width: 0; }
fluent-button.di-action-btn::part(control) { padding: 0 5px; }
fluent-button.di-action-btn svg { display: block; }

/* Output-template wizard: excluded row that still ships because a kept row sits below it. */
.di-sandwich-tag {
    display: inline-block;
    margin-top: 0.3rem;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.78rem;
    background: color-mix(in srgb, #dd7a01 14%, transparent);
    color: #8c4b02;
    cursor: help;
}
.di-rownum { color: var(--neutral-foreground-hint); font-weight: 600; }
.di-desc { color: var(--neutral-foreground-hint); font-size: 0.82rem; margin-top: 0.1rem; }
.di-error { color: #ba0517; }
.di-ok { color: #2e844a; }

.di-type-badge {
    display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.45rem;
    border: 1px solid var(--neutral-stroke-divider-rest); border-radius: 999px;
    font-size: 0.72rem; color: var(--neutral-foreground-hint); vertical-align: middle;
}

/* Transformation chips in the mapping editor. */
.di-chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.di-chip {
    display: inline-flex; align-items: center; gap: 0.25rem;
    padding: 0.15rem 0.5rem; border-radius: 999px; font-size: 0.8rem;
    background: var(--neutral-layer-2); border: 1px solid var(--neutral-stroke-divider-rest);
}
.di-chip-btn {
    border: none; background: none; cursor: pointer; padding: 0 0.1rem;
    color: var(--neutral-foreground-hint); font-size: 0.8rem; line-height: 1;
}
.di-chip-btn:hover { color: var(--neutral-foreground-rest); }

.di-download { margin-left: 0.6rem; font-weight: 600; color: var(--accent-fill-rest); }

/* AI-suggested mapping badge (Data Import "Match fields"): marks unsaved AI suggestions. */
.di-ai-badge {
    display: inline-block; padding: 0.05rem 0.45rem;
    border-radius: 999px; font-size: 0.72rem; font-weight: 700;
    background: var(--accent-fill-rest); color: #fff;
}

/* Dedicated slim AI column in the mapping table: keeps the Source cells aligned whether or not a
   row carries the badge. */
.di-map-table .di-ai-col { width: 34px; text-align: center; white-space: nowrap; }

/* Left status rail on each mapping row — lets the user scan "what's left to map" at a glance:
   amber = still unmapped, gray = constant value, green = mapped to a source column. Drawn as an
   inset shadow on the first cell so it hugs the row's left edge without shifting the layout. */
.di-map-table tbody td:first-child { box-shadow: inset 3px 0 0 transparent; }
.di-maprow-unmapped td:first-child { box-shadow: inset 3px 0 0 #b26a00; }
.di-maprow-const td:first-child { box-shadow: inset 3px 0 0 var(--neutral-foreground-hint); }
.di-maprow-mapped td:first-child { box-shadow: inset 3px 0 0 #2e844a; }

/* Sibling-row source controls under a mapping's source select ("from row ..."). */
.di-grouprow {
    display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem;
    margin-top: 0.35rem;
}
.di-grouprow .toolbar-select, .di-grouprow .toolbar-input { font-size: 0.82rem; padding: 0.3rem 0.5rem; }
.di-grouprow-label { font-size: 0.78rem; color: var(--neutral-foreground-hint); white-space: nowrap; }

/* Combined source-field builder inside one mapping row. */
.di-composite {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.35rem;
    margin-top: 0.4rem;
}
.di-composite-row {
    display: grid;
    grid-template-columns: 1.5rem minmax(58px, 82px) minmax(150px, 1fr) auto auto auto;
    align-items: center;
    gap: 0.3rem;
    width: 100%;
}
.di-composite-order {
    color: var(--neutral-foreground-hint);
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
}
.di-composite-first {
    display: inline-block;
    min-height: 1px;
}
.di-composite-sep {
    width: 100%;
    min-width: 0;
    font-size: 0.82rem;
    padding: 0.3rem 0.45rem;
}
.di-composite-source {
    width: 100%;
    min-width: 0;
}
.di-composite-source .ss-trigger {
    font-size: 0.82rem;
    padding: 0.3rem 0.45rem;
}

/* Ordered conditional value overrides inside a mapping's Source cell. */
.di-conditional-rules {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin-top: 0.55rem;
}
.di-conditional-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    color: var(--neutral-foreground-hint);
    font-size: 0.78rem;
}
.di-conditional-heading strong { color: var(--neutral-foreground-rest); }
.di-conditional-rule {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.45rem;
    border: 1px solid var(--neutral-stroke-divider-rest);
    border-radius: 0.35rem;
    background: var(--neutral-layer-2);
}
.di-conditional-rulebar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.78rem;
}
.di-conditional-spacer { flex: 1; }
.di-conditional-condition {
    display: grid;
    grid-template-columns: 2.5rem minmax(155px, 1fr) minmax(150px, 190px) minmax(125px, 180px) auto;
    align-items: center;
    gap: 0.3rem;
}
.di-conditional-joiner {
    color: var(--neutral-foreground-hint);
    font-size: 0.78rem;
    text-align: right;
}
.di-conditional-column { min-width: 0; width: 100%; }
.di-conditional-column .ss-trigger,
.di-conditional-operator,
.di-conditional-compare {
    min-width: 0;
    width: 100%;
    font-size: 0.78rem;
    padding: 0.28rem 0.4rem;
}
.di-conditional-no-value {
    color: var(--neutral-foreground-hint);
    font-size: 0.76rem;
}
.di-conditional-result {
    display: grid;
    grid-template-columns: auto auto minmax(170px, 1fr);
    align-items: center;
    gap: 0.4rem;
    padding-left: 2.8rem;
    color: var(--neutral-foreground-hint);
    font-size: 0.78rem;
}
.di-link-button {
    border: 0;
    padding: 0;
    background: transparent;
    color: var(--accent-foreground-rest);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}
.di-link-button:hover { text-decoration: underline; }
.di-link-button:disabled { color: var(--neutral-foreground-hint); cursor: default; text-decoration: none; }
.di-conditional-add { align-self: flex-start; font-size: 0.8rem; }

@media (max-width: 900px) {
    .di-conditional-condition { grid-template-columns: 2.5rem minmax(150px, 1fr); }
    .di-conditional-condition > :not(.di-conditional-joiner) { grid-column: 2; }
    .di-conditional-result { grid-template-columns: 1fr; padding-left: 2.8rem; }
}
