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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface-2: #242736;
    --surface-3: #2e3142;
    --border: #2e3142;
    --border-light: #3a3d50;
    --text: #e4e6f0;
    --text-dim: #8b8fa3;
    --text-muted: #5d6075;
    --accent: #5b7ff5;
    --accent-hover: #4a6de0;
    --accent-dim: rgba(91, 127, 245, 0.15);
    --green: #4ade80;
    --yellow: #facc15;
    --red: #ef4444;
    --green-dim: rgba(74, 222, 128, 0.12);
    --yellow-dim: rgba(250, 204, 21, 0.12);
    --red-dim: rgba(239, 68, 68, 0.12);
    --sidebar-w: 260px;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --radius-xl: 16px;
    --shadow: 0 4px 16px rgba(0,0,0,0.2);
    --shadow-lg: 0 20px 60px rgba(0,0,0,0.5);
    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
}

/* ---- Selection ---- */
::selection {
    background: rgba(91, 127, 245, 0.35);
    color: var(--text);
}

html, body { height: 100%; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* ---- Focus visible (keyboard accessibility) ---- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    outline: none;
}

/* ---- App layout ---- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: width var(--transition);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px;
    border-bottom: 1px solid var(--border);
}

.logo {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--accent);
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: none;
}
.sidebar-toggle:hover { color: var(--text); }

.sidebar-section {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.sidebar-section:last-of-type {
    flex: 0 0 auto;
    max-height: 200px;
    border-top: 1px solid var(--border);
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-dim);
}

.dataset-list, .bookmark-list {
    padding: 0 8px;
}

/* ---- Empty state (sidebar) ---- */
.sidebar-empty {
    padding: 8px 10px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ---- Room group (sidebar) ---- */
.room-group {
    margin-bottom: 2px;
}

.room-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.room-header:hover {
    background: var(--surface-2);
    color: var(--text);
}

.room-group.active > .room-header {
    background: var(--accent-dim);
    color: var(--accent);
}

.room-chevron {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    transition: transform var(--transition);
    color: var(--text-muted);
}

.room-chevron.open {
    transform: rotate(90deg);
}

.room-chevron.invisible {
    visibility: hidden;
}

.room-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}

.room-file-count {
    background: var(--surface-3);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    padding: 0 5px;
    border-radius: 8px;
    line-height: 16px;
    flex-shrink: 0;
}

.room-group.active .room-file-count {
    background: rgba(91, 127, 245, 0.2);
    color: var(--accent);
}

.room-header .ds-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}
.room-header:hover .ds-delete { opacity: 1; }
.ds-delete:hover { color: var(--red); }

.status-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.ready { background: var(--green); }
.status-dot.pending, .status-dot.analyzing, .status-dot.importing { background: var(--yellow); }
.status-dot.error { background: var(--red); }

/* File list (collapsible) */
.room-files {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.25s ease, opacity var(--transition);
    opacity: 0;
}

.room-files.open {
    grid-template-rows: 1fr;
    opacity: 1;
}

.room-files-inner {
    overflow: hidden;
    padding: 2px 0 4px;
}

.room-file-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 30px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    color: var(--text-muted);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.room-file-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.room-file-item .status-dot {
    width: 5px;
    height: 5px;
}

.room-file-icon {
    flex-shrink: 0;
    opacity: 0.5;
}

.room-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.room-file-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}
.room-file-item:hover .room-file-delete { opacity: 1; }
.room-file-delete:hover { color: var(--red); }

/* ---- Bookmark items ---- */
.bookmark-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    color: var(--text-dim);
    transition: background var(--transition-fast), color var(--transition-fast);
}

.bookmark-item:hover {
    background: var(--surface-2);
    color: var(--text);
}

.bookmark-item .bm-delete {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    flex-shrink: 0;
    transition: opacity var(--transition-fast), color var(--transition-fast);
}
.bookmark-item:hover .bm-delete { opacity: 1; }
.bm-delete:hover { color: var(--red); }

.bookmark-item .bm-icon {
    flex-shrink: 0;
    color: var(--text-muted);
}

.bookmark-item .bm-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-dim);
}

.logout-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 12px;
    transition: color var(--transition-fast);
}
.logout-link:hover { color: var(--text-dim); }

/* ---- Main area ---- */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* ---- Buttons ---- */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition-fast), color var(--transition-fast);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}
.btn-text:hover { background: var(--accent-dim); }

.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.btn-primary:hover { background: var(--accent-hover); }

/* ---- Upload zone ---- */
.upload-zone {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.upload-area {
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-xl);
    padding: 64px;
    text-align: center;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    max-width: 480px;
    width: 100%;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.upload-text {
    font-size: 16px;
    color: var(--text);
    margin-top: 16px;
}

.upload-subtext {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 4px;
}

/* ---- Upload progress ---- */
.upload-progress {
    text-align: center;
}

.upload-progress-file {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-top: 8px;
}

.upload-progress-count {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

.upload-progress-bar {
    width: 100%;
    max-width: 260px;
    height: 3px;
    background: var(--surface-3);
    border-radius: 2px;
    margin: 14px auto 0;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.4s ease;
}

.upload-progress-status {
    font-size: 13px;
    color: var(--text-dim);
    margin-top: 10px;
}

/* ---- Import panel ---- */
.import-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.import-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
}

.import-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.import-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.import-top-actions {
    margin-bottom: 20px;
}

.import-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.import-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
}

.import-stat .stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--accent);
}

.import-stat .stat-label {
    font-size: 11px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.import-file-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    transition: border-color 0.3s;
}

.import-file-card.highlighted {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(91, 127, 245, 0.15);
}

.import-file-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.import-file-header strong {
    font-size: 14px;
}

.import-file-desc {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 10px;
    line-height: 1.4;
}

.import-error {
    background: var(--red-dim);
    border: 1px solid rgba(239,68,68,0.3);
    color: var(--red);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 8px;
}

.import-stats-inline {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.import-stats-inline span {
    background: var(--surface-2);
    padding: 2px 8px;
    border-radius: 4px;
}

.status-pill {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: var(--radius);
    margin-left: 8px;
}
.status-pill.ready { background: var(--green-dim); color: var(--green); }
.status-pill.pending, .status-pill.analyzing, .status-pill.importing { background: var(--yellow-dim); color: var(--yellow); }
.status-pill.error { background: var(--red-dim); color: var(--red); }

/* File action buttons in import report */
.import-file-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    margin-bottom: 4px;
}

.dv-open-btn-lg {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background var(--transition-fast);
}
.dv-open-btn-lg:hover { background: var(--accent-hover); }

.import-file-delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 7px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.import-file-delete-btn:hover { color: var(--red); border-color: var(--red); }

.import-bottom-actions {
    margin-top: 20px;
}

.import-section {
    margin-bottom: 20px;
}

.import-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.column-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
}

.column-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
}

.column-card .col-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.column-card .col-meta {
    font-size: 12px;
    color: var(--text-dim);
}

.column-card .col-meta span {
    display: inline-block;
    background: var(--surface-2);
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 4px;
}

.column-card .col-desc {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 4px;
}

.column-card .col-samples {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    font-style: italic;
}

.import-list {
    list-style: none;
}
.import-list li {
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-dim);
}
.import-list li::before {
    content: "\2022";
    color: var(--accent);
    margin-right: 8px;
}

.clarification-box {
    background: var(--yellow-dim);
    border: 1px solid rgba(250, 204, 21, 0.3);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}

.clarification-box h3 {
    color: var(--yellow);
    margin-bottom: 10px;
}

.clarification-box .clarification-q {
    margin-bottom: 8px;
    font-size: 13px;
}

.clarification-confirm {
    margin-top: 8px;
}

.clarification-box input {
    width: 100%;
    padding: 8px 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 13px;
    margin-top: 4px;
}

/* ---- Chat interface ---- */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-header h2 {
    font-size: 15px;
    font-weight: 600;
}

.chat-actions {
    display: flex;
    gap: 4px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ---- Chat empty state ---- */
.chat-empty {
    text-align: center;
    padding: 48px 0;
    color: var(--text-muted);
}

.chat-empty-title {
    font-size: 15px;
}

.chat-empty-sub {
    font-size: 12px;
    margin-top: 4px;
}

.chat-msg {
    max-width: 85%;
    animation: msgIn 0.2s ease;
}

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

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg.assistant {
    align-self: flex-start;
}

.msg-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.chat-msg.user .msg-bubble {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg.assistant .msg-bubble {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* ---- Confidence badge ---- */
.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    margin-bottom: 8px;
    cursor: default;
    position: relative;
    transition: filter var(--transition-fast);
}

.confidence-badge:hover {
    filter: brightness(1.2);
}

.confidence-badge.high {
    background: var(--green-dim);
    color: var(--green);
}
.confidence-badge.medium {
    background: var(--yellow-dim);
    color: var(--yellow);
}
.confidence-badge.low {
    background: var(--red-dim);
    color: var(--red);
}

.confidence-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ---- Markdown in chat ---- */
.msg-bubble .md-p {
    margin: 2px 0;
}

.msg-bubble .md-h1, .msg-bubble .md-h2, .msg-bubble .md-h3, .msg-bubble .md-h4 {
    font-weight: 700;
    margin: 10px 0 4px;
    line-height: 1.3;
}
.msg-bubble .md-h1 { font-size: 17px; }
.msg-bubble .md-h2 { font-size: 15px; }
.msg-bubble .md-h3 { font-size: 14px; color: var(--text-dim); }
.msg-bubble .md-h4 { font-size: 13px; color: var(--text-dim); }

.msg-bubble .md-hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 10px 0;
}

.msg-bubble .md-table-wrap {
    margin: 8px 0;
    position: relative;
}

.msg-bubble .md-table-truncated {
    text-align: center;
    padding: 6px 0;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px dashed var(--border);
}

.msg-bubble .md-table-export {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: inherit;
    cursor: pointer;
    transition: color var(--transition-fast), border-color var(--transition-fast);
}
.msg-bubble .md-table-export:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.msg-bubble .md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.msg-bubble .md-table th {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 2px solid var(--border-light);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.msg-bubble .md-table th strong {
    color: var(--text);
}

.msg-bubble .md-table td {
    padding: 5px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.msg-bubble .md-table tbody tr:hover {
    background: rgba(255,255,255,0.03);
}

.msg-bubble .md-ul, .msg-bubble .md-ol {
    list-style: none;
    padding: 0;
    margin: 4px 0;
}

.msg-bubble .md-ul li, .msg-bubble .md-ol li {
    padding: 2px 0 2px 16px;
    position: relative;
}

.msg-bubble .md-ul li::before {
    content: "\2022";
    position: absolute;
    left: 2px;
    color: var(--accent);
}

.msg-bubble .md-ol {
    counter-reset: md-ol-counter;
}

.msg-bubble .md-ol li {
    counter-increment: md-ol-counter;
}

.msg-bubble .md-ol li::before {
    content: counter(md-ol-counter) ".";
    position: absolute;
    left: 0;
    color: var(--accent);
    font-size: 12px;
}

.msg-bubble .md-inline-code {
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Fira Code', Consolas, monospace;
    font-size: 12px;
}

.msg-bubble strong {
    font-weight: 600;
    color: var(--text);
}

.msg-bubble em {
    font-style: italic;
    color: var(--text-dim);
}

/* ---- Message actions ---- */
.msg-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
}

.msg-action-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color var(--transition-fast), background var(--transition-fast);
}
.msg-action-btn:hover { color: var(--text-dim); background: var(--surface-2); }

/* ---- Info panel ---- */
.info-panel {
    margin-top: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: grid;
    grid-template-rows: 0fr;
    opacity: 0;
    transition: grid-template-rows 0.3s ease, opacity var(--transition);
}

.info-panel-inner {
    overflow: hidden;
}

.info-panel.open {
    grid-template-rows: 1fr;
    opacity: 1;
}

.info-panel.open .info-panel-inner {
    padding: 14px;
}

.info-section {
    margin-bottom: 10px;
}
.info-section:last-child { margin-bottom: 0; }

.info-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

.info-section-content {
    font-size: 13px;
    color: var(--text);
    line-height: 1.5;
}

.info-section-content ul {
    list-style: none;
    padding: 0;
}

.info-section-content li {
    padding: 2px 0;
}
.info-section-content li::before {
    content: "\2192";
    color: var(--accent);
    margin-right: 6px;
}

.quality-warnings {
    list-style: none;
    padding: 0;
}
.quality-warnings li {
    padding: 3px 0;
    font-size: 12px;
    color: var(--yellow);
}
.quality-warnings li::before {
    content: "\26A0";
    margin-right: 6px;
}

.sql-block {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    overflow-x: auto;
    margin: 0;
}

.sql-block code {
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', Consolas, monospace;
    font-size: 12px;
    line-height: 1.6;
    color: var(--text-dim);
    white-space: pre-wrap;
    word-break: break-all;
}

/* ---- Edit textarea in chat ---- */
.edit-textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 8px 10px;
    resize: none;
    outline: none;
    line-height: 1.5;
    min-height: 40px;
}

.edit-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

/* ---- Suggestion chips ---- */
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding: 8px 0;
    animation: msgIn 0.25s ease;
}

.suggestion-chip {
    background: var(--surface);
    border: 1px solid var(--border-light);
    color: var(--text-dim);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
    max-width: 300px;
    text-align: left;
}

.suggestion-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-dim);
}

/* ---- Chat input ---- */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 12px;
    transition: border-color var(--transition);
}

.chat-input-wrapper:focus-within {
    border-color: var(--accent);
}

#chatInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 20px;
    max-height: 120px;
    line-height: 1.5;
    padding: 0;
}

#chatInput::placeholder {
    color: var(--text-muted);
}

.send-btn {
    background: var(--accent);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition-fast);
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { opacity: 0.4; cursor: default; }
.send-btn.stop-mode { background: var(--red); }
.send-btn.stop-mode:hover { background: #dc2626; }

/* ---- Loading ---- */
.loading-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    padding: 12px 16px;
}
.loading-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    animation: dotPulse 1.4s infinite ease-in-out;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* ---- Toast ---- */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 13px;
    box-shadow: var(--shadow);
    animation: toastIn 0.25s ease;
    max-width: 360px;
}

.toast.error { border-color: rgba(239, 68, 68, 0.4); }
.toast.success { border-color: rgba(74, 222, 128, 0.4); }

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

/* ---- Modal dialog ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.12s ease;
}

.modal-dialog {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    padding: 28px 32px 24px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255,255,255,0.04) inset;
    animation: modalIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: center;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.92) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-icon {
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.modal-message {
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
    margin-bottom: 20px;
}

.modal-input-wrap {
    margin-bottom: 20px;
}

.modal-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.modal-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(91, 127, 245, 0.15);
}

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

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.modal-btn {
    padding: 9px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background var(--transition-fast), transform 0.1s;
    min-width: 100px;
}

.modal-btn:active {
    transform: scale(0.97);
}

.modal-btn-cancel {
    background: var(--surface-3);
    color: var(--text-dim);
}

.modal-btn-cancel:hover {
    background: var(--border-light);
    color: var(--text);
}

.modal-btn-primary {
    background: var(--accent);
    color: #fff;
}

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

.modal-btn-danger {
    background: var(--red);
    color: #fff;
}

.modal-btn-danger:hover {
    background: #dc2626;
}

/* ---- Data viewer overlay ---- */
.dv-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}

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

.dv-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 92vw;
    max-width: 1200px;
    height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: panelIn 0.2s ease;
}

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

.dv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 16px;
}

.dv-title-row {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.dv-title-row h2 {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dv-row-count {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.dv-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.dv-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
    transition: border-color var(--transition);
}

.dv-search-wrap:focus-within {
    border-color: var(--accent);
}

.dv-search-wrap svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.dv-search {
    background: none;
    border: none;
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    width: 180px;
}

.dv-search::placeholder {
    color: var(--text-muted);
}

.dv-export-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--green-dim);
    color: var(--green);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    transition: filter var(--transition-fast);
}
.dv-export-btn:hover { filter: brightness(1.2); }

.dv-close-btn {
    width: 32px;
    height: 32px;
}

.dv-table-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
}

.dv-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dv-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.dv-table th {
    background: var(--surface-2);
    text-align: left;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-dim);
    border-bottom: 2px solid var(--border-light);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.dv-table th:hover {
    color: var(--accent);
}

.dv-table td {
    padding: 6px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dv-table tbody tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.015);
}

.dv-table tbody tr:hover {
    background: rgba(91, 127, 245, 0.06);
}

.dv-null {
    color: var(--text-muted);
    font-style: italic;
}

.dv-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: var(--text-muted);
    font-size: 14px;
}

.dv-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
}

.dv-truncated {
    text-align: center;
    padding: 12px;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}


/* ---- Utility ---- */
.hidden { display: none !important; }

/* ---- Login page ---- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--accent);
}

.login-logo p {
    color: var(--text-dim);
    font-size: 14px;
    margin-top: 6px;
}

.form-group {
    margin-bottom: 20px;
}

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

.form-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition);
}

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

.form-group input::placeholder {
    color: var(--text-dim);
    opacity: 0.6;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition);
    margin-top: 8px;
}

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

.login-error {
    background: var(--red-dim);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
    text-align: center;
}

/* ---- Scrollbar (Webkit) ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }

/* ---- Scrollbar (Firefox) ---- */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--surface-3) transparent;
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
    }
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        width: var(--sidebar-w);
        z-index: 100;
        transition: left 0.25s ease;
    }
    .sidebar.open { left: 0; }
    .sidebar-toggle { display: flex; }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 99;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s ease;
    }
    .sidebar-backdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }

    .chat-messages { padding: 16px; }
    .chat-input-area { padding: 12px 16px; }
    .import-body { padding: 16px; }

    .toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }
    .toast {
        max-width: 100%;
    }

    .dv-panel {
        width: 98vw;
        height: 92vh;
        border-radius: var(--radius);
    }
    .dv-search { width: 120px; }
}
