:root {
    --primary: #18181b;       /* Zinc 900 */
    --primary-dark: #09090b;  /* Zinc 950 */
    --primary-light: #f4f4f5; /* Zinc 100 */
    --bg-color: #fafafa;      /* Zinc 50 */
    --chat-bg: #ffffff;       /* Pure white */
    --text-primary: #27272a;  /* Zinc 800 */
    --text-secondary: #71717a; /* Zinc 500 */
    --sidebar-bg: #f8f8f8;
    --sidebar-text: #3f3f46;  /* Zinc 700 */
    --border: #e4e4e7;        /* Zinc 200 */
    --user-msg-bg: #18181b;   /* Zinc 900 */
    --bot-msg-bg: #f4f4f5;    /* Zinc 100 */
    --radius: 18px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Stats accent colors */
    --accent-violet: #8b5cf6;
    --accent-violet-light: #ede9fe;
    --accent-blue: #3b82f6;
    --accent-blue-light: #dbeafe;
    --accent-emerald: #10b981;
    --accent-emerald-light: #d1fae5;
    --accent-amber: #f59e0b;
    --accent-amber-light: #fef3c7;
    --accent-rose: #f43f5e;
    --accent-rose-light: #ffe4e6;
    --accent-cyan: #06b6d4;
    --accent-cyan-light: #cffafe;
    --accent-indigo: #6366f1;
    --accent-indigo-light: #e0e7ff;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* ============================================ */
/* Sidebar Styling                              */
/* ============================================ */
.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 32px 24px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.sidebar-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: 1px solid var(--border);
}

/* ============================================ */
/* Navigation Tabs                              */
/* ============================================ */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 24px;
}

.nav-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    text-align: left;
}

.nav-tab:hover {
    background: white;
    color: var(--text-primary);
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.nav-tab.active {
    background: white;
    color: var(--primary);
    border-color: var(--border);
    box-shadow: var(--shadow-md);
    font-weight: 600;
}

.nav-tab svg {
    flex-shrink: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

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

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0; /* permet à .chat-history-list de scroller sans pousser le footer hors écran */
}

.sidebar-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 28px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.pulse {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #10b981;
    box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.secondary-btn {
    width: 100%;
    padding: 12px 16px;
    background: white;
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    font-family: inherit;
    box-shadow: var(--shadow-sm);
}

.secondary-btn:hover {
    background: var(--primary-light);
    border-color: #d4d4d8;
}

/* ============================================ */
/* Historique des conversations (sidebar)        */
/* ============================================ */
.chat-history-section {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    margin-top: 20px;
}

.chat-history-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0 -8px;
    padding: 0 8px;
}

.chat-history-empty {
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-style: italic;
    padding: 8px 0;
}

.chat-history-item {
    position: relative;
    padding: 10px 30px 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.chat-history-item:hover {
    background: white;
    border-color: var(--border);
}

.chat-history-item.active {
    background: white;
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}

.chat-history-item-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.chat-history-item-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item-date {
    font-size: 0.7rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.chat-history-item-preview {
    font-size: 0.78rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 2px;
}

.chat-history-item-detail {
    font-size: 0.72rem;
    color: var(--primary);
    opacity: 0.7;
    margin-top: 3px;
}

.chat-history-delete-btn {
    position: absolute;
    top: 8px;
    right: 6px;
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
}

.chat-history-item:hover .chat-history-delete-btn {
    display: flex;
}

.chat-history-delete-btn:hover {
    background: var(--accent-rose-light);
    color: var(--accent-rose);
}

/* ============================================ */
/* Popup de profil (nom, prénom, formation/rôle) */
/* ============================================ */
.profile-modal-content {
    max-width: 440px !important;
}

.profile-modal-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.profile-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 320px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.profile-list-empty {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-style: italic;
    padding: 8px 0 16px;
}

.profile-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-row:hover {
    background: var(--primary-light);
    border-color: #d4d4d8;
}

.profile-row-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.profile-row-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-row-detail {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.profile-delete-btn {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--accent-rose);
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-delete-btn:hover {
    background: var(--accent-rose-light);
    border-color: rgba(244, 63, 94, 0.25);
}

.profile-new-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-field-label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.profile-field-label input {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    background: white;
}

.profile-field-label input:focus {
    outline: none;
    border-color: var(--primary);
}

.profile-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
}

.profile-submit-btn {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.profile-submit-btn:hover {
    background: var(--primary-dark);
}

/* ============================================ */
/* Chat Section Styling                         */
/* ============================================ */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
    overflow: hidden;
}

.chat-header {
    padding: 24px 40px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    z-index: 10;
}

.chat-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.01em;
}

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

/* ============================================ */
/* Mode Selector (Tester en tant que...)        */
/* ============================================ */
.mode-selector {
    position: relative;
}

.mode-selector-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.mode-selector-btn:hover {
    border-color: #d4d4d8;
}

.mode-selector-chevron {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.mode-selector.open .mode-selector-chevron {
    transform: rotate(180deg);
}

.mode-selector-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-lg);
    padding: 8px;
    width: 300px;
    display: none;
    flex-direction: column;
    gap: 4px;
    z-index: 100;
}

.mode-selector.open .mode-selector-menu {
    display: flex;
}

.mode-option {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    width: 100%;
    transition: all 0.15s ease;
}

.mode-option:hover {
    background: var(--primary-light);
}

.mode-option.selected {
    background: var(--primary-light);
    border-color: var(--border);
}

.mode-option-icon {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary);
}

.mode-option-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.mode-option-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mode-option-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.mode-option-check {
    margin-left: auto;
    color: var(--text-primary);
    flex-shrink: 0;
    visibility: hidden;
}

.mode-option.selected .mode-option-check {
    visibility: visible;
}

.course-badge {
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 40px;
    display: flex;
    flex-direction: column;
    gap: 32px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 20px;
    max-width: 85%;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.2rem;
    background: var(--primary-light);
    color: var(--primary);
    border: 1px solid var(--border);
}

.message.user .avatar {
    background: var(--primary);
    color: white;
    border: none;
}

.bubble {
    padding: 18px 24px;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.message.user .bubble {
    background: var(--user-msg-bg);
    color: white;
    border-top-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.message.bot .bubble {
    background: var(--bot-msg-bg);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
}

.bubble p {
    margin-bottom: 12px;
}

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

/* Markdown Specifics */
.bubble pre {
    background: var(--primary);
    color: var(--primary-light);
    padding: 16px;
    border-radius: 12px;
    overflow-x: auto;
    margin: 16px 0;
    font-size: 0.9rem;
    border: 1px solid var(--primary-dark);
}

.bubble code {
    background: rgba(0,0,0,0.06);
    padding: 3px 6px;
    border-radius: 6px;
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 0.85em;
    color: var(--primary);
}

.message.user .bubble code {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* Input Area Styling */
.input-area {
    padding: 24px 40px 32px;
    background: var(--chat-bg);
}

#chat-form {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    background: var(--chat-bg);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 8px 8px 8px 24px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

#chat-form:focus-within {
    border-color: #a1a1aa;
    box-shadow: var(--shadow-md);
}

#message-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 0;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    resize: none;
    outline: none;
    max-height: 200px;
    line-height: 1.5;
}

#message-input::placeholder {
    color: var(--text-secondary);
}

#send-btn {
    background: var(--primary);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#send-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

#send-btn:disabled {
    background: var(--border);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Loading Dots */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: var(--bot-msg-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-top-left-radius: 4px;
    width: fit-content;
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

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

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

/* ============================================ */
/* Stats Section                                */
/* ============================================ */
.stats-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    overflow: hidden;
}

.stats-header-bar {
    background: rgba(250, 250, 250, 0.9) !important;
}

.stats-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auto-refresh-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--accent-emerald);
    background: var(--accent-emerald-light);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.refresh-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-emerald);
    animation: pulse 2s infinite;
}

.stats-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 32px 40px 48px;
    scroll-behavior: smooth;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.kpi-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-sm);
    position: relative;
}

.kpi-card::before {
    /* Le dégradé du haut respecte déjà le rayon de la carte : pas besoin de overflow:hidden,
       ce qui permettrait aux info-bulles de déborder proprement de la carte. */
    pointer-events: none;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 16px 16px 0 0;
}

.kpi-total::before { background: linear-gradient(90deg, var(--accent-violet), #a78bfa); }
.kpi-requests::before { background: linear-gradient(90deg, var(--accent-blue), #60a5fa); }
.kpi-prompt::before { background: linear-gradient(90deg, var(--accent-emerald), #34d399); }
.kpi-completion::before { background: linear-gradient(90deg, var(--accent-amber), #fbbf24); }
.kpi-users::before { background: linear-gradient(90deg, var(--accent-indigo), #818cf8); }
.kpi-noncompliant::before { background: linear-gradient(90deg, var(--accent-rose), #fb7185); }
.kpi-speed::before { background: linear-gradient(90deg, var(--accent-cyan), #22d3ee); }
.kpi-cache::before { background: linear-gradient(90deg, var(--accent-blue), #60a5fa); }

.kpi-users .kpi-icon { background: var(--accent-indigo-light); color: var(--accent-indigo); }
.kpi-noncompliant .kpi-icon { background: var(--accent-rose-light); color: var(--accent-rose); }
.kpi-speed .kpi-icon { background: var(--accent-cyan-light); color: var(--accent-cyan); }
.kpi-cache .kpi-icon { background: var(--accent-blue-light); color: var(--accent-blue); }

.kpi-cost::before { background: linear-gradient(90deg, var(--accent-emerald), #34d399); }

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ============================================ */
/* Model Cards                                  */
/* ============================================ */
.model-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
    animation: fadeInUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.model-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
}

.model-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.model-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.model-card-chat::before {
    background: linear-gradient(90deg, var(--accent-violet), var(--accent-indigo));
}

.model-card-embed::before {
    background: linear-gradient(90deg, var(--accent-cyan), #22d3ee);
}

.model-card-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.model-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.model-card-chat .model-card-icon {
    background: var(--accent-violet-light);
    color: var(--accent-violet);
}

.model-card-embed .model-card-icon {
    background: var(--accent-cyan-light);
    color: var(--accent-cyan);
}

.model-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.model-card-title h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.model-card-title span {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.model-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.model-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.model-stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.model-stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}

.model-stat-value.cost {
    color: var(--accent-emerald);
}

.model-stat-value.cost-small {
    font-size: 1.1rem;
}

/* ============================================ */
/* Files Section                                */
/* ============================================ */
.files-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
    overflow: hidden;
    animation: fadeInUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.files-card::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-amber), #fbbf24);
}

.files-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
}

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

.files-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-amber-light);
    color: var(--accent-amber);
    flex-shrink: 0;
}

.files-header-text h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.files-header-text span {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

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

.files-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.files-toggle-btn:hover {
    background: white;
    box-shadow: var(--shadow-sm);
}

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

.files-toggle-btn svg {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.files-card.open #files-toggle-btn svg {
    transform: rotate(180deg);
}

.files-toggle-btn.loading svg {
    animation: spinRefresh 0.8s linear infinite;
}

.files-header-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.files-total-size-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--accent-emerald-light);
    color: #047857;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.files-list {
    display: none;
    border-top: 1px solid var(--border);
    max-height: 520px;
    overflow-y: auto;
}

.files-card.open .files-list {
    display: block;
}

.files-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.files-table thead {
    background: var(--primary-light);
    position: sticky;
    top: 0;
    z-index: 2;
}

.files-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.files-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

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

.file-row-clickable {
    cursor: pointer;
    transition: all 0.15s ease;
}

.file-row-clickable:hover {
    background: var(--primary-light) !important;
}

.file-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}

.file-name-wrap {
    min-width: 0;
}

.file-name-text {
    display: block;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-path-crumb {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.74rem;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 2px;
}

.file-path-crumb .crumb-sep {
    opacity: 0.5;
    margin: 0 1px;
}

.file-ext-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    flex-shrink: 0;
}

.file-ext-badge.pdf { background: #fce4ec; color: #c62828; }
.file-ext-badge.docx { background: #e3f2fd; color: #1565c0; }
.file-ext-badge.xlsx { background: #e8f5e9; color: #2e7d32; }
.file-ext-badge.csv { background: #fff3e0; color: #e65100; }
.file-ext-badge.txt { background: var(--primary-light); color: var(--text-secondary); }
.file-ext-badge.md { background: var(--primary-light); color: var(--primary); }

.folder-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 500;
}

.folder-badge.etudiant { background: var(--accent-blue-light); color: var(--accent-blue); }
.folder-badge.collaborateur { background: var(--accent-violet-light); color: var(--accent-violet); }
.folder-badge.autre { background: var(--primary-light); color: var(--text-secondary); }

.file-size-cell {
    font-variant-numeric: tabular-nums;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
}

.file-chunks-count-cell {
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.file-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.file-view-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* ============================================ */
/* File Modal                                   */
/* ============================================ */
.file-modal-content {
    max-width: 960px !important;
    width: 90% !important;
    height: 85vh;
    display: flex;
    flex-direction: column;
}

.file-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
}

.file-modal-ext-badge {
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    background: var(--accent-violet-light);
    color: var(--accent-violet);
    flex-shrink: 0;
}

.file-modal-title-wrap h2 {
    font-size: 1.1rem !important;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 650px;
}

.file-modal-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 4px;
    flex-wrap: wrap;
}

.file-modal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    gap: 0 !important;
}

.file-modal-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
    gap: 16px;
}

.file-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    flex: 1;
    max-width: 400px;
}

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

.file-search-wrap input {
    border: none;
    outline: none;
    font-family: inherit;
    font-size: 0.82rem;
    width: 100%;
    color: var(--text-primary);
    background: transparent;
}

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

.file-chunks-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: white;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.file-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.file-copy-btn:hover {
    background: var(--primary-dark);
    color: white;
}

.file-content-viewer {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.file-chunk-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s ease;
}

.file-chunk-card:hover {
    border-color: #cbd5e1;
}

.file-chunk-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}

.file-chunk-num {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-indigo);
    background: var(--accent-indigo-light);
    padding: 2px 8px;
    border-radius: 4px;
}

.file-chunk-len {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.file-chunk-text {
    font-size: 0.88rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
}

/* ============================================ */
/* Refresh Button                               */
/* ============================================ */
.refresh-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.refresh-btn:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: #d4d4d8;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.refresh-btn svg {
    transition: transform 0.3s ease;
}

.refresh-btn.loading svg {
    animation: spinRefresh 0.8s linear infinite;
}

@keyframes spinRefresh {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* History Entries (Card style)                 */
/* ============================================ */
.history-entries {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 600px;
    overflow-y: auto;
    padding: 4px;
}

.history-entry {
    background: white;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.history-entry:hover {
    border-color: #d4d4d8;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.history-entry.entry-noncompliant {
    border-left: 4px solid var(--accent-rose);
    background: rgba(244, 63, 94, 0.02);
}

.history-entry-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    gap: 12px;
    flex-wrap: wrap;
}

.history-entry-time {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.history-entry-time svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.history-entry-user-id {
    opacity: 0.7;
    font-weight: 400;
    font-size: 0.85em;
}

.history-entry-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    font-weight: 500;
    font-size: 0.78rem;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-entry-question {
    font-size: 0.88rem;
    color: var(--text-primary);
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

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

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.model-badge.chat {
    background: var(--accent-violet-light);
    color: var(--accent-violet);
}

.model-badge.embed {
    background: var(--accent-cyan-light);
    color: var(--accent-cyan);
}

.meta-separator {
    width: 1px;
    height: 14px;
    background: var(--border);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.meta-item svg {
    width: 13px;
    height: 13px;
    flex-shrink: 0;
}

.history-entry-tokens {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ============================================ */
/* History Filter                               */
/* ============================================ */
.history-filter {
    display: flex;
    background: var(--primary-light);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.history-filter-btn {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-filter-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-total .kpi-icon { background: var(--accent-violet-light); color: var(--accent-violet); }
.kpi-requests .kpi-icon { background: var(--accent-blue-light); color: var(--accent-blue); }
.kpi-prompt .kpi-icon { background: var(--accent-emerald-light); color: var(--accent-emerald); }
.kpi-completion .kpi-icon { background: var(--accent-amber-light); color: var(--accent-amber); }

.kpi-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.kpi-label-row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.kpi-label {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kpi-sublabel {
    font-size: 0.72rem;
    color: var(--text-secondary);
    font-weight: 500;
    margin-top: 2px;
}

/* ============================================ */
/* Info Tooltips                                */
/* ============================================ */
.info-tip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--text-secondary);
    font-size: 0.64rem;
    font-weight: 700;
    cursor: help;
    position: relative;
    flex-shrink: 0;
    border: 1px solid var(--border);
    text-transform: none;
    letter-spacing: normal;
}

.info-tip:hover,
.info-tip:focus {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.info-tip:hover::after,
.info-tip:focus::after {
    content: attr(data-tooltip);
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary);
    color: white;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    width: max-content;
    max-width: 240px;
    white-space: normal;
    box-shadow: var(--shadow-lg);
    z-index: 60;
    text-transform: none;
    letter-spacing: normal;
    pointer-events: none;
}

.info-tip:hover::before,
.info-tip:focus::before {
    content: '';
    position: absolute;
    top: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-bottom-color: var(--primary);
    z-index: 60;
    pointer-events: none;
}

.chart-card-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin: -12px 0 16px;
    line-height: 1.5;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0 16px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.section-title .info-tip {
    font-weight: 700;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.02em;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    transition: all 0.3s ease;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
    animation: fadeInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.1s;
    opacity: 0;
}

.chart-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.3s ease;
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
}

.chart-card-wide {
    grid-column: 1 / -1;
}

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

.chart-card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.chart-toggle {
    display: flex;
    background: var(--primary-light);
    border-radius: 8px;
    padding: 3px;
    gap: 2px;
}

.chart-toggle-btn {
    padding: 6px 14px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-toggle-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.chart-wrapper {
    position: relative;
    height: 280px;
}

.chart-wrapper-square {
    height: 260px;
}

/* History Table */
.history-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
    animation: fadeInUp 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.2s;
    opacity: 0;
}

.history-count {
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
}

.table-wrapper {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.history-table thead {
    background: var(--primary-light);
}

.history-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.history-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

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

.history-table tbody tr {
    transition: background 0.15s ease;
}

.history-table tbody tr:hover {
    background: var(--primary-light);
}

.empty-row td {
    text-align: center;
    color: var(--text-secondary);
    padding: 32px 16px;
    font-style: italic;
}

.token-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.8rem;
}

.token-badge.prompt {
    background: var(--accent-emerald-light);
    color: #059669;
}

.token-badge.completion {
    background: var(--accent-amber-light);
    color: #d97706;
}

.token-badge.total {
    background: var(--accent-violet-light);
    color: var(--accent-violet);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.78rem;
}

.status-badge.ok {
    background: var(--accent-emerald-light);
    color: #059669;
}

.status-badge.warn {
    background: var(--accent-rose-light);
    color: #be123c;
}

.speed-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.8rem;
    background: var(--accent-cyan-light);
    color: #0e7490;
}

.user-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 6px;
    background: var(--accent-blue-light);
    color: var(--accent-blue);
    font-weight: 500;
    font-size: 0.78rem;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================ */
/* Glossaire                                    */
/* ============================================ */
.glossary-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 28px;
    overflow: hidden;
}

.glossary-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.glossary-toggle-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.glossary-toggle-left h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
}

.glossary-toggle-left p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.glossary-chevron {
    transition: transform 0.25s ease;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.glossary-card.open .glossary-chevron {
    transform: rotate(180deg);
}

.glossary-body {
    display: none;
    padding: 0 24px 24px;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px 28px;
}

.glossary-card.open .glossary-body {
    display: grid;
}

.glossary-item dt {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.glossary-item dd {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

@media (max-width: 900px) {
    .glossary-body {
        grid-template-columns: 1fr;
    }
}

/* Uptime Bar */
.uptime-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 20px 24px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow-sm);
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    animation-delay: 0.3s;
    opacity: 0;
}

.uptime-bar strong {
    color: var(--primary);
    font-weight: 600;
}

/* ============================================ */
/* Responsive                                   */
/* ============================================ */
@media (max-width: 1200px) {
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .model-cards-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 220px;
        padding: 24px 16px;
    }
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    .stats-scroll-area {
        padding: 20px;
    }
    .uptime-bar {
        flex-direction: column;
        gap: 12px;
    }
    .model-cards-grid {
        grid-template-columns: 1fr;
    }
    .model-card-stats {
        grid-template-columns: 1fr 1fr;
    }
    .files-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .history-entry-header {
        flex-direction: column;
        align-items: flex-start;
    }
}
/* History Table Enhancements */
.history-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.history-row:hover {
    background-color: var(--hover-bg);
}

.history-row.row-error {
    background-color: rgba(239, 68, 68, 0.05);
    border-left: 4px solid #ef4444;
}

.history-row.row-error:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* ============================================ */
/* Login Page                                   */
/* ============================================ */
.login-body {
    width: 100%;
    height: 100vh;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 40px 36px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.login-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
}

.login-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.login-header h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: -0.01em;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--sidebar-text);
}

.login-field input {
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    color: var(--text-primary);
    background: var(--bg-color);
    outline: none;
    transition: all 0.2s ease;
}

.login-field input:focus {
    border-color: #a1a1aa;
    background: white;
    box-shadow: var(--shadow-sm);
}

.login-error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
}

.login-submit {
    background: var(--primary);
    color: white;
    border: none;
    padding: 13px 16px;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-submit:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

.login-back {
    font-size: 0.82rem;
    color: var(--text-secondary);
    text-decoration: none;
}

.login-back:hover {
    color: var(--primary);
}

/* History Modal */
.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--chat-bg);
    margin: 15% auto;
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 80%;
    max-width: 800px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-height: 80vh;
}

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

.modal-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.close-modal {
    color: var(--text-secondary);
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--text-primary);
    text-decoration: none;
}

.modal-body {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.modal-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.modal-text {
    background: var(--bg-color);
    padding: 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
}

.modal-text pre {
    background: var(--primary);
    color: var(--primary-light);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 8px 0;
}

/* ============================================ */
/* RAG Refresh Terminal Modal                    */
/* ============================================ */
.rag-terminal-content {
    max-width: 760px !important;
    width: 90% !important;
    height: 75vh;
    display: flex;
    flex-direction: column;
}

.rag-terminal-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rag-terminal-status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent-amber);
    flex-shrink: 0;
    animation: ragPulse 1s ease-in-out infinite;
}

.rag-terminal-status-dot.status-done {
    background: var(--accent-emerald);
    animation: none;
}

.rag-terminal-status-dot.status-error {
    background: var(--accent-rose);
    animation: none;
}

@keyframes ragPulse {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    50% { opacity: 0.6; box-shadow: 0 0 0 4px rgba(245, 158, 11, 0); }
}

.rag-terminal-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.rag-terminal {
    flex: 1;
    overflow-y: auto;
    background: #0d1117;
    color: #c9d1d9;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.82rem;
    line-height: 1.65;
    padding: 16px;
    border-radius: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.rag-terminal-line {
    display: block;
}

.rag-terminal-line.line-error {
    color: #ff7b72;
}

.rag-terminal-line.line-system {
    color: #58a6ff;
}

.rag-terminal-line::before {
    content: '❯ ';
    opacity: 0.5;
}

.rag-terminal-files {
    background: var(--bg-color);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 18px;
    max-height: 160px;
    overflow-y: auto;
    flex-shrink: 0;
}

.rag-terminal-files h3 {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.rag-terminal-files ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.rag-terminal-files li {
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.rag-terminal-files li::before {
    content: '📄';
    font-size: 0.8rem;
}

.rag-terminal-removed li {
    color: var(--text-secondary);
    text-decoration: line-through;
}

.rag-terminal-removed li::before {
    content: '🗑️';
}

.rag-terminal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.rag-terminal-hint {
    font-size: 0.82rem;
    color: var(--text-secondary);
}
