/* MAPP E-COMMERCE — CSS reproduisant le design base44 (sidebar sombre, fond crème, accent bleu vif) */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&display=swap');

/* === Palette HSL (extraite directement de base44/src/index.css) === */
:root {
    --background: hsl(42 14% 95%);
    --foreground: hsl(0 0% 10%);
    --card: hsl(0 0% 100%);
    --card-foreground: hsl(0 0% 10%);
    --primary: hsl(222 100% 50%);
    --primary-foreground: hsl(0 0% 100%);
    --primary-soft: hsla(222, 100%, 50%, 0.1);
    --secondary: hsl(42 14% 92%);
    --muted: hsl(42 10% 90%);
    --muted-foreground: hsl(0 0% 40%);
    --accent: hsl(76 100% 57%);
    --destructive: hsl(0 84% 60%);
    --warning: hsl(38 92% 50%);
    --success: hsl(160 84% 39%);
    --info: hsl(199 89% 48%);
    --border: hsl(42 10% 86%);
    --radius: 0.625rem;
    --radius-xl: 0.75rem;

    /* Sidebar (sombre par défaut) */
    --sidebar-bg: hsl(210 20% 16%);
    --sidebar-fg: hsl(210 10% 80%);
    --sidebar-muted: hsl(210 10% 50%);
    --sidebar-accent: hsl(210 18% 22%);
    --sidebar-accent-fg: hsl(0 0% 95%);
    --sidebar-border: hsl(210 15% 24%);

    /* Couleurs canaux (emojis sur fond coloré) */
    --shopify: hsl(160 70% 42%);     /* emerald-500 */
    --manomano: hsl(217 91% 60%);    /* blue-500 */
    --decathlon: hsl(243 75% 59%);   /* indigo-500 */
    --leroy_merlin: hsl(38 92% 50%); /* amber-500 */
}

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

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    background: var(--background);
    color: var(--foreground);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.005em;
}

/* === LAYOUT === */
.layout { display: block; }

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: 200px;
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.sidebar-brand {
    padding: 1.25rem 1rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
}

.sidebar-brand-logo {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--primary);
    color: var(--primary-foreground);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.sidebar-brand-text {
    line-height: 1.2;
}

.sidebar-brand-name {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--sidebar-accent-fg);
}

.sidebar-brand-tagline {
    font-size: 11px;
    color: var(--sidebar-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 0 0.75rem;
    overflow-y: auto;
}

.sidebar-section { margin-bottom: 1.25rem; }

.sidebar-section-title {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
    padding: 0 0.5rem;
    margin-bottom: 0.375rem;
    text-transform: uppercase;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.625rem;
    border-radius: 0.5rem;
    font-size: 13px;
    font-weight: 500;
    color: var(--sidebar-fg);
    text-decoration: none;
    margin-bottom: 0.125rem;
    transition: all 0.15s;
    cursor: pointer;
}

.sidebar-link:hover:not(.disabled) {
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-fg);
}

.sidebar-link.active {
    background: var(--primary);
    color: var(--primary-foreground);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.sidebar-link.disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.sidebar-link svg {
    width: 16px; height: 16px;
    flex-shrink: 0;
}

.sidebar-bottom {
    padding: 0 0.75rem 1rem;
}

.sidebar-help {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--sidebar-accent);
    color: var(--sidebar-accent-fg);
    border: none;
    border-radius: 0.5rem;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
}

.sidebar-help:hover { background: var(--sidebar-border); }

/* === MAIN === */
.main {
    margin-left: 200px;
    min-height: 100vh;
    padding: 1.5rem;
    /* Pleine largeur disponible — pas de max-width pour s'adapter aux grands écrans */
}

@media (min-width: 1024px) {
    .main { padding: 2rem 2.5rem; }
}

@media (min-width: 1600px) {
    .main { padding: 2rem 3rem; }
}

/* === OVERLAY DE CHARGEMENT (génération des écritures) === */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.loading-overlay.open {
    display: flex;
    opacity: 1;
}

.loading-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 2rem 2.5rem;
    width: 480px;
    max-width: 92vw;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
    text-align: center;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    margin: 0 auto 1.25rem;
    border: 4px solid hsl(217 91% 60% / 0.15);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: loading-spin 0.9s linear infinite;
}
@keyframes loading-spin {
    to { transform: rotate(360deg); }
}

.loading-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0 0 0.5rem 0;
}

.loading-step {
    font-size: 0.9375rem;
    color: var(--muted-foreground);
    margin: 0 0 1.5rem 0;
    min-height: 1.5em;
}

.loading-bar-wrap {
    height: 8px;
    background: var(--muted);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), hsl(217 91% 75%));
    border-radius: 999px;
    width: 0%;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.loading-pct {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    font-variant-numeric: tabular-nums;
}

.loading-hint {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 1rem;
    font-style: italic;
}

.main-header { margin-bottom: 1.5rem; }

.view-header-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--foreground);
}

.main-header .subtitle {
    margin-top: 0.25rem;
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

.section-stack > * + * { margin-top: 1.25rem; }

/* === DROPZONE === */
.dropzone {
    background: var(--card);
    border: 2px dashed var(--border);
    border-radius: var(--radius-xl);
    padding: 2.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dropzone:hover { border-color: hsl(0 0% 60%); }

.dropzone.dragover {
    border-color: var(--primary);
    background: var(--primary-soft);
    transform: scale(1.005);
}

.dropzone-icon {
    width: 48px; height: 48px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: var(--muted);
    display: flex; align-items: center; justify-content: center;
    color: var(--muted-foreground);
    transition: all 0.2s;
}

.dropzone.dragover .dropzone-icon {
    background: var(--primary-soft);
    color: var(--primary);
}

.dropzone-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.25rem;
}

.dropzone-link {
    font-size: 0.875rem;
}

.dropzone-link a {
    color: var(--primary);
    font-weight: 500;
    cursor: pointer;
}

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

.dropzone-info {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.75rem;
}

/* === DEMO BANNER === */
.demo-banner {
    position: relative;
    text-align: center;
    padding: 0.25rem 0;
}

.demo-banner::before {
    content: '';
    position: absolute;
    left: 0; right: 0; top: 50%;
    border-top: 1px dashed var(--border);
}

.demo-banner-link {
    position: relative;
    display: inline-block;
    background: var(--background);
    padding: 0.25rem 1rem;
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.demo-banner-link:hover { text-decoration: underline; }

/* === FILE LIST === */
.file-list {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0.75rem;
}

.file-list h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
    padding: 0 0.25rem;
}

.file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    transition: background 0.15s;
}

.file-item:hover { background: var(--muted); }

.file-item-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    flex: 1;
}

.file-item-name .file-size { color: var(--muted-foreground); font-size: 0.75rem; }

.file-item-actions { display: flex; align-items: center; gap: 0.5rem; }

.file-channel-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: white;
}

.file-channel-badge.shopify { background: var(--shopify); }
.file-channel-badge.manomano { background: var(--manomano); }
.file-channel-badge.decathlon { background: var(--decathlon); }
.file-channel-badge.leroy_merlin { background: var(--leroy_merlin); }
.file-channel-badge.unknown { background: var(--destructive); }

.file-remove {
    background: transparent; border: none; color: var(--muted-foreground);
    cursor: pointer; font-size: 1rem; padding: 0 0.375rem; line-height: 1;
}

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

/* === FILE NAMING GUIDE === */
.naming-guide {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.naming-guide-icon {
    width: 32px; height: 32px;
    flex-shrink: 0;
    margin-top: 2px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}

.naming-guide-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.naming-guide-text {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    line-height: 1.6;
}

.naming-guide-text .highlight {
    font-weight: 500;
    color: var(--foreground);
}

.naming-guide-examples {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.naming-guide-examples code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
    background: var(--muted);
    color: var(--foreground);
    border-radius: 0.375rem;
    font-weight: 500;
}

/* === CHANNELS === */
.channels-section { /* container */ }

.channels-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 0.75rem;
}

.channels-header h2 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.channels-header-count {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.channels-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) { .channels-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1280px) { .channels-grid { grid-template-columns: repeat(4, 1fr); } }

.channel-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1rem;
    min-width: 0;
}

.channel-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.channel-card-title {
    display: flex; align-items: center; gap: 0.625rem;
}

.channel-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    color: white;
    font-size: 0.875rem;
    display: flex; align-items: center; justify-content: center;
}

.channel-icon.shopify { background: var(--shopify); }
.channel-icon.manomano { background: var(--manomano); }
.channel-icon.decathlon { background: var(--decathlon); }
.channel-icon.leroy_merlin { background: var(--leroy_merlin); }

.channel-card-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
}

.channel-card-status {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
}

.channel-card.complete .channel-card-status {
    color: var(--success);
}

.channel-card-files {
    display: flex; flex-direction: column; gap: 0.5rem;
}

.channel-card-files li {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    background: hsl(42 10% 90% / 0.5);
    border: 1px solid var(--border);
}

.channel-card-files li.found {
    background: hsl(160 84% 39% / 0.08);
    border-color: hsl(160 84% 39% / 0.3);
}

.channel-card-files li .file-pattern {
    display: flex; align-items: center; gap: 0.5rem;
    overflow: hidden; min-width: 0;
}

.channel-card-files li .file-pattern code {
    color: var(--muted-foreground);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.6875rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.channel-card-files li.found .file-pattern code { color: var(--foreground); }

.file-status-icon {
    width: 14px; height: 14px;
    color: var(--muted-foreground);
    flex-shrink: 0;
}

.channel-card-files li.found .file-status-icon { color: var(--success); }

.badge-status {
    font-size: 10px;
    font-weight: 700;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    background: var(--primary-soft);
    color: var(--primary);
}

.channel-card-files li.found .badge-status {
    background: hsl(160 84% 39% / 0.15);
    color: var(--success);
}

/* Badge "Optionnel" — gris discret, contraste avec "Requis" bleu */
.badge-status.badge-optional {
    background: hsl(210 16% 93%);
    color: hsl(215 16% 47%);
}
.channel-card-files li.found .badge-status.badge-optional {
    background: hsl(160 84% 39% / 0.15);
    color: var(--success);
}

/* === ACTION BAR === */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 0.875rem 1.25rem;
}

.action-bar-status {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.action-bar-status.success { color: var(--success); }
.action-bar-status.error { color: var(--destructive); }
.action-bar-status.processing { color: var(--info); }

.action-bar-buttons { display: flex; gap: 0.5rem; }

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    transition: all 0.15s;
    height: 2rem;
    white-space: nowrap;
}

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

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

.btn-primary:hover:not(:disabled) { background: hsl(222 100% 45%); }

.btn-outline {
    background: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-outline:hover:not(:disabled) { background: var(--muted); }

.btn-large { height: 2.5rem; padding: 0 1.25rem; font-size: 0.875rem; font-weight: 600; }

.btn svg { width: 14px; height: 14px; }

/* === RESULTS === */
.results-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
}

.results-card h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 1rem;
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.kpi {
    background: var(--muted);
    border-radius: 0.5rem;
    padding: 0.875rem;
    text-align: center;
}

.kpi-value {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.1;
    letter-spacing: -0.02em;
}

.kpi-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.download-section {
    text-align: center;
    padding: 1.5rem;
    background: hsl(160 84% 39% / 0.08);
    border-radius: 0.5rem;
    margin: 1rem 0;
}

.download-section .btn {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.download-section .btn:hover:not(:disabled) { background: hsl(160 84% 35%); }

.download-info {
    color: var(--muted-foreground);
    font-size: 0.75rem;
    margin-top: 0.5rem;
}

/* === ANOMALIES === */
.anomalies-detail h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 1rem 0 0.5rem;
}

.anomaly-row {
    display: grid;
    grid-template-columns: 70px 1fr auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    background: var(--muted);
    border-left: 3px solid var(--border);
}

.anomaly-row.error { border-left-color: var(--destructive); }
.anomaly-row.warning { border-left-color: var(--warning); }
.anomaly-row.info { border-left-color: var(--info); }

.anomaly-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    text-align: center;
    color: white;
}

.anomaly-badge.error { background: var(--destructive); }
.anomaly-badge.warning { background: var(--warning); }
.anomaly-badge.info { background: var(--info); }

.anomaly-count {
    background: var(--card);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 600;
    color: var(--muted-foreground);
    font-size: 0.75rem;
}

/* === FILTERS BAR === */
.filters-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-group input,
.filter-group select {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.8125rem;
    background: var(--card);
    color: var(--foreground);
    height: 2rem;
    min-width: 130px;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.table-info {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
}

/* === DATA TABLE === */
.table-container {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: auto;
    max-height: 70vh;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.data-table thead {
    position: sticky;
    top: 0;
    background: var(--muted);
    z-index: 1;
}

.data-table th {
    padding: 0.625rem 0.75rem;
    font-weight: 600;
    color: var(--foreground);
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table th.num,
.data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

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

.data-table tbody tr:hover {
    background: var(--muted);
}

.data-table td {
    padding: 0.5rem 0.75rem;
    color: var(--foreground);
    vertical-align: middle;
}

.data-table td.num {
    font-variant-numeric: tabular-nums;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.pagination button {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.8125rem;
    font-family: inherit;
    color: var(--foreground);
}

.pagination button:hover:not(:disabled) {
    background: var(--muted);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pagination button.current {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.pagination .page-info {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin: 0 0.5rem;
}

/* === ANOMALIES VIEW === */
.anomalies-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.anomalies-stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    text-align: center;
}

.anomalies-stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.1;
}
.anomalies-stat.error .anomalies-stat-value { color: var(--destructive); }
.anomalies-stat.warning .anomalies-stat-value { color: var(--warning); }
.anomalies-stat.info .anomalies-stat-value { color: var(--info); }

.anomalies-stat-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.25rem;
}

.anomalies-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.anomaly-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 0.75rem;
    align-items: center;
}

.anomaly-card.error { border-left-color: var(--destructive); }
.anomaly-card.warning { border-left-color: var(--warning); }
.anomaly-card.info { border-left-color: var(--info); }

.anomaly-card-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}

.anomaly-severity {
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: white;
    letter-spacing: 0.04em;
}

.anomaly-severity.error { background: var(--destructive); }
.anomaly-severity.warning { background: var(--warning); }
.anomaly-severity.info { background: var(--info); }

.anomaly-card-canal {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    font-weight: 500;
}

.anomaly-card-content {
    min-width: 0;
}

.anomaly-card-title {
    font-weight: 600;
    color: var(--foreground);
    font-size: 0.875rem;
    margin-bottom: 0.125rem;
}

.anomaly-card-detail {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    line-height: 1.5;
}

.anomaly-card-ref {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    background: var(--muted);
    padding: 0.125rem 0.5rem;
    border-radius: 0.25rem;
    white-space: nowrap;
}

/* === ANOMALIES — cartes de groupe (1 carte = 1 type d'anomalie + N refs) === */
.anomaly-group {
    background: var(--card);
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.625rem;
}
.anomaly-group.error { border-left-color: var(--destructive); }
.anomaly-group.warning { border-left-color: var(--warning); }
.anomaly-group.info { border-left-color: var(--info); }

.anomaly-group-header {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    flex-wrap: wrap;
}

.anomaly-group-title {
    font-weight: 600;
    color: var(--foreground);
    font-size: 0.9375rem;
    flex: 1;
    min-width: 0;
}

.anomaly-group-count {
    background: var(--secondary);
    color: var(--muted-foreground);
    font-size: 0.6875rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
}
.anomaly-group.error .anomaly-group-count {
    background: hsl(0 84% 95%);
    color: hsl(0 84% 45%);
}
.anomaly-group.warning .anomaly-group-count {
    background: hsl(35 91% 95%);
    color: hsl(35 91% 45%);
}
.anomaly-group.info .anomaly-group-count {
    background: hsl(217 91% 95%);
    color: hsl(217 91% 50%);
}

.anomaly-group-toggle {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    display: flex;
    transition: transform 0.15s, background 0.15s;
}
.anomaly-group-toggle:hover { background: var(--secondary); }
.anomaly-group-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.anomaly-group-toggle svg { transition: transform 0.15s; }

.anomaly-group-detail {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin-top: 0.375rem;
    line-height: 1.4;
}

.anomaly-group-refs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.625rem;
    padding-top: 0.625rem;
    border-top: 1px dashed var(--border);
    max-height: 240px;
    overflow-y: auto;
}

.anomaly-ref-chip {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.6875rem;
    background: var(--muted);
    color: var(--muted-foreground);
    padding: 0.125rem 0.4375rem;
    border-radius: 0.25rem;
    white-space: nowrap;
    border: 1px solid transparent;
}
.anomaly-ref-chip:hover {
    border-color: var(--border);
    color: var(--foreground);
}

/* === PLACEHOLDER === */
.placeholder-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 3rem 2rem;
    text-align: center;
    color: var(--muted-foreground);
}

.placeholder-card p { margin: 0.25rem 0; }

.card-subtitle {
    color: var(--muted-foreground);
    font-size: 0.875rem;
}

/* === CHARTS GRID (Résumé + Flash) === */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

@media (min-width: 900px) {
    .charts-grid { grid-template-columns: 1fr 1fr; }
    .chart-card-wide { grid-column: 1 / -1; }
}

.chart-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
}

.chart-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}

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

.chart-card-wide .chart-wrapper { height: 320px; }

/* === TOGGLE HT/TTC === */
.toggle-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.toggle-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.toggle-pill {
    display: inline-flex;
    background: var(--muted);
    padding: 2px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.toggle-btn {
    padding: 4px 14px;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted-foreground);
    font-family: inherit;
    transition: all 0.15s;
}

.toggle-btn.active {
    background: var(--primary);
    color: var(--primary-foreground);
}

#resume-period-info,
.filter-info-hint {
    margin-left: 1rem;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* === VUE PARAMÈTRES === */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.settings-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
}

.settings-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0 0 0.25rem 0;
}

.settings-card-subtitle {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin: 0 0 1rem 0;
    line-height: 1.4;
}

.settings-card-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.settings-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.settings-field label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--foreground);
}

.settings-field input {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem 0.625rem;
    font-size: 0.875rem;
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    color: var(--foreground);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.settings-field input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px hsl(217 91% 60% / 0.2);
}

.settings-field input.settings-overridden {
    border-color: hsl(35 91% 55%);
    background: hsl(35 91% 95% / 0.4);
}

.settings-field-hint {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    font-style: italic;
}

/* === MODAL DIALOG (sélecteur types anomalies, etc.) === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.modal-backdrop.open { opacity: 1; }
.modal-backdrop[hidden] { display: none; }

.modal-dialog {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -48%);
    width: 540px;
    max-width: 92vw;
    max-height: 84vh;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.25);
    z-index: 100;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transition: opacity 0.18s ease, transform 0.18s ease;
}
.modal-dialog.open {
    opacity: 1;
    transform: translate(-50%, -50%);
}
.modal-dialog[hidden] { display: none; }

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal-header h2 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.modal-intro {
    padding: 0.875rem 1.25rem 0.5rem 1.25rem;
    margin: 0;
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

.modal-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0 1.25rem 0.75rem 1.25rem;
}

.btn-sm {
    padding: 0.3125rem 0.625rem;
    font-size: 0.75rem;
}

.modal-types-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 1.25rem;
    border-top: 1px solid var(--border);
}

.modal-type-row {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
}
.modal-type-row:last-child { border-bottom: none; }
.modal-type-row input[type="checkbox"] {
    margin-top: 0.1875rem;
    flex-shrink: 0;
    accent-color: var(--primary);
}
.modal-type-row-body {
    flex: 1;
    min-width: 0;
}
.modal-type-row-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
}
.modal-type-row-meta {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.125rem;
}
.modal-type-row-count {
    background: var(--secondary);
    color: var(--muted-foreground);
    font-size: 0.6875rem;
    padding: 0.0625rem 0.375rem;
    border-radius: 999px;
    font-weight: 600;
}
.modal-type-row[data-severity="error"] .modal-type-row-count {
    background: hsl(0 84% 95%);
    color: hsl(0 84% 45%);
}
.modal-type-row[data-severity="warning"] .modal-type-row-count {
    background: hsl(35 91% 95%);
    color: hsl(35 91% 45%);
}
.modal-type-row[data-severity="info"] .modal-type-row-count {
    background: hsl(217 91% 95%);
    color: hsl(217 91% 50%);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.875rem 1.25rem;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* === DRAWER AIDE (latéral droit) === */
.help-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.help-backdrop.open { opacity: 1; }
.help-backdrop[hidden] { display: none; }

.help-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: 480px;
    max-width: 92vw;
    background: var(--card);
    border-left: 1px solid var(--border);
    box-shadow: -8px 0 32px rgba(15, 23, 42, 0.12);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.help-drawer.open { transform: translateX(0); }
.help-drawer[hidden] { display: none; }

.help-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.help-drawer-title-wrap {
    display: flex;
    align-items: center;
    gap: 0.625rem;
}
.help-drawer-title-wrap h2 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
}
.help-drawer-close {
    background: transparent;
    border: none;
    color: var(--muted-foreground);
    cursor: pointer;
    padding: 0.375rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.help-drawer-close:hover {
    background: var(--secondary);
    color: var(--foreground);
}

.help-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
}

.help-section + .help-section { margin-top: 1.5rem; }

.help-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted-foreground);
    margin: 0 0 0.75rem 0;
}

.help-section-intro {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    margin: 0 0 1rem 0;
    line-height: 1.5;
}

.help-doc-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    text-decoration: none;
    margin-bottom: 0.5rem;
    transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.help-doc-link:hover {
    border-color: var(--primary);
    background: hsl(217 91% 60% / 0.06);
}
.help-doc-link:active { transform: translateY(1px); }
.help-doc-link > svg:first-child { color: var(--primary); flex-shrink: 0; }
.help-doc-link > svg:last-child { color: var(--muted-foreground); flex-shrink: 0; }
.help-doc-link-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    flex: 1;
    min-width: 0;
}
.help-doc-link-title {
    font-size: 0.875rem;
    font-weight: 600;
}
.help-doc-link-sub {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.help-channel {
    margin-bottom: 1.25rem;
}
.help-channel-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}
.help-channel-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.help-channel-count {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    font-weight: 400;
}
.help-channel-sub {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
    margin: 0 0 0.5rem 0;
}
.help-channel-note {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin: 0.5rem 0 0 0;
}
.help-channel ul,
.help-mode ul {
    list-style: none;
    padding: 0 0 0 1rem;
    margin: 0.25rem 0;
}
.help-channel ul li,
.help-mode ul li {
    font-size: 0.8125rem;
    color: var(--foreground);
    padding: 0.25rem 0;
}
.help-channel code,
.help-mode code,
.help-examples code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.75rem;
    color: var(--foreground);
}
.help-mode {
    margin: 0.5rem 0 0.75rem 0;
}
.help-mode h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0 0 0.25rem 0;
}
.help-optional code {
    color: var(--muted-foreground);
    font-style: italic;
}
.help-optional span {
    font-size: 0.6875rem;
    color: var(--muted-foreground);
    font-style: italic;
    margin-left: 0.25rem;
}

.help-examples {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}
.help-examples h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--foreground);
    margin: 0 0 0.5rem 0;
}
.help-examples ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.help-examples ul li {
    font-size: 0.75rem;
    color: var(--primary);
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    padding: 0.1875rem 0;
}

/* === BANDEAU DE CONTRÔLE COMPTABLE (Résumé) === */
.control-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.control-stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-left-width: 4px;
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
}

.control-stat.ok { border-left-color: var(--success); }
.control-stat.warn { border-left-color: var(--warning); }
.control-stat.err { border-left-color: var(--destructive); }
.control-stat.info { border-left-color: var(--info); }

.control-stat-label {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.control-stat-value {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.2;
}

.control-stat-detail {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-top: 0.125rem;
}

/* === CARTES DE CONTRÔLE FLASH (équilibre + anomalies) === */
.control-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 768px) {
    .control-cards-grid { grid-template-columns: 1fr; }
}

.control-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-left-width: 5px;
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-card.ok { border-left-color: var(--success); }
.control-card.warn { border-left-color: var(--warning); }
.control-card.err { border-left-color: var(--destructive); }
.control-card.info { border-left-color: var(--info); }

.control-card-icon {
    font-size: 1.875rem;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-card.ok .control-card-icon { background: rgba(22, 163, 74, 0.1); color: var(--success); }
.control-card.err .control-card-icon { background: rgba(220, 38, 38, 0.1); color: var(--destructive); }
.control-card.warn .control-card-icon { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.control-card.info .control-card-icon { background: rgba(14, 165, 233, 0.1); color: var(--info); }

.control-card-body {
    flex: 1;
    min-width: 0;
}

.control-card-title {
    font-size: 0.7rem;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.control-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--foreground);
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 0.125rem;
}

.control-card-detail {
    font-size: 0.8125rem;
    color: var(--muted-foreground);
}

/* Grille 2x2 pour Flash */
.charts-grid-2x2 {
    grid-template-columns: 1fr;
}
@media (min-width: 900px) {
    .charts-grid-2x2 { grid-template-columns: 1fr 1fr; }
}

/* === FLASH BANNER === */
.flash-banner {
    background: linear-gradient(135deg, hsl(222 100% 50%), hsl(222 100% 35%));
    color: white;
    border-radius: var(--radius-xl);
    padding: 1.5rem 1.75rem;
    margin-bottom: 1.25rem;
}

.flash-banner-title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.25rem;
}

.flash-banner-period {
    font-size: 0.875rem;
    opacity: 0.85;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main { margin-left: 0; padding: 1rem; }
    .anomaly-card { grid-template-columns: 1fr; }
    .data-table { font-size: 0.75rem; }
    .chart-wrapper { height: 240px; }
}
