/* ============ CONSOMMATION API ============ */
.usage-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}

.usage-card {
    padding: 14px 16px;
    background: #FAFBFC;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.usage-card.highlighted {
    background: var(--primary-bg);
    border-color: var(--primary-light);
}

.usage-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.usage-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.usage-card.highlighted .usage-value {
    color: var(--primary);
}

.usage-sub {
    font-size: 11px;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

@media (max-width: 700px) {
    .usage-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============ VARIABLES DYNAMIQUES (formulaire) ============ */
.variables-toggle {
    margin-bottom: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.variables-section {
    margin-top: 16px;
    padding: 16px;
    background: #FAFBFC;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.variables-section h4 {
    color: var(--primary);
    font-size: 14px;
    margin-bottom: 8px;
}

.variables-table {
    margin-top: 12px;
    margin-bottom: 16px;
}

.variables-header,
.variable-row {
    display: grid;
    grid-template-columns: 1.2fr 1.8fr 1.2fr 1.5fr 32px;
    gap: 8px;
    align-items: center;
}

.variables-header {
    margin-bottom: 6px;
    padding: 0 4px;
}

.variables-header span {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.variable-row {
    margin-bottom: 6px;
}

.variable-row input,
.variable-row select {
    padding: 7px 9px;
    font-size: 13px;
}

.btn-remove-variable {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: var(--bg);
    border-radius: 4px;
    color: var(--danger);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}

.btn-remove-variable:hover {
    background: #FFE0E0;
}

.code-construction-group {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.code-construction-group textarea {
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 12px;
}

.help-text code {
    background: var(--primary-bg);
    color: var(--primary);
    padding: 1px 6px;
    border-radius: 3px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 11px;
}

/* ============ ANALYSE DES VARIABLES (résultats) ============ */
.variables-analysis {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.variable-analysis-card {
    padding: 16px;
    border-radius: 8px;
    border-left: 4px solid;
    background: white;
    border: 1px solid var(--border);
}

.variable-analysis-card.risk-critique { border-left-color: var(--danger); background: #FEF2F2; }
.variable-analysis-card.risk-élevé { border-left-color: #FF6B35; background: #FFF4ED; }
.variable-analysis-card.risk-modéré { border-left-color: var(--warning); background: #FFFBEB; }
.variable-analysis-card.risk-faible { border-left-color: var(--success); background: #F1F8F4; }

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

.var-name {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-weight: 700;
    font-size: 14px;
    color: var(--text);
}

.var-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.var-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    background: rgba(0, 0, 0, 0.06);
}

.var-badge.iso-correcte { background: #D1F2E0; color: #1B5E20; }
.var-badge.iso-partielle { background: #FFF3CD; color: #856404; }
.var-badge.iso-absente { background: #FFE0E0; color: var(--danger); }

.var-source {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 6px;
}

.var-constat {
    font-size: 14px;
    margin-bottom: 6px;
}

.var-risk {
    font-size: 13px;
    color: var(--text-light);
    font-style: italic;
    margin-bottom: 8px;
}

.var-reco {
    font-size: 13px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    border-left: 2px solid var(--primary);
}

.var-reco strong {
    color: var(--primary);
}

/* ============ ANALYSE DU CODE ============ */
.code-analysis-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.code-check-card {
    padding: 12px 14px;
    background: var(--primary-bg);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.code-check-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.code-check-value {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
}

.code-check-value.value-oui { color: var(--success); }
.code-check-value.value-non { color: var(--danger); }
.code-check-value.value-non_applicable { color: var(--text-light); font-weight: 500; }

@media (max-width: 700px) {
    .code-analysis-grid { grid-template-columns: 1fr; }
    .variables-header, .variable-row { grid-template-columns: 1fr; }
    .variables-header { display: none; }
    .variable-row { padding: 12px; background: white; border-radius: 6px; margin-bottom: 10px; }
}

/* ============ SÉLECTEUR DE MODE ============ */
.mode-selector {
    margin-bottom: 24px;
}

.mode-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 8px;
}

.mode-tabs input[type="radio"] {
    display: none;
}

.mode-tab {
    display: flex;
    flex-direction: column;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.mode-tab strong {
    font-size: 14px;
    color: var(--text);
    margin-bottom: 4px;
}

.mode-tab span {
    font-size: 12px;
    color: var(--text-light);
}

.mode-tab:hover {
    border-color: var(--primary-light);
    background: var(--primary-bg);
}

.mode-tabs input[type="radio"]:checked + .mode-tab {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.mode-tabs input[type="radio"]:checked + .mode-tab strong {
    color: var(--primary);
}

/* ============ ÉVALUATION DU MODÈLE ============ */
.model-eval-card {
    background: var(--primary-bg);
    border-radius: 8px;
    padding: 16px 18px;
    border-left: 3px solid var(--primary);
}

.model-eval-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.model-eval-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.model-badge-ok {
    background: #D1F2E0;
    color: #1B5E20;
}

.model-badge-warn {
    background: #FFF3CD;
    color: #7D5700;
}

.model-eval-justification {
    color: var(--text-secondary);
    margin: 0 0 12px;
    font-size: 0.88rem;
    line-height: 1.55;
}

.model-eval-suggestion {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 12px 14px;
    border-left: 3px solid #E8A000;
}

.model-suggestion-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 4px;
}

.model-suggestion-name {
    font-weight: 600;
    font-size: 0.95rem;
    display: block;
    margin-bottom: 6px;
}

.model-suggestion-reason {
    color: var(--text-secondary);
    font-size: 0.88rem;
    line-height: 1.55;
    margin: 0;
}

/* ============ ARCHITECTURE ============ */
.arch-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.arch-card {
    padding: 14px 16px;
    background: var(--primary-bg);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

.arch-label {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.arch-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    text-transform: capitalize;
}

.arch-value.value-bonne,
.arch-value.value-oui { color: var(--success); }

.arch-value.value-partielle { color: var(--warning); }

.arch-value.value-absente,
.arch-value.value-non { color: var(--danger); }

.arch-comment {
    padding: 14px;
    background: #FAFBFC;
    border-left: 3px solid var(--primary-light);
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.6;
}

/* ============ BLOCS PROMPTS AMÉLIORÉS ============ */
.improved-block {
    margin-bottom: 20px;
}

.improved-block h4 {
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--primary);
    font-weight: 700;
}

/* ============ RESPONSIVE MODE TABS ============ */
@media (max-width: 700px) {
    .mode-tabs { grid-template-columns: 1fr; }
    .arch-grid { grid-template-columns: 1fr; }
}

/* ============ RESET & BASE ============ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #1F4E79;
    --primary-light: #2E75B6;
    --primary-bg: #EAF1F8;
    --success: #4CAF50;
    --warning: #FF9800;
    --danger: #F44336;
    --neutral: #595959;
    --bg: #F7F9FC;
    --card-bg: #FFFFFF;
    --border: #E0E6ED;
    --text: #1A1A1A;
    --text-light: #595959;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.08);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 20px;
}

header {
    margin-bottom: 32px;
}

header h1 {
    color: var(--primary);
    font-size: 28px;
    margin-bottom: 6px;
}

.subtitle {
    color: var(--text-light);
    font-size: 15px;
}

footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* ============ CARDS ============ */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card h2 {
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 20px;
}

.card h3 {
    color: var(--primary);
    font-size: 16px;
    margin-bottom: 12px;
}

.error-card {
    border-left: 4px solid var(--danger);
    background: #FEF2F2;
}

.error-card h3 {
    color: var(--danger);
}

/* ============ FORMULAIRE ============ */
.form-group {
    margin-bottom: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

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

.required {
    color: var(--danger);
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(46, 117, 182, 0.12);
}

textarea {
    resize: vertical;
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.5;
}

.help-text {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 4px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    vertical-align: middle;
}

.badge-success {
    background: #D1F2E0;
    color: #1B5E20;
}

.metadata-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 18px;
    background: #FAFBFC;
}

.metadata-section summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--primary);
    padding: 4px 0;
}

.metadata-section[open] summary {
    margin-bottom: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ============ BOUTONS ============ */
.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-primary:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-primary:disabled {
    background: #B0B0B0;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--border);
    color: var(--text);
}

.btn-secondary:hover {
    background: #D0D6DD;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-inline {
    position: absolute;
    top: 8px;
    right: 8px;
}

/* ============ LOADING ============ */
#loading {
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============ RÉSULTATS ============ */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.results-header .actions {
    display: flex;
    gap: 8px;
}

.score-summary {
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 24px;
    background: var(--primary-bg);
    border-radius: 12px;
    margin-bottom: 24px;
}

.score-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: white;
    border: 6px solid var(--primary);
    flex-shrink: 0;
}

.score-circle.green { border-color: var(--success); }
.score-circle.orange { border-color: var(--warning); }
.score-circle.red { border-color: var(--danger); }

#score-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
}

.score-circle.green #score-value { color: var(--success); }
.score-circle.orange #score-value { color: var(--warning); }
.score-circle.red #score-value { color: var(--danger); }

.score-circle small {
    color: var(--text-light);
    font-size: 12px;
}

.score-details .verdict {
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.score-line {
    color: var(--text-light);
    margin-bottom: 4px;
}

.usage-line {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 8px;
}

.section-block {
    margin-bottom: 28px;
}

.section-block.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.synthesis {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
    padding: 16px;
    background: #FAFBFC;
    border-left: 3px solid var(--primary-light);
    border-radius: 4px;
}

/* ============ DIMENSIONS ============ */
.dimensions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.dimension-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    background: white;
}

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

.dimension-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--primary);
}

.dimension-weight {
    font-size: 12px;
    color: var(--text-light);
}

.criterion {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}

.criterion-name {
    color: var(--text);
}

.criterion-score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 24px;
    border-radius: 4px;
    font-weight: 700;
    font-size: 13px;
}

.score-1, .score-2 {
    background: #FFE0E0;
    color: var(--danger);
}

.score-3 {
    background: #FFF3CD;
    color: #856404;
}

.score-4, .score-5 {
    background: #D1F2E0;
    color: #1B5E20;
}

/* ============ LISTES ============ */
.bullet-list {
    list-style: none;
    padding: 0;
}

.bullet-list li {
    padding: 8px 0 8px 24px;
    position: relative;
    line-height: 1.5;
}

.bullet-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success);
    font-weight: 700;
}

.weakness-list {
    list-style: none;
    padding: 0;
}

.weakness-item {
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    border-left: 3px solid;
    background: white;
}

.weakness-item.severity-critique { border-left-color: var(--danger); background: #FEF2F2; }
.weakness-item.severity-haute { border-left-color: #FF6B35; background: #FFF4ED; }
.weakness-item.severity-moyenne { border-left-color: var(--warning); background: #FFFBEB; }
.weakness-item.severity-basse { border-left-color: #6B7280; background: #F9FAFB; }

.weakness-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.weakness-criterion {
    font-weight: 700;
    font-size: 14px;
}

.weakness-location {
    display: inline-block;
    margin-left: 8px;
    font-size: 11px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--primary-bg);
    color: var(--primary);
    text-transform: uppercase;
    vertical-align: middle;
}

.weakness-severity {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.06);
}

.weakness-statement {
    font-size: 14px;
    margin-bottom: 6px;
}

.weakness-risk {
    font-size: 13px;
    color: var(--text-light);
    font-style: italic;
}

/* ============ RECOMMANDATIONS ============ */
.reco-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.reco-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
}

.reco-priority {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    padding: 8px;
    background: var(--primary-bg);
    border-radius: 6px;
}

.reco-priority-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.reco-priority-label {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
}

.reco-content h4 {
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text);
}

.reco-meta {
    display: flex;
    gap: 12px;
    margin-bottom: 6px;
    font-size: 12px;
    color: var(--text-light);
}

.reco-meta span {
    padding: 2px 8px;
    background: var(--bg);
    border-radius: 4px;
}

.reco-gain {
    font-size: 13px;
    color: var(--primary);
    font-style: italic;
    margin-top: 6px;
}

/* ============ CODE BLOCK ============ */
.improved-prompt-wrapper {
    position: relative;
}

.code-block {
    background: #1E1E1E;
    color: #E0E0E0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: "SF Mono", Monaco, Consolas, "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
}

#error-detail {
    background: #FEF2F2;
    color: var(--danger);
    padding: 12px;
    border-radius: 6px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12px;
    margin-top: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 300px;
    overflow-y: auto;
}

/* ============ UTILS ============ */
.hidden {
    display: none !important;
}

.target-model-custom {
    margin-top: 8px;
    width: 100%;
}

@media (max-width: 768px) {
    .container { padding: 16px 12px; }
    .card { padding: 20px; }
    .form-grid { grid-template-columns: 1fr; }
    .section-block.two-cols { grid-template-columns: 1fr; gap: 16px; }
    .score-summary { flex-direction: column; text-align: center; gap: 16px; }
    .results-header { flex-direction: column; gap: 12px; align-items: flex-start; }
}

/* ============ HEADER ============ */
.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

/* ============ BARRE PROJET ============ */
.project-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: 8px;
    margin-bottom: 20px;
}

.project-bar-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    font-weight: 500;
}

.project-bar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.2s;
}

.project-bar-dot.dot-active {
    background: var(--success);
}

.prompt-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 20px;
}

.prompt-bar-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--border);
    flex-shrink: 0;
    transition: background 0.2s;
}

.prompt-bar-dot.dot-active {
    background: var(--primary);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0;
    text-decoration: underline;
    font-family: inherit;
    white-space: nowrap;
}

.btn-link:hover { color: var(--primary); }

/* ============ DRAWER ============ */
.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.history-drawer {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: white;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
    z-index: 101;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
}

.history-drawer.open {
    right: 0;
}

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

.drawer-header h3 {
    color: var(--primary);
    font-size: 18px;
    margin: 0;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
}

.btn-icon:hover {
    background: var(--border);
    color: var(--text);
}

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

.drawer-section {
    margin-bottom: 28px;
}

.drawer-section h4 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    transition: border-color 0.15s;
}

.saved-item:hover {
    border-color: var(--primary-light);
}

.saved-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.saved-item-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.saved-item-meta {
    font-size: 11px;
    color: var(--text-light);
}

.version-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    border-radius: 4px;
    vertical-align: middle;
}

/* v1 slightly muted so higher versions stand out */
.version-badge.v1 {
    color: var(--text-light);
    background: color-mix(in srgb, var(--border) 40%, transparent);
}

.saved-item-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

/* Prompt item avec panneau d'analyses imbriqué */
.prompt-item {
    display: block;
    padding: 0;
}

.prompt-item .saved-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    gap: 8px;
}

.prompt-analyses-panel {
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 60%, var(--bg-card));
    padding: 4px 0;
}

.saved-item-nested {
    padding: 5px 10px 5px 20px;
    border-bottom: none;
}

.saved-item-nested:last-child {
    border-bottom: none;
}

.empty-state.nested {
    padding: 6px 20px;
    font-size: 12px;
}

.loading-text {
    display: block;
    padding: 6px 20px;
    font-size: 12px;
    color: var(--text-light);
}

.analyses-toggle {
    font-size: 10px;
    padding: 2px 5px;
    color: var(--text-light);
    background: none;
    border: none;
    cursor: pointer;
    transition: color 0.15s;
}

.analyses-toggle:hover,
.analyses-toggle.open {
    color: var(--primary);
}

/* Indicateur de liaison dans le formulaire de sauvegarde analyse */
.save-prompt-hint {
    font-size: 11px;
    color: var(--primary);
    font-weight: 600;
    padding: 2px 6px;
    background: color-mix(in srgb, var(--primary) 10%, transparent);
    border-radius: 4px;
    white-space: nowrap;
}

.btn-danger {
    background: #FFE0E0;
    color: var(--danger);
    border: none;
    border-radius: 6px;
    padding: 4px 9px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
    font-family: inherit;
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.empty-state {
    color: var(--text-light);
    font-size: 13px;
    font-style: italic;
    text-align: center;
    padding: 16px 0;
}

/* ============ SECTION DRAWER ============ */
.drawer-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.drawer-section-header h4 {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ============ ITEMS PROJET ============ */
.project-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 8px;
    transition: border-color 0.15s;
}

.project-item:hover { border-color: var(--primary-light); }

.project-item-active {
    border-color: var(--primary);
    background: var(--primary-bg);
}

.project-item-body {
    margin-bottom: 8px;
}

.project-item-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.project-item-name {
    font-weight: 700;
    font-size: 13px;
    color: var(--text);
}

.project-active-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--primary);
    color: white;
    letter-spacing: 0.4px;
}

.project-item-company {
    display: block;
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 2px;
}

.project-item-meta {
    display: block;
    font-size: 11px;
    color: var(--text-light);
}

.project-item-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

/* ============ FORMULAIRE PROJET (DRAWER) ============ */
.project-form-wrapper {
    margin-bottom: 12px;
}

.project-form {
    padding: 12px;
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-form input[type="text"],
.project-form textarea {
    padding: 6px 10px;
    font-size: 13px;
    width: 100%;
}

.project-form textarea {
    resize: vertical;
    font-family: inherit;
    font-size: 13px;
}

.project-form-dates {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.project-date-label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.project-date-label input[type="date"] {
    padding: 5px 8px;
    font-size: 12px;
    width: 100%;
}

.project-form-actions {
    display: flex;
    gap: 6px;
}

/* ============ SAUVEGARDE INLINE ============ */
.save-inline {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-self: flex-start;
}

.inline-save-form {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
    padding: 8px 10px;
    background: var(--primary-bg);
    border-radius: 6px;
    border: 1px solid var(--primary-light);
}

.inline-save-form input[type="text"] {
    flex: 1;
    min-width: 150px;
    padding: 5px 10px;
    font-size: 13px;
}

@media (max-width: 768px) {
    .history-drawer { width: 100%; right: -100%; }
    .header-content { flex-direction: column; gap: 12px; }
    .form-actions { flex-wrap: wrap; }
}

/* ============ AUTHENTIFICATION ============ */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.auth-container {
    width: 100%;
    max-width: 440px;
    padding: 24px 16px;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 36px 40px;
    box-shadow: var(--shadow-lg);
}

.auth-card-info {
    text-align: center;
}

.auth-logo {
    text-align: center;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.auth-logo h1 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 12px;
    color: var(--text-light);
}

.auth-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 20px;
}

.auth-link {
    margin-top: 20px;
    text-align: center;
    font-size: 13px;
    color: var(--text-light);
}

.auth-link a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
}

.auth-link a:hover {
    text-decoration: underline;
}

.auth-message {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 24px;
}

.pending-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* ---- Flash messages ---- */
.flash {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 14px;
    line-height: 1.4;
}

.flash-success {
    background: #E8F5E9;
    border: 1px solid #A5D6A7;
    color: #2E7D32;
}

.flash-error {
    background: #FFEBEE;
    border: 1px solid #EF9A9A;
    color: #C62828;
}

.flash-info {
    background: var(--primary-bg);
    border: 1px solid var(--primary-light);
    color: var(--primary);
}

.flash-container {
    margin-bottom: 16px;
}

/* ---- Bouton pleine largeur ---- */
.btn-full {
    width: 100%;
    text-align: center;
    display: block;
    padding: 10px;
}


/* ---- Radio group ---- */
.radio-group {
    display: flex;
    gap: 20px;
    margin-top: 4px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 400;
    cursor: pointer;
    font-size: 14px;
}

.radio-label input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* ---- Champs entreprise (cachés par défaut) ---- */
.enterprise-fields {
    display: none;
    padding: 16px;
    background: #FAFBFC;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
}

.enterprise-fields.visible {
    display: block;
}

/* ---- User badge (header) ---- */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user-badge {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-bg);
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid var(--primary-light);
}

/* ---- Admin table ---- */
.admin-table-wrapper {
    overflow-x: auto;
}

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

.admin-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.admin-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background: #FAFBFC;
}

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

.admin-empty {
    text-align: center;
    color: var(--text-light);
    padding: 24px !important;
}

.admin-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ---- Status badges ---- */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.status-pending {
    background: #FFF3E0;
    color: #6D3200;
    border: 1px solid #FFCC80;
}

.status-active {
    background: #E8F5E9;
    color: #2E7D32;
    border: 1px solid #A5D6A7;
}

.status-blocked {
    background: #FFEBEE;
    color: #C62828;
    border: 1px solid #EF9A9A;
}

.badge-admin {
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary-light);
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 10px;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 4px;
}

/* ---- Boutons action admin ---- */
.btn-success {
    background: var(--success);
    color: #fff;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.btn-success:hover {
    background: #43A047;
}

/* ---- Bloc lien de réinitialisation (admin) ---- */
.reset-link-box {
    background: #FFFDE7;
    border: 1px solid #FDD835;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 20px;
}

.reset-link-box p {
    font-size: 13px;
    margin-bottom: 10px;
}

.reset-link-url {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #E0E0E0;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

.reset-link-url code {
    flex: 1;
    font-size: 12px;
    word-break: break-all;
    color: var(--text);
    font-family: monospace;
}

.reset-link-hint {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 0 !important;
}

/* ---- Bouton neutre (admin) ---- */
.btn-neutral {
    background: #f0f0f0;
    color: var(--text);
    border: 1px solid #ccc;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.btn-neutral:hover {
    background: #e0e0e0;
}

/* ---- Bouton copier ---- */
.btn-copy {
    white-space: nowrap;
    background: var(--primary-bg);
    color: var(--primary);
    border: 1px solid var(--primary-light);
    padding: 4px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.btn-copy:hover {
    background: var(--primary-light);
    color: #fff;
}

@media (max-width: 480px) {
    .auth-card { padding: 24px 20px; }
}

/* ============ LAYOUT SIDEBAR ============ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    min-width: 220px;
    max-width: 260px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0;
    z-index: 10;
}

.main-wrapper {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 12px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--card-bg);
    position: sticky;
    top: 0;
    z-index: 1;
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.sidebar-new-btn {
    width: 24px;
    height: 24px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
    color: var(--primary);
    line-height: 1;
    padding: 0;
}

.sidebar-new-btn:hover { background: var(--primary-bg); }

.sidebar .project-form-wrapper {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.sidebar-tree {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

/* -- Nœud projet -- */
.tree-project { border-bottom: 1px solid var(--border); }

.tree-project-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 8px;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.tree-project-row:hover { background: var(--bg); }
.tree-project-row.is-active { background: var(--primary-bg); }

.tree-chevron {
    font-size: 9px;
    color: var(--text-light);
    width: 14px;
    flex-shrink: 0;
    transition: transform 0.15s;
    display: inline-block;
    text-align: center;
}

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

.tree-project-name {
    flex: 1;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-project-row.is-active .tree-project-name { color: var(--primary); }

.tree-active-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--success);
    flex-shrink: 0;
}

.tree-project-actions { display: none; gap: 2px; }
.tree-project-row:hover .tree-project-actions { display: flex; }

.tree-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 3px;
    font-size: 11px;
    color: var(--text-light);
    line-height: 1;
    font-family: inherit;
}

.tree-btn:hover { background: var(--border); color: var(--text); }
.tree-btn.danger:hover { background: #FFE0E0; color: var(--danger); }

/* -- Contenu enfants du projet -- */
.tree-children { background: var(--bg); }

/* -- Groupe de prompt (même nom) -- */
.tree-prompt-group-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 8px 5px 24px;
    cursor: pointer;
    transition: background 0.12s;
    user-select: none;
}

.tree-prompt-group-row:hover {
    background: color-mix(in srgb, var(--border) 50%, transparent);
}

.tree-prompt-group-name {
    flex: 1;
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* -- Version d'un prompt -- */
.tree-version-row {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 8px 4px 38px;
    cursor: pointer;
    transition: background 0.12s;
}

.tree-version-row:hover {
    background: color-mix(in srgb, var(--border) 60%, transparent);
}

.tree-version-row.is-loaded {
    background: color-mix(in srgb, var(--primary) 8%, transparent);
}

.tree-version-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    opacity: 0;
}

.tree-version-row.is-loaded .tree-version-dot { opacity: 1; }

.tree-version-label {
    flex: 1;
    font-size: 11px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-version-row.is-loaded .tree-version-label {
    font-weight: 700;
    color: var(--primary);
}

.tree-version-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--primary);
    background: color-mix(in srgb, var(--primary) 12%, transparent);
    padding: 1px 5px;
    border-radius: 4px;
    flex-shrink: 0;
}

.tree-version-actions { display: none; gap: 2px; }
.tree-version-row:hover .tree-version-actions { display: flex; }

/* -- Analyses sous une version -- */
.tree-analyses-container { background: color-mix(in srgb, var(--bg) 70%, white); }

.tree-analysis-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 52px;
    transition: background 0.12s;
}

.tree-analysis-row:hover {
    background: color-mix(in srgb, var(--border) 60%, transparent);
}

.tree-analysis-name {
    flex: 1;
    font-size: 11px;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.tree-analysis-name:hover { color: var(--primary); text-decoration: underline; }

.tree-analysis-score {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-light);
    flex-shrink: 0;
}

.tree-analysis-actions { display: none; gap: 2px; }
.tree-analysis-row:hover .tree-analysis-actions { display: flex; }

/* -- Analyses orphelines -- */
.tree-orphan-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px 4px 24px;
    cursor: pointer;
    user-select: none;
}

.tree-orphan-header:hover {
    background: color-mix(in srgb, var(--border) 40%, transparent);
}

.tree-orphan-label {
    flex: 1;
    font-size: 11px;
    font-style: italic;
    color: var(--text-light);
}

/* -- États vides / chargement -- */
.sidebar-empty {
    padding: 20px 14px;
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
    text-align: center;
}

.tree-loading {
    padding: 6px 8px 6px 24px;
    font-size: 11px;
    color: var(--text-light);
    font-style: italic;
}

.tree-empty {
    padding: 4px 8px 4px 40px;
    font-size: 11px;
    color: var(--text-light);
    font-style: italic;
}

@media (max-width: 900px) {
    .sidebar { width: 220px; min-width: 200px; max-width: 220px; }
}

@media (max-width: 680px) {
    .app-layout { flex-direction: column; }
    .sidebar {
        width: 100%;
        max-width: none;
        height: auto;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }
    .sidebar-tree { max-height: 240px; }
}

/* ============ COMPARAISON ============ */

/* En-tête */
.cmp-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

/* Noms des analyses */
.cmp-names-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.cmp-name-tag {
    padding: 4px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.88rem;
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cmp-name-tag.cmp-a { background: #ede9fe; color: #1e1b4b; }
.cmp-name-tag.cmp-b { background: #d1fae5; color: #052e16; }

.cmp-vs {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* Scores globaux */
.cmp-scores-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 28px;
}

.cmp-score-block {
    text-align: center;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.cmp-score-val {
    font-size: 3rem;
    font-weight: 800;
    line-height: 1;
}

.cmp-score-block.cmp-a .cmp-score-val { color: #4338ca; }
.cmp-score-block.cmp-b .cmp-score-val { color: #065f46; }

.cmp-score-unit {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.cmp-delta {
    min-width: 48px;
    text-align: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 1rem;
}

.delta-pos { background: #D1F2E0; color: #065f46; }
.delta-neg { background: #FDECEA; color: #b71c1c; }
.delta-eq  { background: var(--primary-bg); color: var(--text-muted); }

/* Graphique radar */
.cmp-chart-wrapper {
    max-width: 560px;
    margin: 0 auto 32px;
    position: relative;
}

/* Tableau de scores */
.cmp-table-wrapper {
    overflow-x: auto;
}

.cmp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.cmp-table thead th {
    padding: 8px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.cmp-table thead th:first-child { text-align: left; }

.cth-a { color: #4338ca !important; }
.cth-b { color: #065f46 !important; }

.cmp-dim-row td {
    padding: 10px 12px 4px;
    font-weight: 700;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: var(--primary-bg);
    border-top: 1px solid var(--border);
}

.cmp-table tbody tr:not(.cmp-dim-row):hover { background: var(--primary-bg); }

.crit-name {
    padding: 7px 12px;
    color: var(--text-secondary);
}

.crit-val {
    padding: 7px 12px;
    text-align: center;
    font-weight: 600;
    font-size: 1rem;
}

.crit-a { color: #4338ca; }
.crit-b { color: #065f46; }

.crit-delta {
    padding: 7px 8px;
    text-align: center;
    font-weight: 700;
    font-size: 0.85rem;
    min-width: 36px;
}

/* Picker modal */
.cmp-picker-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.cmp-picker-overlay.hidden { display: none; }

.cmp-picker-modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

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

.cmp-picker-header h3 { margin: 0; font-size: 1rem; }

.cmp-picker-list {
    overflow-y: auto;
    padding: 8px;
    flex: 1;
}

.cmp-picker-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: none;
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    text-align: left;
    transition: background 0.12s;
    gap: 12px;
}

.cmp-picker-item:hover { background: var(--primary-bg); }

.cpi-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cpi-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.cmp-picker-msg {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ============ TARIF LLM ============ */
.btn-tarif {
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1.5px solid var(--primary);
    border-radius: 6px;
    background: transparent;
    color: var(--primary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    margin-top: 6px;
}

.btn-tarif:hover:not(:disabled) {
    background: var(--primary);
    color: #fff;
}

.btn-tarif:disabled {
    border-color: var(--border);
    color: var(--text-light);
    cursor: not-allowed;
    opacity: 0.55;
}

.llm-tarif-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.llm-tarif-overlay.hidden { display: none; }

.llm-tarif-modal {
    background: var(--card-bg);
    border-radius: 12px;
    width: 100%;
    max-width: 760px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0,0,0,0.22);
    overflow: hidden;
}

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

.llm-tarif-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.llm-tarif-ref {
    padding: 10px 20px;
    background: var(--primary-bg);
    border-bottom: 1px solid var(--primary-light);
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.llm-tarif-ref strong { color: var(--primary); }

.llm-tarif-legend {
    display: flex;
    gap: 20px;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.llt-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.llt-more { color: #b91c1c; font-weight: 700; }
.llt-less { color: #166534; font-weight: 700; }

.llm-tarif-scroll {
    overflow-y: auto;
    flex: 1;
}

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

.llm-tarif-table thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    padding: 8px 12px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    z-index: 1;
}

.llm-tarif-table thead th.llt-ratio { text-align: center; }

.llm-tarif-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.llm-tarif-table tbody tr:hover { background: var(--primary-bg); }

.llt-ref-row {
    background: var(--primary-bg) !important;
    font-weight: 600;
}

.llt-ref-row:hover { background: var(--primary-bg) !important; }

.llt-provider {
    padding: 9px 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.llt-model {
    padding: 9px 12px;
    font-weight: 500;
    color: var(--text);
}

.llt-ref-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: 4px;
    background: var(--primary);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    vertical-align: middle;
    letter-spacing: 0.3px;
}

.llt-ratio {
    padding: 9px 12px;
    text-align: center;
    font-weight: 700;
    font-size: 0.88rem;
    white-space: nowrap;
}

.ratio-more { color: #b91c1c; }
.ratio-less { color: #166534; }
.ratio-eq   { color: var(--text-light); font-weight: 600; }

.llt-usecase {
    padding: 9px 12px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    max-width: 220px;
}

.llt-price {
    display: block;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.llt-rel {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-top: 1px;
}

/* ============ IMPRESSION / PDF ============ */
@media print {
    /* Forcer les couleurs d'arrière-plan et les couleurs de texte */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    @page {
        size: A4;
        margin: 1.5cm;
    }

    body {
        background: white !important;
        font-size: 12px;
        line-height: 1.5;
        color: #1A1A1A;
    }

    .container {
        max-width: 100%;
        padding: 0;
        margin: 0;
    }

    /* --- Masquer tout ce qui n'est pas le résultat --- */
    .sidebar,
    header,
    .form-card,
    #loading,
    #error,
    footer,
    .prompt-bar,
    .results-header .actions {
        display: none !important;
    }

    /* --- Carte résultats : retirer l'ombre et le padding externe --- */
    #results.card {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    /* --- En-tête résultats --- */
    .results-header {
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 2px solid #1F4E79;
    }

    .results-header h2 {
        font-size: 18px;
    }

    /* --- Score summary --- */
    .score-summary {
        break-inside: avoid;
        padding: 16px;
        margin-bottom: 16px;
    }

    .score-circle {
        width: 90px;
        height: 90px;
    }

    #score-value { font-size: 28px; }

    /* --- Blocs sections --- */
    .section-block {
        margin-bottom: 18px;
    }

    /* Garder le h3 avec son contenu */
    .section-block h3 {
        break-after: avoid;
        font-size: 14px;
        margin-bottom: 8px;
    }

    /* Éviter les coupures à l'intérieur des éléments importants */
    .score-summary,
    .usage-grid,
    .dimension-card,
    .reco-item,
    .weakness-item,
    .variable-analysis-card,
    .arch-grid,
    .code-analysis-grid,
    .improved-block {
        break-inside: avoid;
    }

    /* --- Grilles d'usage : 4 colonnes maintenues --- */
    .usage-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }

    .usage-value { font-size: 16px; }

    /* --- Dimensions --- */
    .dimensions-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    /* --- Deux colonnes (forces / faiblesses) --- */
    .section-block.two-cols {
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }

    /* --- Blocs de code améliorés : fond clair pour l'impression --- */
    .code-block {
        background: #f4f4f4 !important;
        color: #1a1a1a !important;
        border: 1px solid #ccc !important;
        max-height: none !important;
        overflow: visible !important;
        font-size: 10px;
        line-height: 1.4;
        white-space: pre-wrap;
    }

    /* --- Synthèse --- */
    .synthesis {
        font-size: 12px;
    }

    /* --- Recommandations --- */
    .reco-item {
        border: 1px solid #ccc;
        padding: 10px 12px;
    }

    /* --- Faiblesses --- */
    .weakness-item {
        padding: 8px 10px;
    }

    /* --- Analyse variables --- */
    .variable-analysis-card {
        padding: 10px 12px;
    }
}
