:root {
    --bg: #f3f4f6;
    --bg-elevated: #ffffff;
    --bg-muted: #e6e8ec;
    --sidebar: #0f172a;
    --sidebar-muted: #1e293b;
    --border: #d5dae2;
    --text: #0f172a;
    --text-muted: #52606d;
    --accent: #2563eb;
    --accent-soft: #dbeafe;
    --success: #0f766e;
    --warning: #b45309;
    --danger: #b91c1c;
    --shadow: 0 16px 32px rgba(15, 23, 42, 0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --font-sans: "IBM Plex Sans", "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "Consolas", monospace;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-sans);
    color: var(--text);
    background-color: var(--bg);
    background-image:
        radial-gradient(circle at 20% 20%, rgba(15, 23, 42, 0.04) 0%, rgba(15, 23, 42, 0.00) 55%),
        radial-gradient(circle at 80% 0%, rgba(15, 23, 42, 0.05) 0%, rgba(15, 23, 42, 0.00) 50%),
        radial-gradient(circle at 0% 80%, rgba(15, 23, 42, 0.04) 0%, rgba(15, 23, 42, 0.00) 55%);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

.app-shell {
    display: grid;
    grid-template-columns: auto 1fr;
    min-height: 100vh;
}

.app-shell.landing-no-sidebar {
    grid-template-columns: 1fr;
}

.sidebar {
    background: var(--sidebar);
    color: #e2e8f0;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    transition: width 0.2s ease;
    width: 260px;
}

.sidebar.collapsed {
    width: 88px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.sidebar-collapse {
    background: transparent;
    border: 1px solid rgba(226, 232, 240, 0.15);
    color: #e2e8f0;
    border-radius: 999px;
    width: 32px;
    height: 32px;
    cursor: pointer;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-main-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #cbd5f5;
    border: 1px solid rgba(226, 232, 240, 0.18);
    cursor: pointer;
    background: rgba(148, 163, 184, 0.08);
    transition: background 0.15s ease, border 0.15s ease, color 0.15s ease;
    width: 100%;
    font: inherit;
    text-align: left;
}

.sidebar-main-menu:hover {
    background: var(--sidebar-muted);
    color: #ffffff;
}

.sidebar-main-menu.active {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.4);
    color: #ffffff;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: #cbd5f5;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border 0.15s ease, color 0.15s ease;
}

.sidebar-item:hover {
    background: var(--sidebar-muted);
    color: #ffffff;
}

.sidebar-item.active {
    background: rgba(37, 99, 235, 0.2);
    border-color: rgba(37, 99, 235, 0.35);
    color: #ffffff;
}

.sidebar-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-item-icon {
    width: 28px;
    display: flex;
    justify-content: center;
    font-size: 1.1rem;
}

.sidebar-item-label {
    flex: 1;
    white-space: nowrap;
}

.sidebar-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(226, 232, 240, 0.15);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.content-wrapper {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar-title {
    font-weight: 600;
    font-size: 1.2rem;
}

.topbar-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.workspace {
    padding: 28px;
}

.landing {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.landing-header {
    text-align: center;
    margin: 6px 0 2px;
}

.landing-kicker {
    margin: 0;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

.landing-title {
    margin: 8px 0 10px;
    font-size: clamp(1.8rem, 2.2vw, 2.35rem);
    font-weight: 700;
    color: var(--text);
}

.landing-subtitle {
    margin: 0 auto;
    max-width: 760px;
    color: var(--text-muted);
    line-height: 1.5;
}

.landing-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 24px;
    align-items: stretch;
}

.landing-card {
    grid-column: span 2;
}

.landing-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 26px;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
    display: flex;
    flex-direction: column;
    min-height: 290px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.landing-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 38px rgba(15, 23, 42, 0.13);
    border-color: #c5ccda;
}

.landing-card.is-disabled {
    opacity: 0.74;
}

.landing-card-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eef2ff;
    color: #1d4ed8;
    border: 1px solid #dbe4ff;
    font-size: 1.22rem;
    margin-bottom: 14px;
}

.landing-card-title {
    margin: 0 0 8px;
    font-size: 1.05rem;
    font-weight: 650;
}

.landing-card-desc {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.45;
    font-size: 0.93rem;
    flex: 1;
}

.landing-card-action {
    margin-top: 16px;
    width: 100%;
    justify-content: center;
}

.landing-card-action.is-open {
    background: var(--accent);
    color: #ffffff;
}

.landing-card-action.is-download {
    background: #15803d;
    color: #ffffff;
}

.landing-card-action.is-download:hover {
    background: #166534;
}

.landing-card-action.is-disabled {
    background: #cbd5e1;
    color: #475569;
    opacity: 1;
    cursor: not-allowed;
}

.card {
    background: var(--bg-elevated);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title {
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid.two {
    grid-template-columns: minmax(260px, 320px) 1fr;
}

.dm-layout.grid.two {
    grid-template-columns: minmax(320px, 380px) 1fr;
}

.rag-layout {
    align-items: stretch;
    min-height: calc(100vh - 180px);
}

.rag-workspace {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 180px);
}

.rag-workspace-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.rag-chat {
    flex: 1;
    min-height: 0;
    max-height: none;
}

.rag-input {
    flex-shrink: 0;
}

.suggestion-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #e8edf3;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96) 0%, rgba(248, 250, 252, 0.98) 100%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.suggestion-label {
    font-size: 0.72rem;
    line-height: 1;
    color: #6b7280;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.suggestion-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.suggestion-chip {
    appearance: none;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    background: #f8fafc;
    color: #111827;
    padding: 7px 12px;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.3;
    text-align: left;
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.suggestion-row.light .suggestion-chip {
    background: #f8fafc;
    border-color: #e5e7eb;
    color: #1f2937;
}

.suggestion-row.deep .suggestion-chip {
    background: #f1f5f9;
    border-color: #dbe3ee;
    color: #0f172a;
}

.suggestion-chip:hover {
    background: #eef2f7;
    border-color: #d3dbe6;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
}

.suggestion-chip:focus-visible {
    outline: none;
    border-color: #c7d2fe;
    box-shadow: 0 0 0 3px rgba(199, 210, 254, 0.45);
}

.suggestion-chip:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06);
}

.suggestion-status {
    font-size: 0.78rem;
    color: #6b7280;
}

.dm-sources-card {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 180px);
}

.dm-sources-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    min-height: 0;
}

.dm-sources-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 6px;
    align-content: start;
}

.dm-source-tile {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    min-height: 150px;
    display: flex;
    flex-direction: column;
}

.dm-source-tile-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 6px;
}

.dm-source-tile-title {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    flex: 1;
}

.dm-source-name {
    font-weight: 600;
    text-transform: capitalize;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.2;
    word-break: break-word;
}

.dm-source-files {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.dm-source-status {
    margin-bottom: 8px;
}

.dm-source-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.dm-source-actions .button {
    width: 100%;
    justify-content: center;
    padding: 8px 10px;
    font-size: 0.82rem;
}

.rag-empty {
    flex: 1;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    gap: 8px;
}

.rag-empty-title {
    font-weight: 600;
    color: var(--text);
}

.rag-empty-subtitle {
    font-size: 0.95rem;
}

.rag-empty-helper {
    font-size: 0.85rem;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.input,
.textarea,
.select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--text);
    background: #ffffff;
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

.button {
    border: none;
    background: var(--accent);
    color: #ffffff;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.button.secondary {
    background: var(--bg-muted);
    color: var(--text);
}

.button.ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
}

.message-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 6px;
}

.message {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: #ffffff;
}

.message.user {
    border-color: rgba(37, 99, 235, 0.3);
    background: rgba(37, 99, 235, 0.08);
}

.message.assistant {
    background: #ffffff;
}

.message-role {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.message-content {
    font-size: 0.95rem;
    line-height: 1.6;
}

.message-content pre {
    background: #f8fafc;
    color: #0f172a;
    padding: 12px;
    border-radius: 10px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.message-content code {
    font-family: var(--font-mono);
}

.message-content ul {
    padding-left: 20px;
}

.message-actions {
    display: flex;
    justify-content: flex-end;
}

.rag-copy-btn {
    border: 1px solid var(--border);
    background: var(--bg-muted);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border 0.15s ease;
}

.rag-copy-btn:hover {
    background: #eef2ff;
    color: var(--text);
    border-color: rgba(37, 99, 235, 0.3);
}

.rag-copy-btn.copied {
    color: var(--success);
    border-color: rgba(15, 118, 110, 0.4);
    background: rgba(15, 118, 110, 0.08);
}

.code-block {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.status-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.progress {
    width: 100%;
    height: 8px;
    border-radius: 999px;
    background: var(--bg-muted);
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    transition: width 0.2s ease;
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid rgba(15, 23, 42, 0.2);
    border-top-color: var(--accent);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============ MODAL STYLING ============ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-dialog {
    background: white;
    border-radius: 12px;
    box-shadow: 0 25px 50px rgba(15, 23, 42, 0.25), 0 10px 32px rgba(15, 23, 42, 0.12);
    max-width: 520px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafbfc;
}

.modal-header h5 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #9ca3af;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    border-radius: 6px;
}

.modal-close:hover {
    color: var(--text);
    background: #e5e7eb;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-body .form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.modal-body label {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}

.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="password"],
.modal-body input[type="number"],
.modal-body select,
.modal-body textarea {
    padding: 10px 12px;
    border: 1px solid #d5dae2;
    border-radius: 8px;
    font-size: 14px;
    font-family: var(--font-sans);
    transition: all 0.2s ease;
}

.modal-body input[type="text"]:focus,
.modal-body input[type="email"]:focus,
.modal-body input[type="password"]:focus,
.modal-body input[type="number"]:focus,
.modal-body select:focus,
.modal-body textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    background: #fafbfc;
}

/* ============ DOCUMENT MANAGEMENT LAYOUT ============ */
.document-management-layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
    height: 100%;
    padding: 24px;
}

.dm-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    max-height: calc(100vh - 48px);
    padding-right: 8px;
}

.dm-sidebar::-webkit-scrollbar {
    width: 8px;
}

.dm-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.dm-sidebar::-webkit-scrollbar-thumb {
    background: #d5dae2;
    border-radius: 4px;
}

.dm-sidebar::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.dm-workspace {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    min-width: 0;
}

.dm-chat-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: white;
    border: 1px solid #e5e7eb;
}

.dm-chat-card .card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.dm-chat-card .card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.dm-chat-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 1;
    overflow: hidden;
    padding: 20px 24px;
}

.dm-chat-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.dm-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.dm-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.dm-chat-messages::-webkit-scrollbar-thumb {
    background: #d5dae2;
    border-radius: 3px;
}

.dm-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    color: #9ca3af;
    min-height: 200px;
}

.dm-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.dm-empty-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.dm-empty-subtitle {
    font-size: 14px;
    color: #9ca3af;
}

.dm-message {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px;
    border-radius: 10px;
    word-wrap: break-word;
    animation: slideIn 0.2s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.dm-message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    max-width: 80%;
}

.dm-message-assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid #e5e7eb;
    max-width: 100%;
}

.dm-message-role {
    font-size: 0.70rem;
    font-weight: 700;
    opacity: 0.5;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dm-message-content {
    font-size: 14px;
    line-height: 1.6;
}

.dm-chat-input {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.dm-chat-input textarea {
    resize: vertical;
    min-height: 60px;
    max-height: 150px;
    padding: 10px 12px;
    border: 1px solid #d5dae2;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: all 0.2s ease;
}

.dm-chat-input textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* ============ CONNECTIONS PANEL ============ */
.dm-connections-panel {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    border-radius: 12px;
    background: white;
    border: 1px solid #e5e7eb;
}

.dm-connections-panel .card-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafbfc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.dm-connections-panel .card-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.dm-connections-panel .card-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.dm-product-selector {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e7eb;
}

.dm-product-selector label {
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}

/* ============ IFRAME TOOLS ============ */
.document-management-container,
.iframe-tool-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 100px);
    position: relative;
}

.session-document-list {
    display: grid;
    gap: 8px;
    margin-top: 12px;
}

.rag-use-case-help,
.rag-use-case-lock {
    display: block;
    margin-top: 7px;
    color: var(--text-muted);
    line-height: 1.4;
}

.rag-use-case-lock {
    color: var(--primary, #2563eb);
    font-weight: 600;
}

.rag-operation-overlay {
    position: fixed;
    inset: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, 0.38);
    backdrop-filter: blur(4px);
}

.rag-operation-panel {
    width: min(520px, 100%);
    display: grid;
    gap: 16px;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
}

.session-document-chip {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-soft, #f7f9fc);
    font-size: 0.82rem;
}

.session-document-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-document-mode {
    color: var(--text-muted);
    font-size: 0.72rem;
}

.session-document-remove {
    width: 24px;
    height: 24px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
}

.session-document-remove:hover {
    background: #fee2e2;
    color: #b91c1c;
}

.testcase-export-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.iframe-tool-preload-host,
.jira-agent-preload-host {
    display: none;
}

.ai-tool-iframe-host,
.jira-agent-iframe-host {
    width: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
}

.ai-tool-iframe,
.jira-agent-iframe {
    width: 100%;
    flex: 1;
    min-height: 100%;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-elevated);
    box-shadow: var(--shadow);
}

.iframe-open-external-button {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 20;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(15, 23, 42, 0.14);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--text);
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.16);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.iframe-open-external-button:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.2);
}

.iframe-loading-overlay {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(243, 244, 246, 0.68);
    pointer-events: none;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1280px) {
    .document-management-layout {
        grid-template-columns: 360px 1fr;
    }

    .dm-connections-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 1024px) {
    .document-management-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .dm-sidebar {
        max-height: 500px;
    }

    .dm-connections-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .document-management-layout {
        padding: 16px;
        gap: 16px;
    }

    .dm-connections-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    .dm-connection-card {
        min-height: 160px;
        padding: 16px 12px;
    }

    .dm-chat-card .card-header {
        padding: 16px;
        flex-direction: column;
        align-items: stretch;
    }

    .dm-chat-body {
        padding: 16px;
    }

    .modal-dialog {
        width: 95%;
        max-width: 480px;
    }

    .dm-message-user {
        max-width: 95%;
    }
}

@media (max-width: 480px) {
    .document-management-layout {
        padding: 12px;
    }

    .dm-connections-grid {
        grid-template-columns: 1fr;
    }

    .dm-connection-card {
        min-height: 140px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-dialog {
        min-width: 280px;
    }
}

@media (max-width: 1360px) {
    .landing {
        max-width: 980px;
    }

    .landing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .landing-grid .landing-card {
        grid-column: auto;
    }

    .landing-grid .landing-card:nth-child(4),
    .landing-grid .landing-card:nth-child(5) {
        grid-column: auto;
    }
}

@media (max-width: 1100px) {
    .grid.two {
        grid-template-columns: 1fr;
    }

    .landing {
        max-width: 860px;
    }

    .landing-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dm-layout.grid.two {
        grid-template-columns: 1fr;
    }

    .dm-sources-card {
        min-height: auto;
    }

    .dm-sources-list {
        grid-template-columns: 1fr;
        overflow: visible;
        padding-right: 0;
    }

    .document-management-layout {
        grid-template-columns: 1fr;
    }

    .dm-sidebar {
        max-height: none;
    }
}

@media (max-width: 720px) {
    .document-management-layout {
        padding: 12px;
        gap: 12px;
    }

    .suggestion-container {
        padding: 10px 12px;
        margin-bottom: 12px;
    }

    .suggestion-chip {
        max-width: none;
    }

    .dm-connections-grid {
        grid-template-columns: 1fr;
    }

    .modal-dialog {
        width: 95%;
    }

    .dm-message-user {
        max-width: 95%;
    }

    .sidebar {
        width: 88px;
    }

    .sidebar.collapsed {
        width: 72px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .workspace {
        padding: 20px;
    }

    .landing-grid {
        grid-template-columns: 1fr;
    }

    .landing-card {
        min-height: 250px;
    }
}


