/* ============================================
   XCALIBER ANALYTICS - STYLES (LIGHT THEME)
   ============================================ */

:root {
    /* Brand Colors */
    --red-700: #B91C1C;
    --red-600: #DC2626;
    --red-500: #EF4444;
    --red-100: #FEE2E2;
    --red-50: #FEF2F2;
    
    /* Neutrals - Light Theme */
    --gray-950: #0A0A0B;
    --gray-900: #18181B;
    --gray-800: #27272A;
    --gray-700: #3F3F46;
    --gray-600: #52525B;
    --gray-500: #71717A;
    --gray-400: #A1A1AA;
    --gray-300: #D4D4D8;
    --gray-200: #E4E4E7;
    --gray-100: #F4F4F5;
    --gray-50: #FAFAFA;
    --white: #FFFFFF;
    
    /* Functional */
    --success: #059669;
    --warning: #D97706;
    --error: #DC2626;
    
    /* Typography */
    --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    
    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
    
    /* Radii */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Sidebar widths */
    --sidebar-width: 280px;
}

/* ============================================
   RESET & BASE
   ============================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    min-height: 100vh;
}

/* ============================================
   SCREENS
   ============================================ */

.screen {
    display: none;
    min-height: 100vh;
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ============================================
   SPLASH SCREEN
   ============================================ */

.splash-screen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s ease;
}

.splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

.splash-screen.hidden {
    display: none;
}

.splash-screen video {
    max-width: 80%;
    max-height: 70vh;
    object-fit: contain;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */

#login-screen {
    display: none;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

#login-screen.active {
    display: flex;
}

.login-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--red-50) 0%, var(--white) 50%, var(--gray-100) 100%);
    z-index: 0;
}

.login-bg::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 80%;
    height: 150%;
    background: radial-gradient(ellipse, rgba(185, 28, 28, 0.08) 0%, transparent 70%);
}

.login-container {
    position: relative;
    z-index: 1;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-10);
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--gray-200);
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-8);
}

.login-header .logo {
    margin-bottom: var(--space-4);
}

.login-crest {
    width: 280px;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.header-crest {
    height: 36px;
    width: auto;
    flex-shrink: 0;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-2);
}

.login-header .tagline {
    color: var(--gray-500);
    font-size: 0.938rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
}

.input-group input,
.input-group select {
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: var(--font-sans);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    background: var(--white);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--red-500);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.input-group input::placeholder {
    color: var(--gray-400);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    background: var(--red-700);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.btn-primary:hover {
    background: var(--red-600);
}

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

.btn-primary-sm {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-4);
    background: var(--red-700);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.813rem;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.btn-primary-sm:hover {
    background: var(--red-600);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: transparent;
    color: var(--gray-600);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.btn-ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.btn-ghost-sm {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    background: transparent;
    color: var(--gray-500);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-ghost-sm:hover {
    background: var(--gray-100);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.error-message {
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* ============================================
   APP HEADER
   ============================================ */

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-3) var(--space-4);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    height: 60px;
    flex-shrink: 0;
}

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

.header-center {
    display: flex;
    align-items: center;
}

.header-center h1 {
    font-size: 1.125rem;
    font-weight: 600;
}

.logo-icon {
    flex-shrink: 0;
}

.app-title {
    font-weight: 600;
    font-size: 1.125rem;
    color: var(--gray-900);
}

.user-email {
    font-size: 0.875rem;
    color: var(--gray-500);
}

/* Hamburger Button */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--gray-600);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.hamburger-btn:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.hamburger-btn.active {
    background: var(--red-50);
    color: var(--red-700);
}

/* ============================================
   APP BODY - THREE COLUMN LAYOUT
   ============================================ */

.app-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    height: calc(100vh - 60px);  /* FIX: Constrain to viewport minus header */
}

/* ============================================
   SIDEBARS (LEFT & RIGHT)
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-color: var(--gray-200);
    overflow-y: auto;
    flex-shrink: 0;
    transition: transform var(--transition-slow), opacity var(--transition-slow);
}

.sidebar-left {
    border-right: 1px solid var(--gray-200);
}

.sidebar-right {
    border-left: 1px solid var(--gray-200);
}

/* Collapsed states — hidden off-screen */
.sidebar-left.collapsed {
    transform: translateX(-100%);
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: var(--shadow-xl);
    pointer-events: none;
    opacity: 0;
}

.sidebar-right.collapsed {
    transform: translateX(100%);
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: var(--shadow-xl);
    pointer-events: none;
    opacity: 0;
}

/* Open state — shown as overlay */
.sidebar-left.open {
    transform: translateX(0);
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: var(--shadow-xl);
    pointer-events: all;
    opacity: 1;
}

.sidebar-right.open {
    transform: translateX(0);
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    box-shadow: var(--shadow-xl);
    pointer-events: all;
    opacity: 1;
}

.sidebar-header {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border-bottom: 1px solid var(--gray-100);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-1);
}

.sidebar-header p {
    font-size: 0.813rem;
    color: var(--gray-500);
}

.schema-section,
.tool-section {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--gray-100);
}

.schema-section h3,
.tool-section h3 {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
}

.schema-section h3 svg,
.tool-section h3 svg {
    color: var(--gray-400);
}

.schema-fields {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.schema-fields li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
}

.schema-fields code {
    font-family: var(--font-mono);
    font-size: 0.813rem;
    color: var(--red-700);
    background: var(--red-50);
    padding: 2px 6px;
    border-radius: 4px;
}

.schema-fields span {
    color: var(--gray-500);
    font-size: 0.813rem;
}

.brand-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.brand-tag {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: var(--gray-100);
    color: var(--gray-600);
    border-radius: 999px;
}

.brand-tag.primary {
    background: var(--red-100);
    color: var(--red-700);
    font-weight: 500;
}

.example-queries {
    padding: var(--space-4) var(--space-5);
}

.example-queries h3 {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-3);
}

.example-btn {
    display: block;
    width: 100%;
    text-align: left;
    padding: var(--space-3);
    margin-bottom: var(--space-2);
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
}

.example-btn:hover {
    background: var(--red-50);
    border-color: var(--red-200);
    color: var(--red-700);
}

/* ============================================
   DROP ZONE
   ============================================ */

.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    background: var(--gray-50);
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--red-400);
    background: var(--red-50);
}

.drop-zone.drag-over {
    transform: scale(1.02);
}

.drop-zone-content svg {
    color: var(--gray-400);
    margin-bottom: var(--space-3);
}

.drop-zone:hover .drop-zone-content svg,
.drop-zone.drag-over .drop-zone-content svg {
    color: var(--red-500);
}

.drop-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: var(--space-1);
}

.drop-hint {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ============================================
   FILE QUEUE
   ============================================ */

.file-queue {
    margin-top: var(--space-4);
}

.file-queue h4 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-2);
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    max-height: 150px;
    overflow-y: auto;
    margin-bottom: var(--space-3);
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2) var(--space-3);
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    font-size: 0.813rem;
}

.file-item-info {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    overflow: hidden;
}

.file-item-name {
    color: var(--gray-700);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-item-size {
    color: var(--gray-400);
    font-size: 0.75rem;
}

.file-item-remove {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-item-remove:hover {
    color: var(--error);
}

.queue-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================
   IMPORT PROGRESS
   ============================================ */

.import-progress {
    margin-top: var(--space-4);
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-2);
}

#progress-filename {
    font-size: 0.813rem;
    font-weight: 500;
    color: var(--gray-700);
}

#progress-percent {
    font-size: 0.813rem;
    font-weight: 600;
    color: var(--red-700);
}

.progress-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: var(--space-2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--red-600), var(--red-500));
    border-radius: 999px;
    width: 0%;
    transition: width var(--transition-fast);
}

.progress-status {
    font-size: 0.75rem;
    color: var(--gray-500);
}

/* ============================================
   IMPORT HISTORY
   ============================================ */

.import-history {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.import-history li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-2);
    font-size: 0.813rem;
}

.history-empty {
    color: var(--gray-400);
    font-style: italic;
}

.history-item {
    background: var(--gray-50);
    border-radius: var(--radius-sm);
}

.history-item-name {
    color: var(--gray-700);
}

.history-item-status {
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: 0.75rem;
}

.history-item-status.success {
    color: var(--success);
}

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

/* ============================================
   DATABASE STATS
   ============================================ */

.db-stats {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.db-stats li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.813rem;
}

.stat-label {
    color: var(--gray-500);
}

.stat-value {
    font-weight: 600;
    color: var(--gray-700);
    font-family: var(--font-mono);
}

/* ============================================
   CHAT AREA
   ============================================ */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--gray-50);
    min-width: 0;
    height: 100%;          /* FIX: Fill parent height */
    overflow: hidden;       /* FIX: Contain children */
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    min-height: 0;         /* FIX: Critical for flex scroll */
}

.welcome-message {
    max-width: 500px;
    margin: auto;
    text-align: center;
    padding: var(--space-10);
}

.welcome-message h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: var(--space-4);
}

.welcome-message p {
    color: var(--gray-600);
    margin-bottom: var(--space-4);
}

.welcome-message ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.welcome-message li {
    color: var(--gray-500);
    font-size: 0.938rem;
}

.message {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-content {
    background: var(--red-700);
    color: var(--white);
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
    padding: var(--space-3) var(--space-4);
    max-width: 80%;
}

.message-assistant .message-content {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm) var(--radius-lg) var(--radius-lg) var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}

.message-content p {
    margin-bottom: var(--space-3);
}

.message-content p:last-child {
    margin-bottom: 0;
}

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

.message-content code {
    font-family: var(--font-mono);
    font-size: 0.875em;
    background: var(--gray-100);
    padding: 2px 6px;
    border-radius: 4px;
}

.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: var(--space-3) 0;
    font-size: 0.875rem;
}

.message-content th,
.message-content td {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--gray-200);
}

.message-content th {
    font-weight: 600;
    background: var(--gray-50);
}

.loading-dots {
    display: flex;
    gap: 4px;
    padding: var(--space-2) 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--gray-400);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0.8); }
    40% { transform: scale(1.2); }
}

/* ============================================
   CHAT INPUT
   ============================================ */

.chat-input-area {
    padding: var(--space-4) var(--space-6);
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    flex-shrink: 0;        /* FIX: Never shrink */
    position: relative;    /* FIX: Stay in flow */
    z-index: 10;           /* FIX: Above messages */
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: var(--space-3);
    max-width: 800px;
    margin: 0 auto;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: var(--space-2);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--red-400);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

#chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 1rem;
    resize: none;
    padding: var(--space-2);
    max-height: 150px;
    line-height: 1.5;
}

#chat-input:focus {
    outline: none;
}

#chat-input::placeholder {
    color: var(--gray-400);
}

.send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--red-700);
    color: var(--white);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--red-600);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.input-hint {
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: var(--space-2);
}

/* ============================================
   ADMIN SCREEN
   ============================================ */

.admin-body {
    flex: 1;
    padding: var(--space-8);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-6);
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.admin-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
}

.admin-card h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: var(--space-5);
    color: var(--gray-900);
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.form-message {
    font-size: 0.875rem;
    padding: var(--space-2);
    border-radius: var(--radius-sm);
}

.form-message.success {
    background: rgba(5, 150, 105, 0.1);
    color: var(--success);
}

.form-message.error {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error);
}

.users-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.user-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: var(--gray-50);
    border-radius: var(--radius-md);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.user-name {
    font-weight: 500;
    color: var(--gray-900);
}

.user-meta {
    font-size: 0.813rem;
    color: var(--gray-500);
}

.user-role {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 500;
}

.user-role.admin {
    background: var(--red-100);
    color: var(--red-700);
}

.user-role.viewer {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--white);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-xl);
}

.modal-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-3);
}

.modal-content p {
    color: var(--gray-600);
    margin-bottom: var(--space-5);
    font-size: 0.938rem;
}

.modal-actions {
    margin-top: var(--space-5);
}

.api-key-note {
    margin-top: var(--space-4);
    font-size: 0.813rem;
    color: var(--gray-500);
}

.api-key-note a {
    color: var(--red-600);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1200px) {
    /* Right sidebar auto-collapses — JS handles the rest */
}

@media (max-width: 900px) {
    /* Left sidebar auto-collapses — JS handles the rest */
    .header-tabs .header-tab span {
        display: none;
    }
    .header-tabs .header-tab {
        padding: 6px 10px;
        gap: 0;
    }
}

@media (max-width: 640px) {
    .app-title {
        display: none;
    }
    
    .user-email {
        display: none;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .chat-messages {
        padding: var(--space-4);
    }
    
    .chat-input-area {
        padding: var(--space-3);
    }
    
    .sidebar {
        width: 100%;
        max-width: 320px;
    }
}

/* Sidebar overlay — dims content when sidebar is open on small screens */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 199;
    cursor: pointer;
}

.sidebar-overlay.active {
    display: block;
}

/* ============================================
   PASTE DATA SECTION (FIX #3)
   ============================================ */

.section-hint {
    font-size: 0.813rem;
    color: var(--gray-500);
    margin-bottom: var(--space-3);
}

.paste-textarea {
    width: 100%;
    min-height: 120px;
    padding: var(--space-3);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.813rem;
    line-height: 1.5;
    resize: vertical;
    background: var(--white);
    color: var(--gray-900);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.paste-textarea:focus {
    outline: none;
    border-color: var(--red-500);
    box-shadow: 0 0 0 3px var(--red-100);
}

.paste-textarea::placeholder {
    color: var(--gray-400);
}

.paste-controls {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.format-select {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font-size: 0.813rem;
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
}

.format-select:focus {
    outline: none;
    border-color: var(--red-500);
}

.paste-buttons {
    display: flex;
    gap: var(--space-2);
    margin-left: auto;
}

/* History item improvements */
.history-item-status {
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.history-item-status.success {
    color: var(--green-600);
}

.history-item-status.error {
    color: var(--red-600);
}

/* ============================================
   XA SMART CHAT ADDITIONS
   ============================================ */

.app-title-group {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.app-subtitle {
    font-size: 0.7rem;
    color: var(--text-tertiary, #71717A);
    font-weight: 500;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: var(--text-tertiary, #71717A);
    padding: 4px 10px;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
}

.connection-status.connected {
    color: #22C55E;
}

.connection-status.disconnected {
    color: #EF4444;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

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

.welcome-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.xa-logo {
    display: inline-block;
    margin-bottom: 0.5rem;
}

.welcome-header h2 {
    margin: 0.5rem 0 0.25rem;
    color: var(--text-primary, #FAFAFA);
}

.powered-by {
    font-size: 0.8rem;
    color: var(--text-tertiary, #71717A);
    margin: 0;
}

.welcome-message .hint {
    font-size: 0.85rem;
    color: var(--text-secondary, #A1A1AA);
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}


.sql-block, .json-block {
    background: #1a1a2e !important;  /* FIX: Dark background for contrast */
    border: 1px solid #2d2d44 !important;
    border-radius: 8px;
    padding: 14px 16px;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    line-height: 1.55;
    margin: 0.75rem 0;
    color: #e2e8f0;  /* FIX: Light text */
}

.sql-block {
    border-left: 3px solid #F59E0B !important;  /* FIX: Amber accent */
}

.json-block {
    border-left: 3px solid #60a5fa !important;  /* FIX: Blue accent */
}

.sql-block code,
.json-block code {
    color: #e2e8f0 !important;  /* FIX: Light text for readability */
    background: transparent !important;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
    background: #FAFAFA;
    border-radius: 8px;
    overflow: hidden;
}

.results-table th,
.results-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #E5E5E5;
    color: #374151;
}

.results-table th {
    background: #F3F4F6;
    color: #6B7280;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.results-table tr:hover td {
    background: #F9FAFB;
}

.message-assistant .message-content {
    background: #3B3B3B;
    border: 1px solid #4A4A4A;
    color: #F5F5F5;
}

.message-assistant .message-content p {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.message-assistant .message-content strong {
    color: #FCD34D;
    font-weight: 600;
}

.message-assistant .message-content code {
    background: rgba(251, 191, 36, 0.15);
    color: #FBBF24;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85em;
}

    height: 6px;
    border-radius: 50%;
    background: #F59E0B;
    animation: bounce 1.4s ease-in-out infinite;
}

.message.loading .loading-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.message.loading .loading-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes bounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

/* ============================================
   VOICE MEMOS STYLES
   ============================================ */

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    gap: 4px;
    background: rgba(30, 41, 59, 0.5);
    padding: 4px;
    border-radius: 10px;
    margin-right: 16px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-tab:hover {
    color: #e2e8f0;
    background: rgba(71, 85, 105, 0.3);
}

.nav-tab.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.nav-tab svg {
    width: 16px;
    height: 16px;
}

/* Memos Area */

/* ============================================
   VOICE MEMOS - FIELD INTELLIGENCE DASHBOARD
   Light theme, high contrast, amber accents
   ============================================ */

.memos-area {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    overflow: hidden;
}

.memos-area.hidden {
    display: none;
}

.memos-container {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 0;
    height: 100%;
    overflow: hidden;
}

/* ============================================
   MEMO LIST PANEL - LEFT SIDE
   ============================================ */

.memo-list-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-right: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.03);
}

.memo-list-header {
    padding: 24px 20px 20px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-bottom: 1px solid #e2e8f0;
}

.memo-list-header h2 {
    font-family: 'DM Sans', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.memo-list-header p {
    font-size: 13px;
    color: #64748b;
    font-weight: 400;
}

/* Filter Pills */
.memo-filters {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.filter-btn {
    padding: 8px 16px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    color: #475569;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

.filter-btn.active {
    background: #F59E0B;
    border-color: #F59E0B;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.35);
}

/* Memo List Scroll Area */
.memo-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
}

.memo-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #94a3b8;
    gap: 16px;
}

.loading-dots {
    display: flex;
    gap: 6px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #F59E0B;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* ============================================
   MEMO CARD - CLEAN & READABLE
   ============================================ */

.memo-card {
    padding: 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.25s ease;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.memo-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.memo-card.selected {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #F59E0B;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.2);
}

.memo-card-header {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

/* Memo Icon */
.memo-icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    border-radius: 12px;
    color: #64748b;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.memo-icon svg {
    width: 20px;
    height: 20px;
}

.memo-card.selected .memo-icon {
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

/* Memo Info */
.memo-info {
    flex: 1;
    min-width: 0;
}

.memo-id {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 6px;
}

.memo-address {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #475569;
    margin-bottom: 10px;
    font-weight: 400;
}

.memo-address svg {
    width: 14px;
    height: 14px;
    color: #94a3b8;
    flex-shrink: 0;
}

/* Memo Meta Row */
.memo-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
    color: #64748b;
}

.memo-meta svg {
    width: 12px;
    height: 12px;
}

.memo-meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Stats Badges */
.memo-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.stat-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.stat-badge svg {
    width: 12px;
    height: 12px;
}

.stat-badge.products {
    background: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.stat-badge.pricing {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.stat-badge.buydowns {
    background: #fffbeb;
    color: #d97706;
    border: 1px solid #fde68a;
}

/* Status Badge */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-badge.processed {
    background: #dcfce7;
    color: #16a34a;
}

.status-badge.processing {
    background: #fef3c7;
    color: #d97706;
}

.status-badge.pending {
    background: #f1f5f9;
    color: #64748b;
}

/* Confidence Score */
.confidence-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 600;
}

.confidence-score.high { color: #16a34a; }
.confidence-score.medium { color: #d97706; }
.confidence-score.low { color: #dc2626; }

/* ============================================
   MEMO DETAIL PANEL - RIGHT SIDE
   ============================================ */

.memo-detail-panel {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    overflow: hidden;
}

.memo-detail-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    gap: 16px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
}

.memo-detail-empty svg {
    width: 56px;
    height: 56px;
    opacity: 0.4;
    color: #cbd5e1;
}

.memo-detail-empty p {
    font-size: 15px;
    color: #64748b;
}

.memo-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

/* Detail Header */
.memo-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
    border-bottom: 1px solid #e2e8f0;
}

.memo-detail-title {
    display: flex;
    align-items: center;
    gap: 14px;
}

.memo-detail-title .icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    border-radius: 12px;
    color: white;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.memo-detail-title .icon svg {
    width: 22px;
    height: 22px;
}

.memo-detail-title h3 {
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 3px;
}

.memo-detail-title p {
    font-size: 13px;
    color: #64748b;
}

.close-detail-btn {
    width: 36px;
    height: 36px;
    display: none;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: none;
    border-radius: 10px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s;
}

.close-detail-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Detail Sections */
.memo-sections {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #f8fafc;
}

.memo-section {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.memo-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #fafbfc;
    border-bottom: 1px solid #e2e8f0;
}

.memo-section-header h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.memo-section-header h4 svg {
    width: 14px;
    height: 14px;
    color: #94a3b8;
}

.memo-section-body {
    padding: 18px;
}

/* Audio Player */
.audio-player {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.play-btn {
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    flex-shrink: 0;
}

.play-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(245, 158, 11, 0.45);
}

.play-btn svg {
    width: 20px;
    height: 20px;
}

.audio-progress {
    flex: 1;
}

.audio-progress .progress-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.audio-progress .progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #F59E0B, #D97706);
    border-radius: 3px;
    transition: width 0.1s;
}

.progress-times {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 11px;
    color: #94a3b8;
    font-family: 'JetBrains Mono', monospace;
}

/* Location Card */
.location-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
}

.location-card svg {
    width: 20px;
    height: 20px;
    color: #F59E0B;
}

.location-card span {
    color: #1e293b;
    font-size: 14px;
    font-weight: 500;
}

/* Transcript */
.transcript-text {
    font-size: 14px;
    line-height: 1.75;
    color: #334155;
}

.transcript-toggle {
    font-size: 13px;
    color: #F59E0B;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 500;
    margin-top: 12px;
    padding: 0;
}

.transcript-toggle:hover {
    color: #D97706;
    text-decoration: underline;
}

/* Product Cards */
.product-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.product-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    border-radius: 10px;
}

.product-name {
    color: #047857;
    font-weight: 600;
    font-size: 14px;
}

.product-variant {
    color: #059669;
    margin-left: 8px;
    font-weight: 400;
}

.product-sku {
    padding: 5px 12px;
    background: #d1fae5;
    border-radius: 8px;
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    color: #047857;
    font-weight: 500;
}

/* Pricing Table */
.pricing-table {
    width: 100%;
    border-collapse: collapse;
}

.pricing-table th {
    text-align: left;
    padding: 12px 14px;
    background: #f8fafc;
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #e2e8f0;
}

.pricing-table th:last-child,
.pricing-table td:last-child {
    text-align: right;
}

.pricing-table td {
    padding: 14px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
    color: #1e293b;
}

.pricing-table tr:last-child td {
    border-bottom: none;
}

.pricing-table tr:hover td {
    background: #fafbfc;
}

.pricing-table .brand-name {
    font-weight: 600;
}

.pricing-table .buydown-badge {
    margin-left: 8px;
    padding: 3px 8px;
    background: #fef3c7;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #d97706;
}

.pricing-table .price {
    font-family: 'JetBrains Mono', monospace;
    color: #2563eb;
    font-weight: 500;
}

.pricing-table .type {
    color: #64748b;
    text-transform: capitalize;
    font-size: 13px;
}

/* Buydown Cards */
.buydown-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.buydown-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
}

.buydown-brand {
    color: #92400e;
    font-weight: 600;
    font-size: 14px;
}

.buydown-amount {
    padding: 5px 12px;
    background: #fde68a;
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #92400e;
    font-weight: 600;
}

/* AI Summary */
.summary-card {
    padding: 18px;
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fde68a;
    border-radius: 12px;
}

.summary-text {
    font-size: 14px;
    line-height: 1.7;
    color: #374151;
    font-style: italic;
    margin-bottom: 14px;
}

.summary-meta {
    display: flex;
    gap: 20px;
    padding-top: 14px;
    border-top: 1px solid rgba(245, 158, 11, 0.2);
}

.summary-meta span {
    font-size: 12px;
    color: #92400e;
}

.summary-meta .value {
    font-weight: 600;
    text-transform: capitalize;
}

.summary-meta .value.high { color: #dc2626; }
.summary-meta .value.medium { color: #d97706; }
.summary-meta .value.low { color: #64748b; }

/* Memo Detail Footer */
.memo-detail-footer {
    padding: 16px 24px;
    background: #fafbfc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #64748b;
}

/* No Memos State */
.no-memos {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #94a3b8;
    text-align: center;
}

.no-memos svg {
    width: 56px;
    height: 56px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.no-memos p {
    font-size: 15px;
    color: #64748b;
}

/* ============================================
   MEMO CARD ANIMATIONS
   ============================================ */

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

.memo-card {
    animation: memoSlideIn 0.3s ease forwards;
}

.memo-card:nth-child(1) { animation-delay: 0.05s; }
.memo-card:nth-child(2) { animation-delay: 0.1s; }
.memo-card:nth-child(3) { animation-delay: 0.15s; }
.memo-card:nth-child(4) { animation-delay: 0.2s; }
.memo-card:nth-child(5) { animation-delay: 0.25s; }

/* ============================================
   RESPONSIVE - VOICE MEMOS
   ============================================ */

@media (max-width: 900px) {
    .memos-container {
        grid-template-columns: 1fr;
    }
    
    .memo-list-panel {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
    
    .memo-detail-panel {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    
    .memo-detail-panel.open {
        transform: translateX(0);
    }
    
    .close-detail-btn {
        display: flex;
    }
    
    .nav-tabs {
        display: none;
    }
}

/* ============================================
   CALL NOTES - STORE LINK & SYNOPSIS
   ============================================ */

.store-link-section {
    margin-bottom: 12px;
}

.store-link-card {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 12px;
    border: 1px solid var(--border);
}

.store-link-card.linked {
    border-color: rgba(16, 185, 129, 0.3);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, transparent 100%);
}

.store-link-card.unlinked {
    border-color: rgba(245, 158, 11, 0.3);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, transparent 100%);
}

.store-link-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8125rem;
    font-weight: 500;
    margin-bottom: 8px;
}

.store-link-card.linked .store-link-status {
    color: #10B981;
}

.store-link-card.unlinked .store-link-status {
    color: #F59E0B;
}

.store-link-detail {
    font-size: 0.9375rem;
    color: var(--text);
}

.store-link-detail strong {
    font-weight: 600;
}

.link-store-btn {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.link-store-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.store-link-note {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}

.store-link-note small {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Synopsis Section */
.synopsis-section {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, transparent 100%);
    border-radius: 8px;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.synopsis-text {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text);
    font-weight: 500;
}

/* Memo card synopsis preview */
.memo-synopsis {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Status badges */
.status-badge.linked {
    background: rgba(16, 185, 129, 0.15);
    color: #10B981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.unlinked {
    background: rgba(245, 158, 11, 0.15);
    color: #F59E0B;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.sequence-badge {
    background: rgba(99, 102, 241, 0.15);
    color: #818CF8;
    border: 1px solid rgba(99, 102, 241, 0.3);
    font-size: 0.6875rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* ============================================
   HEADER TABS - Call Logs / Smart Chat Toggle
   LIGHT THEME with proper contrast for field reps
   ============================================ */

/* Tab Navigation Container */
.header-tabs {
    display: flex;
    gap: 4px;
    background: #f1f5f9;
    border-radius: 8px;
    padding: 4px;
    margin: 0 16px;
}

/* Individual Tab Button */
.header-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: #475569;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.header-tab:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #1e293b;
}

.header-tab.active {
    background: white;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.header-tab svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.header-tab span {
    white-space: nowrap;
}

/* Tab Content Areas */
.tab-content {
    display: none !important;
}

.tab-content.active {
    display: flex !important;
    flex-direction: column;
    flex: 1;
}

/* ============================================
   CALL LOGS TAB CONTENT
   ============================================ */

.call-logs-area {
    background: #ffffff;
    padding: 24px;
    overflow-y: auto;
}

.call-logs-container {
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.call-logs-header {
    margin-bottom: 24px;
}

.call-logs-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: #0f172a;
    margin: 0 0 4px 0;
}

.call-logs-header p {
    color: #475569;
    margin: 0;
}

.audio-drop-zone {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    margin-bottom: 16px;
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    background: var(--gray-50);
    color: var(--gray-500);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.audio-drop-zone:hover {
    border-color: var(--red-500);
    background: var(--red-50);
    color: var(--red-700);
}

.audio-drop-zone.drag-over {
    border-color: var(--red-600);
    background: var(--red-100);
    color: var(--red-700);
}

.audio-drop-zone strong {
    text-decoration: underline;
}

.call-logs-body {
    display: flex;
    gap: 16px;
}

.call-logs-body .call-logs-list {
    flex: 1;
    min-width: 0;
}

.memo-detail-panel {
    flex: 1;
    min-width: 0;
    display: none;
}

.memo-detail-panel.active {
    display: block;
}

.call-logs-search {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.call-logs-search input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    background: #f8fafc;
    color: #0f172a;
}

.call-logs-search input::placeholder {
    color: #94a3b8;
}

.call-logs-search input:focus {
    outline: none;
    border-color: #3b82f6;
    background: white;
}

.call-logs-search .search-btn {
    padding: 12px 16px;
    background: #3b82f6;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
}

.call-logs-search .search-btn:hover {
    background: #2563eb;
}

.call-logs-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.call-log-empty {
    text-align: center;
    padding: 60px 24px;
    color: #64748b;
}

.call-log-empty svg {
    margin-bottom: 16px;
    color: #94a3b8;
}

.call-log-empty p {
    margin: 0;
}

.call-log-empty .hint {
    font-size: 13px;
    color: #94a3b8;
    margin-top: 8px;
}

/* Audio Upload Modal */
.audio-file-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #f8fafc;
    border-radius: 12px;
    margin-bottom: 20px;
}

.audio-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.audio-filename {
    font-weight: 600;
    color: #0f172a;
}

.audio-meta {
    display: flex;
    gap: 8px;
    font-size: 13px;
    color: #64748b;
}

.audio-divider {
    color: #cbd5e1;
}

.audio-context {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.audio-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #475569;
    margin-bottom: 6px;
}

.audio-field input,
.audio-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    color: #0f172a;
    background: white;
    box-sizing: border-box;
}

.audio-field input:focus,
.audio-field textarea:focus {
    outline: none;
    border-color: #10B981;
}

.audio-processing-info {
    background: #f0fdf4;
    border-radius: 12px;
    padding: 16px;
}

.processing-step {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.step-icon {
    font-size: 18px;
}

.step-text {
    font-size: 13px;
    color: #166534;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .header-tabs {
        margin: 0 8px;
        padding: 3px;
    }
    
    .header-tab {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .header-tab span {
        display: none;
    }
    
    .header-tab svg {
        width: 20px;
        height: 20px;
    }
    
    .call-logs-area {
        padding: 16px;
    }
}

/* ============================================
   CHARTS TAB — XA Smart Chat
   ============================================ */

.charts-area {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary, #0f1117);
}

.charts-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

/* ---- Left Controls Panel ---- */
.charts-controls {
    width: 260px;
    min-width: 220px;
    max-width: 280px;
    background: var(--bg-secondary, #161b22);
    border-right: 1px solid var(--border-color, #21262d);
    overflow-y: auto;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-shrink: 0;
}

.chart-ctrl-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chart-ctrl-title {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #B91C1C;
    display: flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(185,28,28,0.2);
}

.chart-ctrl-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-ctrl-field label {
    font-size: 0.75rem;
    color: var(--text-muted, #8b949e);
    font-weight: 500;
}

.chart-ctrl-field select,
.chart-ctrl-field input[type="text"] {
    background: var(--bg-primary, #0f1117);
    border: 1px solid var(--border-color, #21262d);
    border-radius: 6px;
    color: var(--text-primary, #e6edf3);
    font-size: 0.82rem;
    padding: 6px 8px;
    width: 100%;
    outline: none;
    transition: border-color 0.15s;
}

.chart-ctrl-field select:focus,
.chart-ctrl-field input[type="text"]:focus {
    border-color: #B91C1C;
}

.chart-ctrl-field select[multiple] {
    padding: 4px;
    min-height: 80px;
}

.chart-ctrl-field select[multiple] option {
    padding: 4px 6px;
    border-radius: 3px;
}

.chart-ctrl-field select[multiple] option:checked {
    background: #B91C1C;
    color: #fff;
}

.chart-ctrl-hint {
    font-size: 0.68rem;
    color: var(--text-muted, #8b949e);
    opacity: 0.7;
    margin-top: -2px;
}

.chart-ctrl-toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-top: 2px;
}

.chart-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary, #8d96a0);
    user-select: none;
}

.chart-toggle input[type="checkbox"] {
    accent-color: #B91C1C;
    width: 13px;
    height: 13px;
    cursor: pointer;
}

/* Chart Type Grid */
.chart-type-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chart-type-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chart-group-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted, #8b949e);
    padding: 2px 0;
}

.chart-type-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.chart-type-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: var(--bg-primary, #0f1117);
    border: 1.5px solid var(--border-color, #21262d);
    border-radius: 6px;
    color: var(--text-secondary, #8d96a0);
    cursor: pointer;
    padding: 5px 6px;
    min-width: 54px;
    transition: border-color 0.12s, background 0.12s, color 0.12s;
    flex: 1;
    min-width: 44px;
    max-width: 70px;
}

.chart-type-btn:hover {
    border-color: #B91C1C;
    color: #F9FAFB;
}

.chart-type-btn.active {
    border-color: #B91C1C;
    background: rgba(185,28,28,0.18);
    color: #EF4444;
}

.chart-type-icon {
    font-size: 1.1rem;
    line-height: 1;
    letter-spacing: -0.05em;
}

.chart-type-label {
    font-size: 0.63rem;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

/* Render + Download Buttons */
.chart-render-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: #B91C1C;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    width: 100%;
    margin-top: 4px;
}

.chart-render-btn:hover { background: #991B1B; }
.chart-render-btn:active { background: #7F1D1D; }

.chart-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: transparent;
    color: var(--text-secondary, #8d96a0);
    border: 1.5px solid var(--border-color, #21262d);
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 0.82rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
    width: 100%;
}

.chart-download-btn:hover {
    border-color: #B91C1C;
    color: #EF4444;
}

/* ---- Right Charts Main ---- */
.charts-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 16px;
    gap: 14px;
    min-width: 0;
}

.chart-canvas-wrap {
    flex: 1;
    min-height: 0;
    position: relative;
    background: var(--bg-secondary, #161b22);
    border: 1px solid var(--border-color, #21262d);
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#xa-chart-canvas {
    width: 100% !important;
    height: 100% !important;
    display: block;
    padding: 16px;
    box-sizing: border-box;
}

.chart-no-data {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted, #8b949e);
    padding: 40px;
    text-align: center;
}

.chart-no-data p {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-secondary, #8d96a0);
}

.chart-no-data-hint {
    font-size: 0.8rem !important;
    opacity: 0.6;
}

/* ---- Data Preview ---- */
.chart-data-preview {
    background: var(--bg-secondary, #161b22);
    border: 1px solid var(--border-color, #21262d);
    border-radius: 10px;
    max-height: 160px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chart-data-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color, #21262d);
    background: rgba(255,255,255,0.02);
}

.chart-data-preview-header span {
    font-size: 0.75rem;
    color: var(--text-muted, #8b949e);
    font-weight: 500;
}

.chart-clear-btn {
    background: none;
    border: none;
    color: var(--text-muted, #8b949e);
    cursor: pointer;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    transition: color 0.12s, background 0.12s;
}

.chart-clear-btn:hover {
    color: #EF4444;
    background: rgba(239,68,68,0.1);
}

.chart-preview-table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    flex: 1;
}

.chart-preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.chart-preview-table th {
    background: rgba(185,28,28,0.12);
    color: #F87171;
    padding: 4px 10px;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color, #21262d);
    position: sticky;
    top: 0;
}

.chart-preview-table td {
    padding: 3px 10px;
    color: var(--text-secondary, #8d96a0);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    white-space: nowrap;
}

.chart-preview-table tr:last-child td {
    border-bottom: none;
}

/* ---- Chart Checkbox in Chat ---- */
.chart-checkbox-bar {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.chart-cb-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 20px;
    background: rgba(185,28,28,0.08);
    border: 1px solid rgba(185,28,28,0.2);
    font-size: 0.78rem;
    color: var(--text-muted, #8b949e);
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    user-select: none;
}

.chart-cb-label:hover {
    background: rgba(185,28,28,0.15);
    border-color: rgba(185,28,28,0.4);
    color: #F87171;
}

.chart-cb-label input[type="checkbox"] {
    accent-color: #B91C1C;
    width: 13px;
    height: 13px;
    cursor: pointer;
}

.chart-cb-label:has(input:checked) {
    background: rgba(185,28,28,0.2);
    border-color: #B91C1C;
    color: #EF4444;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .charts-layout {
        flex-direction: column;
    }
    .charts-controls {
        width: 100%;
        max-width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color, #21262d);
        max-height: 280px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }
    .chart-ctrl-section {
        flex: 1;
        min-width: 140px;
    }
    .charts-main {
        padding: 10px;
    }
}

/* ============================================
   RESPONSIVE HEADER FIXES
   ============================================ */

/* At medium widths, compress the right side */
@media (max-width: 900px) {
    .connection-status .status-dot + span {
        display: none; /* hide "Connected" text, keep dot */
    }
    .connection-status {
        padding: 4px 8px;
        gap: 4px;
    }
    .user-email {
        display: none;
    }
    .app-subtitle {
        display: none;
    }
    .header-tabs {
        margin: 0 6px;
        padding: 3px;
    }
    .header-tab {
        padding: 6px 9px;
    }
    .header-tab span {
        display: none;
    }
}

@media (max-width: 540px) {
    .app-header {
        padding: var(--space-2) var(--space-2);
        gap: 4px;
    }
    .header-left {
        gap: var(--space-2);
        flex-shrink: 0;
    }
    .header-right {
        gap: var(--space-1);
        flex-shrink: 0;
    }
    .btn-ghost {
        font-size: 12px;
        padding: 4px 8px;
    }
    .header-tabs {
        margin: 0 4px;
        gap: 2px;
    }
    .app-title-group {
        display: none;
    }
}
