:root {
    color-scheme: light dark;
    --bg: #f7f9fc;
    --surface: #ffffff;
    --surface-muted: #f3f6fb;
    --surface-active: #edf4ff;
    --border: #d9e1ec;
    --border-strong: #c4cfde;
    --text: #152033;
    --muted: #667085;
    --primary: #075ee8;
    --primary-hover: #054fc6;
    --primary-soft: #e9f2ff;
    --danger: #b42318;
    --danger-soft: #fff1f0;
    --success: #067647;
    --shadow-sm: 0 1px 2px rgb(16 24 40 / 5%);
    --shadow-lg: 0 14px 38px rgb(16 24 40 / 10%);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1220;
        --surface: #111a2b;
        --surface-muted: #172238;
        --surface-active: #172b4b;
        --border: #293751;
        --border-strong: #3a4a68;
        --text: #e7edf7;
        --muted: #9aa8bd;
        --primary: #4d91ff;
        --primary-hover: #75aaff;
        --primary-soft: #152d52;
        --danger: #ff8a80;
        --danger-soft: #3a1d24;
        --success: #5dd6a3;
        --shadow-sm: 0 1px 2px rgb(0 0 0 / 20%);
        --shadow-lg: 0 18px 46px rgb(0 0 0 / 30%);
    }
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; }
body { margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }
button, textarea, input { font: inherit; }
button { color: inherit; }
button:focus-visible, textarea:focus-visible, input:focus-visible, summary:focus-visible {
    outline: 3px solid color-mix(in srgb, var(--primary) 28%, transparent);
    outline-offset: 2px;
}
.app-shell { min-height: 100vh; }
.app-header {
    position: relative;
    z-index: 20;
    height: 70px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 18px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 96%, transparent);
    box-shadow: var(--shadow-sm);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    font-size: 1.15rem;
    font-weight: 760;
    letter-spacing: -.025em;
}
.brand-mark {
    display: grid;
    grid-template-columns: repeat(3, 4px);
    align-items: center;
    gap: 3px;
    height: 28px;
}
.brand-mark i { width: 4px; border-radius: 4px; background: var(--primary); }
.brand-mark i:nth-child(1) { height: 15px; }
.brand-mark i:nth-child(2) { height: 27px; }
.brand-mark i:nth-child(3) { height: 20px; }
.permission-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-left: 18px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    background: var(--surface);
    font-size: .82rem;
    font-weight: 600;
}
.permission-badge svg { width: 17px; fill: none; stroke: #f5a000; stroke-width: 1.8; }
.header-link { margin-left: auto; color: var(--muted); font-size: .85rem; font-weight: 650; }
.header-link:hover { color: var(--text); }
.identity { margin-left: auto; color: var(--muted); font-size: .82rem; }
.header-link + .identity { margin-left: 0; }

.chat-shell {
    display: grid;
    grid-template-columns: 296px minmax(0, 1fr);
    height: calc(100dvh - 70px);
}
.sessions {
    padding: 20px 16px 28px;
    overflow: auto;
    border-right: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 94%, var(--bg));
}
.new-chat-button {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: white;
    background: var(--primary);
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 5px 14px color-mix(in srgb, var(--primary) 23%, transparent);
}
.new-chat-button span { font-size: 1.55rem; font-weight: 300; line-height: 1; }
.new-chat-button:hover { background: var(--primary-hover); }
.new-chat-button:disabled { opacity: .55; cursor: not-allowed; }
.session-search {
    height: 44px;
    margin-top: 16px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: var(--surface);
}
.session-search:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent); }
.session-search svg { width: 18px; flex: 0 0 auto; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.session-search input { width: 100%; min-width: 0; border: 0; outline: 0; color: var(--text); background: transparent; }
.session-search input::placeholder { color: var(--muted); }
.sessions nav { margin-top: 22px; }
.session-group { margin: 0 0 20px; padding: 0 0 16px; border-bottom: 1px solid var(--border); }
.session-group:last-child { border-bottom: 0; }
.session-group h2 { margin: 0 8px 8px; font-size: .78rem; font-weight: 750; color: var(--muted); text-transform: uppercase; letter-spacing: .055em; }
.session-list { display: grid; gap: 3px; }
.session-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 38px; border-left: 3px solid transparent; border-radius: 7px; }
.session-row:hover { background: var(--surface-muted); }
.session-row.active { border-left-color: var(--primary); background: var(--surface-active); }
.session-item {
    min-width: 0;
    min-height: 44px;
    padding: 8px 7px 8px 10px;
    text-align: left;
    border: 0;
    background: transparent;
    cursor: pointer;
}
.session-item span {
    display: -webkit-box;
    overflow: hidden;
    color: var(--text);
    font-size: .86rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}
.session-menu-trigger {
    width: 34px;
    height: 34px;
    align-self: center;
    border: 0;
    border-radius: 7px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font-weight: 800;
    letter-spacing: 1px;
}
.session-menu-trigger:hover { color: var(--text); background: color-mix(in srgb, var(--border) 50%, transparent); }
.session-menu {
    position: absolute;
    z-index: 10;
    top: 40px;
    right: 2px;
    width: 142px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.session-menu button { width: 100%; padding: 9px 10px; text-align: left; border: 0; border-radius: 6px; color: var(--danger); background: transparent; cursor: pointer; font-size: .84rem; font-weight: 650; }
.session-menu button:hover { background: var(--danger-soft); }
.session-empty { margin: 26px 10px; color: var(--muted); font-size: .84rem; line-height: 1.5; }

.conversation { min-width: 0; display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; background: var(--surface); }
.conversation-header {
    min-height: 66px;
    padding: 14px clamp(22px, 4vw, 58px);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.conversation-header h1 { margin: 0; font-size: 1.08rem; letter-spacing: -.015em; }
.conversation-header p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }
.messages { min-height: 0; padding: 30px clamp(20px, 5vw, 72px); overflow-y: auto; scroll-behavior: smooth; }
.message-column { width: min(900px, 100%); min-height: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.welcome-state { width: min(900px, 100%); margin: auto; padding: 40px 0 56px; text-align: center; }
.welcome-mark { width: 52px; height: 52px; margin: 0 auto 18px; display: grid; place-items: center; border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--border)); border-radius: 50%; color: var(--primary); background: var(--primary-soft); font-size: 1.45rem; }
.welcome-state h2 { margin: 0; font-size: clamp(1.55rem, 3vw, 2rem); letter-spacing: -.035em; }
.connected-report-section { margin-top: 28px; }
.connected-report-section h3 { margin: 0 0 12px; font-size: 1rem; font-weight: 650; }
.connected-report-table-wrap { overflow-x: auto; border: 1px solid var(--border-strong); border-radius: 11px; background: var(--surface); box-shadow: var(--shadow-sm); }
.connected-report-table { width: 100%; min-width: 440px; border-collapse: collapse; text-align: left; }
.connected-report-table th, .connected-report-table td { padding: 13px 16px; border-bottom: 1px solid var(--border); }
.connected-report-table th { color: var(--text); background: var(--surface-muted); font-size: .79rem; font-weight: 750; }
.connected-report-table td { color: var(--muted); font-size: .82rem; }
.connected-report-table td:first-child { width: 75%; color: var(--text); font-weight: 650; }
.connected-report-table th:nth-child(2), .connected-report-table td:nth-child(2) { width: 25%; }
.connected-report-table tbody tr:last-child td { border-bottom: 0; }
.connection-status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.connection-status i { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 12%, transparent); }
.welcome-suggestions { margin-top: 24px; text-align: left; }
.welcome-suggestions h3 { margin: 0 0 10px; font-size: .92rem; }
.suggestion-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; text-align: left; }
.suggestion-grid button { min-height: 58px; padding: 13px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); background: var(--surface); cursor: pointer; box-shadow: var(--shadow-sm); }
.suggestion-grid button:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); background: var(--primary-soft); transform: translateY(-1px); }
.suggestion-grid button span { line-height: 1.35; font-weight: 620; }
.suggestion-grid svg { width: 18px; flex: 0 0 auto; fill: none; stroke: var(--primary); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.message { width: 100%; max-width: 820px; }
.message.user { width: min(700px, 82%); max-width: 82%; align-self: flex-end; }
.message-body { min-width: 0; }
.message-role { display: block; margin: 0 0 7px 2px; color: var(--text); font-size: .8rem; font-weight: 750; }
.message.assistant .message-role { color: var(--primary); }
.message-content { padding: 17px 19px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.65; }
.message.user .message-content { border-color: color-mix(in srgb, var(--primary) 28%, var(--border)); background: var(--primary-soft); }
.message-metadata { margin: -1px 12px 0; padding: 10px 7px 2px; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; }
.message-metadata svg { width: 16px; fill: #f3b10b; }
.clarification-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.clarification-option { padding: 8px 11px; color: var(--primary); text-align: left; border: 1px solid color-mix(in srgb, var(--primary) 45%, var(--border)); border-radius: 999px; background: var(--primary-soft); cursor: pointer; }
.clarification-option:hover { color: white; background: var(--primary); border-color: var(--primary); }
.clarification-option:disabled { opacity: .55; cursor: not-allowed; }
.progress-message .message-content { color: var(--muted); }
.progress-row { min-height: 56px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--border); border-radius: 12px; color: var(--muted); background: var(--surface); box-shadow: var(--shadow-sm); font-size: .86rem; }
.typing-indicator { display: inline-flex; align-items: center; gap: 4px; }
.typing-indicator i { width: 6px; height: 6px; border-radius: 50%; background: var(--primary); animation: typing 1.2s infinite ease-in-out; }
.typing-indicator i:nth-child(2) { animation-delay: .15s; }
.typing-indicator i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .45; } 30% { transform: translateY(-4px); opacity: 1; } }
.cancel-button { margin-left: auto; padding: 6px 10px; border: 1px solid var(--border); border-radius: 7px; color: var(--muted); background: var(--surface-muted); cursor: pointer; font-size: .76rem; font-weight: 650; }
.cancel-button:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.notice { padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); }
.notice.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 30%, var(--border)); background: var(--danger-soft); }
.notice strong { display: block; margin-bottom: 4px; }
.notice p { margin: 0; line-height: 1.5; }
.notice details { margin-top: 10px; color: var(--muted); font-size: .78rem; }
.notice summary { cursor: pointer; font-weight: 650; }
.notice details div { margin-top: 7px; }
.notice code { overflow-wrap: anywhere; }

.composer-area { padding: 12px clamp(20px, 5vw, 72px) 22px; background: linear-gradient(180deg, transparent, var(--surface) 28%); }
.composer {
    position: relative;
    width: min(900px, 100%);
    min-height: 108px;
    margin: 0 auto;
    padding: 15px 72px 30px 18px;
    border: 1px solid var(--border-strong);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.composer:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 11%, transparent), var(--shadow-lg); }
.composer.at-limit { border-color: var(--danger); }
.composer textarea { width: 100%; min-height: 46px; max-height: 176px; padding: 4px 0; display: block; resize: none; overflow-y: hidden; border: 0; outline: 0; color: var(--text); background: transparent; line-height: 1.5; }
.composer textarea::placeholder { color: var(--muted); }
.send-button { position: absolute; right: 16px; top: 50%; width: 44px; height: 44px; display: grid; place-items: center; transform: translateY(-50%); border: 0; border-radius: 50%; color: white; background: var(--primary); cursor: pointer; box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 28%, transparent); }
.send-button:hover { background: var(--primary-hover); }
.send-button:disabled { opacity: .38; cursor: not-allowed; box-shadow: none; }
.send-button svg { width: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.composer-meta { position: absolute; left: 18px; right: 72px; bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); font-size: .69rem; }
.character-count { font-variant-numeric: tabular-nums; }
.composer.at-limit .character-count { color: var(--danger); font-weight: 700; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgb(15 23 42 / 52%); backdrop-filter: blur(2px); }
.confirm-dialog { width: min(430px, 100%); padding: 28px; border: 1px solid var(--border); border-radius: 15px; background: var(--surface); box-shadow: 0 24px 70px rgb(0 0 0 / 24%); }
.dialog-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--danger); background: var(--danger-soft); font-size: 1.15rem; font-weight: 800; }
.confirm-dialog h2 { margin: 15px 0 7px; font-size: 1.18rem; }
.confirm-dialog p { margin: 0; color: var(--muted); line-height: 1.55; overflow-wrap: anywhere; }
.dialog-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 9px; }

.button { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; padding: 9px 14px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; font-weight: 680; }
.button.primary { color: white; background: var(--primary); border-color: var(--primary); }
.button.primary:hover { background: var(--primary-hover); }
.button.secondary { color: var(--text); background: var(--surface-muted); }
.button.danger { color: var(--danger); background: transparent; }
.button.danger-solid { color: white; border-color: var(--danger); background: var(--danger); }
.button:disabled { opacity: .5; cursor: not-allowed; }
.full { width: 100%; }
.loading { margin: auto; color: var(--muted); }

.admin-page { width: min(1080px, calc(100% - 40px)); height: calc(100dvh - 70px); margin: 0 auto; padding: 38px 0 60px; overflow-y: auto; }
.admin-heading { margin-bottom: 26px; }
.admin-heading h1 { margin: 10px 0 6px; font-size: clamp(1.7rem, 4vw, 2.25rem); letter-spacing: -.035em; }
.admin-heading p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.55; }
.back-link { color: var(--primary); font-size: .875rem; font-weight: 650; }
.admin-alert { margin-bottom: 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-muted); line-height: 1.5; }
.admin-alert h2 { margin: 0 0 5px; font-size: 1.05rem; }
.admin-alert p { margin: 0; }
.admin-alert.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); }
.admin-alert.success { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); background: color-mix(in srgb, var(--success) 8%, var(--surface)); }
.configuration-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.configuration-card { display: flex; flex-direction: column; gap: 20px; padding: 24px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); box-shadow: 0 12px 32px color-mix(in srgb, var(--text) 6%, transparent); }
.suggested-question-settings { margin-bottom: 18px; }
.configuration-card h2 { margin: 0 0 7px; font-size: 1.2rem; }
.configuration-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.configuration-status { margin: 0; display: grid; gap: 10px; }
.configuration-status div { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; }
.configuration-status dt { color: var(--muted); }
.configuration-status dd { margin: 0; overflow-wrap: anywhere; font-weight: 650; }
.file-picker { display: grid; gap: 8px; }
.file-picker label { font-weight: 650; }
.file-picker input[type="file"] { width: 100%; padding: 10px; color: var(--text); border: 1px dashed var(--border); border-radius: 9px; background: var(--surface-muted); }
.file-picker small, .configuration-actions small { color: var(--muted); }
.suggested-question-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.suggested-question-fields label { display: grid; gap: 7px; color: var(--text); font-size: .82rem; font-weight: 650; }
.suggested-question-fields input { width: 100%; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 8px; color: var(--text); background: var(--surface); }
.configuration-actions { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.prompt-settings { display: grid; gap: 20px; }
.prompt-section {
    display: grid;
    gap: 18px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: 0 12px 32px color-mix(in srgb, var(--text) 6%, transparent);
}
.prompt-section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; }
.prompt-section-heading h2 { margin: 0 0 6px; font-size: 1.25rem; }
.prompt-section-heading p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.5; }
.prompt-section > small { color: var(--muted); }
.instructions-editor {
    width: 100%;
    min-height: 120px;
    max-height: 320px;
    resize: vertical;
    overflow-y: auto;
    padding: 16px 18px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    color: var(--text);
    background: var(--surface);
    line-height: 1.55;
}
.instructions-editor:focus { border-color: var(--primary); }
.knowledge-uploader { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; padding: 16px; border: 1px dashed var(--border-strong); border-radius: 11px; background: var(--surface-muted); }
.knowledge-uploader .file-picker { flex: 1; }
.selected-files { display: flex; flex-wrap: wrap; gap: 8px; }
.selected-files > span { padding: 7px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-muted); font-size: .84rem; }
.selected-files small { margin-left: 5px; color: var(--muted); }
.knowledge-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 12px; }
.knowledge-file { min-width: 0; display: flex; align-items: center; gap: 13px; padding: 13px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.knowledge-file-icon { width: 46px; height: 46px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 10px; color: white; background: #6d55f7; }
.knowledge-file-icon svg { width: 25px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.knowledge-file > div { min-width: 0; display: grid; gap: 4px; }
.knowledge-file strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.knowledge-file small { color: var(--muted); }
.knowledge-remove { width: 30px; height: 30px; flex: 0 0 auto; margin-left: auto; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.45rem; line-height: 1; }
.knowledge-remove:hover { color: var(--danger); background: var(--danger-soft); }
.knowledge-remove:disabled { opacity: .45; cursor: not-allowed; }
.knowledge-empty { padding: 28px; border: 1px dashed var(--border); border-radius: 11px; color: var(--muted); background: var(--surface-muted); text-align: center; }
.power-bi-source-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); }
.power-bi-source-table { width: 100%; min-width: 780px; border-collapse: collapse; table-layout: fixed; text-align: left; }
.power-bi-source-table th, .power-bi-source-table td { height: 54px; padding: 9px 13px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.power-bi-source-table th { height: 42px; color: var(--muted); background: var(--surface-muted); font-size: .74rem; font-weight: 750; text-transform: uppercase; letter-spacing: .025em; }
.power-bi-source-table td { overflow: hidden; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; }
.power-bi-source-table th:nth-child(1), .power-bi-source-table td:nth-child(1) { width: 35%; }
.power-bi-source-table th:nth-child(2), .power-bi-source-table td:nth-child(2) { width: 31%; }
.power-bi-source-table th:nth-child(3), .power-bi-source-table td:nth-child(3) { width: 20%; }
.power-bi-source-table th:nth-child(4), .power-bi-source-table td:nth-child(4) { width: 14%; }
.power-bi-source-table tbody tr:last-child td { border-bottom: 0; }
.power-bi-report-name, .power-bi-report-name a { color: var(--text); font-weight: 650; }
.power-bi-report-name a:hover { color: var(--primary); }
.power-bi-source-action { text-align: right; }
.button.compact { min-height: 34px; padding: 7px 12px; font-size: .78rem; }
.source-status { padding: 3px 7px; border: 1px solid var(--border); border-radius: 999px; color: var(--muted); background: var(--surface); font-size: .67rem; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
.source-status.enabled { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.source-status.new { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 40%, var(--border)); }
.dataset-report-empty { color: var(--muted); font-size: .78rem; }
.page-error { max-width: 640px; margin: 80px auto; padding: 28px; text-align: center; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.page-error h1 { margin-top: 0; }
.page-error p { margin-bottom: 22px; color: var(--muted); }
#blazor-error-ui { display: none; position: fixed; inset: auto 0 0; z-index: 1000; padding: 12px 52px 12px 18px; background: #fee2e2; color: #7f1d1d; }
#blazor-error-ui .reload { margin-left: 8px; text-decoration: underline; }
#blazor-error-ui .dismiss { position: absolute; top: 7px; right: 14px; padding: 2px 8px; color: inherit; background: transparent; border: 0; cursor: pointer; font-size: 1.25rem; }

@media (max-width: 820px) {
    body { overflow: auto; }
    .app-header { padding: 0 14px; }
    .permission-badge, .identity { display: none; }
    .header-link { margin-left: auto; }
    .chat-shell { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); height: calc(100dvh - 70px); }
    .sessions { max-height: 220px; padding: 14px; border-right: 0; border-bottom: 1px solid var(--border); }
    .sessions nav { margin-top: 14px; display: flex; gap: 10px; overflow-x: auto; }
    .session-group { min-width: min(270px, 78vw); margin: 0; padding: 0 10px 0 0; border-right: 1px solid var(--border); border-bottom: 0; }
    .conversation-header { min-height: 58px; padding: 11px 16px; }
    .messages { padding: 20px 14px; }
    .welcome-state { padding: 24px 0; }
    .suggestion-grid { grid-template-columns: 1fr; }
    .message.user { width: 92%; max-width: 92%; }
    .composer-area { padding: 10px 12px 14px; }
    .composer { min-height: 92px; border-radius: 13px; }
    .composer-shortcut { display: none; }
    .composer-meta { justify-content: flex-end; }
    .suggested-question-fields, .configuration-grid, .knowledge-list { grid-template-columns: 1fr; }
    .prompt-section-heading, .knowledge-uploader { align-items: stretch; flex-direction: column; }
    .prompt-section-heading .button, .knowledge-uploader .button { width: 100%; }
    .prompt-section { padding: 18px; }
    .admin-page { width: min(100% - 28px, 1080px); padding-top: 26px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
