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

:root {
    --navy: #201667;
    --navy-light: #2e2080;
    --navy-faded: rgba(32, 22, 103, 0.06);
    --gold: #c5a44e;
    --gold-light: #f5edda;
    --gold-dark: #a8893d;
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-secondary: #5a5a72;
    --text-muted: #8e8ea0;
    --border: #e8e8ee;
    --border-light: #f0f0f5;
    --error: #c0392b;
    --error-bg: #fdf0ef;
    --missing-bg: #fef8f8;
    --conf-high: #2e7d52;
    --conf-mid: #c5a44e;
    --conf-low: #c0392b;
    --radius: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(32, 22, 103, 0.04), 0 1px 2px rgba(32, 22, 103, 0.06);
    --shadow-md: 0 4px 12px rgba(32, 22, 103, 0.06), 0 2px 4px rgba(32, 22, 103, 0.04);
    --shadow-lg: 0 8px 24px rgba(32, 22, 103, 0.08), 0 4px 8px rgba(32, 22, 103, 0.04);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: #ffffff;
    padding: 0 32px;
    border-bottom: 3px solid var(--navy);
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 32px;
    padding: 16px 0;
}

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

.logo {
    height: 44px;
    width: auto;
}

.header-text {
    border-left: 1px solid var(--border);
    padding-left: 32px;
}

header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--navy);
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 400;
    margin-top: 2px;
    letter-spacing: 0.02em;
}

/* Main */
main {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 32px 48px;
    width: 100%;
    flex: 1;
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 32px;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
}

/* Upload Section */
#upload-section {
    max-width: 540px;
    margin: 48px auto;
}

.upload-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.card-header {
    text-align: center;
    margin-bottom: 28px;
}

.card-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 6px;
}

.card-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

#dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 44px 24px;
    cursor: pointer;
    transition: all var(--transition);
    background: var(--navy-faded);
    text-align: center;
}

#dropzone:hover,
#dropzone.dragover {
    border-color: var(--navy);
    background: rgba(32, 22, 103, 0.04);
    box-shadow: 0 0 0 4px rgba(32, 22, 103, 0.06);
}

#dropzone.has-file {
    border-color: var(--gold);
    border-style: solid;
    background: var(--gold-light);
}

.dropzone-icon {
    color: var(--navy);
    opacity: 0.35;
    margin-bottom: 12px;
}

#dropzone:hover .dropzone-icon,
#dropzone.dragover .dropzone-icon {
    opacity: 0.6;
}

.dropzone-text {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
}

.dropzone-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 4px;
}

#file-info {
    margin-top: 16px;
}

.file-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--gold-light);
    border: 1px solid rgba(197, 164, 78, 0.25);
    border-radius: 6px;
    font-size: 0.82rem;
    color: var(--navy);
    font-weight: 500;
}

.file-badge svg {
    flex-shrink: 0;
    opacity: 0.6;
}

#clear-file {
    background: none;
    border: none;
    font-size: 1.15rem;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 2px;
    line-height: 1;
    margin-left: 4px;
}

#clear-file:hover {
    color: var(--error);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
    padding: 12px 28px;
    background: var(--navy);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    width: 100%;
}

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

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--surface);
    color: var(--navy);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--navy-faded);
    border-color: var(--navy);
}

.hidden {
    display: none !important;
}

/* Progress Section */
#progress-section {
    max-width: 600px;
    margin: 60px auto;
}

.progress-container {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
}

.progress-header {
    text-align: center;
    margin-bottom: 28px;
}

.progress-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 4px;
}

.progress-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.progress-bar {
    height: 4px;
    background: var(--border-light);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 28px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--navy), var(--gold));
    border-radius: 2px;
    width: 0%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#progress-steps {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 24px;
}

.step {
    display: flex;
    flex-direction: column;
    flex: 1 1 0;
    align-items: center;
    text-align: center;
    gap: 6px;
    font-size: 0.78rem;
    line-height: 1.3;
    color: var(--text-muted);
    font-weight: 400;
}

.step.active {
    color: var(--navy);
    font-weight: 500;
}

.step.done {
    color: var(--gold-dark);
}

.step-indicator {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: all var(--transition);
}

.step.active .step-indicator {
    border-color: var(--navy);
    background: var(--navy-faded);
}

.step.done .step-indicator {
    border-color: var(--gold);
    background: var(--gold);
    color: white;
}

.step.done .step-indicator::after {
    content: '\2713';
    font-weight: 600;
}

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

.step.active .step-indicator {
    animation: pulse 1.8s ease-in-out infinite;
}

#progress-message {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Results Section */
#results-section {
    margin-top: 8px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.results-title h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--navy);
}

#fund-meta {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

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

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 0;
    gap: 4px;
}

.tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    border-radius: 6px 6px 0 0;
}

.tab:hover {
    color: var(--text);
    background: var(--navy-faded);
}

.tab.active {
    color: var(--navy);
    border-bottom-color: var(--gold);
    background: transparent;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Data Tables */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-top: 0;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 0.82rem;
}

.data-table th {
    background: var(--navy);
    color: white;
    font-weight: 500;
    text-align: left;
    padding: 11px 14px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-light);
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.data-table tbody tr:hover td {
    background: var(--navy-faded);
}

.data-table td:first-child {
    font-weight: 500;
    color: var(--navy);
    white-space: nowrap;
    position: sticky;
    left: 0;
    background: var(--surface);
    z-index: 0;
    border-right: 1px solid var(--border-light);
}

.data-table tbody tr:hover td:first-child {
    background: var(--navy-faded);
}

.data-table tbody tr:nth-child(even) td {
    background: rgba(32, 22, 103, 0.015);
}

.data-table tbody tr:nth-child(even) td:first-child {
    background: rgba(32, 22, 103, 0.015);
}

.data-table tbody tr:nth-child(even):hover td,
.data-table tbody tr:nth-child(even):hover td:first-child {
    background: var(--navy-faded);
}

td.missing {
    background: var(--missing-bg) !important;
    color: var(--text-muted);
    font-style: italic;
}

td.missing::after {
    content: '\2014';
}

/* Citations & confidence */
td.cell-cited {
    cursor: pointer;
    position: relative;
}

td.cell-cited.conf-low {
    border-left: 3px solid var(--conf-low);
}

td.cell-cited.conf-mid {
    border-left: 3px solid var(--conf-mid);
}

td.cell-cited.conf-high {
    border-left: 3px solid var(--conf-high);
}

.conf-badge {
    display: inline-block;
    float: right;
    margin-left: 8px;
    padding: 1px 6px;
    border-radius: 9px;
    font-size: 0.68rem;
    font-weight: 600;
    line-height: 1.5;
    color: #fff;
    vertical-align: middle;
}

.conf-badge.conf-high { background: var(--conf-high); }
.conf-badge.conf-mid  { background: var(--conf-mid); }
.conf-badge.conf-low  { background: var(--conf-low); }

/* "Contrôle 4 yeux" verification */
.verification-banner {
    margin: 16px 0 0;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 500;
    border: 1px solid transparent;
}

.verification-banner.banner-ok {
    background: rgba(46, 125, 82, 0.08);
    border-color: var(--conf-high);
    color: var(--conf-high);
}

.verification-banner.banner-issues {
    background: rgba(197, 164, 78, 0.1);
    border-color: var(--conf-mid);
    color: #8a6d1f;
}

.verification-banner.banner-unavailable {
    background: var(--missing-bg);
    border-color: var(--border);
    color: var(--text-muted);
}

td.cell-flagged {
    cursor: pointer;
    position: relative;
}

td.cell-flagged.flag-warning {
    box-shadow: inset 0 0 0 2px var(--conf-mid);
}

td.cell-flagged.flag-error {
    box-shadow: inset 0 0 0 2px var(--conf-low);
}

.flag-badge {
    display: inline-block;
    float: right;
    margin-left: 6px;
    font-size: 0.8rem;
    line-height: 1.4;
}

.flag-badge.flag-warning { color: var(--conf-mid); }
.flag-badge.flag-error   { color: var(--conf-low); }

.citation-panel-flag {
    margin-top: 14px;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 0.82rem;
    line-height: 1.5;
    white-space: pre-line;
}

.citation-panel-flag.flag-warning {
    background: rgba(197, 164, 78, 0.1);
    border: 1px solid var(--conf-mid);
    color: #8a6d1f;
}

.citation-panel-flag.flag-error {
    background: rgba(192, 57, 43, 0.08);
    border: 1px solid var(--conf-low);
    color: var(--conf-low);
}

.citation-panel-flag.hidden {
    display: none;
}

.citation-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 92vw;
    height: 100vh;
    padding: 24px 28px;
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--transition);
    visibility: hidden;
    z-index: 100;
}

.citation-panel.open {
    transform: translateX(0);
    visibility: visible;
}

.citation-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.citation-panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.citation-panel-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
}

.citation-panel-close:hover {
    color: var(--navy);
}

.citation-panel-field {
    font-weight: 600;
    color: var(--navy);
    margin-bottom: 8px;
}

.citation-panel-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.citation-panel-value {
    font-weight: 500;
    color: var(--text);
}

.citation-panel-meta .conf-badge {
    float: none;
    margin-left: 0;
}

.citation-panel-quote {
    margin: 0;
    padding: 12px 16px;
    background: var(--gold-light);
    border-left: 3px solid var(--gold);
    border-radius: 6px;
    color: var(--text);
    font-style: italic;
    white-space: pre-wrap;
}

.citation-panel-quote.empty {
    background: var(--missing-bg);
    border-left-color: var(--border);
    color: var(--text-muted);
}

/* Error Section */
.error-box {
    max-width: 480px;
    margin: 60px auto;
    padding: 36px;
    background: var(--surface);
    border: 1px solid #f0d0cc;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.error-icon {
    color: var(--error);
    margin-bottom: 16px;
    opacity: 0.7;
}

#error-message {
    color: var(--error);
    margin-bottom: 20px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.error-box .btn-primary {
    width: auto;
    margin-top: 0;
}

/* Responsive */
@media (max-width: 768px) {
    header { padding: 0 16px; }
    .header-inner { gap: 16px; padding: 14px 0; }
    .header-text { padding-left: 16px; }
    header h1 { font-size: 1.05rem; }
    main { padding: 20px 16px; }
    .upload-card { padding: 24px; }
    #upload-section { margin: 24px auto; }
    .results-header { flex-direction: column; }
    #progress-steps { flex-wrap: wrap; gap: 8px; }
    .data-table { font-size: 0.76rem; }
    .data-table td, .data-table th { padding: 7px 10px; }
}

@media (max-width: 480px) {
    .logo { height: 32px; }
    .header-text { display: none; }
    .tabs { overflow-x: auto; }
}
