/* Shared layout safeguards. Wide datasets scroll inside their table container. */
.workspace-content { overflow-wrap: anywhere; }
.page-heading { flex-wrap: wrap; }
.page-heading > div { min-width: 0; flex: 1 1 20rem; }
.workspace-content :is(fieldset, .row > *, .workspace-columns > *, .workspace-grid > *, .research-insight-grid > *, .research-chat-layout > *) { min-width: 0; }
.workspace-content :is(input, select, textarea, audio, img, svg) { max-width: 100%; }
.workspace-content :is(.panel-heading, .insight-section-heading, .note-meta, .chat-header, .chat-role, .chat-composer-footer, .symbol-toolbar, .table-actions) { flex-wrap: wrap; }
.workspace-content :is(.panel-heading > div, .chat-header > div, .chat-composer-footer > span) { min-width: 0; }
.workspace-content :is(.context-badge, .status-pill) { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.status-pill::before { flex-shrink: 0; }
.workspace-footer { flex-wrap: wrap; }
.table-responsive { position: relative; max-width: 100%; min-width: 0; overscroll-behavior-x: contain; }
.workspace-shell {
    --card-header-surface: color-mix(in srgb, var(--bs-primary) 10%, var(--workspace-surface));
    --card-footer-surface: color-mix(in srgb, var(--bs-primary) 5%, var(--workspace-surface));
}
.workspace-shell[data-bs-theme="dark"] {
    --card-header-surface: color-mix(in srgb, var(--bs-primary) 15%, var(--workspace-surface));
    --card-footer-surface: color-mix(in srgb, var(--bs-primary) 8%, var(--workspace-surface));
}
.mobile-card-label { display: none; }
.mobile-card-value { display: contents; }
@media (max-width: 767.98px) {
    .workspace-content .table-responsive:has(.mobile-row-cards) { overflow: visible; }
    .workspace-content .table-responsive > table.mobile-row-cards {
        display: block; min-width: 0; width: 100%; border: 0; background: transparent;
    }
    .mobile-row-cards thead {
        position: absolute; width: 1px; height: 1px; overflow: hidden;
        clip-path: inset(50%); white-space: nowrap;
    }
    .mobile-row-cards tbody { display: grid; gap: 1rem; }
    .workspace-content .mobile-row-cards tbody tr {
        display: block; min-width: 0; border: 1px solid var(--bs-border-color);
        border-radius: .85rem; background: var(--workspace-surface);
        box-shadow: 0 .25rem .85rem rgb(0 0 0 / .06); overflow: hidden;
    }
    .workspace-content .mobile-row-cards td {
        display: block; width: 100%; min-width: 0; padding: .75rem 1rem;
        white-space: normal; overflow-wrap: anywhere; background: var(--workspace-surface);
    }
    .workspace-content .mobile-row-cards tr.selected-note { border-color: var(--bs-primary); }
    .workspace-content .mobile-row-cards td:last-child { border-bottom: 0; }
    .workspace-content .mobile-row-cards td:first-child { background: var(--card-header-surface); }
    .mobile-row-cards td:first-child .mobile-card-value { font-weight: 600; }
    .workspace-content .mobile-row-cards td:last-child:not(:first-child) { background: var(--card-footer-surface); }
    .mobile-row-cards .mobile-card-label {
        display: block; margin-bottom: .3rem; font-size: .75rem;
        font-weight: 600; color: var(--workspace-muted);
    }
    .mobile-row-cards .mobile-card-value { display: block; min-width: 0; }
    .mobile-row-cards .mobile-card-value :is(button, a) { max-width: 100%; white-space: normal; }
}
.workspace-content .table-responsive > table { display: table; overflow: visible; }
.workspace-content .table-responsive > .table { min-width: 32rem; }
@media (min-width: 768px) {
    .workspace-content .table-responsive > table.history-table { min-width: 34rem; }
}
.workspace-selector, .appearance-controls { min-width: 0; }
.workspace-selector select { min-width: 0; flex: 1; }
.appearance-controls { flex-wrap: wrap; }
.mode-buttons { flex-shrink: 0; }
.appearance-error { max-width: calc(100vw - 2.5rem); overflow-wrap: anywhere; }
.chat-user-message, .chat-provenance, .chat-header h2 { overflow-wrap: anywhere; }
.chat-role .badge { white-space: normal; text-align: left; }
.chat-composer-footer > span { flex: 1 1 10rem; }
.chat-composer > label.d-flex { align-items: flex-start; }
.chat-composer > label.d-flex input { flex-shrink: 0; margin-top: .25rem; }
.speech-controls audio { min-width: 0; }
.workspace-content form.d-flex { flex-wrap: wrap; }
.workspace-content form.d-flex > .form-control { flex: 1 1 10rem; min-width: 0; }
.workspace-content form.d-flex > button { flex-shrink: 0; }
.chart-scroll { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.chart-canvas { min-width: 900px; }
.chart-scroll-hint { margin-bottom: .75rem; }
.strategy-condition { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10rem), 1fr)); }
@media (max-width: 1000px) {
    .chat-conversations { max-height: none; overflow: visible; }
    .chat-conversation-list { max-height: 18rem; overflow-y: auto; }
}
@media (max-width: 700px) {
    .page-heading > div { flex: 0 1 auto; }
    .workspace-search { min-width: 0; }
    .workspace-selector { flex: 1 1 100%; max-width: none; }
    .workspace-selector select { max-width: none; }
    .workspace-toolbar { flex-basis: 100%; justify-content: space-between; }
    .chat-assistant-message, .chat-composer { padding: 1rem; }
    .chat-user-message { max-width: 100%; }
    .workspace-content fieldset { padding: 1rem; }
}
@media (max-width: 450px) {
    .strategy-condition, .alert-editor-panel .condition-fields { grid-template-columns: minmax(0, 1fr); }
    .context-list { grid-template-columns: minmax(0, 1fr); gap: .35rem; }
    .context-list dd { margin-bottom: .75rem; }
    .chat-composer-footer > span { flex-basis: 100%; }
}
