/* ==========================================================================
   DATA ANALYTICS DEMO — Dark Theme
   Slate/cyan palette. Inter + JetBrains Mono.
   ========================================================================== */

:root {
    /* Dark surface system */
    --surface-0: #0f172a;
    --surface-1: #1e293b;
    --surface-2: #334155;
    --surface-3: #475569;
    --surface-4: #64748b;
    --surface-raised: #1e293b;

    /* Text hierarchy */
    --text-100: #f1f5f9;
    --text-80: #e2e8f0;
    --text-60: #cbd5e1;
    --text-40: #94a3b8;
    --text-30: #64748b;

    /* Accent — cyan */
    --accent: #06b6d4;
    --accent-strong: #22d3ee;
    --accent-muted: rgba(6, 182, 212, 0.15);
    --accent-subtle: rgba(6, 182, 212, 0.08);

    /* Semantic */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #f43f5e;
    --info: #3b82f6;

    /* Borders */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-default: rgba(255, 255, 255, 0.10);
    --border-strong: rgba(255, 255, 255, 0.18);

    /* Type */
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;

    /* Shape */
    --radius-xs: 3px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    /* Motion */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --dur-fast: 150ms;
    --dur-normal: 250ms;
}

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

html, body {
    height: 100%;
    font-family: var(--font-body);
    background: var(--surface-0);
    color: var(--text-100);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ==========================================================================
   LOGIN OVERLAY
   ========================================================================== */
.login-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0c1222 0%, #0f172a 40%, #162032 100%);
}

.login-bg-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    pointer-events: none;
}

.login-bg-orb-1 {
    top: -60px;
    right: -40px;
    width: 380px;
    height: 380px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.2), transparent 70%);
}

.login-bg-orb-2 {
    bottom: -40px;
    left: 60px;
    width: 260px;
    height: 260px;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.12), transparent 70%);
}

.login-card {
    position: relative;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    padding: 32px 28px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
    animation: fadeSlideIn 0.4s var(--ease-out);
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
    justify-content: center;
}

.login-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #0891b2);
    color: #fff;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.35);
}

.login-brand-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text-100);
    letter-spacing: -0.01em;
}

.login-brand-tag {
    font-family: var(--font-mono);
    font-size: 0.54rem;
    color: var(--text-40);
}

.login-field {
    margin-bottom: 14px;
}

.login-field label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-40);
    margin-bottom: 5px;
}

.login-field input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--text-100);
    background: var(--surface-0);
    outline: none;
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.login-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.login-field input::placeholder {
    color: var(--text-30);
}

.login-error {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--danger);
    margin-bottom: 10px;
}

.login-submit {
    width: 100%;
    padding: 10px;
    margin-top: 4px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
}

.login-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Sidebar User ===== */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0 0;
    margin-top: 6px;
    border-top: 1px solid var(--border-subtle);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent-muted);
    color: var(--accent);
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-80);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-rol {
    font-family: var(--font-mono);
    font-size: 0.54rem;
    color: var(--text-40);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.btn-logout {
    background: none;
    border: none;
    color: var(--text-30);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-xs);
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-logout:hover {
    color: var(--danger);
    background: rgba(244, 63, 94, 0.1);
}

/* ===== Layout ===== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--surface-1);
    border-right: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 22px 18px 14px;
    border-bottom: 1px solid var(--border-default);
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-icon {
    color: var(--accent);
    display: flex;
    align-items: center;
}

.brand-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-100);
    letter-spacing: -0.01em;
}

.brand-tag {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 0.56rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-top: 4px;
    background: var(--accent-muted);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
}

/* ===== Sidebar Navigation ===== */
.sidebar-nav {
    display: flex;
    gap: 2px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-default);
}

.nav-item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 10px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-40);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

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

.nav-item.active {
    background: var(--accent-muted);
    color: var(--accent);
}

.nav-item svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.nav-item.active svg,
.nav-item:hover svg {
    opacity: 1;
}

.sidebar-tab-content {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

.sidebar-footer {
    padding: 10px 14px;
    border-top: 1px solid var(--border-default);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ===== Upload Zone ===== */
.upload-zone {
    border: 1.5px dashed var(--border-strong);
    border-radius: var(--radius-md);
    padding: 24px 14px;
    text-align: center;
    cursor: pointer;
    transition: all var(--dur-normal) var(--ease-out);
    background: var(--surface-0);
}

.upload-zone:hover,
.upload-zone.dragover {
    border-color: var(--accent);
    border-style: solid;
    background: var(--accent-subtle);
}

.upload-icon-ring {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    color: var(--text-40);
    transition: all var(--dur-normal) var(--ease-out);
}

.upload-zone:hover .upload-icon-ring {
    border-color: var(--accent);
    color: var(--accent);
}

.upload-zone h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-80);
    margin-bottom: 2px;
}

.upload-zone p {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-40);
    letter-spacing: 0.03em;
}

.upload-zone input[type="file"] { display: none; }

/* ===== Upload Progress ===== */
.upload-progress {
    display: none;
    margin-top: 12px;
    padding: 12px;
    background: var(--surface-0);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
}

.upload-progress.visible {
    display: block;
    animation: fadeSlideIn 0.3s var(--ease-out);
}

.progress-bar {
    height: 2px;
    background: var(--surface-3);
    border-radius: 1px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 1px;
    animation: indeterminate 2s ease-in-out infinite;
}

.progress-text {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    color: var(--text-40);
    margin-top: 6px;
    text-align: center;
}

/* ===== Files Panel ===== */
.files-panel {
    display: none;
}

.files-panel.visible {
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: fadeSlideIn 0.3s var(--ease-out);
}

/* ===== File Card ===== */
.file-card {
    background: var(--surface-0);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    border: 1px solid var(--border-default);
    transition: all var(--dur-fast) var(--ease-out);
    position: relative;
}

.file-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--accent);
    border-radius: 1px;
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}

.file-card:hover {
    border-color: var(--border-strong);
}

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

.file-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.file-card .file-name {
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.7rem;
    color: var(--text-100);
    word-break: break-all;
    flex: 1;
}

.file-delete-btn {
    background: none;
    border: none;
    color: var(--text-30);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 2px 5px;
    border-radius: var(--radius-xs);
    transition: all var(--dur-fast) var(--ease-out);
    flex-shrink: 0;
    line-height: 1;
}

.file-delete-btn:hover {
    color: var(--danger);
    background: rgba(244, 63, 94, 0.1);
}

.file-card .file-meta {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--text-40);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-tables {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 6px;
}

.table-tag {
    font-family: var(--font-mono);
    background: var(--accent-muted);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.56rem;
    font-weight: 500;
}

.badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: var(--radius-xs);
    font-size: 0.52rem;
    font-weight: 600;
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.badge-success {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

/* ===== Add File ===== */
.add-file-zone { margin-top: 8px; }

.btn-add-file {
    width: 100%;
    padding: 7px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-40);
    font-size: 0.7rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-add-file:hover {
    border-color: var(--accent);
    border-style: solid;
    color: var(--accent);
    background: var(--accent-subtle);
}

/* ===== New Session ===== */
.btn-new-session {
    width: 100%;
    padding: 7px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-40);
    font-size: 0.66rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn-new-session:hover {
    border-color: var(--danger);
    color: var(--danger);
}

/* ===== Dashboard sidebar ===== */
.btn-create-dashboard {
    width: 100%;
    padding: 8px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-40);
    font-size: 0.72rem;
    font-family: var(--font-body);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-bottom: 10px;
}

.btn-create-dashboard:hover {
    border-color: var(--accent);
    border-style: solid;
    color: var(--accent);
    background: var(--accent-subtle);
}

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

.dashboard-sidebar-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--surface-0);
    border: 1px solid var(--border-default);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.dashboard-sidebar-item:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
}

.dashboard-sidebar-item .dash-name {
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-80);
}

.dashboard-sidebar-item .dash-meta {
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--text-40);
    margin-top: 2px;
}

/* ==========================================================================
   MAIN AREA
   ========================================================================== */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--surface-0);
}

.view-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

/* ===== View Header ===== */
.view-header {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--surface-1);
}

.view-header h2 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-100);
    flex: 1;
}

/* ===== Chat Header ===== */
.chat-header {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--surface-1);
}

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

.chat-header h2 {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-100);
}

.header-separator {
    color: var(--text-30);
    font-size: 0.85rem;
    font-weight: 300;
}

.header-context {
    font-family: var(--font-mono);
    font-size: 0.62rem;
    color: var(--text-40);
    letter-spacing: 0.03em;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--text-40);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--text-30);
}

.status-dot.online {
    background: var(--success);
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
    animation: pulse 3s ease-in-out infinite;
}

/* ===== Messages ===== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: var(--surface-0);
}

.message {
    max-width: 80%;
    animation: messageIn 0.35s var(--ease-out);
}

.message.user { align-self: flex-end; }
.message.assistant { align-self: flex-start; }

.message-label {
    font-family: var(--font-mono);
    font-size: 0.54rem;
    color: var(--text-30);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    line-height: 1.7;
    color: var(--text-80);
}

.message.user .message-bubble {
    background: var(--accent);
    color: #0f172a;
    border-bottom-right-radius: var(--radius-xs);
}

.message.assistant .message-bubble {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-bottom-left-radius: var(--radius-xs);
}

.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }

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

.message.user .message-bubble strong {
    color: #0f172a;
}

.message-bubble code {
    background: var(--surface-2);
    padding: 2px 6px;
    border-radius: var(--radius-xs);
    font-size: 0.84em;
    font-family: var(--font-mono);
    color: var(--accent);
}

.message.user .message-bubble code {
    background: rgba(0,0,0,0.15);
    color: #0f172a;
}

/* ===== Chart (ECharts) ===== */
.message:has(.chart-container) {
    max-width: 95%;
    width: 95%;
}

.chart-container {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    margin-top: 10px;
    padding: 16px;
    overflow: hidden;
    position: relative;
}

.chart-container .echart {
    width: 100%;
    min-height: 480px;
}

.chart-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 10;
}

.chart-action-btn {
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-40);
    padding: 5px 7px;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-action-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-subtle);
}

/* ===== Chart Modal ===== */
.chart-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 40px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.chart-modal.active {
    display: flex;
    animation: fadeIn 0.2s var(--ease-out);
}

.chart-modal-content {
    width: 100%;
    height: 100%;
    max-width: 1800px;
    max-height: 1000px;
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    border: 1px solid var(--border-default);
    box-shadow: 0 16px 64px rgba(0, 0, 0, 0.4);
}

.chart-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    color: var(--text-80);
    padding: 7px 13px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    cursor: pointer;
    z-index: 10;
    transition: all var(--dur-fast) var(--ease-out);
}

.chart-modal-close:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

.chart-modal .echart {
    width: 100%;
    height: 100%;
}

/* ===== Code Block ===== */
.code-toggle { margin-top: 8px; }

.code-toggle-btn {
    background: none;
    border: none;
    color: var(--text-40);
    font-size: 0.6rem;
    font-family: var(--font-mono);
    cursor: pointer;
    padding: 3px 0;
    transition: color var(--dur-fast) var(--ease-out);
}

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

.code-block {
    display: none;
    background: #020617;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin-top: 6px;
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    line-height: 1.7;
    color: var(--text-60);
    border: 1px solid var(--border-default);
}

.code-block.visible {
    display: block;
    animation: fadeSlideIn 0.2s var(--ease-out);
}

/* ===== Welcome ===== */
.welcome-message {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.welcome-content { max-width: 420px; }

.welcome-icon-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 1px solid var(--border-default);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 18px;
    color: var(--accent);
    background: var(--accent-subtle);
}

.welcome-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-100);
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.welcome-content p {
    color: var(--text-60);
    font-size: 0.84rem;
    line-height: 1.7;
}

.welcome-features {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.feature-pill {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--radius-xl);
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    font-family: var(--font-mono);
    font-size: 0.58rem;
    color: var(--text-40);
}

.feature-pill svg { color: var(--accent); opacity: 0.8; }

/* ===== Input Area ===== */
.input-area {
    padding: 12px 24px 10px;
    border-top: 1px solid var(--border-default);
    background: var(--surface-1);
}

.input-wrapper {
    display: flex;
    gap: 6px;
    align-items: flex-end;
    background: var(--surface-0);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 3px;
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

.input-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.input-wrapper textarea {
    flex: 1;
    background: transparent;
    border: none;
    padding: 9px 11px;
    color: var(--text-100);
    font-size: 0.84rem;
    font-family: var(--font-body);
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 120px;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder { color: var(--text-30); }

.btn-send {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #0f172a;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--accent-strong);
    transform: scale(1.04);
}

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

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

.input-hint {
    font-family: var(--font-mono);
    font-size: 0.52rem;
    color: var(--text-30);
    text-align: center;
    margin-top: 4px;
    letter-spacing: 0.05em;
}

/* ===== Loading ===== */
.loading-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}

.loading-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    animation: loadPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

/* ===== Proposals ===== */
.proposals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 6px;
    margin-top: 10px;
}

.proposal-card {
    display: flex;
    align-items: center;
    padding: 9px 12px;
    background: var(--surface-0);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
    text-align: left;
    font-family: var(--font-body);
    color: var(--text-60);
    font-size: 0.76rem;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
}

.proposal-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--accent);
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-out);
}

.proposal-card:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
    color: var(--text-100);
    transform: translateY(-1px);
}

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

.proposal-label { flex: 1; font-weight: 500; }

/* ===== Error ===== */
.error-text {
    color: var(--danger);
    font-size: 0.7rem;
    font-family: var(--font-mono);
    padding: 8px 10px;
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.15);
    border-radius: var(--radius-sm);
    margin-top: 8px;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn-primary {
    padding: 7px 16px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #0f172a;
    font-family: var(--font-body);
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

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

.btn-secondary {
    padding: 7px 16px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-60);
    font-family: var(--font-body);
    font-size: 0.76rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--dur-fast) var(--ease-out);
}

.btn-secondary:hover {
    border-color: var(--border-strong);
    color: var(--text-100);
}

.btn-danger-sm {
    padding: 4px 10px;
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: var(--radius-xs);
    background: rgba(244, 63, 94, 0.08);
    color: var(--danger);
    font-family: var(--font-body);
    font-size: 0.66rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-danger-sm:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}

.btn-icon-sm {
    background: none;
    border: none;
    color: var(--text-30);
    font-size: 1rem;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-icon-sm:hover { color: var(--danger); }

.btn-back {
    background: none;
    border: none;
    color: var(--text-40);
    font-family: var(--font-body);
    font-size: 0.76rem;
    cursor: pointer;
    padding: 4px 0;
}

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

/* ==========================================================================
   DASHBOARD GRID
   ========================================================================== */
.dashboard-grid {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 20px 24px;
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: min-content;
    gap: 16px;
    align-content: start;
}

.dashboard-chart-card {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 14px;
    min-height: 360px;
    cursor: grab;
}

.dashboard-chart-card:active {
    cursor: grabbing;
}

/* SortableJS drag states */
.sortable-ghost {
    border: 2px dashed var(--accent) !important;
    opacity: 0.4;
    background: var(--accent-subtle) !important;
}

.sortable-drag {
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
    opacity: 0.95;
}

.sortable-chosen {
    outline: 2px solid var(--accent-muted);
    outline-offset: 2px;
}

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

.dashboard-chart-title {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-80);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-40);
    font-size: 0.84rem;
}

.loading-placeholder {
    text-align: center;
    padding: 40px;
    color: var(--text-40);
    font-family: var(--font-mono);
    font-size: 0.7rem;
}

/* ==========================================================================
   MODAL
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 8000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-card {
    background: var(--surface-1);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-default);
}

.modal-header h3 {
    font-size: 0.92rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-30);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-close:hover { color: var(--text-100); }

.modal-body {
    padding: 18px;
}

.modal-body .form-group {
    margin-bottom: 12px;
}

.modal-body .form-group label {
    display: block;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-40);
    margin-bottom: 4px;
}

.modal-body .form-group input,
.modal-body .form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--text-100);
    background: var(--surface-0);
    outline: none;
}

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 18px;
    border-top: 1px solid var(--border-default);
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toast {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.76rem;
    font-weight: 500;
    animation: fadeSlideIn 0.3s var(--ease-out);
    max-width: 320px;
}

.toast-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: var(--success);
}

.toast-error {
    background: rgba(244, 63, 94, 0.15);
    border: 1px solid rgba(244, 63, 94, 0.3);
    color: var(--danger);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-30); }

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

@keyframes loadPulse {
    0%, 80%, 100% { transform: scale(0.5); opacity: 0.3; }
    40% { transform: scale(1.2); opacity: 1; }
}

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

@keyframes indeterminate {
    0% { width: 0%; margin-left: 0%; }
    50% { width: 50%; margin-left: 25%; }
    100% { width: 0%; margin-left: 100%; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .messages-container { padding: 16px 12px; }
    .input-area { padding: 8px 12px; }
    .dashboard-grid { grid-template-columns: 1fr; }
}

::selection {
    background: var(--accent-muted);
    color: var(--text-100);
}
