/* Enterprise Document Compliance Analyzer - Modern Clean Design */

:root {
    /* Neutral color palette - enterprise ready */
    --color-primary: #1a1a2e;
    --color-primary-light: #16213e;
    --color-accent: #0f4c75;
    --color-accent-hover: #1b6ca8;
    
    /* Grays */
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-border: #e5e7eb;
    --color-border-light: #f0f1f3;
    --color-text: #1f2937;
    --color-text-secondary: #6b7280;
    --color-text-muted: #9ca3af;
    
    /* Status colors - muted */
    --color-success: #059669;
    --color-success-bg: #ecfdf5;
    --color-warning: #d97706;
    --color-warning-bg: #fffbeb;
    --color-error: #dc2626;
    --color-error-bg: #fef2f2;
    --color-info: #0284c7;
    --color-info-bg: #f0f9ff;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    /* Typography scale */
    --text-xs: 12px;
    --text-sm: 13px;
    --text-md: 14px;
    --text-lg: 16px;
    --text-xl: 18px;
    --line-height-tight: 1.35;
    --line-height-normal: 1.5;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;

    /* Motion */
    --transition-fast: 0.2s;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--color-bg);
    min-height: 100vh;
    color: var(--color-text);
    font-size: var(--text-md);
    line-height: var(--line-height-normal);
    display: flex;
    justify-content: center;
}

.container {
    width: 75%;
    max-width: 1400px;
    min-width: 0;
    margin: 0 auto;
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    border-left: 1px solid var(--color-border);
    border-right: 1px solid var(--color-border);
}

/* Responsive container width */
@media (max-width: 1200px) {
    .container {
        width: 85%;
    }
}

@media (max-width: 900px) {
    .container {
        width: 95%;
        min-width: unset;
    }
}

@media (max-width: 640px) {
    .container {
        width: 100%;
        border-left: none;
        border-right: none;
    }
}

/* Header */
.header {
    background: var(--color-primary);
    color: white;
    padding: var(--space-4) var(--space-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-logo {
    width: 32px;
    height: 32px;
    background: var(--color-accent);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: var(--text-md);
}

.header h1 {
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.header p {
    display: none;
}

.header-badge {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.8);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* User info */
.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.user-info span {
    color: rgba(255,255,255,0.9);
    font-size: var(--text-sm);
}

.user-info .user-avatar {
    font-size: 16px;
    opacity: 0.9;
    line-height: 1;
}

.user-info .logout-btn {
    background: transparent;
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 6px var(--space-3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-xs);
    font-weight: 500;
    transition: all var(--transition-fast);
}

.user-info .logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
    border-color: rgba(255,255,255,0.3);
}

/* Header right section */
.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    position: relative;
}

/* UI Language Selector */
.ui-lang-selector {
    position: relative;
}

.ui-lang-btn {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: var(--text-xs);
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.ui-lang-btn:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

.ui-lang-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    min-width: 130px;
    display: none;
    overflow: hidden;
}

.ui-lang-dropdown.open {
    display: block;
}

.ui-lang-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
    transition: background 0.15s;
}

.ui-lang-dropdown button:hover {
    background: var(--color-bg);
}

.history-toggle {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.history-toggle:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

/* Input Section */
.input-section {
    padding: var(--space-5) var(--space-6);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}

.form-group {
    margin-bottom: var(--space-4);
}

.form-group:last-of-type {
    margin-bottom: 0;
}

.form-group-small {
    max-width: 250px;
}

.form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--color-text);
    font-size: var(--text-sm);
}

label .required {
    color: var(--color-error);
}

select, input, textarea {
    width: 100%;
    padding: 10px var(--space-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    transition: all var(--transition-fast);
    background: var(--color-surface);
    color: var(--color-text);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

select:hover, input:hover, textarea:hover {
    border-color: #d1d5db;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}

/* File input */
.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: 0;
    top: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.file-input-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-4);
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: var(--text-sm);
}

.file-input-label:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: var(--color-text);
}

.file-input-label.has-file {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    border-style: solid;
    color: var(--color-success);
}

.file-input-label svg {
    width: 20px;
    height: 20px;
    opacity: 0.7;
}

/* Button */
.btn {
    background: var(--color-accent);
    color: white;
    padding: 10px var(--space-5);
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--text-md);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

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

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover {
    background: #f3f4f6;
}

/* Options Row with Web Search Toggle */
.options-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
    padding: 8px 0;
}

/* Web Search Toggle */
.web-search-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
}

.web-search-toggle:hover {
    background: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info);
}

.web-search-toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 40px;
    height: 22px;
    background: var(--color-border);
    border-radius: 11px;
    position: relative;
    transition: all 0.3s;
    flex-shrink: 0;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    top: 2px;
    left: 2px;
    transition: all 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.web-search-toggle input:checked + .toggle-slider {
    background: var(--color-info);
}

.web-search-toggle input:checked + .toggle-slider::before {
    left: 20px;
}

.web-search-toggle input:checked ~ .toggle-label {
    color: var(--color-info);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.toggle-label svg {
    opacity: 0.7;
}

.web-search-toggle input:checked ~ .toggle-label svg {
    opacity: 1;
}

/* Split Button with Language Selector */
.submit-row {
    position: relative;
}

.btn-split {
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    padding: 0;
}

.btn-split:hover {
    background: var(--color-accent-hover);
}

.btn-split:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-split-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
}

.btn-split-divider {
    width: 1px;
    background: rgba(255, 255, 255, 0.3);
}

.btn-split-lang {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 600;
    font-size: 13px;
}

.btn-split-lang:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Language Dropdown */
.lang-dropdown {
    position: absolute;
    bottom: 100%;
    right: 0;
    width: 280px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    margin-bottom: 8px;
    display: none;
    z-index: 1000;
    max-height: 400px;
    overflow: hidden;
}

.lang-dropdown.open {
    display: block;
}

.lang-search {
    padding: 10px;
    border-bottom: 1px solid var(--color-border);
}

.lang-search input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    outline: none;
}

.lang-search input:focus {
    border-color: var(--color-accent);
}

.lang-list {
    max-height: 320px;
    overflow-y: auto;
}

.lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.lang-item:hover {
    background: var(--color-bg);
}

.lang-item.selected {
    background: var(--color-accent);
    color: white;
}

.lang-item.selected .lang-iso {
    color: rgba(255, 255, 255, 0.8);
}

.lang-flag {
    font-size: 18px;
}

.lang-name {
    flex: 1;
    font-size: 14px;
}

.lang-iso {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-secondary);
    font-family: 'SF Mono', Monaco, monospace;
}

/* Reference docs */
.reference-docs {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 16px;
    max-height: 300px;
    overflow-y: auto;
}

.reference-docs h4 {
    color: var(--color-text-secondary);
    margin-bottom: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.reference-docs ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.reference-docs li {
    background: var(--color-surface);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

/* Chat area */
.chat-area {
    flex: 1;
    min-height: 0;
    padding: 20px 24px;
    overflow-y: auto;
    background: var(--color-bg);
}

.message {
    margin-bottom: 16px;
    padding: 16px;
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    animation: fadeIn 0.2s ease-out;
}

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

.message.user {
    background: var(--color-surface);
    border-left: 3px solid var(--color-accent);
}

/* User query with bubble style */
.message.user-query {
    background: var(--color-surface);
    border-left: 3px solid var(--color-accent);
    padding: 0;
    overflow: hidden;
}

.query-bubble {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: white;
    padding: 16px 20px;
    font-size: 15px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.query-metadata {
    background: var(--color-bg);
    padding: 12px 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    border-top: 1px solid var(--color-border);
}

.query-meta-item {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.query-meta-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: -2px;
    margin-right: 6px;
    color: var(--color-text-muted);
}

.query-meta-ico svg {
    display: block;
}

.query-meta-item strong {
    color: var(--color-text);
    font-weight: 500;
}

.message.assistant {
    background: var(--color-surface);
    border-left: 3px solid var(--color-success);
}

.message.error {
    background: var(--color-error-bg);
    border-left: 3px solid var(--color-error);
}

.message.info {
    background: var(--color-warning-bg);
    border-left: 3px solid var(--color-warning);
}

.message-label {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.message.user .message-label {
    color: var(--color-accent);
}

.message.assistant .message-label {
    color: var(--color-success);
}

.message.error .message-label {
    color: var(--color-error);
}

.message.info .message-label {
    color: var(--color-warning);
}

.message-content {
    line-height: 1.6;
    color: var(--color-text);
}

/* Loading */
.loading {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
}

.loading.active {
    display: block;
}

.spinner {
    border: 2px solid var(--color-border);
    border-top: 2px solid var(--color-accent);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 4px;
}

.loading-stop-btn {
    display: block;
    margin: 18px auto 0;
    max-width: 280px;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-muted);
}

.empty-state-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-icon svg {
    display: block;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 13px;
    color: var(--color-text-muted);
}

/* Markdown content styles */
.message-content h1, .message-content h2, .message-content h3, 
.message-content h4, .message-content h5, .message-content h6 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

.message-content h1 { 
    font-size: 1.4em; 
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-border);
}

.message-content h2 { 
    font-size: 1.25em; 
    padding-bottom: 6px;
    border-bottom: 1px solid var(--color-border-light);
}

.message-content h3 { font-size: 1.1em; }
.message-content h4 { font-size: 1em; }

.message-content p {
    margin-bottom: 12px;
}

.message-content ul, .message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin-bottom: 6px;
}

.message-content code {
    background: var(--color-bg);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    font-size: 0.85em;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.message-content pre {
    background: var(--color-primary);
    color: #e5e7eb;
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 16px 0;
    font-size: 13px;
}

.message-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    border: none;
}

.message-content blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--color-text-secondary);
}

.message-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 13px;
}

.message-content th, .message-content td {
    border: 1px solid var(--color-border);
    padding: 10px 12px;
    text-align: left;
}

.message-content th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text);
}

.message-content tr:nth-child(even) {
    background: var(--color-bg);
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 20px 0;
}

.message-content a {
    color: var(--color-accent);
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Full-analysis suggest edits card */
.suggest-edits-card {
    margin-top: 20px;
    padding: 16px;
    border: 1px solid #f0d6a7;
    border-radius: var(--radius-md);
    background: #fffaf0;
}

.suggest-edits-card h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #8a5a00;
}

.suggest-edits-fallback {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px dashed #d5b277;
    border-radius: var(--radius-sm);
    background: #fffdf7;
}

.suggest-edits-fallback p {
    margin: 0;
    font-size: 13px;
    color: #8a5a00;
}

.suggest-edits-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.suggest-edit-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: #ffffff;
    padding: 12px;
}

.suggest-edit-markdown h3 {
    margin: 0 0 8px 0;
    font-size: 15px;
    color: var(--color-text);
}

.suggest-edit-markdown p {
    margin: 6px 0;
    line-height: 1.5;
    white-space: pre-wrap;
}

.suggest-edit-reason {
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-text-secondary);
    padding: 10px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-sm);
}

.suggest-edit-reason p {
    margin: 4px 0;
}

.suggest-edit-reason a {
    color: var(--color-accent);
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}

.suggest-edit-reason a:hover {
    color: var(--color-accent-hover);
}

.diff-removed {
    background: #fde8e8;
    color: #8b1d1d;
    text-decoration: line-through;
    border-radius: 3px;
    padding: 0 2px;
}

.diff-added {
    background: #e6f6e9;
    color: #14532d;
    border-radius: 3px;
    padding: 0 2px;
}

/* Progress steps */
.progress-steps {
    margin-top: 20px;
    text-align: left;
    max-width: 360px;
    margin-left: auto;
    margin-right: auto;
}

.progress-steps .step {
    padding: 10px 14px;
    margin: 6px 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--color-text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-steps .step::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
    flex-shrink: 0;
}

.progress-steps .step.active {
    background: var(--color-info-bg);
    border-color: var(--color-info);
    color: var(--color-info);
    font-weight: 500;
}

.progress-steps .step.active::before {
    background: var(--color-info);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.progress-steps .step.done {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    color: var(--color-success);
}

.progress-steps .step.done::before {
    content: '✓';
    width: auto;
    height: auto;
    background: none;
    font-size: 12px;
    font-weight: 700;
}

/* Step timing display */
.progress-steps .step .step-time {
    margin-left: auto;
    font-size: 11px;
    font-weight: 500;
    color: inherit;
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

.progress-steps .step.done .step-time {
    color: var(--color-success);
    opacity: 1;
}

.progress-steps .step.active .step-time {
    color: var(--color-info);
}

.elapsed-time {
    margin-top: 16px;
    font-size: 13px;
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

/* Stats badge */
.stats-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 8px 12px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--color-text-secondary);
}

.stats-badge span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Form row for inline elements */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

/* Scrollbar styling */
.chat-area::-webkit-scrollbar {
    width: 6px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        border-radius: 0;
        border: none;
    }
    
    .header {
        padding: 12px 16px;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .input-section {
        padding: 16px;
    }
    
    .chat-area {
        padding: 16px;
    }
}

/* Print styles */
@media print {
    .input-section, .header {
        display: none;
    }
    
    .chat-area {
        overflow: visible;
    }
    
    .message {
        break-inside: avoid;
    }
}

/* === Analysis History Panel === */
.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    height: 100vh;
    background: var(--color-surface);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.history-panel.open {
    right: 0;
}

.history-header {
    padding: 16px 20px;
    background: var(--color-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.history-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.history-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.history-loading,
.history-empty,
.history-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
    font-size: 14px;
}

.history-error {
    color: var(--color-error);
}

.history-item {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 10px;
    transition: all 0.2s;
}

.history-item:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-sm);
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.history-date {
    font-size: 11px;
    color: var(--color-text-muted);
}

.history-lang {
    font-size: 10px;
    background: var(--color-accent);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
}

.history-doc {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-question {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    line-clamp: 2;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 10px;
}

.history-actions {
    display: flex;
    gap: 6px;
    justify-content: flex-end;
}

.history-btn {
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.history-btn:hover {
    background: var(--color-surface);
    border-color: var(--color-text-muted);
}

.history-btn.view:hover {
    border-color: var(--color-info);
    color: var(--color-info);
}

.history-btn.download:hover {
    border-color: var(--color-success);
    color: var(--color-success);
}

.history-btn.delete:hover {
    border-color: var(--color-error);
    color: var(--color-error);
}

/* History panel scrollbar */
.history-list::-webkit-scrollbar {
    width: 6px;
}

.history-list::-webkit-scrollbar-track {
    background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.history-list::-webkit-scrollbar-thumb:hover {
    background: #d1d5db;
}

/* Responsive history panel */
@media (max-width: 480px) {
    .history-panel {
        width: 100%;
        right: -100%;
    }
}

/* === Knowledge Base Document List === */
#refDocList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#refDocList .doc-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    position: relative;
}

#refDocList .doc-item:hover {
    background: var(--color-info-bg);
    color: var(--color-info);
}

#refDocList .doc-item.doc-url {
    border-left: 2px solid var(--color-accent);
}

#refDocList .doc-item.doc-url:hover {
    background: rgba(15, 76, 117, 0.08);
}

.url-badge {
    font-size: 10px;
    color: var(--color-accent);
    margin-left: 4px;
}

#refDocList .doc-item:hover .doc-menu-btn {
    opacity: 1;
}

#refDocList .doc-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
}

#refDocList .doc-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Document menu button */
#refDocList .doc-menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all 0.2s;
    color: var(--color-text-secondary);
}

#refDocList .doc-menu-btn:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* Document menu dropdown */
.doc-menu-dropdown {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    z-index: 1000;
    min-width: 120px;
    overflow: hidden;
}

.doc-menu-dropdown button {
    display: block;
    width: 100%;
    padding: 10px 14px;
    border: none;
    background: transparent;
    text-align: left;
    cursor: pointer;
    font-size: 13px;
    color: var(--color-text);
    transition: background 0.2s;
}

.doc-menu-dropdown button:hover {
    background: var(--color-info-bg);
}

.doc-menu-dropdown button.delete-btn:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}

#refDocList .no-docs {
    color: var(--color-text-muted);
    font-style: italic;
    padding: 8px 10px;
    font-size: 13px;
}

#refDocList .doc-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    min-height: 36px;
    padding: 8px 0;
    margin-top: 4px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--color-accent);
    transition: all 0.2s;
    box-sizing: border-box;
}

#refDocList .doc-upload-btn:hover {
    background: var(--color-info-bg);
    border-color: var(--color-accent);
}

#refDocList .upload-icon {
    font-size: 20px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* === Document Modal === */
.doc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.doc-modal.open {
    opacity: 1;
    visibility: visible;
}

.doc-modal-content {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Large modal for PDF viewing */
.doc-modal-content.doc-modal-large {
    max-width: 95vw;
    width: 95vw;
    max-height: 95vh;
    height: 95vh;
}

/* PDF viewer iframe */
.doc-pdf-viewer {
    width: 100%;
    height: calc(95vh - 60px);
    border: none;
    background: #525659;
}

.upload-modal-content {
    max-width: 500px;
}

.doc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--color-primary);
    color: white;
}

.doc-modal-header h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.doc-modal-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.doc-modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.doc-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    font-size: 14px;
    line-height: 1.6;
}

/* Remove padding when showing PDF */
.doc-modal-body:has(.doc-pdf-viewer) {
    padding: 0;
    overflow: hidden;
}

.doc-content-pre {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
    background: var(--color-bg);
    padding: 15px;
    border-radius: var(--radius-md);
    margin: 0;
    max-height: 60vh;
    overflow-y: auto;
}

.doc-loading {
    text-align: center;
    padding: 40px;
    color: var(--color-text-secondary);
}

.doc-error {
    text-align: center;
    padding: 40px;
    color: var(--color-error);
}

/* === Upload Modal Styles === */
.upload-info {
    color: var(--color-text-secondary);
    margin-bottom: 16px;
    font-size: 14px;
}

/* Folder selection in upload modal */
.folder-select-group {
    margin-bottom: 16px;
}

.folder-select-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
}

.folder-select-row {
    display: flex;
    gap: 8px;
}

.folder-select-row select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.folder-select-row select:focus {
    outline: none;
    border-color: var(--color-accent);
}

.new-folder-input {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.new-folder-input input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
}

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

.new-folder-input button {
    padding: 8px 16px;
    border: none;
    background: var(--color-accent);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.new-folder-input button:hover {
    background: var(--color-accent-hover);
}

/* KB Selection Checkbox Styles */
.kb-checkbox {
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--color-accent);
    margin-right: 2px;
}

.kb-checkbox:hover {
    transform: scale(1.1);
}

/* KB Selection Indicator */
.kb-selection-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--color-accent);
    color: white;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 12px;
}

.kb-selection-indicator .selection-info {
    font-weight: 500;
}

.kb-selection-indicator .clear-selection-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.kb-selection-indicator .clear-selection-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Folder display in document list */
.doc-folder {
    padding: 8px 12px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border-light);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background 0.15s;
}

.doc-folder:hover {
    background: var(--color-border-light);
}

.folder-expand-icon {
    font-size: 10px;
    color: var(--color-text-muted);
    transition: transform 0.2s;
    width: 12px;
}

.doc-folder.expanded .folder-expand-icon {
    transform: rotate(90deg);
}

.folder-count {
    font-size: 11px;
    color: var(--color-text-muted);
    font-weight: 400;
    margin-left: auto;
    margin-right: 8px;
}

.folder-menu-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
}

.doc-folder:hover .folder-menu-btn {
    opacity: 1;
}

.folder-menu-btn:hover {
    background: var(--color-border);
    color: var(--color-text);
}

/* Folder documents container */
.folder-docs-container {
    overflow: hidden;
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease-out;
}

.folder-docs-container > * {
    overflow: hidden;
}

.folder-docs-container.collapsed {
    grid-template-rows: 0fr;
}

.folder-docs-container.expanded {
    grid-template-rows: 1fr;
}

.folder-docs-inner {
    min-height: 0;
}

.folder-docs-inner .doc-item {
    border-left: 2px solid var(--color-border-light);
    margin-left: 10px;
}

.doc-in-folder {
    padding-left: 28px !important;
}

/* Upload modal tabs */
.upload-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 8px;
}

.upload-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    transition: all 0.2s;
}

.upload-tab:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.upload-tab.active {
    background: var(--color-accent);
    color: white;
}

.upload-tab-content {
    display: none;
}

.upload-tab-content.active {
    display: block;
}

/* URL input styling */
.url-input-group {
    margin-bottom: 16px;
}

.url-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.url-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(15, 76, 117, 0.1);
}

.url-input::placeholder {
    color: var(--color-text-muted);
}

.url-error {
    color: var(--color-error);
    font-size: 12px;
    margin-top: 6px;
}

.upload-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.upload-dropzone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 16px;
}

.upload-dropzone:hover,
.upload-dropzone.dragover {
    border-color: var(--color-accent);
    background: var(--color-info-bg);
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.dropzone-icon {
    font-size: 32px;
}

.dropzone-hint {
    font-size: 12px;
    color: var(--color-text-muted);
}

.upload-status {
    min-height: 24px;
    margin-bottom: 16px;
    text-align: center;
    font-size: 14px;
}

.upload-progress {
    color: var(--color-info);
}

.upload-success {
    color: var(--color-success);
}

.upload-error {
    color: var(--color-error);
}

.upload-partial {
    color: var(--color-warning);
}

/* Selected files list */
.selected-files-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.selected-file-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.selected-file-item .file-icon {
    font-size: 16px;
}

.selected-file-item .file-name {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selected-file-item .file-size {
    font-size: 11px;
    color: var(--color-text-muted);
}

.selected-file-item .remove-file-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}

.selected-file-item .remove-file-btn:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}

/* Folder selection - required */
.folder-select-group .required {
    color: var(--color-error);
    font-weight: 600;
}

.folder-error {
    color: var(--color-error);
    font-size: 12px;
    margin-top: 6px;
}

.upload-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-cancel {
    padding: 10px 20px;
    border: 1px solid var(--color-border);
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: var(--color-bg);
}

.btn-upload {
    padding: 10px 20px;
    border: none;
    background: var(--color-accent);
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-upload:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.btn-upload:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Follow-up Chat Mode ===== */
.followup-container {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: 12px 20px;
    position: sticky;
    bottom: 0;
}

.followup-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 13px;
}

.followup-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-info);
    font-weight: 600;
}

.followup-session {
    color: var(--color-text-muted);
    font-size: 12px;
    flex: 1;
}

.followup-new-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

.followup-new-btn:hover {
    background: var(--color-bg);
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.followup-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.followup-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 8px 12px;
    transition: border-color 0.2s;
}

.followup-input-row:focus-within {
    border-color: var(--color-accent);
}

.followup-file-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.followup-file-btn:hover {
    background: var(--color-surface);
    color: var(--color-accent);
}

.followup-file-btn.has-file {
    background: var(--color-info-bg);
    color: var(--color-info);
}

.followup-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    min-height: 36px;
    max-height: 120px;
    padding: 6px 0;
}

.followup-input:focus {
    outline: none;
}

.followup-input::placeholder {
    color: var(--color-text-muted);
}

.followup-web-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.followup-web-toggle:hover {
    background: var(--color-surface);
}

.followup-web-toggle input {
    display: none;
}

.toggle-slider-small {
    width: 28px;
    height: 16px;
    background: var(--color-border);
    border-radius: 8px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider-small::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.followup-web-toggle input:checked + .toggle-slider-small {
    background: var(--color-info);
}

.followup-web-toggle input:checked + .toggle-slider-small::before {
    transform: translateX(12px);
}

.toggle-icon {
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.followup-web-toggle input:checked ~ .toggle-icon {
    opacity: 1;
}

.followup-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.followup-send-btn:hover:not(:disabled) {
    background: var(--color-accent-hover);
}

.followup-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.followup-file-preview {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--color-info-bg);
    border-radius: var(--radius-md);
    font-size: 13px;
}

.followup-file-name {
    color: var(--color-info);
    font-weight: 500;
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.followup-file-remove {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.followup-file-remove:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}

/* Follow-up message styling */
.message.followup-question {
    background: var(--color-info-bg);
    border-left: 3px solid var(--color-info);
}

.message.followup-answer {
    background: var(--color-surface);
    border-left: 3px solid var(--color-success);
}

.followup-context {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--color-border-light);
}

/* Loading state for follow-up */
.followup-loading {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    margin: 12px 0;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.followup-loading .spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Input section collapse in chat mode */
.input-section.collapsed {
    max-height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
    border: none;
    transition: all 0.3s ease;
}

.input-section.collapsed * {
    visibility: hidden;
}

/* ----- Prepare text & analysis scope (line selection) ----- */
.file-prepare-status {
    display: flex;
    align-items: center;
    min-height: 22px;
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
}

.file-prepare-status[hidden] {
    display: none !important;
}

.file-prepare-status.is-loading {
    color: var(--color-text-muted);
}

.prepare-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.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;
}

.analysis-scope-block {
    margin-top: 12px;
    padding: 0;
    background: transparent;
    border: none;
}

.scope-file-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.scope-file-card {
    border: none;
    border-radius: 0;
    padding: 0;
    background: transparent;
}

.scope-file-meta {
    font-size: 12px;
    color: var(--color-text-muted);
    margin: 0 0 10px;
}

.scope-file-card select.scope-mode-select {
    max-width: 100%;
    margin-bottom: 8px;
    font-size: 13px;
}

.scope-file-summary {
    font-size: 12px;
    color: var(--color-text-secondary);
    margin-bottom: 10px;
}

.scope-open-btn {
    display: inline-block;
    width: auto;
    padding: 8px 18px;
    font-size: 13px;
    background: var(--color-accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-weight: 500;
}

.scope-open-btn:hover {
    background: var(--color-accent-hover);
}

.scope-open-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Line selection modal */
.scope-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10050;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.45);
}

.scope-modal.open {
    display: flex;
}

.scope-modal-dialog {
    width: min(960px, 100%);
    max-height: min(92vh, 900px);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.scope-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    background: var(--color-surface);
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
}

.scope-modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
    line-height: 1.3;
    margin: 0;
    word-break: break-word;
}

.scope-modal-close {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    opacity: 0.85;
}

.scope-modal-close:hover {
    opacity: 1;
    background: var(--color-bg);
}

.scope-modal-toolbar {
    padding: 12px 18px;
    border-bottom: 1px solid var(--color-border);
}

.scope-modal-help {
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.45;
    margin-bottom: 10px;
}

.scope-modal-toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.scope-modal-toolbar-actions .btn {
    width: auto;
    margin-top: 0;
    padding: 6px 12px;
    font-size: 12px;
}

/* Scope modal buttons now reuse global .btn styles */

.scope-modal-body {
    flex: 1;
    min-height: 0;
    overflow: auto;
    padding: 0;
}

.scope-lines-scroll {
    margin: 12px 18px 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: auto;
    max-height: min(52vh, 480px);
    background: var(--color-surface);
}

.scope-line-row {
    display: flex;
    align-items: stretch;
    min-height: 26px;
    font-size: 13px;
    font-family: inherit;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    user-select: none;
    cursor: pointer;
}

.scope-line-row:last-child {
    border-bottom: none;
}

.scope-line-row.is-selected {
    background: var(--color-success-bg);
    border-bottom-color: rgba(5, 150, 105, 0.22);
}

.scope-line-block-cb {
    flex-shrink: 0;
    width: 28px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 4px;
    border-right: 1px solid var(--color-border-light);
    background: transparent;
}

.scope-line-block-cb input {
    width: 14px;
    height: 14px;
    accent-color: var(--color-success);
    cursor: pointer;
}

.scope-line-block-cb input:indeterminate {
    accent-color: var(--color-accent);
}

.scope-line-num {
    flex-shrink: 0;
    width: 44px;
    padding: 4px 8px;
    text-align: right;
    color: var(--color-text-muted);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border-light);
}

.scope-line-text {
    flex: 1;
    padding: 4px 10px;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--color-text);
}

.scope-modal-loading {
    padding: 24px;
    text-align: center;
    color: var(--color-text-secondary);
}

.scope-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 12px 18px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.scope-modal-footer .btn {
    width: auto;
    margin-top: 0;
    min-width: 120px;
    font-size: 13px;
    padding: 8px 18px;
}

.toast-region {
    position: fixed;
    right: var(--space-4);
    bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    z-index: 10100;
    pointer-events: none;
}

.toast {
    min-width: 240px;
    max-width: min(420px, 86vw);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: var(--text-sm);
    pointer-events: auto;
    transform: translateY(0);
    opacity: 1;
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.toast.closing {
    opacity: 0;
    transform: translateY(6px);
}

.toast-info {
    background: var(--color-info);
}

.toast-success {
    background: var(--color-success);
}

.toast-warning {
    background: var(--color-warning);
}

.toast-error {
    background: var(--color-error);
}

.confirm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10110;
}

.confirm-modal.open {
    display: block;
}

.confirm-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.confirm-modal-dialog {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(480px, calc(100% - (2 * var(--space-4))));
    max-height: min(560px, calc(100vh - (2 * var(--space-4))));
    overflow-y: auto;
    margin: 0;
    z-index: 1;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6);
    box-sizing: border-box;
}

.confirm-title {
    margin: 0;
    font-size: var(--text-lg);
    color: var(--color-text);
}

.confirm-message {
    margin: var(--space-3) 0 0;
    color: var(--color-text-secondary);
    font-size: var(--text-md);
}

.confirm-prompt-field {
    width: 100%;
    margin-top: var(--space-4);
    padding: 10px 12px;
    font-size: var(--text-md);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text);
    box-sizing: border-box;
}

.confirm-actions {
    margin-top: var(--space-5);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
}

.confirm-checkbox-row {
    margin-top: var(--space-4);
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: start;
    width: 100%;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    line-height: 1.35;
}

.confirm-checkbox-row input[type="checkbox"] {
    margin: 0;
    flex: 0 0 auto;
    margin-top: 2px;
}

.confirm-checkbox-row span {
    display: block;
    width: 100%;
}

.has-modal-open {
    overflow: hidden;
}

.top-nav {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.top-nav a {
    color: rgba(255, 255, 255, 0.88);
    text-decoration: none;
    font-size: var(--text-sm);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    transition: background var(--transition-fast);
}

.top-nav a:hover,
.top-nav a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.notification-menu {
    position: relative;
}

.notification-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    width: min(340px, 82vw);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3);
    z-index: 1001;
}

.notification-dropdown.open {
    display: block;
}

.notification-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
}

.notification-item + .notification-item {
    margin-top: var(--space-2);
}

.notification-item.success {
    background: var(--color-success-bg);
}

.notification-item strong {
    font-size: var(--text-sm);
}

.notification-item span {
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-6);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
}

.btn-inline {
    width: auto;
    margin-top: var(--space-2);
}

.history-skeleton .skeleton-line,
.skeleton-line {
    height: 14px;
    border-radius: 999px;
    margin: var(--space-2) 0;
    background: linear-gradient(90deg, #eef0f3 0%, #f7f8fa 50%, #eef0f3 100%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.2s linear infinite;
}

.history-skeleton .skeleton-line:nth-child(2) {
    width: 85%;
}

.history-skeleton .skeleton-line:nth-child(3) {
    width: 65%;
}

.onboarding-modal[hidden] {
    display: none;
}

.onboarding-modal {
    position: fixed;
    inset: 0;
    z-index: 10090;
    background: rgba(15, 23, 42, 0.45);
    padding: var(--space-5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.onboarding-card {
    width: min(520px, 100%);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-6);
}

.onboarding-card h2 {
    margin: 0;
    font-size: var(--text-xl);
}

.onboarding-card p {
    margin: var(--space-3) 0;
    color: var(--color-text-secondary);
}

.onboarding-card ul {
    margin: 0 0 var(--space-4) var(--space-4);
    color: var(--color-text-secondary);
}

.mobile-nav {
    display: none;
}

.standalone-page {
    width: min(900px, 100%);
    margin: 0 auto;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.standalone-header {
    background: var(--color-primary);
    color: #fff;
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.standalone-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: var(--space-5);
}

.profile-grid {
    margin-top: var(--space-4);
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-2) var(--space-4);
}

.profile-grid dt {
    color: var(--color-text-secondary);
}

.settings-row {
    margin-top: var(--space-4);
}

.settings-actions {
    margin-top: var(--space-4);
}

.settings-note {
    color: var(--color-text-secondary);
}

.settings-success {
    margin-top: var(--space-3);
    color: var(--color-success);
    background: var(--color-success-bg);
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-sm);
}

.error-page {
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-5);
}

.error-card {
    width: min(520px, 100%);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    padding: var(--space-7);
}

.error-code {
    margin: 0;
    color: var(--color-accent);
    font-weight: 700;
    font-size: clamp(30px, 6vw, 44px);
}

.error-card p {
    margin: var(--space-3) 0 var(--space-5);
    color: var(--color-text-secondary);
}

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

@keyframes skeletonPulse {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

@media (max-width: 980px) {
    .top-nav {
        display: none;
    }

    .mobile-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10040;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
        border-top: 1px solid var(--color-border);
        background: var(--color-surface);
    }

    .mobile-nav a,
    .mobile-nav button {
        border: none;
        text-align: center;
        text-decoration: none;
        background: transparent;
        color: var(--color-text);
        padding: var(--space-3) var(--space-2);
        font-size: var(--text-xs);
    }

    .container {
        padding-bottom: 62px;
    }
}

/* ===== v3 Light dashboard (reference-aligned) ===== */
body {
    margin: 0;
    display: block;
    background: #f9fafb;
    color: #111827;
    --sidebar-w: 272px;
    --sidebar-w-collapsed: 72px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    transition: grid-template-columns 0.22s ease;
}

body.sidebar-collapsed:not(.sidebar-open) .app-shell {
    grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr);
}

.sidebar {
    background: #ffffff;
    color: #374151;
    border-right: 1px solid #e5e7eb;
    padding: 16px 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 40;
    overflow: hidden;
}

.sidebar-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand strong {
    display: block;
    color: #111827;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
}

.sidebar-brand-tag {
    margin: 2px 0 0;
    color: #6b7280;
    font-size: 11px;
    font-weight: 500;
}

.sidebar .header-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 10px;
    background: linear-gradient(140deg, #2563eb 0%, #3b82f6 100%);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
    font-weight: 700;
    font-size: 13px;
}

.sidebar-collapse-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    color: #4b5563;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
}

.sidebar-collapse-btn:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

.sidebar-collapse-btn svg {
    transition: transform 0.2s ease;
}

body.sidebar-collapsed:not(.sidebar-open) .sidebar-collapse-btn svg {
    transform: rotate(180deg);
}

@media (max-width: 980px) {
    .sidebar-collapse-btn {
        display: none;
    }
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #374151;
    text-decoration: none;
    padding: 10px 11px;
    border-radius: 10px;
    transition: background-color 0.15s, color 0.15s;
    font-size: 14px;
    font-weight: 500;
}

.sidebar-nav-link:hover {
    background: #f3f4f6;
    color: #111827;
}

.sidebar-nav-link[aria-current="page"] {
    background: #f3f4f6;
    color: #111827;
    font-weight: 600;
}

.sidebar-nav-icon {
    flex-shrink: 0;
    color: #6b7280;
}

.sidebar-nav-link[aria-current="page"] .sidebar-nav-icon {
    color: #2563eb;
}

.sidebar-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-recent {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
}

.sidebar-recent-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-recent-pinned-wrap {
    flex-shrink: 0;
}

.sidebar-recent-section-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0 4px 4px;
}

.sidebar-recent-section-label--compact {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    padding-bottom: 6px;
    color: #9ca3af;
}

.sidebar-recent-sublist {
    list-style: none;
    margin: 0;
    padding: 0;
}

.sidebar-recent-sublist li {
    margin: 0;
}

.sidebar-recent-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sidebar-recent-title {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex: 1;
}

.sidebar-recent-badge {
    font-size: 11px;
    font-weight: 600;
    color: #4b5563;
    background: #f3f4f6;
    border-radius: 999px;
    padding: 2px 8px;
    min-width: 1.25rem;
    text-align: center;
}

.sidebar-recent-new {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    text-decoration: none;
    font-size: 18px;
    line-height: 1;
    font-weight: 500;
}

.sidebar-recent-new:hover {
    background: #f9fafb;
    border-color: #d1d5db;
}

.sidebar-recent-list {
    flex: 1;
    min-height: 48px;
}

.sidebar-recent-list li {
    margin: 0;
}

.sidebar-recent-item {
    list-style: none;
}

.sidebar-recent-row {
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 0;
}

.sidebar-recent-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.sidebar-recent-pinned-badge {
    flex-shrink: 0;
    max-width: 5.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #92400e;
    background: #fef3c7;
    border: 1px solid #fde68a;
    padding: 2px 6px;
    border-radius: 6px;
    line-height: 1.3;
}

.sidebar-recent-link {
    display: block;
    flex: 1;
    min-width: 0;
    padding: 8px 6px 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #374151;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-recent-link:hover {
    background: #f9fafb;
}

.sidebar-recent-menu-wrap {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.sidebar-recent-kebab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #6b7280;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
}

.sidebar-recent-kebab:hover,
.sidebar-recent-kebab[aria-expanded='true'] {
    background: #f3f4f6;
    color: #374151;
}

.sidebar-recent-more {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    color: #2563eb;
    text-align: left;
    cursor: pointer;
}

.sidebar-recent-more:hover:not(:disabled) {
    background: #f9fafb;
    text-decoration: underline;
}

.sidebar-recent-more:disabled {
    opacity: 0.6;
    cursor: wait;
}

.sidebar-recent-sentinel {
    height: 1px;
    margin: 0;
    padding: 0;
    list-style: none;
    flex-shrink: 0;
    pointer-events: none;
    overflow: hidden;
}

.sidebar-recent-loading-more {
    list-style: none;
    margin: 0;
    padding: 6px 10px 8px;
}

.sidebar-recent-loading-more-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #6b7280;
}

.sidebar-recent-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: sidebar-recent-spin 0.7s linear infinite;
}

@keyframes sidebar-recent-spin {
    to {
        transform: rotate(360deg);
    }
}

.sidebar-recent-menu-portal {
    position: fixed;
    z-index: 10200;
    min-width: 180px;
    padding: 6px;
    background: var(--color-surface, #fff);
    border: 1px solid var(--color-border, #e5e7eb);
    border-radius: var(--radius-lg, 10px);
    box-shadow: var(--shadow-lg, 0 10px 40px rgba(15, 23, 42, 0.12));
}

.sidebar-recent-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    margin: 0;
    border: none;
    border-radius: var(--radius-md, 8px);
    background: transparent;
    font-size: 13px;
    color: var(--color-text, #374151);
    cursor: pointer;
}

.sidebar-recent-menu-item:hover {
    background: #f3f4f6;
}

.sidebar-recent-menu-danger {
    color: var(--color-error, #b91c1c);
}

.sidebar-recent-menu-danger:hover {
    background: rgba(185, 28, 28, 0.08);
}

.sidebar-recent-empty {
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
    padding: 0 4px;
}

.sidebar-recent-all {
    font-size: 12px;
    font-weight: 500;
    color: #2563eb;
    text-decoration: none;
    padding: 0 4px 2px;
}

.sidebar-recent-all:hover {
    text-decoration: underline;
}

.sidebar-user {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fafafa;
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    background: #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.sidebar-user-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-email {
    font-size: 11px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-user-logout {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 9px;
    border: 1px solid var(--color-border);
    color: var(--color-accent);
    background: #fff;
    text-decoration: none;
    transition: background-color 0.15s, border-color 0.15s;
}

.sidebar-user-logout:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

body.sidebar-collapsed:not(.sidebar-open) .sidebar-brand-text,
body.sidebar-collapsed:not(.sidebar-open) .sidebar-brand-tag,
body.sidebar-collapsed:not(.sidebar-open) .sidebar-nav-label,
body.sidebar-collapsed:not(.sidebar-open) .sidebar-recent,
body.sidebar-collapsed:not(.sidebar-open) .sidebar-user-text {
    display: none;
}

body.sidebar-collapsed:not(.sidebar-open) .sidebar-top {
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

body.sidebar-collapsed:not(.sidebar-open) .sidebar-brand {
    justify-content: center;
}

body.sidebar-collapsed:not(.sidebar-open) .sidebar-nav-link {
    justify-content: center;
    padding: 10px 8px;
}

body.sidebar-collapsed:not(.sidebar-open) .sidebar-user {
    flex-direction: column;
    padding: 10px 6px;
    gap: 8px;
}

.app-main {
    min-width: 0;
    padding: 18px 22px;
}

.app-main .container {
    width: 100%;
    max-width: none;
    margin: 0;
    min-width: 0;
    height: calc(100vh - 36px);
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    overflow: hidden;
}

.app-main .header {
    background: rgba(255, 255, 255, 0.9);
    color: #0f172a;
    padding: 16px 20px;
    border-bottom: 1px solid #e4e9f4;
}

.app-main .header h1 {
    font-size: 20px;
    color: #0f172a;
}

.header-subtitle {
    margin: 2px 0 0;
    color: #64748b;
    font-size: 13px;
}

.sidebar-toggle {
    display: none;
    border: 1px solid #d4dced;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    width: 36px;
    height: 36px;
    cursor: pointer;
}

.app-main .ui-lang-btn,
.app-main .history-toggle {
    background: #f8fafc;
    border: 1px solid #d9e0ee;
    color: #0f172a;
}

.app-main .ui-lang-btn:hover,
.app-main .history-toggle:hover {
    background: #eef3fb;
    border-color: #c7d4ea;
}

.user-pill {
    background: #f8fafc;
    border: 1px solid #d9e1ef;
    border-radius: 999px;
    padding: 5px 10px;
}

.user-pill span {
    color: #334155;
}

.user-menu {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.user-menu-trigger {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    min-height: 38px;
    padding: 0;
    margin: 0;
    cursor: pointer;
    background: #f8fafc;
    border: 1px solid #d9e1ef;
    border-radius: 999px;
}

.user-menu-trigger:hover {
    background: #eef3fb;
    border-color: #c7d4ea;
}

.user-menu.is-open .user-menu-trigger {
    background: #eef3fb;
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.user-menu-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 240px;
    max-width: min(320px, 92vw);
    background: #ffffff;
    border: 1px solid #dbe3f2;
    border-radius: 14px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
    z-index: 300;
    overflow: hidden;
}

.user-menu-dropdown[hidden] {
    display: none !important;
}

.user-menu-info {
    padding: 14px 16px;
    border-bottom: 1px solid #e8eef7;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-menu-name {
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
    word-break: break-word;
}

.user-menu-email {
    font-size: 12px;
    color: #64748b;
    word-break: break-all;
}

.user-menu-logout {
    display: block;
    padding: 12px 16px;
    text-align: center;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-accent);
    background: #fff;
    transition: background-color 0.15s, color 0.15s;
}

.user-menu-logout:hover {
    background: #f3f4f6;
    color: var(--color-accent-hover);
}

.standalone-header .header-right {
    margin-left: auto;
}

.breadcrumbs {
    padding: 10px 20px;
    background: rgba(247, 250, 255, 0.95);
    border-bottom: 1px solid #e6edf8;
}

.input-section {
    background: #fcfdff;
    border-bottom: 1px solid #e4e9f4;
}

.reference-docs {
    background: #ffffff;
    border: 1px solid #dbe4f3;
}

.chat-area {
    background: #f9fafb;
}

.message {
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.app-main .message.assistant {
    background: #f3f4f6;
    border-color: #e5e7eb;
}

.followup-container {
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
}

.app-main .followup-input-row {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
}

.app-main .followup-input-row:focus-within {
    border-color: #93c5fd;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

/* Knowledge base page — same scroll column as .chat-area on analysis */
.kb-page-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px;
    background: #f9fafb;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.app-main .kb-page-content > .kb-page-card--padded {
    padding: 16px 20px 20px;
}

.app-main .kb-page-content > .kb-management-card {
    margin-bottom: 0;
}

/* Prevent flex items from collapsing: history-page-card uses overflow:hidden,
   which makes the flex automatic min-size 0 and hides upload jobs / KB list. */
.app-main .kb-page-content > .standalone-card {
    flex-shrink: 0;
}

/* KB page also contains compliance-style cards (KB tree) */
.app-main .kb-page-content > .compliance-card {
    flex-shrink: 0;
}

.standalone-page {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 22px;
}

.standalone-header {
    background: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
    padding: 18px 20px;
}

.standalone-header .header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.standalone-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    background: #fff;
}

.settings-page-subtitle {
    margin: 6px 0 0;
    font-size: 14px;
    color: #6b7280;
    font-weight: 400;
}

.standalone-header .header-left > div {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.standalone-header .header-left h1 {
    margin: 0;
}

.standalone-header .header-subtitle {
    margin: 6px 0 0;
    font-size: 14px;
    color: #6b7280;
    font-weight: 400;
}

.standalone-breadcrumbs {
    margin: 0;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    background: #fff;
    padding: 10px 18px;
    font-size: 13px;
    color: #6b7280;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.history-toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.history-toolbar-new {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.standalone-page .history-item {
    background: #fafafa;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 12px;
}

.standalone-page .history-item:hover {
    border-color: #cbd5e1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.standalone-page .history-lang {
    background: #eef2ff;
    color: #4338ca;
    font-weight: 600;
}

.standalone-page .history-btn {
    border-color: #e5e7eb;
    color: #4b5563;
    padding: 8px;
    border-radius: 8px;
    min-width: 38px;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0;
}

.standalone-page .history-btn svg {
    flex-shrink: 0;
}

.settings-tabs-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    background: #f3f4f6;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    margin: 0 0 18px;
    width: fit-content;
    max-width: 100%;
}

.settings-tab {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #6b7280;
}

.settings-tab--active {
    background: #fff;
    color: #111827;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.settings-card {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    padding: 0;
    overflow: hidden;
}

.settings-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 22px 0;
    flex-wrap: wrap;
}

.settings-card-head-text h2 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.settings-card-head-text .settings-note {
    margin: 6px 0 0;
    font-size: 13px;
    color: #6b7280;
}

.settings-card-head .btn {
    flex-shrink: 0;
    width: auto;
}

@media (max-width: 520px) {
    .settings-card-head .btn {
        width: 100%;
    }
}

.settings-card-body {
    padding: 16px 22px 22px;
}

.settings-card-body .settings-row {
    margin-top: 0;
}

.settings-card-body .settings-success {
    margin-top: 14px;
}

.followup-kbd-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #9ca3af;
    padding: 0 4px;
}

.followup-kbd-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    margin: 0 2px;
    font-size: 11px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
    color: #4b5563;
}

.error-card {
    border: 1px solid #dbe3f2;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.1);
}

.error-logo {
    margin: 0 auto 12px;
}

.sidebar-overlay {
    display: none;
}

.app-shell-simple .app-main {
    display: flex;
    align-items: flex-start;
}

.history-page-card {
    padding: 0;
    overflow: hidden;
}

.history-page-list {
    max-height: min(72vh, 820px);
}

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

    .sidebar {
        position: fixed;
        left: -100%;
        transition: left 0.25s ease;
        width: min(280px, 84vw);
        box-shadow: 0 22px 40px rgba(15, 23, 42, 0.42);
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.5);
        z-index: 30;
    }

    .app-main {
        padding: 12px;
    }

    .app-main .container {
        height: calc(100vh - 24px);
        border-radius: 14px;
    }

    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .header-right {
        gap: 8px;
    }

    .standalone-page {
        padding: 12px;
    }
}

.kb-uploads-table-wrap {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.kb-uploads-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.kb-uploads-table th,
.kb-uploads-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: middle;
}

.kb-uploads-table thead th {
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 600;
    font-size: 12px;
    text-transform: none;
    letter-spacing: 0;
}

.kb-uploads-table tbody tr:last-child td {
    border-bottom: none;
}

.kb-uploads-table tbody tr:hover td {
    background: #fafafa;
}

.kb-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.kb-status-pill::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kb-status-pill--done {
    background: #ecfdf5;
    color: #047857;
}

.kb-status-pill--done::before {
    background: #10b981;
}

.kb-status-pill--failed {
    background: #fef2f2;
    color: #b91c1c;
}

.kb-status-pill--failed::before {
    background: #ef4444;
}

.kb-status-pill--neutral {
    background: #f3f4f6;
    color: #4b5563;
}

.kb-status-pill--neutral::before {
    background: #9ca3af;
}

.kb-status-pill--cancelled {
    color: #64748b;
    background: #f1f5f9;
    border-color: #e2e8f0;
}

.kb-status-pill--cancelled::before {
    background: #94a3b8;
}

.kb-job-err {
    max-width: 280px;
    word-break: break-word;
    color: var(--color-text-secondary);
}

.kb-uploads-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px 20px 0;
}

.kb-uploads-toolbar-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.kb-uploads-toolbar-hint {
    padding: 0 20px 8px;
    margin: 0;
}

.kb-uploads-table-title {
    padding: 0 20px;
    margin: 10px 0 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #0f172a;
}

.kb-uploads-list-wrap {
    padding: 12px 20px 20px;
}

.kb-management-card {
    margin-bottom: 16px;
}

.reference-docs--full {
    margin: 0;
}

.kb-docs-card .reference-docs {
    padding: 0 0 8px;
    margin-bottom: 0;
    max-height: min(52vh, 620px);
    overflow-y: auto;
    overflow-x: hidden;
    background: transparent;
    border: none;
    border-radius: 0;
}

.kb-docs-card .reference-docs h4 {
    margin: 0;
    padding: 16px 20px 12px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #0f172a;
    text-transform: none;
}

.kb-docs-card .reference-docs ul {
    gap: 8px;
    padding: 0 12px 12px;
}

/* Override global .reference-docs li (monospace chip) on KB page */
.kb-docs-card .reference-docs #refDocList > li {
    list-style: none;
    font-family: inherit;
    font-size: 14px;
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 0;
    margin: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kb-docs-card #refDocList > li.doc-folder {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    min-height: 46px;
    background: #ffffff;
    font-weight: 500;
    color: #0f172a;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.kb-docs-card #refDocList > li.doc-folder:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.kb-docs-card #refDocList > li.doc-folder .folder-name {
    color: #0f172a;
    font-weight: 600;
    font-size: 14px;
}

.kb-docs-card #refDocList > li.doc-folder .folder-count {
    color: #64748b;
    font-weight: 500;
    font-size: 13px;
}

.kb-docs-card #refDocList > li.doc-folder .folder-expand-icon {
    color: #64748b;
    font-size: 10px;
    width: 14px;
    flex-shrink: 0;
    text-align: center;
}

.kb-docs-card #refDocList > li.doc-folder .folder-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.kb-docs-card #refDocList .folder-menu-btn,
.kb-docs-card #refDocList .doc-menu-btn {
    opacity: 1;
    color: #64748b;
    border-radius: 8px;
}

.kb-docs-card #refDocList .folder-menu-btn:hover,
.kb-docs-card #refDocList .doc-menu-btn:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.kb-docs-card #refDocList > .folder-docs-container {
    margin: 2px 0 4px;
    padding: 0 0 0 4px;
    border-left: 2px solid #e2e8f0;
}

.kb-docs-card .folder-docs-inner .doc-item {
    border-left: none;
    margin-left: 0;
}

.kb-docs-card #refDocList .doc-item {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    background: #ffffff;
    color: #334155;
    font-size: 14px;
}

.kb-docs-card #refDocList .doc-item.doc-in-folder {
    background: #f8fafc;
    padding-left: 16px !important;
}

.kb-docs-card #refDocList .doc-item:hover {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #cbd5e1;
}

.kb-docs-card #refDocList .doc-item.doc-url:hover {
    background: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

.kb-docs-card #refDocList .no-docs {
    border: 1px dashed #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
    color: #64748b;
    font-style: normal;
    padding: 20px 16px;
    text-align: center;
}

.kb-docs-card #refDocList .kb-checkbox {
    accent-color: #2563eb;
}

.kb-docs-card #refDocList > li.skeleton-line {
    height: 14px;
    border-radius: 999px;
    margin: 8px 12px;
    padding: 0;
    border: none;
    box-shadow: none;
    background: linear-gradient(90deg, #eef0f3 0%, #f7f8fa 50%, #eef0f3 100%);
    background-size: 200% 100%;
    animation: skeletonPulse 1.2s linear infinite;
}

/* Knowledge base — upload dialog (enterprise) */
.upload-modal-content--enterprise {
    max-width: 560px;
    width: 92%;
    max-height: min(88vh, 720px);
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    background: #fff;
}

.upload-modal-content--enterprise .doc-modal-body {
    padding: 0 22px 16px;
}

.upload-modal-content--enterprise .doc-modal-header {
    background: #f8fafc;
    color: #0f172a;
    border-bottom: 1px solid #e2e8f0;
    padding: 18px 22px;
    align-items: flex-start;
}

.upload-modal-content--enterprise .doc-modal-close {
    color: #64748b;
}

.upload-modal-content--enterprise .doc-modal-close:hover {
    color: #0f172a;
    background: #e2e8f0;
}

.kb-upload-modal__heading {
    min-width: 0;
    flex: 1;
    padding-right: 12px;
}

.kb-upload-modal__heading h3 {
    font-size: 1.125rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
    line-height: 1.3;
}

.kb-upload-modal__lede {
    margin: 6px 0 0;
    font-size: 13px;
    color: #64748b;
    font-weight: 400;
    line-height: 1.45;
}

.kb-upload-modal__close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
}

.kb-upload-modal__body {
    padding-top: 16px;
}

.kb-upload-segment {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    padding: 4px;
    margin-bottom: 20px;
    background: #f1f5f9;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
}

.kb-upload-segment__btn {
    margin: 0;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}

.kb-upload-segment__btn:hover {
    color: #334155;
}

.kb-upload-segment__btn.active {
    background: #fff;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.kb-upload-section {
    margin-bottom: 18px;
}

.kb-upload-section__label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.kb-upload-select {
    width: 100%;
    padding: 11px 12px;
    font-size: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: #0f172a;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.kb-upload-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.kb-upload-new-folder {
    margin-top: 10px;
    align-items: stretch;
}

.kb-upload-new-folder .kb-upload-input {
    flex: 1;
    min-width: 0;
    width: auto;
}

/* In flex rows, base .btn sets width:100% — override for create-folder action */
.kb-upload-new-folder .kb-upload-new-folder__btn {
    width: auto;
    flex: 0 0 auto;
    min-width: 120px;
    justify-content: center;
}

.kb-upload-field-error {
    margin-top: 8px;
    font-size: 13px;
}

.kb-upload-dropzone {
    border: 1px dashed #94a3b8;
    border-radius: 12px;
    padding: 28px 20px;
    background: #fafbfc;
    transition: border-color 0.2s, background 0.2s;
    margin-bottom: 12px;
}

.kb-upload-dropzone:hover,
.kb-upload-dropzone.dragover {
    border-color: #3b82f6;
    background: #f0f9ff;
}

.kb-upload-dropzone__inner {
    gap: 10px;
}

.kb-upload-ico {
    color: #64748b;
}

.kb-upload-ico--ok {
    color: #059669;
}

.kb-upload-dropzone__title {
    font-size: 14px;
    font-weight: 600;
    color: #0f172a;
}

.kb-upload-dropzone__title--ok {
    color: #0f766e;
}

.kb-upload-file-list {
    margin-bottom: 0;
    max-height: 220px;
}

.kb-upload-file-row {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 8px;
}

.kb-upload-file-row__badge {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #475569;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    padding: 3px 6px;
    border-radius: 4px;
}

.kb-upload-file-row__ico {
    color: #64748b;
}

.kb-upload-file-row__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    color: #64748b;
}

.kb-upload-file-row__remove svg {
    width: 14px;
    height: 14px;
}

.kb-upload-file-row__remove:hover {
    background: #fef2f2;
    color: #b91c1c;
}

.kb-upload-status {
    min-height: 28px;
    margin: 12px 0 0;
    text-align: left;
    font-size: 13px;
}

.kb-upload-modal__footer {
    flex-shrink: 0;
    padding: 14px 22px 18px;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    border-radius: 0 0 13px 13px;
}

.kb-upload-modal__footer-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
}

.kb-upload-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    box-sizing: border-box;
    padding: 0 18px;
    line-height: 1;
    white-space: nowrap;
    font-weight: 500;
    border-radius: 8px;
    background: #fff;
}

.kb-upload-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    box-sizing: border-box;
    padding: 0 20px;
    line-height: 1;
    white-space: nowrap;
    font-weight: 600;
    border-radius: 8px;
    background: #1e40af !important;
    color: #fff !important;
    border: none !important;
}

.kb-upload-btn-primary:hover:not(:disabled) {
    background: #1d4ed8 !important;
}

.kb-upload-btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.kb-upload-panel__intro {
    margin-top: 0;
    margin-bottom: 12px;
}

.kb-upload-url-hint {
    margin-top: 4px;
}

.upload-modal-content--enterprise .new-folder-input button {
    background: #fff;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.upload-modal-content--enterprise .new-folder-input button:hover {
    background: #f1f5f9;
}

/* Knowledge base — active jobs (in-flow) + upload drawer */
.kb-active-jobs-panel {
    margin: 0 0 16px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
}

.kb-active-jobs-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 10px 12px;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #ffffff;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
}

.kb-active-jobs-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.kb-active-jobs-panel__title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.kb-active-jobs-panel__refresh {
    flex-shrink: 0;
    padding: 6px 12px;
    font-size: 12px;
}

.kb-active-jobs-panel__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.kb-active-jobs-panel__row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.kb-active-jobs-panel__main {
    flex: 1 1 220px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kb-active-jobs-panel__name {
    font-size: 14px;
    font-weight: 500;
    color: #0f172a;
    word-break: break-word;
}

.kb-active-jobs-panel__idhint {
    font-size: 11px;
    font-family: ui-monospace, monospace;
    color: #94a3b8;
}

.kb-active-jobs-panel__target {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12px;
}

.kb-active-jobs-panel__target-label {
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 10px;
}

.kb-active-jobs-panel__target-value {
    color: #0f172a;
    font-weight: 500;
}

.kb-active-jobs-panel__target-path {
    font-size: 11px;
    color: #94a3b8;
    word-break: break-all;
    line-height: 1.35;
}

.kb-active-jobs-panel__meta {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.kb-active-jobs-panel__cancel {
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.kb-active-jobs-panel__cancel:hover {
    color: #b91c1c;
    background: #fef2f2;
}

/* Knowledge base — inline upload card (main document flow) */
.kb-upload-inline-card {
    margin-bottom: 1.25rem;
}

.kb-upload-inline__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 4px 12px;
    border-bottom: 1px solid #e2e8f0;
    margin-bottom: 4px;
}

.kb-upload-inline__head .kb-uploads-toolbar-title {
    margin: 0;
}

.kb-upload-inline__head .kb-uploads-toolbar-hint {
    margin: 0;
    text-align: right;
}

@media (max-width: 720px) {
    .kb-upload-inline__head {
        flex-direction: column;
        align-items: flex-start;
    }
    .kb-upload-inline__head .kb-uploads-toolbar-hint {
        text-align: left;
    }
}

.kb-upload-inline__host {
    padding: 12px 4px 4px;
}

.kb-upload-inline__host .kb-upload-drawer-form.upload-modal-content--enterprise {
    max-width: 100%;
    width: 100%;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

/* ===== Compliance page: single-flow blocks ===== */
.page-analysis .app-main .container {
    height: auto;
    overflow: visible;
}

.compliance-flow {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px 20px;
    background: #f9fafb;
    overflow: visible;
}

.compliance-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
    overflow: hidden;
    min-width: 0;
}

.input-section--card {
    padding: 16px 18px 18px;
    border-bottom: none;
    background: transparent;
}

.compliance-card--form .options-row {
    margin-bottom: 10px;
}

.compliance-card--form .reference-docs {
    margin-bottom: 0;
}

.reference-docs--card {
    padding: 0 0 12px;
    background: transparent;
    border: none;
    border-radius: 0;
    max-height: min(44vh, 520px);
}

/* Override global .reference-docs li monospace chip on compliance page */
.compliance-card--kb .reference-docs {
    max-height: none;
    overflow: visible;
    padding: 0;
    margin-bottom: 0;
}

.compliance-card--kb .reference-docs #refDocList > li {
    list-style: none;
    font-family: inherit;
    font-size: 14px;
    color: #0f172a;
    background: transparent;
    border: none;
    border-bottom: 1px solid #eef2f7;
    border-radius: 0;
    padding: 10px 14px;
    margin: 0;
    box-shadow: none;
}

.compliance-card--kb .reference-docs #refDocList > li:last-child {
    border-bottom: none;
}

.compliance-card--kb .reference-docs #refDocList {
    gap: 0;
    padding: 0;
}

.compliance-card--kb .reference-docs h4 {
    margin: 0;
    padding: 16px 18px 12px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #0f172a;
    text-transform: none;
    border-bottom: 1px solid #eef2f7;
}

.chat-panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-panel .chat-area {
    min-height: 0;
    padding: 18px 18px;
    background: #f9fafb;
    max-height: min(62vh, 720px);
}

.chat-panel .followup-container {
    flex-shrink: 0;
}

.followup-container--panel {
    position: sticky;
    bottom: 0;
    border-top: 1px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(8px);
}

@media (max-width: 980px) {
    .compliance-flow {
        padding: 12px;
    }
}
