:root {
    color-scheme: dark;

    /* Base/Canvas - near-black with blue undertone */
    --canvas: #0E1116;
    --bg: #0E1116;

    /* Surface levels for layering */
    --surface: #161A22;
    --elevated: #1F2530;
    --panel: #161A22;
    --panel-strong: #1F2530;

    /* Accents */
    --accent: #7C9EFF;
    --accent-ai: #4FD1C5;

    /* Legacy color mappings for compatibility */
    --blue: #7C9EFF;
    --green: #4FD1C5;
    --amber: #E5A63D;
    --purple: #A78BFA;
    --red: #EF6B6B;

    /* Text hierarchy */
    --text: #E6E8EC;
    --text-primary: #E6E8EC;
    --text-secondary: #B6BBC4;
    --text-tertiary: #6B7280;
    --muted: #B6BBC4;

    /* Borders */
    --border: #2A2F38;

    /* Layout */
    --mobile-header-height: 4rem;
    /*
     * Top bar height nudged up to comfortably seat the slightly larger brand
     * typography (1.2rem, weight 800) without feeling cramped. Keep in sync
     * with .app-sidebar's sticky `top` + `max-height` in the desktop media
     * query below.
     */
    --app-top-bar-height: 3.75rem;
    /*
     * Vertical chrome subtracted from `100dvh` to size full-bleed content
     * pages (e.g. the assistant) so they fit exactly in the viewport.
     * Defaults to the mobile header height; the desktop @media block below
     * overrides it to the top bar height.
     */
    --app-shell-content-offset: var(--mobile-header-height);
    /*
     * Sidebar horizontal padding — exposed as a token so the top-bar brand
     * can use the same inset and its left edge lines up with the sidebar nav
     * items (rather than sitting visually further right).
     */
    --app-sidebar-inline-padding: 1.25rem;

    /* Floating Upload + Assistant FABs (shared with widget CSS files) */
    --floating-fab-safe-bottom: env(safe-area-inset-bottom, 0px);
    --floating-fab-offset-y: clamp(0.75rem, 3vw, 1.5rem);
    --floating-fab-zone-height: 3.35rem;
    --floating-fab-row-gap: 0.65rem;
    --floating-fab-stack-rows: 1;
    --floating-fab-content-breathing-room: 1.35rem;
    --floating-fab-upload-inline-shift: 8.6rem;
    --floating-fab-upload-inline-shift-narrow: 7.35rem;

    --floating-widget-clearance: 8rem;

    /* Dashboard / documents density (shared rhythm) */
    --dashboard-shell-pad-y: 1.75rem;
    --dashboard-stack-gap: 1.125rem;
    --hero-panel-pad: clamp(1.125rem, 3vw, 1.75rem);
    --eyebrow-margin-bottom: 0.25rem;
    --hero-copy-margin-top: 0.375rem;
    --toolbar-pad: 1rem;
    --toolbar-gap: 0.75rem;
    --toolbar-margin-bottom: 1.125rem;
    --toolbar-label-gap: 0.35rem;
    --toolbar-control-min-height: 2.75rem;
    --document-tabs-margin-bottom: 0.875rem;
    --document-tab-pad-y: 0.5rem;
    --document-tab-pad-x: 0.75rem;
    --document-tab-font-size: 0.8125rem;
    --document-tab-min-height: 2.75rem;
    --document-grid-gap: 0.75rem;
    --document-card-pad-y: 0.875rem;
    --document-card-pad-x: 1rem;
    --document-card-title-margin: 0.5rem 0 0.3rem;
    --document-actions-gap: 0.5rem;
    --document-actions-margin-top: 0.75rem;
    --kpi-grid-gap: 0.75rem;
    --kpi-card-pad-y: 1rem;
    --kpi-card-pad-x: 1.125rem;
    --dashboard-panel-pad: clamp(0.875rem, 2.5vw, 1.25rem);
    --section-heading-margin-bottom: 0.875rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.25);
    --shadow-md: 0 8px 24px rgb(0 0 0 / 0.28);
    --shadow-lg: 0 24px 60px rgb(0 0 0 / 0.32);
    --shadow-xl: 0 32px 80px rgb(0 0 0 / 0.38);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Public Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    scrollbar-gutter: stable;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.35);
}

h1,
h2 {
    font-family: "Public Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: -0.04em;
}

h1 {
    font-size: clamp(1.8rem, 4vw, 2.75rem);
    line-height: 1.08;
}

h1:focus,
h1:focus-visible,
h2:focus,
h2:focus-visible {
    outline: none;
}

a,
button,
input,
select,
textarea {
    outline-offset: 3px;
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast),
                background-color var(--transition-fast),
                color var(--transition-fast),
                opacity var(--transition-fast),
                transform var(--transition-fast);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.app-shell {
    /*
     * Default (mobile) layout: single column. The desktop media query below
     * upgrades this to a two-row grid where the top bar spans both columns
     * across the full screen width.
     */
    display: grid;
    grid-template-columns: 1fr;
    min-height: 100vh;
}

.mobile-app-header {
    display: none;
}

.app-main-column {
    display: flex;
    flex-direction: column;
    min-width: 0;
    /*
     * NOTE: previously `min-height: 100vh` here, which on desktop forces the
     * main column to overflow its grid row (row 2 = `100vh - top-bar-height`),
     * shifting the page into a scroll state and pushing viewport-locked pages
     * (the assistant) below the fold. The mobile media query restores
     * `min-height: 100dvh` for the single-column mobile layout below.
     */
    background: transparent;
}

.app-top-bar {
    /* Hidden on mobile — the mobile-app-header takes its place. */
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: var(--app-top-bar-height);
    /*
     * Left padding matches the sidebar's inline padding so the brand's left
     * edge is flush with the sidebar nav items (Dashboard, Documents, etc.).
     * Right padding keeps the trail (upload icon + account chip) hugged to
     * the screen edge with a small comfortable inset.
     */
    padding: 0 clamp(0.85rem, 2vw, 1.25rem) 0 var(--app-sidebar-inline-padding);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 40;
}

.app-top-bar__brand {
    color: var(--text);
    text-decoration: none;
    font-family: "Public Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.015em;
    line-height: 1;
    align-self: center;
    transition: color var(--transition-fast);
}

.app-top-bar__brand:hover,
.app-top-bar__brand:focus-visible {
    color: var(--accent);
}

.app-top-bar__trail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    margin-left: auto;
    min-width: 0;
}

/*
 * Height applies to the trail's trigger buttons only. Descendant
 * buttons inside opened dropdowns/dialogs (notification rows, menu
 * items) must size to their own content, so no bare `button` here.
 */
.app-top-bar__trail > *,
.app-top-bar__trail > button,
.app-top-bar__trail .upload-widget__launcher,
.app-top-bar__trail .assistant-trigger,
.app-top-bar__trail .notification-center__trigger,
.app-top-bar__trail .user-account-menu__trigger {
    height: 2.25rem;
    box-sizing: border-box;
}

.mobile-app-header__actions {
    display: none;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
}

.mobile-app-header__account {
    display: none;
}

.assistant-full-page {
    /*
     * Fill the .app-content flex container completely. The combination of
     * flex:1, min-height:0, and overflow:hidden ensures this container
     * never grows past its parent — the chat messages scroll internally.
     */
    flex: 1 1 0;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    max-height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
    min-width: 0;
    overflow: hidden;
}

/*
 * Split view: source pane on the left, assistant chat on the right.
 * Source pane keeps a readable floor while the chat track can shrink to its
 * own responsive layout. The split stacks below 1100px because the desktop
 * sidebar subtracts 16rem from the content column before this grid is sized.
 */
.assistant-full-page--split {
    grid-template-columns: minmax(16rem, 0.85fr) minmax(0, 1.4fr);
    grid-template-rows: auto minmax(0, 1fr);
}

.assistant-layout-toolbar {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface), var(--canvas) 45%);
}

.assistant-layout-toolbar__lead {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    min-width: 0;
    flex: 1;
}

.assistant-layout-toolbar__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.assistant-layout-toolbar__doc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(36rem, 55vw);
}

.assistant-layout-toolbar__modes {
    display: inline-flex;
    border: 1px solid var(--border);
    border-radius: 0.65rem;
    overflow: hidden;
    background: var(--canvas);
}

.assistant-layout-mode {
    border: none;
    margin: 0;
    padding: 0.45rem 0.95rem;
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
    background: transparent;
    color: var(--text-secondary);
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.assistant-layout-mode:hover {
    color: var(--text);
    background: color-mix(in srgb, var(--elevated), transparent 35%);
}

.assistant-layout-mode--active {
    background: color-mix(in srgb, var(--accent), transparent 82%);
    color: var(--text);
}

.assistant-layout-document {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid color-mix(in srgb, var(--border), transparent 35%);
    background: color-mix(in srgb, var(--canvas), var(--surface) 22%);
}

.assistant-layout-document__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.45rem 0.65rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.assistant-layout-document__label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.assistant-layout-document__actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.assistant-layout-document__link {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-ai);
    text-decoration: none;
}

.assistant-layout-document__link:hover {
    text-decoration: underline;
}

.assistant-split-frame {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: none;
    background: var(--canvas);
}

.assistant-split-frame--pdf {
    background: var(--canvas);
}

.assistant-preview-image-wrap {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--canvas);
}

.assistant-preview-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.35rem;
    border: 1px solid color-mix(in srgb, var(--border), transparent 40%);
}

.assistant-layout-document__unsupported {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.1rem;
    background: var(--canvas);
}

.assistant-layout-document__placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 1.25rem;
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.5;
}

.assistant-layout-document__placeholder p {
    margin: 0 0 0.65rem;
}

.assistant-layout-document__hint {
    font-size: 0.82rem;
    color: var(--text-tertiary);
}

.assistant-layout-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.85em;
    color: var(--accent-ai);
}

.assistant-layout-chat {
    grid-column: 1 / -1;
    grid-row: 2;
    min-height: 0;
    min-width: 0;
    /*
     * `overflow: hidden` here prevents the inner chat panel (sidebar | main |
     * context rail) from ever spilling out of its grid track. Without this,
     * tall message lists could push the whole page taller than 100dvh and
     * trigger document-level scroll instead of in-panel scroll.
     */
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.assistant-full-page--split .assistant-layout-chat {
    grid-column: 2;
}

/*
 * In split view the chat panel is already sharing screen real estate with the
 * document pane, so it defaults to focus mode (set via the DefaultFocusMode
 * parameter on AssistantChatWidget). The Panels/Focus toggle in the header
 * still lets the user bring the side panels back when they want them.
 */

@media (min-width: 1025px) {
    /*
     * Desktop: top bar spans the full screen width (above sidebar + main),
     * forming a two-row grid. Sidebar sticks below the top bar so they read
     * as one cohesive surface-colored chrome wrapping the rounded content card.
     */
    :root {
        /* Desktop chrome offset = top bar height (no fixed mobile header). */
        --app-shell-content-offset: var(--app-top-bar-height);
    }

    .app-shell {
        background: var(--surface);
        grid-template-columns: 16rem 1fr;
        grid-template-rows: var(--app-top-bar-height) 1fr;
        grid-template-areas:
            "topbar topbar"
            "sidebar main";
    }

    .app-top-bar {
        display: flex;
        grid-area: topbar;
    }

    .app-sidebar {
        grid-area: sidebar;
        border-right: none;
        background: var(--surface);
        /*
         * Stick to the top of the viewport offset by the top bar so the
         * sidebar nav items are always visible when the page scrolls.
         *
         * Using `max-height` (not `height`) combined with `align-self: start`
         * avoids a known grid+sticky footgun where an explicit `height` on a
         * sticky grid item can cause it to release from sticky and scroll
         * upward behind the top bar on long pages.
         */
        align-self: start;
        top: var(--app-top-bar-height);
        height: auto;
        max-height: calc(100vh - var(--app-top-bar-height));
    }

    .app-main-column {
        grid-area: main;
        min-height: 0;
        max-height: calc(100vh - var(--app-top-bar-height));
        overflow: hidden;
        scrollbar-gutter: stable;
    }

    .app-content {
        background: var(--canvas);
        border-top-left-radius: 1.1rem;
        position: relative;
        min-height: 0;
        max-height: 100%;
    }

    /* Brand lives in the top bar on desktop; hide the duplicate inside the sidebar. */
    .app-sidebar .sidebar-header {
        display: none;
    }

    .assistant-full-page {
        /* Already flex:1 from base rule; just ensure it fills the container. */
        flex: 1 1 0;
        min-height: 0;
        max-height: 100%;
        overflow: hidden;
    }
}

@media (max-width: 1100px) {
    .assistant-full-page--split {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(28vh, 40vh) minmax(0, 1fr);
    }

    .assistant-full-page--split .assistant-layout-document {
        grid-column: 1;
        grid-row: 2;
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 42vh;
        overflow: auto;
    }

    .assistant-full-page--split .assistant-layout-chat {
        grid-column: 1;
        grid-row: 3;
        /* Ensure chat panel stays within its grid track and scrolls internally. */
        min-height: 0;
        overflow: hidden;
    }
}

.app-sidebar {
    background: var(--surface);
    /*
     * No right border on desktop — the sidebar shares its surface color with
     * the top bar and content chrome so they read as one cohesive piece.
     * The mobile drawer adds its own border-left override below.
     *
     * Horizontal padding comes from --app-sidebar-inline-padding (1.25rem),
     * which is also used by the top bar so the brand and nav items share a
     * left edge.
     */
    padding: 1.75rem var(--app-sidebar-inline-padding);
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    display: grid;
    gap: 1rem;
}

.brand,
.app-sidebar .brand {
    font-family: "Public Sans", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text);
    text-decoration: none;
}

.brand:hover {
    color: var(--accent);
}

.drawer-close,
.mobile-nav-toggle {
    border: 1px solid var(--border);
    background: var(--canvas);
    color: var(--text);
    cursor: pointer;
}

.drawer-close:hover,
.mobile-nav-toggle:hover {
    background: var(--elevated);
    border-color: color-mix(in srgb, var(--border), #ffffff 15%);
}

.drawer-close:active,
.mobile-nav-toggle:active {
    transform: scale(0.96);
}

.mobile-nav-toggle {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    display: inline-grid;
    place-items: center;
    gap: 0.22rem;
    padding: 0.7rem;
    flex-shrink: 0;
}

.mobile-nav-toggle span {
    width: 1.2rem;
    height: 0.12rem;
    border-radius: 999px;
    background: currentColor;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.drawer-close {
    display: none;
}

.nav-scrim {
    display: none;
}

.app-sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.35rem;
}

.app-sidebar .nav-item {
    display: block;
    padding: 0.6rem 0.75rem;
    border-radius: 0.6rem;
    border-left: 3px solid transparent;
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color var(--transition-fast),
                color var(--transition-fast),
                border-color var(--transition-fast),
                transform var(--transition-fast);
}

.app-sidebar .nav-item:hover {
    background: var(--elevated);
    color: var(--text);
}

.app-sidebar .nav-button {
    width: 100%;
    border: 0;
    background: transparent;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.app-sidebar .nav-button:hover {
    color: var(--text);
}

.app-sidebar .nav-item.active {
    background: rgba(124, 158, 255, 0.12);
    border-left-color: var(--accent);
    color: var(--text);
}

.app-sidebar .nav-item.active:hover {
    background: rgba(124, 158, 255, 0.18);
}

.app-sidebar .nav-section {
    margin-top: 0.75rem;
}

.app-sidebar .nav-section__label {
    padding: 0.25rem 0.75rem 0.15rem;
    margin: 0;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-tertiary);
}

.deadline-row-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: 0.75rem;
    transition: background-color var(--transition-fast);
}

.deadline-row-link:hover {
    background: var(--elevated);
}

.deadline-row-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.app-content {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: 100%;
    padding: 0;
    padding-right: 0.25rem;
    /*
     * Pages scroll inside this column when their content exceeds the
     * viewport. The assistant full-page layout opts out of page scroll via
     * its own `max-height: 100%; overflow: hidden` so its inner messages
     * area keeps handling scroll locally without the page ever scrolling.
     */
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
}

/* When the assistant full-page is mounted, we don't want an inner page
 * scrollbar on top of its own internal scrolling — the assistant already
 * fills 100% of .app-content and its internal layout owns overflow. */
.app-content:has(.assistant-full-page) {
    overflow: hidden;
}

.dashboard-shell {
    width: min(1180px, calc(100% - 3rem));
    margin: 0 auto;
    padding: var(--dashboard-shell-pad-y) 0 var(--floating-widget-clearance);
}

/* Home dashboard: one vertical rhythm between hero, KPI row, panels, and split (gap only; no stacked margin). */
main.dashboard-home:has(> .dashboard-stack) {
    display: grid;
    gap: var(--dashboard-stack-gap);
}

main.dashboard-home:has(> .dashboard-stack) > .hero-panel {
    margin-bottom: 0;
}

/* Vertical rhythm for dashboard home and similar stacked layouts (matches toolbar / detail shell spacing). */
.dashboard-stack {
    display: grid;
    gap: var(--dashboard-stack-gap);
}

@media (max-width: 1024px) {
    :root {
        --dashboard-shell-pad-y: 1.25rem;
        --floating-widget-clearance: max(
            8rem,
            calc(
                var(--floating-fab-offset-y)
                + var(--floating-fab-zone-height) * var(--floating-fab-stack-rows)
                + (var(--floating-fab-stack-rows) - 1) * var(--floating-fab-row-gap)
                + var(--floating-fab-content-breathing-room)
                + var(--floating-fab-safe-bottom)
            )
        );
    }

    .dashboard-shell {
        width: calc(100% - 2rem);
        padding: var(--dashboard-shell-pad-y) 0 var(--floating-widget-clearance);
    }
}

@media (max-width: 640px) {
    :root {
        --floating-fab-offset-y: clamp(0.65rem, 2.5vw, 1.15rem);
        --floating-fab-content-breathing-room: 2rem;
        --floating-widget-clearance: max(
            10rem,
            calc(
                var(--floating-fab-offset-y)
                + var(--floating-fab-zone-height) * var(--floating-fab-stack-rows)
                + (var(--floating-fab-stack-rows) - 1) * var(--floating-fab-row-gap)
                + var(--floating-fab-content-breathing-room)
                + var(--floating-fab-safe-bottom)
            )
        );
        --dashboard-shell-pad-y: 1rem;
    }

    .dashboard-shell {
        width: calc(100% - 1.5rem);
        padding: var(--dashboard-shell-pad-y) 0 var(--floating-widget-clearance);
    }
}

/* Narrow phones: upload FAB moves bottom-left, assistant stays bottom-right — one row, not stacked. */
@media (max-width: 30rem) {
    :root {
        --floating-fab-stack-rows: 1;
        --floating-fab-offset-y: clamp(0.55rem, 2.2vw, 1rem);
    }
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: clamp(1rem, 4vw, 3rem);
    background:
        radial-gradient(circle at top left, rgb(124 158 255 / 0.12), transparent 30rem),
        radial-gradient(circle at bottom right, rgb(79 209 197 / 0.10), transparent 28rem),
        var(--canvas);
}

.auth-panel {
    width: min(100%, 28rem);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: 0 30px 80px rgb(0 0 0 / 0.4);
    padding: clamp(1.5rem, 5vw, 2.5rem);
}

.auth-intro {
    display: grid;
    gap: 0.6rem;
    margin-bottom: 1.75rem;
}

.auth-brand {
    justify-self: start;
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 800;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.auth-brand:hover {
    color: var(--accent);
}

.auth-panel h1 {
    margin: 0;
    font-size: clamp(1.7rem, 6vw, 2.4rem);
    line-height: 1.1;
    font-weight: 800;
}

.auth-form fieldset {
    border: 0;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1.1rem;
}

.auth-form fieldset:disabled {
    opacity: 0.65;
    pointer-events: none;
}

.auth-field {
    display: grid;
    gap: 0.5rem;
}

.auth-field label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.auth-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 3rem;
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    background: var(--canvas);
    color: var(--text);
    padding: 0 1rem;
    font: inherit;
    font-size: 0.95rem;
}

.auth-input:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 20%);
}

.auth-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 158, 255, 0.15);
    outline: none;
}

.auth-input::placeholder {
    color: var(--text-tertiary);
}

.auth-button {
    min-height: 3rem;
    border: 0;
    border-radius: 0.7rem;
    background: linear-gradient(135deg, var(--accent), #6B8AE6);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    transition: filter var(--transition-fast),
                transform var(--transition-fast);
}

.auth-button:hover {
    filter: brightness(1.1);
}

.auth-button:active {
    transform: scale(0.98);
}

.auth-button:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.auth-alert,
.auth-validation {
    border: 1px solid color-mix(in srgb, var(--red), #ffffff 18%);
    border-radius: 0.7rem;
    background: rgba(220, 95, 95, 0.12);
    color: #ffd9d9;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
}

.auth-validation {
    margin: 0 0 1rem;
}

.auth-validation ul {
    margin: 0;
    padding-left: 1.2rem;
}

.auth-footnote {
    margin: 1.5rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
    text-align: center;
}

.auth-footnote a {
    color: var(--accent);
    text-decoration: none;
}

.auth-footnote a:hover {
    text-decoration: underline;
}

.auth-confirmation {
    border: 1px solid color-mix(in srgb, var(--accent), transparent 55%);
    border-radius: 0.7rem;
    background: color-mix(in srgb, var(--accent), transparent 90%);
    color: var(--text);
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
}

.auth-button--link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
    text-decoration: none;
}

.auth-input--code {
    letter-spacing: 0.35em;
    font-size: 1.15rem;
    text-align: center;
}

.auth-mfa-enroll {
    display: grid;
    gap: 0.75rem;
    justify-items: center;
    margin-bottom: 1.25rem;
}

/* QR must stay dark-on-light regardless of theme or scanners fail. */
.auth-mfa-qr {
    width: min(11rem, 60vw);
    background: #fff;
    border-radius: 0.7rem;
    padding: 0.6rem;
}

.auth-mfa-qr svg {
    display: block;
    width: 100%;
    height: auto;
}

.auth-mfa-secret {
    margin: 0;
    color: var(--muted);
    font-size: 0.82rem;
    text-align: center;
    overflow-wrap: anywhere;
}

.auth-mfa-secret code {
    color: var(--text);
    user-select: all;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (max-width: 1024px) {
    .app-shell {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
    }

    /* Mobile: no top-bar grid row, so the main column owns the full viewport. */
    .app-main-column {
        min-height: 100dvh;
    }

    .mobile-app-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 100;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.65rem;
        height: var(--mobile-header-height);
        padding: 0 max(0.75rem, env(safe-area-inset-right, 0px))
                 0 max(0.75rem, env(safe-area-inset-left, 0px));
        background: rgba(14, 17, 22, 0.92);
        border-bottom: 1px solid var(--border);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        min-width: 0;
    }

    .mobile-app-header .brand {
        font-size: 1.1rem;
        font-weight: 700;
        margin-right: auto;
        /*
         * Cap the brand at ~10rem on tablet and shrink further on phones so
         * the trailing icon row (upload + assistant + account) plus the
         * hamburger always fits at iPhone 14 (390px) and iPhone Plus widths
         * without horizontal scroll. The <= 26rem override below tightens
         * once more for sub-420px viewports.
         */
        max-width: min(11rem, 38vw);
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-app-header__actions {
        display: flex;
        gap: 0.35rem;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .mobile-app-header__account {
        display: flex;
        align-items: center;
    }

    /*
     * iPhone-class phones (<= 26rem ≈ 416px): tighten brand + action gaps so
     * brand text + 3 icon buttons + hamburger all fit on one line at 390px
     * (iPhone 14) without horizontal scroll. Falls within the existing
     * <= 1024px mobile media block above.
     */
    @media (max-width: 26rem) {
        .mobile-app-header {
            gap: 0.4rem;
            padding-left: max(0.6rem, env(safe-area-inset-left, 0px));
            padding-right: max(0.6rem, env(safe-area-inset-right, 0px));
        }

        .mobile-app-header .brand {
            font-size: 1rem;
            max-width: min(7.5rem, 30vw);
        }

        .mobile-app-header__actions {
            gap: 0.25rem;
        }
    }

    .app-content {
        padding-top: var(--mobile-header-height);
    }

    .app-sidebar {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: auto;
        z-index: 200;
        width: min(21rem, calc(100vw - 3rem));
        height: 100dvh;
        border-right: 0;
        border-left: 1px solid var(--border);
        box-shadow: -20px 0 60px rgb(0 0 0 / 0.45);
        transform: translateX(100%);
        visibility: hidden;
        transition: transform var(--transition-slow),
                    visibility var(--transition-slow);
    }

    .app-sidebar.is-open {
        transform: translateX(0);
        visibility: visible;
    }

    .sidebar-header {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .app-sidebar .brand {
        font-size: 1.15rem;
    }

    .drawer-close {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 0.6rem;
        display: grid;
        place-items: center;
        position: relative;
    }

    .drawer-close span {
        position: absolute;
        width: 1.05rem;
        height: 0.12rem;
        border-radius: 999px;
        background: currentColor;
        transition: transform var(--transition-fast);
    }

    .drawer-close span:first-child {
        transform: rotate(45deg);
    }

    .drawer-close span:last-child {
        transform: rotate(-45deg);
    }

    .nav-scrim {
        position: fixed;
        inset: 0;
        z-index: 150;
        display: block;
        border: 0;
        background: rgb(0 0 0 / 0.6);
        cursor: pointer;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-slow);
    }

    .nav-scrim.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    @media (prefers-reduced-motion: reduce) {
        .app-sidebar,
        .nav-scrim {
            transition: none;
        }
    }
}

.hero-panel,
.kpi-card,
.toolbar,
.document-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast),
                transform var(--transition-fast);
}

.hero-panel {
    padding: var(--hero-panel-pad);
    margin-bottom: var(--dashboard-stack-gap);
    background: linear-gradient(135deg, var(--surface) 0%, color-mix(in srgb, var(--surface), var(--accent) 4%) 100%);
}

.eyebrow {
    color: var(--muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 500;
    margin-bottom: var(--eyebrow-margin-bottom);
}

.hero-panel h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4.5vw, 2.5rem);
}

.hero-copy {
    color: var(--muted);
    margin: var(--hero-copy-margin-top) 0 0;
    line-height: 1.45;
}

.hero-panel--compact {
    padding: clamp(0.85rem, 2.2vw, 1.15rem) clamp(1rem, 2.5vw, 1.35rem);
    margin-bottom: 0.75rem;
}

.hero-panel--compact h1 {
    font-size: clamp(1.35rem, 3.5vw, 1.85rem);
}

.hero-copy--tight {
    margin-top: 0.25rem;
    font-size: 0.88rem;
    line-height: 1.4;
}

/*
 * Shared flat page header.
 *
 * Used at the top of every routed page so the eyebrow / title / lead block
 * lands at the *exact* same X/Y coordinates regardless of which page the user
 * navigates to. Sits directly on the page background — no card chrome — and
 * inherits horizontal alignment from `.dashboard-shell`.
 */
.page-header {
    margin: 0 0 var(--dashboard-stack-gap);
    padding: 0;
}

.page-header__row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header__inner {
    min-width: 0;
}

.page-header__eyebrow {
    color: var(--muted);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-size: 0.78rem;
    font-weight: 500;
    margin: 0 0 0.4rem;
}

.page-header__title {
    margin: 0;
    font-size: clamp(1.5rem, 3.5vw, 2rem);
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text);
}

.page-header__lead {
    margin: 0.45rem 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
    max-width: 60ch;
}

.page-header__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/*
 * Legacy dense-list shell width is preserved for opt-in callers but is no
 * longer applied to data-list pages — every page now uses the standard
 * `.dashboard-shell` width so the page header anchor stays identical.
 */
.dashboard-shell--dense-list {
    width: min(1320px, calc(100% - 2rem));
}

@media (max-width: 1024px) {
    .dashboard-shell--dense-list {
        width: calc(100% - 2rem);
    }
}

@media (max-width: 640px) {
    .dashboard-shell--dense-list {
        width: calc(100% - 1.5rem);
    }
}

.muted {
    color: var(--muted);
}

.kpi-grid {
    display: grid;
    gap: var(--kpi-grid-gap);
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
    padding: var(--kpi-card-pad-y) var(--kpi-card-pad-x);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.kpi-card:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 12%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.kpi-card:hover::before {
    opacity: 1;
}

.kpi-card strong {
    display: block;
    font-size: 2.1rem;
    margin-top: 0.3rem;
    letter-spacing: -0.02em;
}

.kpi-label {
    color: var(--muted);
    font-size: 0.875rem;
}

.kpi-card.warning {
    border-color: color-mix(in srgb, var(--amber), var(--border) 55%);
}

.kpi-card.warning::before {
    background: var(--amber);
}

.kpi-card.danger {
    border-color: color-mix(in srgb, var(--red), var(--border) 45%);
}

.kpi-card.danger::before {
    background: var(--red);
}

.dashboard-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    padding: var(--dashboard-panel-pad);
    transition: border-color 0.15s ease;
}

.dashboard-panel:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 8%);
}

.section-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.625rem 0.875rem;
    margin-bottom: var(--section-heading-margin-bottom);
}

.section-heading > div:first-child {
    min-width: 0;
    flex: 1 1 12rem;
}

.section-heading .secondary-button {
    flex-shrink: 0;
}

.section-heading h2 {
    margin: 0;
    font-size: 1.25rem;
}

.type-summary-grid {
    display: grid;
    gap: var(--kpi-grid-gap);
    grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
}

.type-summary-card {
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    color: var(--text);
    display: grid;
    gap: 0.25rem;
    padding: 0.9rem;
    text-decoration: none;
    transition: border-color var(--transition-fast),
                transform var(--transition-fast);
}

.type-summary-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.type-summary-card strong {
    font-size: 1.5rem;
}

.type-summary-card small,
.compact-document-row small {
    color: var(--text-tertiary);
}

.dashboard-split {
    display: grid;
    gap: var(--kpi-grid-gap);
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.compact-document-list {
    display: grid;
    gap: 0.65rem;
    max-height: 24rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-right: 0.35rem;
    scrollbar-gutter: stable;
}

.compact-document-row {
    align-items: center;
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    color: var(--text);
    display: flex;
    gap: 1rem;
    justify-content: space-between;
    padding: 0.8rem;
    text-decoration: none;
}

.compact-document-row > span:first-child {
    display: grid;
    gap: 0.2rem;
    /*
     * `min-width: 0` lets the title column shrink below its content width so
     * long document titles ellipsis-truncate inside the flex row instead of
     * pushing the status badge off the right edge on narrow viewports.
     */
    min-width: 0;
}

.compact-document-row > span:first-child > strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-document-row:hover {
    border-color: var(--accent);
}

.toolbar {
    display: grid;
    gap: var(--toolbar-gap);
    grid-template-columns: minmax(16rem, 2fr) repeat(2, minmax(12rem, 1fr));
    padding: var(--toolbar-pad);
    margin-bottom: var(--toolbar-margin-bottom);
}

.toolbar.toolbar--dense {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.5rem 0.75rem;
    padding: 0.65rem 0.85rem;
    margin-bottom: 0.65rem;
}

.toolbar.toolbar--dense .toolbar-field-grow {
    flex: 1 1 14rem;
    min-width: min(100%, 12rem);
}

.toolbar label {
    display: grid;
    gap: var(--toolbar-label-gap);
    color: var(--muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.toolbar input,
.toolbar select {
    min-height: var(--toolbar-control-min-height);
    border: 1px solid var(--border);
    border-radius: 0.6rem;
    background: var(--canvas);
    color: var(--text);
    padding: 0 0.9rem;
    font: inherit;
    font-size: 0.95rem;
}

.toolbar input:hover,
.toolbar select:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 20%);
}

.toolbar input:focus,
.toolbar select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 158, 255, 0.15);
    outline: none;
}

.toolbar input::placeholder {
    color: var(--text-tertiary);
}

.document-type-tabs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.4rem 0.45rem;
    margin-bottom: var(--document-tabs-margin-bottom);
}

@media (min-width: 768px) {
    .document-type-tabs {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.35rem;
        margin-inline: -0.15rem;
        padding-inline: 0.15rem;
        scrollbar-width: thin;
        scrollbar-color: color-mix(in srgb, var(--border), transparent 35%) transparent;
    }

    .document-type-tabs::-webkit-scrollbar {
        height: 6px;
    }

    .document-type-tabs::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: color-mix(in srgb, var(--border), transparent 20%);
    }
}

.document-type-tab {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-secondary);
    min-height: var(--document-tab-min-height);
    padding: var(--document-tab-pad-y) var(--document-tab-pad-x);
    font-size: var(--document-tab-font-size);
    font-weight: 500;
    line-height: 1.25;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast),
                color var(--transition-fast);
}

.document-type-tab:hover,
.document-type-tab:focus-visible {
    border-color: var(--accent);
    color: var(--text);
}

.document-type-tab.active {
    border-color: color-mix(in srgb, var(--accent), var(--border) 25%);
    background: color-mix(in srgb, var(--accent) 18%, var(--surface));
    color: var(--text);
}

.document-type-tabs--dense {
    margin-bottom: 0.65rem;
}

.document-type-tabs--dense .document-type-tab {
    min-height: 2.35rem;
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
}

.document-type-tabs--wrap {
    flex-wrap: wrap;
    justify-content: flex-start;
    overflow-x: visible;
    padding-bottom: 0;
}

@media (min-width: 768px) {
    .document-type-tabs--wrap {
        overflow-x: visible;
    }
}

.repo-inline-status {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin: 0 0 0.5rem;
}

.repo-table-viewport {
    position: relative;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: min(70vh, 52rem);
    border: 1px solid color-mix(in srgb, var(--border), transparent 35%);
    border-radius: 0.75rem;
    background: color-mix(in srgb, var(--surface), var(--canvas) 28%);
    box-shadow: inset 0 1px 0 color-mix(in srgb, #ffffff, transparent 96%);
    scrollbar-gutter: stable both-edges;
    padding-right: 0.25rem;
}

.repo-table-viewport::after {
    content: "";
    position: sticky;
    right: 0;
    top: 0;
    bottom: 0;
    width: 2rem;
    pointer-events: none;
    background: linear-gradient(to left, color-mix(in srgb, var(--canvas), transparent 15%), transparent);
    z-index: 2;
    float: right;
    height: calc(100% - 8px);
    margin-left: -2rem;
}

.admin-user-table-viewport {
    max-height: min(65vh, 48rem);
}

.repo-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.repo-data-table th,
.repo-data-table td {
    padding: 0.28rem 0.65rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border), transparent 42%);
    border-left: none;
    border-right: none;
    text-align: left;
    vertical-align: middle;
    line-height: 1.3;
    transition: background-color 0.12s ease;
}

.repo-data-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding-top: 0.45rem;
    padding-bottom: 0.45rem;
    background: color-mix(in srgb, var(--elevated), var(--canvas) 55%);
    color: var(--text-tertiary);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    box-shadow: 0 1px 0 color-mix(in srgb, var(--border), transparent 38%);
}

.repo-data-table tbody tr:last-child td {
    border-bottom: none;
}

.repo-data-table tbody tr:nth-child(even) td {
    background: color-mix(in srgb, var(--canvas), transparent 72%);
}

.repo-data-table__row:hover td {
    background: color-mix(in srgb, var(--accent), transparent 93%) !important;
}

.repo-data-table__row--selected td,
.repo-data-table__row--selected:hover td {
    background: color-mix(in srgb, var(--accent), transparent 86%) !important;
}

/*
 * Multi-edit / bulk-action affordances.
 *
 * .bulk-action-bar surfaces the count of selected rows + actions (edit, delete,
 * clear) above the table when at least one document is selected. Sticky
 * positioning keeps it visible while the user scrolls long lists.
 */
.repo-col-select {
    width: 2.5rem;
    text-align: center;
    padding-right: 0 !important;
}

.repo-col-select input[type="checkbox"] {
    width: 1.05rem;
    height: 1.05rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.bulk-action-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin: 0 0 0.65rem;
    padding: 0.55rem 0.9rem;
    border: 1px solid color-mix(in srgb, var(--accent), var(--border) 35%);
    border-radius: 0.65rem;
    background: color-mix(in srgb, var(--accent), var(--surface) 88%);
    box-shadow: 0 8px 24px rgb(0 0 0 / 0.18);
    font-size: 0.85rem;
}

.bulk-action-bar__count {
    font-weight: 700;
    color: var(--text);
    margin-right: 0.25rem;
}

.bulk-action-bar__action {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background-color var(--transition-fast),
                border-color var(--transition-fast);
}

.bulk-action-bar__action:hover {
    background: var(--elevated);
    border-color: color-mix(in srgb, var(--accent), var(--border) 35%);
}

.bulk-action-bar__action--danger {
    color: var(--red);
    border-color: color-mix(in srgb, var(--red), var(--border) 50%);
}

.bulk-action-bar__action--danger:hover {
    background: color-mix(in srgb, var(--red), transparent 90%);
    border-color: var(--red);
}

.bulk-action-bar__clear {
    margin-left: auto;
    padding: 0.3rem 0.55rem;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font: inherit;
    font-size: 0.8rem;
}

.bulk-action-bar__clear:hover {
    color: var(--text);
}

.bulk-action-bar__status {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/*
 * Bulk-edit modal: each field row is a 3-column grid — toggle | label/input.
 * The label sits next to the toggle; the input fills the remaining width.
 */
.bulk-edit-grid {
    display: grid;
    gap: 0.65rem;
    margin: 0.5rem 0 1rem;
}

.bulk-edit-row {
    display: grid;
    gap: 0.4rem;
    grid-template-columns: minmax(12rem, 0.5fr) minmax(14rem, 1fr);
    align-items: center;
}

.bulk-edit-row__hint {
    grid-column: 2;
    margin: -0.15rem 0 0;
}

@media (max-width: 720px) {
    .bulk-edit-row {
        grid-template-columns: 1fr;
    }

    .bulk-edit-row__hint {
        grid-column: 1;
    }
}

.bulk-edit-row__check {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
}

.bulk-edit-row__check input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
}

.bulk-edit-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border);
}

.bulk-delete-dialog {
    max-width: 28rem;
}

.repo-col-numeric {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.repo-col-actions {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}

.repo-col-type {
    max-width: 7.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.repo-cell-title {
    font-weight: 600;
    max-width: min(22rem, 28vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repo-cell-counterparty {
    max-width: min(16rem, 18vw);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repo-cell-title a {
    color: var(--text);
    font-weight: 600;
    text-decoration: none;
}

.repo-cell-title a:hover,
.repo-cell-title a:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

.repo-cell-title__link {
    all: unset;
    cursor: pointer;
    color: var(--text);
    font-weight: 600;
}

.repo-cell-title__link:hover,
.repo-cell-title__link:focus-visible {
    color: var(--accent);
    text-decoration: underline;
}

/*
 * Stack a primary label over a muted secondary line in a single
 * table cell (used by the contacts list to show name + title/role).
 * Keeps the row height predictable while exposing two pieces of
 * info without growing the column count.
 */
.repo-cell-stack {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
}

.repo-cell-stack__sub {
    font-size: 0.75rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*
 * Inline help text under a form input — explanatory copy that
 * doesn't belong in placeholder text. Used by ContactDirectoryEditDialog
 * for the optional vendor-link field. Sized + tinted to read as
 * supporting context without competing with the validation message
 * slot below it.
 */
.form-help {
    margin: 0.25rem 0 0;
    font-size: 0.78rem;
    line-height: 1.45;
}

/*
 * Page-specific spacing for the contacts page's category filter
 * tab strip. Forwarded to <MaterialTabs/> as AdditionalClass — the
 * shared component owns the visual styling, this hook just adds
 * bottom margin so the table doesn't crowd the strip.
 */
.contacts-page__category-tabs {
    margin-bottom: 0.85rem;
}

.repo-cell-tags {
    max-width: 10rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.repo-row-actions {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0;
}

.repo-row-actions > * + * {
    margin-left: 0.5rem;
    padding-left: 0.5rem;
    border-left: 1px solid color-mix(in srgb, var(--border), transparent 25%);
}

.repo-action-link {
    padding: 0;
    border: 0;
    background: none;
    color: var(--accent);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}

.repo-action-link:hover,
.repo-action-link:focus-visible {
    text-decoration: underline;
}

button.repo-action-link {
    color: var(--accent);
}

.repo-action-danger {
    padding: 0.12rem 0.38rem;
    border-radius: 0.3rem;
    border: 1px solid color-mix(in srgb, var(--red), transparent 45%);
    background: color-mix(in srgb, var(--red), transparent 88%);
    color: #ffb4b4;
    font: inherit;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.repo-action-danger:hover:not(:disabled),
.repo-action-danger:focus-visible:not(:disabled) {
    background: color-mix(in srgb, var(--red), transparent 78%);
}

.repo-result-count {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
}

.admin-user-table .repo-role-select {
    min-height: 2rem;
    max-width: 100%;
    padding: 0.15rem 0.4rem;
    font-size: 0.78rem;
    border-radius: 0.4rem;
}

.admin-user-table thead th {
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.admin-user-table .repo-col-actions {
    text-align: left;
}

@media (max-width: 1024px) {
    .repo-col-hide-md {
        display: none;
    }

    .repo-cell-title {
        max-width: min(16rem, 32vw);
    }

    .repo-cell-counterparty {
        max-width: min(11rem, 20vw);
    }
}

@media (max-width: 768px) {
    .repo-col-hide-sm {
        display: none;
    }

    .toolbar.toolbar--dense {
        flex-direction: column;
    }

    .toolbar.toolbar--dense label,
    .toolbar.toolbar--dense .toolbar-field-grow {
        flex: 1 1 auto;
        min-width: 100%;
    }

    .repo-cell-title {
        max-width: min(12rem, 40vw);
    }

    .repo-cell-counterparty {
        max-width: min(9rem, 22vw);
    }
}

.document-grid {
    display: grid;
    gap: var(--document-grid-gap);
    grid-template-columns: repeat(auto-fit, minmax(17.5rem, 1fr));
}

.document-card {
    border-left-width: 4px;
    padding: var(--document-card-pad-y) var(--document-card-pad-x);
    cursor: default;
}

.document-card:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 14%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
    background: color-mix(in srgb, var(--panel), #ffffff 2%);
}

.document-card h2 {
    margin: var(--document-card-title-margin);
    font-size: 1.2rem;
    line-height: 1.28;
}

.document-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--document-actions-gap);
    margin-top: var(--document-actions-margin-top);
}

.document-actions .secondary-button,
.document-actions .danger-button {
    min-height: var(--toolbar-control-min-height);
}

.secondary-button,
.danger-button {
    border: 1px solid color-mix(in srgb, var(--border), #ffffff 12%);
    border-radius: 0.65rem;
    color: var(--text);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0.45rem 0.8rem;
    text-decoration: none;
    font: inherit;
    font-size: 0.85rem;
    transition: all 0.15s ease;
}

.secondary-button {
    background: color-mix(in srgb, var(--elevated), #ffffff 3%);
}

.danger-button {
    background: color-mix(in srgb, var(--red) 14%, var(--surface));
    border-color: color-mix(in srgb, var(--red) 50%, var(--border));
    color: #ffa0a0;
}

.secondary-button:hover:not(:disabled),
.secondary-button:focus-visible {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--elevated), #ffffff 8%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.danger-button:hover:not(:disabled),
.danger-button:focus-visible {
    border-color: var(--red);
    background: color-mix(in srgb, var(--red) 22%, var(--surface));
    color: #ffbdbd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.secondary-button:active:not(:disabled),
.danger-button:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: none;
}

.secondary-button:disabled,
.danger-button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.primary-button {
    border: 0;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, var(--accent), #6B8AE6);
    color: #ffffff;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0 1rem;
    text-decoration: none;
    font: inherit;
    font-size: 0.85rem;
    box-shadow: 0 2px 10px rgba(124, 158, 255, 0.25);
    transition: all 0.15s ease;
}

.primary-button:hover:not(:disabled) {
    filter: brightness(1.12);
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124, 158, 255, 0.35);
}

.primary-button:active:not(:disabled) {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 1px 4px rgba(124, 158, 255, 0.2);
}

.primary-button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.secondary-button--small,
.danger-button--small {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
    min-height: 1.85rem;
}

.delete-confirmation {
    color: var(--muted);
    flex-basis: 100%;
    margin: 0;
}

.document-viewer-page {
    width: min(1320px, calc(100% - 2rem));
    margin: 0 auto;
    padding: clamp(0.65rem, 2vw, 1rem) 0 calc(1rem + var(--floating-widget-clearance));
    min-height: calc(100dvh - var(--mobile-header-height));
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    min-width: 0;
}

.document-viewer-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 0.65rem 1rem;
    padding: 0.65rem 0.85rem;
    border: 1px solid color-mix(in srgb, var(--border), transparent 35%);
    border-radius: 0.75rem;
    background: color-mix(in srgb, var(--surface), var(--canvas) 35%);
}

.document-viewer-toolbar__lead {
    min-width: min(100%, 14rem);
    flex: 1 1 auto;
}

.document-viewer-toolbar__title {
    margin: 0.15rem 0 0;
    font-size: clamp(1.05rem, 2.5vw, 1.35rem);
    line-height: 1.25;
    font-weight: 700;
}

.document-viewer-toolbar__meta {
    margin: 0.2rem 0 0;
    font-size: 0.8rem;
}

.document-viewer-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: flex-end;
}

.document-viewer-primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.25rem;
    padding: 0.45rem 0.85rem;
    border: 0;
    border-radius: 0.65rem;
    background: linear-gradient(135deg, var(--accent), #6b8ae6);
    color: #fff;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition:
        filter var(--transition-fast),
        transform var(--transition-fast);
}

.document-viewer-primary-action:hover,
.document-viewer-primary-action:focus-visible {
    filter: brightness(1.08);
}

.document-viewer-primary-action:active {
    transform: scale(0.98);
}

.document-viewer-stage {
    flex: 1 1 auto;
    min-height: min(72dvh, 52rem);
    display: flex;
    flex-direction: column;
    border: 1px solid color-mix(in srgb, var(--border), transparent 35%);
    border-radius: 0.75rem;
    overflow: hidden;
    background: var(--canvas);
}

.document-viewer-frame {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 0;
    background: var(--canvas);
}

.document-viewer-frame--pdf {
    min-height: min(68dvh, 48rem);
}

.document-viewer-image-shell {
    flex: 1;
    min-height: min(68dvh, 48rem);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem;
    background: var(--canvas);
}

.document-viewer-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 0.35rem;
}

.document-auth-preview {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.document-auth-preview--frame {
    min-height: min(68dvh, 48rem);
}

.document-auth-preview--frame iframe {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 0;
}

.document-auth-preview--image {
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: var(--canvas);
}

.document-auth-preview--text {
    min-height: min(68dvh, 48rem);
}

.document-auth-preview--table {
    min-height: min(68dvh, 48rem);
    /*
     * The Tabular preview owns its own border and padding (matches the
     * artifact / chat panels' visual language). Stretch it to the
     * stage's full height so the inner table can scroll without
     * collapsing the surrounding card.
     */
}

.document-auth-preview--unsupported {
    min-height: min(40dvh, 28rem);
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: var(--canvas);
    border: 1px dashed var(--border);
    border-radius: 0.65rem;
}

.document-auth-preview__placeholder {
    text-align: center;
    max-width: 32rem;
    color: var(--text-secondary);
}

.document-auth-preview__placeholder-title {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.document-auth-preview__placeholder-copy {
    margin: 0 0 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
}

.document-auth-preview__download-action {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    background: var(--surface-alt, var(--surface));
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.document-auth-preview__download-action:hover {
    background: color-mix(in srgb, var(--surface-alt, var(--surface)), var(--text) 6%);
    border-color: color-mix(in srgb, var(--border), var(--text) 15%);
}

/* --- Extracted text preview (Word, email, RTF) --- */

.document-extracted-text-preview {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.document-extracted-text-preview__status {
    padding: 1rem;
    font-size: 0.85rem;
}

.document-extracted-text-preview__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: min(40dvh, 28rem);
    padding: 1.5rem;
    text-align: center;
}

.document-extracted-text-preview__empty-title {
    margin: 0 0 0.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.document-extracted-text-preview__empty-copy {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
    max-width: 30rem;
}

.document-extracted-text-preview__header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--border), transparent 40%);
    font-size: 0.78rem;
}

.document-extracted-text-preview__badge {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.document-extracted-text-preview__truncated {
    font-size: 0.75rem;
}

.document-extracted-text-preview__scroll {
    flex: 1;
    min-height: 0;
    overflow: auto;
}

.document-extracted-text-preview__text {
    margin: 0;
    padding: 1rem;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: var(--font-sans, system-ui, -apple-system, sans-serif);
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--canvas);
}

.document-text-preview {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 1rem;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--text);
    background: var(--canvas);
}

.assistant-layout-document .document-auth-preview {
    min-height: 0;
}

.document-viewer-fallback {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.65rem;
    padding: clamp(1rem, 4vw, 2rem);
    max-width: 36rem;
    margin: 0 auto;
    text-align: center;
}

.document-viewer-fallback__title {
    margin: 0;
    font-size: 1.05rem;
}

.document-viewer-fallback__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.card-header,
.tag-list {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.type-pill,
.status-badge,
.tag-list li,
.ingestion-note {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 500;
    transition: background-color var(--transition-fast),
                color var(--transition-fast);
}

.type-pill {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
}

.status-badge {
    margin-left: auto;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.06);
    border-color: transparent;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.tag-list {
    list-style: none;
    padding: 0;
    margin: 0.65rem 0 0;
}

.tag-list li {
    color: var(--muted);
    background: rgba(16, 24, 34, 0.8);
}

.ingestion-note {
    display: inline-block;
    color: #ffd9d9;
    border-color: var(--red);
    background: rgba(220, 95, 95, 0.1);
}

.status-active .status-badge,
.status-badge.status-active {
    background: rgba(79, 209, 197, 0.15);
    color: var(--green);
    border-color: transparent;
}

.status-warning .status-badge,
.status-badge.status-warning {
    background: rgba(229, 166, 61, 0.15);
    color: var(--amber);
    border-color: transparent;
}

.status-pending .status-badge,
.status-badge.status-pending {
    background: rgba(229, 166, 61, 0.15);
    color: var(--amber);
    border-color: transparent;
}

.status-completed .status-badge,
.status-badge.status-completed {
    background: rgba(79, 209, 197, 0.15);
    color: var(--green);
    border-color: transparent;
}

.status-overdue .status-badge,
.status-badge.status-overdue {
    background: rgba(239, 107, 107, 0.15);
    color: var(--red);
    border-color: transparent;
}

.status-other .status-badge,
.status-badge.status-other {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-secondary);
    border-color: transparent;
}

.status-info .status-badge,
.status-badge.status-info {
    background: rgba(124, 158, 255, 0.15);
    color: var(--blue);
    border-color: transparent;
}

.status-active {
    border-left-color: var(--green);
}

.status-warning {
    border-left-color: var(--amber);
}

.status-pending {
    border-left-color: var(--amber);
}

.status-completed {
    border-left-color: var(--green);
}

.status-overdue {
    border-left-color: var(--red);
}

.empty-state,
.loading-message {
    color: var(--muted);
    padding: 2rem;
    text-align: center;
    font-size: 0.95rem;
}

.loading-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.error-state {
    background: color-mix(in srgb, var(--red) 12%, var(--surface));
    border: 1px solid color-mix(in srgb, var(--red) 40%, transparent);
    border-radius: 0.75rem;
    padding: 2rem;
    text-align: center;
    color: var(--text);
}

.error-state p {
    margin: 0 0 1rem;
    color: var(--red);
}

.btn-retry {
    background: var(--elevated);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text);
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-retry:hover {
    background: var(--panel-strong);
    border-color: var(--accent);
}

.btn-retry:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 1100px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 900px) {
    .dashboard-split {
        grid-template-columns: 1fr;
    }

    .compact-document-list {
        max-height: 18rem;
    }
    
    .toolbar {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 540px) {
    .kpi-grid {
        grid-template-columns: 1fr;
        gap: var(--kpi-grid-gap);
    }

    .kpi-card {
        padding: var(--kpi-card-pad-y) var(--kpi-card-pad-x);
    }

    .dashboard-stack .section-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 0.75rem;
    }

    .dashboard-stack .section-heading > div:first-child {
        flex: none;
    }

    .dashboard-stack .section-heading .secondary-button {
        align-self: stretch;
        justify-content: center;
    }
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* Upload Document Form */
.upload-form {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow-lg);
    padding: clamp(1.5rem, 4vw, 2.5rem);
}

.upload-form__legend {
    color: var(--text);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.upload-form fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.upload-form fieldset:disabled {
    opacity: 0.65;
    pointer-events: none;
}

.upload-form__field {
    margin-bottom: 1.25rem;
}

.upload-form__field label {
    display: grid;
    gap: 0.5rem;
}

.upload-form__field label > span {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.upload-form__field label > span span[aria-hidden="true"] {
    color: var(--accent);
}

.upload-form__row {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, 1fr);
    margin-bottom: 1.25rem;
}

.upload-form__row .upload-form__field {
    margin-bottom: 0;
}

@media (max-width: 640px) {
    .upload-form__row {
        grid-template-columns: 1fr;
    }
}

.upload-form__input {
    width: 100%;
    box-sizing: border-box;
    min-height: 3rem;
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    background: var(--canvas);
    color: var(--text);
    padding: 0 1rem;
    font: inherit;
    font-size: 0.95rem;
}

.upload-form__input[type="file"] {
    padding: 0;
    line-height: 3rem;
}

.upload-form__input:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 20%);
}

.upload-form__input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124, 158, 255, 0.15);
    outline: none;
}

.upload-form__input::placeholder {
    color: var(--text-tertiary);
}

.upload-form__input::file-selector-button {
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--elevated);
    color: var(--text);
    min-height: calc(3rem - 2px);
    padding: 0 1rem;
    margin-right: 1rem;
    margin-left: 0;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.65rem 0 0 0.65rem;
    transition: background-color var(--transition-fast);
}

.upload-form__input::file-selector-button:hover {
    background: var(--panel-strong);
}

.vendor-counterparty-combobox {
    display: grid;
    gap: 0.5rem;
    min-width: 0;
}

.vendor-counterparty-combobox__label {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
}

.upload-form__hint {
    color: var(--text-tertiary);
    font-size: 0.85rem;
    margin: 0.5rem 0 0;
}

.upload-form__hint strong {
    color: var(--text-secondary);
}

/*
 * Vendor row inside the upload form: select fills the remaining width, the
 * "+ New vendor" button sits on the right. Stacks vertically on narrow viewports
 * so the dropdown stays usable.
 */
.upload-form__vendor-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.upload-form__vendor-select {
    flex: 1 1 auto;
    min-width: 0;
}

.upload-form__vendor-add {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

@media (max-width: 540px) {
    .upload-form__vendor-row {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-form__vendor-add {
        justify-content: center;
    }
}

.upload-form__actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.upload-form__submit {
    min-height: 3rem;
    min-width: 10rem;
    border: 0;
    border-radius: 0.7rem;
    background: linear-gradient(135deg, var(--accent), #6B8AE6);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    padding: 0 1.5rem;
    transition: filter var(--transition-fast),
                transform var(--transition-fast);
}

.upload-form__submit:hover:not(:disabled) {
    filter: brightness(1.1);
}

.upload-form__submit:active:not(:disabled) {
    transform: scale(0.98);
}

.upload-form__submit:disabled {
    opacity: 0.65;
    cursor: not-allowed;
}

.upload-form__field--inline {
    margin-bottom: 0.75rem;
}

.upload-form__checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.45;
}

.upload-form__checkbox {
    margin-top: 0.2rem;
    flex-shrink: 0;
}

/*
 * Upload mode tabs migrated to the shared <MaterialTabs/> component
 * (see src/DocumentRepository/Components/Shared/MaterialTabs.*).
 * The .upload-form__mode-tabs hook is forwarded as AdditionalClass on
 * the tablist so the legacy bottom margin survives the migration.
 */
.upload-form__mode-tabs {
    margin: 0 0 1rem;
}

.upload-form__tabpanel {
    min-height: 0;
}

.upload-widget__body .upload-form {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    border-radius: 0;
}

.upload-widget__body .upload-form__legend {
    margin-bottom: 0.55rem;
    padding-bottom: 0.4rem;
    font-size: 0.98rem;
}

.upload-widget__body .upload-form__mode-tabs {
    margin-bottom: 0.65rem;
}

.upload-widget__body .upload-form__field {
    margin-bottom: 0.55rem;
}

.upload-widget__body .upload-form__row {
    gap: 0.55rem;
    margin-bottom: 0.55rem;
}

.upload-widget__body .upload-form__input {
    min-height: 2.45rem;
    padding: 0 0.75rem;
    font-size: 0.875rem;
}

.upload-widget__body .upload-form__input[type="file"] {
    line-height: 2.45rem;
}

.upload-widget__body .upload-form__input::file-selector-button {
    min-height: calc(2.45rem - 2px);
    padding: 0 0.65rem;
    margin-right: 0.65rem;
    font-size: 0.82rem;
}

.upload-widget__body .upload-form__hint {
    margin-top: 0.28rem;
    font-size: 0.78rem;
    line-height: 1.35;
}

.upload-widget__body .upload-form__actions {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
}

.upload-widget__body .upload-form__submit {
    min-height: 2.5rem;
    font-size: 0.875rem;
}

.upload-widget__body .secondary-button {
    min-height: 2.5rem;
    font-size: 0.875rem;
}

.groups-org-picker {
    max-width: 24rem;
    margin-bottom: 1rem;
}

.card-actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.admin-audit-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    background: var(--surface);
}

.admin-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.admin-audit-table th,
.admin-audit-table td {
    padding: 0.55rem 0.65rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.admin-audit-table th {
    background: color-mix(in srgb, var(--elevated), var(--canvas) 35%);
    color: var(--text-secondary);
    font-weight: 600;
}

.admin-audit-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-audit-summary {
    max-width: 28rem;
}

.admin-dialog--wide {
    max-width: min(44rem, 94vw);
}

/*
 * Shared modal backdrop — used by document modals and admin/vendor dialogs.
 * `.document-modal-backdrop` keeps its higher z-index for document-layer modals.
 * `.dialog-backdrop` is the general-purpose variant for admin/vendor dialogs.
 */
.document-modal-backdrop,
.dialog-backdrop {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: clamp(0.75rem, 2vw, 1.5rem);
    padding-left: max(clamp(0.75rem, 2vw, 1.5rem), env(safe-area-inset-left, 0px));
    padding-right: max(clamp(0.75rem, 2vw, 1.5rem), env(safe-area-inset-right, 0px));
    padding-top: max(clamp(0.75rem, 2vw, 1.5rem), env(safe-area-inset-top, 0px));
    padding-bottom: max(clamp(0.75rem, 2vw, 1.5rem), env(safe-area-inset-bottom, 0px));
    background: rgb(0 0 0 / 0.72);
    backdrop-filter: blur(5px);
}

.document-modal-backdrop {
    z-index: 200;
}

.dialog-backdrop {
    z-index: 100;
    animation: dialogBackdropFadeIn 150ms ease;
}

@keyframes dialogBackdropFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/*
 * Shared modal dialog panel base — common chrome for all modal dialogs.
 * Use `.modal-dialog` directly for new dialogs, or the existing
 * `.admin-dialog` / `.document-edit-dialog` aliases.
 */
.modal-dialog,
.admin-dialog,
.document-edit-dialog {
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 1rem;
    background: var(--panel);
    box-shadow: 0 30px 90px rgb(0 0 0 / 0.55);
    overscroll-behavior: contain;
}

.modal-dialog,
.admin-dialog {
    width: min(100% - 2rem, 28rem);
    max-height: calc(100vh - 4rem);
    padding: 1.5rem;
    animation: dialogEnter 200ms ease;
}

.document-edit-dialog {
    width: min(100% - 1rem, 36rem);
    max-height: min(94dvh, 52rem);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1rem 1.15rem 1.15rem;
    border-color: color-mix(in srgb, var(--border), var(--accent) 24%);
}

@keyframes dialogEnter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-dialog h2,
.admin-dialog h2 {
    margin: 0 0 1rem;
    font-size: 1.3rem;
}

.document-edit-dialog .document-pdf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0;
    border-bottom: 0;
}

@media (max-width: 36rem) {
    .document-edit-dialog {
        width: 100%;
        max-height: calc(100dvh - 1.5rem);
        padding: 0.85rem 0.95rem 1rem;
        border-radius: 0.85rem;
    }

    .document-edit-dialog .document-pdf-header {
        align-items: stretch;
        flex-direction: column;
    }

    .document-edit-dialog .document-pdf-header > .secondary-button {
        align-self: stretch;
        justify-content: center;
    }
}

.dialog-note {
    margin: 0 0 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: rgba(124, 158, 255, 0.10);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-field {
    margin-bottom: 1rem;
}

.form-field label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 2.75rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    background: var(--canvas);
    color: var(--text);
    font: inherit;
}

.form-input:focus {
    border-color: var(--accent);
    outline: none;
}

.form-input:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

textarea.form-input,
.form-input[rows] {
    min-height: 4.5rem;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    line-height: 1.5;
    resize: vertical;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

/*
 * Narrow phones (<= 30rem ≈ 480px): stretch the action buttons so they
 * stack to full width instead of cramming side-by-side. Keeps the
 * "Cancel / Confirm" pattern usable on iPhone-class viewports.
 */
@media (max-width: 30rem) {
    .dialog-actions {
        justify-content: stretch;
    }

    .dialog-actions > .primary-button,
    .dialog-actions > .secondary-button,
    .dialog-actions > .danger-button {
        flex: 1 1 100%;
        justify-content: center;
    }
}

/* Validation message rendered by Blazor's <ValidationMessage> */
.validation-message {
    display: block;
    margin-top: 0.4rem;
    color: #ffd9d9;
    font-size: 0.85rem;
}

.group-member-list {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
}

.group-member-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--border);
}

.upload-error {
    border: 1px solid color-mix(in srgb, var(--red), #ffffff 18%);
    border-radius: 0.7rem;
    background: rgba(220, 95, 95, 0.12);
    color: #ffd9d9;
    padding: 0.85rem 1rem;
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

.validation-message {
    color: #ffa3a3;
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

.impersonation-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    padding: 0.65rem 1rem;
    border-bottom: 1px solid color-mix(in srgb, var(--amber), #ffffff 28%);
    background: color-mix(in srgb, var(--amber), var(--canvas) 82%);
    color: var(--text-primary);
}

.impersonation-banner__text {
    margin: 0;
    font-size: 0.95rem;
}

.impersonation-banner__exit {
    flex-shrink: 0;
}

.support-tools-panel .support-tools-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
    max-width: 36rem;
}

.support-tools-panel .checkbox-field label {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.support-tools-panel .checkbox-field input {
    margin-top: 0.2rem;
}

/*
 * Assistant chat composer file input hide.
 *
 * The composer + menu's "Attach screenshot / image" item wraps a Blazor
 * <InputFile /> in a <label>; the file input itself must be visually hidden
 * so only the styled label rows show. This rule MUST be un-scoped because
 * <InputFile /> renders under its own component scope id which doesn't
 * match the widget's scope, so a scoped selector silently misses and the
 * browser's native "Choose File" chip leaks into the menu.
 */
.assistant-widget__plus-menu-file {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    /* Belt-and-braces — clip if anything tries to make it visible. */
    overflow: hidden;
}

/*
 * ============================================================================
 * Assistant chat visualization styles (charts, graphs, pie, bars).
 *
 * These rules MUST live in the un-scoped global stylesheet because the SVG
 * markup is built by the child component <AssistantMessageContent /> while
 * the surrounding chat widget belongs to <AssistantChatWidget />. Blazor's
 * scoped CSS would tag selectors with the widget's scope id, which never
 * matches the child's elements — leaving things like SVG text font-size
 * unstyled and falling back to the inherited 16px (which then renders
 * gigantic relative to the 100×100 viewBox and overflows everything).
 * ============================================================================
 */
.assistant-widget__visualization {
    display: grid;
    gap: 0.75rem;
    margin: 0.75rem 0;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: var(--canvas);
    padding: 0.9rem;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    container-type: inline-size;
}

.assistant-widget__visualization h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text);
}

.assistant-widget__markdown {
    line-height: 1.55;
    overflow-wrap: anywhere;
    min-width: 0;
    max-width: 100%;
}

.assistant-widget__markdown > :first-child {
    margin-top: 0;
}

.assistant-widget__markdown > :last-child {
    margin-bottom: 0;
}

.assistant-widget__markdown h1,
.assistant-widget__markdown h2,
.assistant-widget__markdown h3,
.assistant-widget__markdown h4 {
    color: var(--text);
    line-height: 1.3;
}

.assistant-widget__markdown h1 {
    font-size: 1.25rem;
}

.assistant-widget__markdown h2 {
    font-size: 1.1rem;
}

.assistant-widget__markdown h3,
.assistant-widget__markdown h4 {
    font-size: 1rem;
}

.assistant-widget__markdown p,
.assistant-widget__markdown ul,
.assistant-widget__markdown ol,
.assistant-widget__markdown blockquote,
.assistant-widget__markdown pre,
.assistant-widget__markdown table {
    margin: 0.75rem 0;
}

.assistant-widget__markdown ul,
.assistant-widget__markdown ol {
    padding-left: 1.25rem;
}

.assistant-widget__markdown li + li {
    margin-top: 0.25rem;
}

.assistant-widget__markdown strong {
    color: var(--text);
    font-weight: 800;
}

.assistant-widget__markdown a {
    color: var(--accent-ai);
}

.assistant-widget__markdown blockquote {
    border-left: 2px solid var(--accent-ai);
    color: var(--text-secondary);
    padding-left: 0.85rem;
}

.assistant-widget__markdown code {
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: 0.35rem;
    padding: 0.05rem 0.3rem;
    font-size: 0.88em;
}

.assistant-widget__markdown pre {
    background: var(--canvas);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow-x: auto;
    padding: 0.85rem;
}

.assistant-widget__markdown pre code {
    background: transparent;
    border: 0;
    padding: 0;
}

.assistant-widget__markdown table {
    border-collapse: collapse;
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

.assistant-widget__markdown th,
.assistant-widget__markdown td {
    border: 1px solid var(--border);
    padding: 0.45rem 0.6rem;
    text-align: left;
    vertical-align: top;
}

.assistant-widget__markdown th {
    background: var(--canvas);
    color: var(--text);
}

/* Bar chart -------------------------------------------------------------- */
.assistant-widget__bar-chart {
    display: grid;
    gap: 0.55rem;
}

.assistant-widget__bar-row {
    display: grid;
    align-items: center;
    gap: 0.5rem;
    grid-template-columns: minmax(5rem, 0.8fr) minmax(7rem, 2fr) auto;
}

.assistant-widget__bar-label,
.assistant-widget__bar-value,
.assistant-widget__chart-axis {
    color: var(--text-secondary);
    font-size: 0.78rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.assistant-widget__bar-track {
    min-height: 0.65rem;
    overflow: hidden;
    border-radius: 999px;
    background: color-mix(in srgb, var(--elevated), #000000 12%);
}

.assistant-widget__bar-fill {
    display: block;
    min-height: 0.65rem;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent-ai), var(--accent));
}

/* Line chart ------------------------------------------------------------- */
.assistant-widget__line-chart svg,
.assistant-widget__graph {
    width: 100%;
    height: 14rem;
    border-radius: 0.65rem;
    background: color-mix(in srgb, var(--surface), #000000 12%);
    display: block;
}

.assistant-widget__line-chart polyline {
    fill: none;
    stroke: var(--accent-ai);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.assistant-widget__line-chart circle {
    fill: var(--accent-ai);
    stroke: var(--canvas);
    stroke-width: 0.6;
    vector-effect: non-scaling-stroke;
}

/* Pie chart -------------------------------------------------------------- */
/*
 * Layout: SVG pie on the left, legend on the right at desktop widths;
 * legend collapses *below* the pie at narrow widths (≤ 36rem). The
 * SVG box is fluid up to 18rem (≈288px) and locks 1:1 aspect-ratio so
 * the disc stays circular regardless of the legend column's flex
 * pressure. `min-width: 0` on the legend column is critical — without
 * it the long legend rows refuse to shrink and squeeze the SVG
 * column to a tiny disc (the bug this layout is replacing).
 */
.assistant-widget__pie-chart {
    display: grid;
    align-items: start;
    gap: 1.25rem;
    grid-template-columns: minmax(8rem, 18rem) minmax(0, 1fr);
    min-width: 0;
    max-width: 100%;
}

.assistant-widget__pie-svg {
    width: 100%;
    max-width: 18rem;
    aspect-ratio: 1 / 1;
    height: auto;
    display: block;
    justify-self: center;
    /* Slight inset shadow so the pie reads against the dark card. */
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.assistant-widget__pie-svg path,
.assistant-widget__pie-svg circle {
    /* Subtle hairline between slices using the canvas color so they read
       as discrete wedges, not a single stained-glass blob. */
    stroke: var(--canvas);
    stroke-width: 0.6;
    stroke-linejoin: round;
}

.assistant-widget__pie-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    color: var(--text-secondary);
    display: grid;
    gap: 0.45rem;
    font-size: 0.85rem;
    min-width: 0;
    align-self: center;
}

.assistant-widget__pie-legend li {
    display: grid;
    /* swatch | label (flex) | value | percentage — all on one row.
       `minmax(0, 1fr)` lets the label ellipsize instead of forcing a wrap. */
    grid-template-columns: 0.7rem minmax(0, 1fr) auto auto;
    align-items: baseline;
    column-gap: 0.6rem;
    line-height: 1.35;
    min-width: 0;
}

.assistant-widget__pie-legend li::before {
    content: "";
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 0.2rem;
    background: var(--swatch, var(--accent-ai));
    align-self: center;
}

.assistant-widget__pie-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.assistant-widget__pie-value {
    color: var(--text);
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.assistant-widget__pie-pct {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    min-width: 3rem;
}

.assistant-widget__pie-total {
    grid-column: 1 / -1;
    margin: 0.4rem 0 0;
    padding-top: 0.45rem;
    border-top: 1px solid color-mix(in srgb, var(--border), transparent 35%);
    color: var(--text);
    font-size: 0.82rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

@media (max-width: 36rem) {
    .assistant-widget__pie-chart {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 0.85rem;
    }

    .assistant-widget__pie-legend {
        width: 100%;
    }

    .assistant-widget__pie-total {
        text-align: left;
    }
}

@container (max-width: 42rem) {
    .assistant-widget__pie-chart {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 0.85rem;
    }

    .assistant-widget__pie-svg {
        max-width: min(18rem, 100%);
    }

    .assistant-widget__pie-legend {
        width: 100%;
    }

    .assistant-widget__pie-total {
        text-align: left;
    }
}

@container (max-width: 30rem) {
    .assistant-widget__pie-legend li {
        grid-template-columns: 0.7rem minmax(0, 1fr) auto;
        row-gap: 0.1rem;
    }

    .assistant-widget__pie-pct {
        grid-column: 2 / -1;
        min-width: 0;
        text-align: left;
    }
}

/* Graph (nodes + edges) ------------------------------------------------- */
.assistant-widget__graph line {
    stroke: color-mix(in srgb, var(--border), #ffffff 12%);
    stroke-width: 0.4;
    vector-effect: non-scaling-stroke;
}

.assistant-widget__graph circle {
    fill: var(--accent-ai);
    stroke: var(--canvas);
    stroke-width: 0.5;
    vector-effect: non-scaling-stroke;
}

/*
 * Text inside an SVG with a 100×100 viewBox uses *user-space* units, so a
 * font-size of 3.2 maps to roughly the same on-screen pixels as 12–13px CSS
 * text when the SVG is rendered at typical chat widget widths (~360px). Pair
 * with text-anchor:middle so labels stay centered under each node, and
 * paint-order so the dark stroke draws BEHIND the fill for legibility on the
 * dark surface.
 */
.assistant-widget__graph text {
    fill: var(--text);
    font-size: 3.2px;
    text-anchor: middle;
    dominant-baseline: hanging;
    paint-order: stroke;
    stroke: color-mix(in srgb, var(--surface), #000000 12%);
    stroke-width: 1.2;
    stroke-linejoin: round;
    pointer-events: none;
}

/* Mermaid diagrams ------------------------------------------------------- */
/*
 * The .assistant-widget__mermaid host starts as a <pre><code>source</code></pre>
 * — readable but plain — and is replaced in place by mermaid.js with sanitized
 * SVG once the module loads (see AssistantChatWidget.razor.js). Until then the
 * `data-mermaid-pending="true"` attribute keeps it visible as monospace source
 * so users see something rather than a blank box.
 */
.assistant-widget__mermaid-wrap {
    overflow: auto;
    max-height: 70vh;
}

.assistant-widget__mermaid {
    margin: 0;
    padding: 0.6rem 0.8rem;
    border-radius: 0.55rem;
    background: color-mix(in srgb, var(--surface), #000000 18%);
    color: var(--text-secondary);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.78rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 2rem;
}

.assistant-widget__mermaid code {
    font: inherit;
    color: inherit;
    background: transparent;
    padding: 0;
}

.assistant-widget__mermaid--rendered {
    background: transparent;
    padding: 0;
    text-align: center;
    color: var(--text);
}

/*
 * Lock the SVG font to the same synchronous platform stack mermaid uses
 * for getBBox() during layout (see MERMAID_FONT_STACK in
 * wwwroot/js/mermaid-diagram-theme.js). Without this, the SVG inherits the page
 * webfont ("Public Sans"), whose glyph metrics differ from the platform
 * stack — text inside each node is positioned for the measured font but
 * RENDERED in a font with taller ascenders, so the top of each label pokes
 * above the node-shape edge and looks visually clipped. Keeping this rule
 * in lockstep with the JS-side font stack is the structural fix.
 */
.assistant-widget__mermaid--rendered svg {
    max-width: 100%;
    height: auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif !important;
}

/* Ensure mermaid text is always readable with proper contrast */
.assistant-widget__mermaid--rendered svg text,
.assistant-widget__mermaid--rendered svg tspan,
.assistant-widget__mermaid--rendered svg .nodeLabel,
.assistant-widget__mermaid--rendered svg .node .label,
.assistant-widget__mermaid--rendered svg .label,
.assistant-widget__mermaid--rendered svg .label text,
.assistant-widget__mermaid--rendered svg .edgeLabel,
.assistant-widget__mermaid--rendered svg .edgeLabel text,
.assistant-widget__mermaid--rendered svg .labelText,
.assistant-widget__mermaid--rendered svg .cluster-label,
.assistant-widget__mermaid--rendered svg .cluster-label text,
.assistant-widget__mermaid--rendered svg foreignObject,
.assistant-widget__mermaid--rendered svg foreignObject div,
.assistant-widget__mermaid--rendered svg foreignObject span,
.assistant-widget__mermaid--rendered svg foreignObject p,
.assistant-widget__mermaid--rendered svg .messageText,
.assistant-widget__mermaid--rendered svg .actor,
.assistant-widget__mermaid--rendered svg .actor text,
.assistant-widget__mermaid--rendered svg .loopText,
.assistant-widget__mermaid--rendered svg .loopText text,
.assistant-widget__mermaid--rendered svg .noteText,
.assistant-widget__mermaid--rendered svg .labelBox,
.assistant-widget__mermaid--rendered svg .labelBox text,
.assistant-widget__mermaid--rendered svg .statediagram-state .state-title,
.assistant-widget__mermaid--rendered svg .state-note text,
.assistant-widget__mermaid--rendered svg .taskText,
.assistant-widget__mermaid--rendered svg .taskTextOutsideRight,
.assistant-widget__mermaid--rendered svg .taskTextOutsideLeft,
.assistant-widget__mermaid--rendered svg .sectionTitle,
.assistant-widget__mermaid--rendered svg .titleText,
.assistant-widget__mermaid--rendered svg .pieTitleText,
.assistant-widget__mermaid--rendered svg .slice,
.assistant-widget__mermaid--rendered svg .legend text,
.assistant-widget__mermaid--rendered svg g.classGroup text,
.assistant-widget__mermaid--rendered svg g text {
    fill: #ffffff !important;
    color: #ffffff !important;
    /*
     * Intentionally NOT setting font-weight here. Mermaid measures every
     * text bbox at the SVG default weight (normal/400) before drawing the
     * node shapes around the labels. Forcing the rendered weight to 500
     * makes glyphs marginally taller/wider than what was measured, which
     * — combined with mermaid's `translate(0, -bbox.height/2)` centering
     * that ignores bbox.y — pushes letter tops past the rect's top edge
     * and produces the "labels clipped at the top" symptom. White text on
     * a dark fill is still readable at normal weight.
     */
}

.assistant-widget__mermaid--rendered svg .edgeLabel {
    background-color: #1a1f2e !important;
}

.assistant-widget__mermaid--rendered svg .edgeLabel rect {
    fill: #1a1f2e !important;
    opacity: 0.9;
}

/* Node styling overrides - force dark backgrounds on ALL nodes regardless
 * of what classDef/style the model emits. This guarantees white text is
 * always readable. Uses descendant selectors (not direct child) because
 * mermaid sometimes wraps shapes inside extra <g> elements. */
.assistant-widget__mermaid--rendered svg .node rect,
.assistant-widget__mermaid--rendered svg .node circle,
.assistant-widget__mermaid--rendered svg .node ellipse,
.assistant-widget__mermaid--rendered svg .node polygon,
.assistant-widget__mermaid--rendered svg .node path,
.assistant-widget__mermaid--rendered svg g.node rect,
.assistant-widget__mermaid--rendered svg g.node circle,
.assistant-widget__mermaid--rendered svg g.node ellipse,
.assistant-widget__mermaid--rendered svg g.node polygon,
.assistant-widget__mermaid--rendered svg g.node path {
    fill: #2a3a5a !important;
    stroke: #5a7fc2 !important;
    stroke-width: 2px !important;
}

/* Edge label backgrounds (the rect behind text on connecting lines) */
.assistant-widget__mermaid--rendered svg .edgeLabel rect,
.assistant-widget__mermaid--rendered svg .edgeLabel foreignObject {
    fill: #1a1f2e !important;
    background: #1a1f2e !important;
}

/* Mermaid embeds a <style> element inside the SVG with classDef rules.
 * Those rules are scoped to the svg and have higher specificity than our
 * rules. Use a descendant selector that includes the parent svg AND the
 * defs > class element pattern mermaid generates so we win the cascade.
 * Belt and suspenders: also re-declare on .label-container and the label
 * background rect that mermaid sometimes uses for stadium/circle nodes. */
.assistant-widget__mermaid--rendered svg .label-container,
.assistant-widget__mermaid--rendered svg .basic.label-container,
.assistant-widget__mermaid--rendered svg .er.entityBox {
    fill: #2a3a5a !important;
    stroke: #5a7fc2 !important;
}

/* Defensive override - any rect/polygon/ellipse/circle/path inside .node
 * that has an inline fill via style attribute gets forcibly overridden. */
.assistant-widget__mermaid--rendered svg .node rect[style],
.assistant-widget__mermaid--rendered svg .node circle[style],
.assistant-widget__mermaid--rendered svg .node ellipse[style],
.assistant-widget__mermaid--rendered svg .node polygon[style],
.assistant-widget__mermaid--rendered svg .node path[style] {
    fill: #2a3a5a !important;
    stroke: #5a7fc2 !important;
}

/* Cluster/subgraph backgrounds */
.assistant-widget__mermaid--rendered svg .cluster rect,
.assistant-widget__mermaid--rendered svg .cluster > rect {
    fill: #1a2744 !important;
    stroke: #3b5a8a !important;
}

/* Make flowchart arrows more visible */
.assistant-widget__mermaid--rendered svg .flowchart-link {
    stroke: #8ba4d9;
    stroke-width: 2px;
}

.assistant-widget__mermaid--rendered svg marker path {
    fill: #8ba4d9;
}

/* Gantt / timeline — layering helpers (DOM reorder in mermaid-diagram-theme.js) */
.assistant-widget__mermaid--rendered svg .grid .tick line {
    stroke: color-mix(in srgb, var(--border), var(--text) 8%) !important;
    opacity: 0.35 !important;
    stroke-width: 1px !important;
}

.assistant-widget__mermaid--rendered svg g.today line,
.assistant-widget__mermaid--rendered svg line.today {
    stroke: color-mix(in srgb, var(--accent), transparent 40%) !important;
    opacity: 0.6 !important;
    stroke-width: 1.5px !important;
}

.assistant-widget__mermaid--rendered svg rect.section {
    opacity: 1 !important;
}

.assistant-widget__mermaid--rendered svg rect.done,
.assistant-widget__mermaid--rendered svg rect[class*="done"] {
    fill: #1a4a47 !important;
    stroke: var(--green) !important;
}

.assistant-widget__mermaid--rendered svg rect.active,
.assistant-widget__mermaid--rendered svg rect[class*="active"]:not([class*="Crit"]) {
    fill: #243a6b !important;
    stroke: var(--accent) !important;
}

.assistant-widget__mermaid--rendered svg rect.crit,
.assistant-widget__mermaid--rendered svg rect[class*="crit"],
.assistant-widget__mermaid--rendered svg rect[class*="Crit"] {
    fill: #4a2828 !important;
    stroke: var(--red) !important;
}

.assistant-widget__mermaid--rendered svg rect.milestone {
    fill: #3d3558 !important;
    stroke: var(--purple) !important;
}

/* Label halo so grid/today lines never cut through text */
.assistant-widget__mermaid--rendered svg .taskText,
.assistant-widget__mermaid--rendered svg .taskTextOutsideRight,
.assistant-widget__mermaid--rendered svg .taskTextOutsideLeft,
.assistant-widget__mermaid--rendered svg .sectionTitle,
.assistant-widget__mermaid--rendered svg .titleText {
    paint-order: stroke fill;
    stroke: var(--canvas);
    stroke-width: 4px;
    stroke-linejoin: round;
}

/* Force all text in mermaid to be white - ultimate fallback */
.assistant-widget__mermaid--rendered svg * {
    --tw-text-opacity: 1;
}

.assistant-widget__mermaid--rendered svg [fill]:not([fill="none"]):not([fill="transparent"]) text,
.assistant-widget__mermaid--rendered svg [style*="fill"] text {
    fill: #ffffff !important;
}

.assistant-widget__mermaid--failed {
    border: 1px dashed color-mix(in srgb, var(--accent-warning, #f59e0b), #000000 10%);
    color: var(--text-secondary);
}

.assistant-widget__mermaid--failed::before {
    content: "Diagram failed to render — raw mermaid source shown below.";
    display: block;
    font-family: inherit;
    font-size: 0.72rem;
    color: color-mix(in srgb, var(--accent-warning, #f59e0b), #ffffff 20%);
    margin-bottom: 0.4rem;
}

/* Artifact reference cards (chat embed) ---------------------------------- */
/*
 * Renders an AssistantArtifactBlock inline in the assistant message bubble.
 * The card carries title + kind chip + Open / Download links pointing at
 * /artifacts/{id} and /artifacts/{id}/download. AssistantArtifactSpecBlock
 * uses the same shell with a dashed border to signal "request acknowledged
 * but not generated yet".
 */
.assistant-widget__artifact {
    display: grid;
    grid-template-columns: 2.4rem 1fr;
    gap: 0.8rem;
    align-items: start;
    margin: 0.75rem 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: var(--canvas);
}

.assistant-widget__artifact--spec {
    border-style: dashed;
}

.assistant-widget__artifact-icon {
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--accent-ai), var(--canvas) 60%);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.assistant-widget__artifact-body {
    min-width: 0;
    display: grid;
    gap: 0.25rem;
}

.assistant-widget__artifact-eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.assistant-widget__artifact-status {
    color: var(--text-secondary);
}

.assistant-widget__artifact-title {
    margin: 0;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.assistant-widget__artifact-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

.assistant-widget__artifact-actions {
    margin-top: 0.4rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.assistant-widget__artifact-link {
    display: inline-flex;
    align-items: center;
    padding: 0.32rem 0.7rem;
    border-radius: 0.45rem;
    border: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface), #000000 8%);
    color: var(--text);
    text-decoration: none;
    font-size: 0.78rem;
    line-height: 1;
}

.assistant-widget__artifact-link:hover {
    background: color-mix(in srgb, var(--surface), #ffffff 6%);
}

.assistant-widget__artifact-link--primary {
    background: color-mix(in srgb, var(--accent-ai), var(--canvas) 30%);
    color: var(--text);
    border-color: color-mix(in srgb, var(--accent-ai), var(--border) 30%);
}

/* Artifacts panel (document + collection detail) ------------------------- */
/*
 * The .artifacts-panel section reuses .dashboard-panel styling visually but
 * is its own selector so its child rows can use a tighter, list-style layout
 * (icon | title+meta | actions) without inheriting heading typography from
 * the broader panel.
 */
.artifacts-panel {
    margin: 1.5rem 0;
    padding: 1.25rem 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.85rem;
    background: var(--surface);
    display: grid;
    gap: 1rem;
}

.artifacts-panel__heading {
    align-items: end;
}

.artifacts-panel__heading-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.artifacts-panel__count {
    font-size: 0.85rem;
}

.artifacts-panel__refresh {
    width: 1.85rem;
    height: 1.85rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.45rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color var(--transition-fast),
                color var(--transition-fast);
}

.artifacts-panel__refresh:hover:not(:disabled),
.artifacts-panel__refresh:focus-visible {
    background: var(--elevated);
    color: var(--text);
    outline: none;
}

.artifacts-panel__refresh:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.artifacts-panel__empty {
    margin: 0;
}

/*
 * Org-wide artifacts admin index (/artifacts). Shares the dashboard
 * shell + page-header pattern with Documents / Collections; the filter
 * row and table styling is local to this page.
 */
.artifacts-admin {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.artifacts-admin__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.75rem;
}

.artifacts-admin__filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 12rem;
    flex: 1 1 12rem;
}

.artifacts-admin__filter-field span {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.artifacts-admin__filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.85rem;
    color: var(--text);
    align-self: end;
    padding: 0.5rem 0;
}

.artifacts-admin__refresh {
    align-self: end;
}

.artifacts-admin__count {
    margin: 0;
    font-size: 0.8rem;
}

.artifacts-admin__source-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.5rem;
    border-radius: 0.4rem;
    font-size: 0.72rem;
    background: var(--elevated);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.artifacts-admin__source-badge--document {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent), var(--border) 50%);
}

.artifacts-admin__source-badge--collection {
    color: var(--accent-ai);
    border-color: color-mix(in srgb, var(--accent-ai), var(--border) 50%);
}

.artifacts-admin__source-badge--orphaned {
    color: var(--red, #ef6b6b);
    border-color: color-mix(in srgb, var(--red, #ef6b6b), var(--border) 50%);
}

.repo-action-link--danger {
    color: var(--red, #ef6b6b);
    background: transparent;
    border: 0;
    cursor: pointer;
    padding: 0;
    font: inherit;
}

.repo-action-link--danger:hover:not(:disabled),
.repo-action-link--danger:focus-visible {
    text-decoration: underline;
    outline: none;
}

.repo-action-link--danger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.artifacts-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.65rem;
}

.artifacts-panel__row {
    display: grid;
    grid-template-columns: 2.4rem 1fr auto;
    gap: 0.85rem;
    align-items: start;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    background: var(--canvas);
    transition: border-color 0.15s ease,
                background-color 0.15s ease;
}

.artifacts-panel__row:hover {
    border-color: color-mix(in srgb, var(--border), #ffffff 12%);
    background: color-mix(in srgb, var(--canvas), #ffffff 2%);
}

.artifacts-panel__row-icon {
    width: 2.4rem;
    height: 2.4rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--accent-ai), var(--canvas) 60%);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.artifacts-panel__row-body {
    min-width: 0;
    display: grid;
    gap: 0.3rem;
}

.artifacts-panel__row-meta {
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.artifacts-panel__chip {
    display: inline-flex;
    align-items: center;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    background: color-mix(in srgb, var(--surface), #ffffff 4%);
    border: 1px solid var(--border);
    font-size: 0.72rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.artifacts-panel__row-status {
    margin-left: 0;
}

.artifacts-panel__row-title {
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.artifacts-panel__row-title:hover {
    text-decoration: underline;
}

.artifacts-panel__row-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.86rem;
    line-height: 1.4;
}

.artifacts-panel__row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: flex-start;
}

.artifacts-panel__action {
    padding: 0.32rem 0.7rem;
    font-size: 0.78rem;
}

@media (max-width: 720px) {
    .artifacts-panel__row {
        grid-template-columns: 2.4rem 1fr;
    }
    .artifacts-panel__row-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

/* Artifact detail page extras ------------------------------------------- */
.artifact-detail__content {
    line-height: 1.55;
}

.artifact-detail__prompt {
    margin: 0;
}

.artifact-detail__prompt summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.artifact-detail__prompt pre {
    margin: 0.5rem 0 0;
    padding: 0.65rem 0.85rem;
    border-radius: 0.55rem;
    background: color-mix(in srgb, var(--surface), #000000 18%);
    color: var(--text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
    font-size: 0.78rem;
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

/* Toolbar toggle (compact inline checkbox + label) */
.toolbar .toolbar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: auto;
    margin-top: 0.25rem;
    cursor: pointer;
}

.toolbar .toolbar-toggle input[type="checkbox"] {
    width: 0.9rem;
    height: 0.9rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    accent-color: var(--accent);
}

.toolbar .toolbar-toggle span {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}