:root {
    --bg: #f5f6fa; --surface: #fff; --text: #1e2230; --muted: #6b7280; --border: #e3e6ee;
    --accent: #4f46e5; --accent-d: #4338ca; --accent-soft: #eef0ff;
    --ok: #15803d; --ok-bg: #dcfce7; --warn: #b45309; --warn-bg: #fef3c7; --bad: #b91c1c; --bad-bg: #fee2e2;
    --radius: 14px; --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 6px 20px rgba(20, 24, 40, .05);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12141c; --surface: #1b1e29; --text: #e8eaf2; --muted: #9aa1b5; --border: #2c3040;
        --accent: #8b87ff; --accent-d: #a5a2ff; --accent-soft: #252849;
        --ok: #4ade80; --ok-bg: #12301e; --warn: #fbbf24; --warn-bg: #36290c; --bad: #f87171; --bad-bg: #3a1717;
        --shadow: none;
    }
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.5; }
h1 { font-size: 1.75rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
a { color: var(--accent); }
.container { width: min(1120px, 100% - 32px); margin-inline: auto; }
main.container { padding-block: 28px 40px; }
.muted { color: var(--muted); font-size: .92rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; word-break: break-all; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar__inner { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand__logo { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 1.2rem; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover, .nav a.is-active { color: var(--text); background: var(--accent-soft); }
.footer { color: var(--muted); font-size: .85rem; padding-bottom: 32px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; margin-bottom: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2--tight { gap: 12px 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { margin: 0; }
.head-actions, .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions--sticky { position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--accent); }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-d); border-color: var(--accent-d); }
.btn--ghost { background: transparent; }
.btn--lg { padding: 13px 28px; font-size: 1.05rem; }
.btn--small { padding: 5px 10px; font-size: .85rem; }
.btn--danger-ghost { color: var(--bad); background: transparent; }
.link { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 6px 0; margin-top: 8px; }
.link:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 2px; }

.hero { text-align: center; max-width: 720px; margin: 8px auto 28px; }
.hero h1 { font-size: 2.1rem; }
.lead { color: var(--muted); font-size: 1.05rem; }
.upload { max-width: 820px; margin-inline: auto; }
.upload .actions { justify-content: center; margin-top: 22px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: var(--bg); border-radius: 12px; margin-bottom: 20px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: 9px; }
.segmented small { color: var(--muted); }
.segmented input:checked + span { background: var(--surface); box-shadow: var(--shadow); color: var(--accent); }
.segmented input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }

.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; min-height: 180px; padding: 24px; border: 2px dashed var(--border); border-radius: var(--radius); transition: .15s; }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.dropzone.is-over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { border-style: solid; border-color: var(--ok); background: var(--ok-bg); }
.dropzone__icon { font-size: 2rem; color: var(--accent); }
.dropzone__badge { font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.dropzone__title { font-weight: 600; word-break: break-all; }
.dropzone__hint { color: var(--muted); font-size: .88rem; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 28px 0; }
@media (max-width: 760px) { .features { grid-template-columns: 1fr; } }
.feature h3 { margin-bottom: 4px; } .feature p { margin: 0; color: var(--muted); font-size: .93rem; }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid transparent; }
.alert ul { margin: 0; padding-left: 18px; }
.alert--error { background: var(--bad-bg); color: var(--bad); }
.alert--warning { background: var(--warn-bg); color: var(--warn); }
.alert--success { background: var(--ok-bg); color: var(--ok); }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.pill--ok { background: var(--ok-bg); color: var(--ok); } .pill--warn { background: var(--warn-bg); color: var(--warn); }
.list__row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list__row:last-child { border-bottom: 0; }
.list__main { flex: 1; min-width: 0; } .list__title { font-weight: 600; text-decoration: none; }
.list__actions { display: flex; gap: 8px; }
.recent { max-width: 820px; margin: 0 auto; }
.empty { text-align: center; color: var(--muted); padding: 28px; }

/* Configuration */
.side__head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.side__head .pill { margin-left: auto; }
.badge { display: inline-grid; place-items: center; padding: 4px 10px; border-radius: 8px; font-size: .8rem; font-weight: 700; color: #fff; }
.badge--a { background: #d97706; } .badge--b { background: #7c3aed; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: .92rem; }
.field > span { font-weight: 600; } .field small { color: var(--muted); font-weight: 400; }
.field--check { flex-direction: row; align-items: flex-start; gap: 10px; padding-top: 24px; } .field--check span { font-weight: 500; }
input[type=text], input[type=number], input[type=search], select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--text); font: inherit; }
.radios { display: flex; flex-direction: column; gap: 6px; }
.preview { overflow: auto; max-height: 230px; border: 1px solid var(--border); border-radius: 10px; margin-top: 8px; }
.preview table { border-collapse: collapse; font-size: .8rem; white-space: nowrap; }
.preview th, .preview td { padding: 5px 9px; border-bottom: 1px solid var(--border); text-align: left; }
.preview th { position: sticky; top: 0; background: var(--bg); font-weight: 600; }
.preview th small { display: block; color: var(--muted); font-weight: 400; }
.preview .is-ref { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.preview .is-amount { background: color-mix(in srgb, var(--ok) 16%, transparent); }
.preview .is-account { background: color-mix(in srgb, var(--muted) 16%, transparent); }
turbo-frame[busy] .side { opacity: .6; transition: opacity .2s; }

/* Résultats */
.verdict { padding: 14px 18px; border-radius: 12px; margin-bottom: 18px; }
.verdict--ok { background: var(--ok-bg); color: var(--ok); } .verdict--warn { background: var(--warn-bg); color: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
@media (max-width: 960px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.stat__n { font-size: 1.6rem; font-weight: 700; line-height: 1.1; } .stat__l { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.stat--ok .stat__n { color: var(--ok); } .stat--warn .stat__n { color: var(--warn); } .stat--bad .stat__n { color: var(--bad); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin: -8px -8px 16px; padding: 0 8px; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 12px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tabs button.is-active { color: var(--accent); border-color: var(--accent); }
.count { display: inline-block; min-width: 22px; padding: 0 7px; margin-left: 4px; border-radius: 999px; background: var(--bg); font-size: .8rem; text-align: center; }
.search { max-width: 320px; margin-bottom: 12px; }
.table-wrap { overflow: auto; max-height: 560px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { position: sticky; top: 0; background: var(--bg); text-align: left; padding: 9px 12px; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.table td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.table tr[hidden] { display: none; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta { font-weight: 700; } .delta--pos { color: var(--ok); } .delta--neg { color: var(--bad); }
.sug { margin-bottom: 2px; }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; font-size: .92rem; } .dl dt { color: var(--muted); } .dl dd { margin: 0; }
.notes { margin: 0; padding-left: 18px; font-size: .92rem; } .notes .bad { color: var(--bad); }

/* Récapitulatif cliquable */
button.stat { font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
.stat--link:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow); }
.stat--link { transition: .12s; }
.insights h2 { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.insights h2 .muted { font-weight: 400; font-size: .85rem; }
.insights__grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 760px) { .insights__grid { grid-template-columns: 1fr; } }
.insight h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.insight ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.insight__btn { width: 100%; display: flex; gap: 10px; align-items: baseline; text-align: left; font: inherit; color: var(--text); background: var(--bg); border: 1px solid transparent; border-radius: 9px; padding: 8px 12px; cursor: pointer; }
.insight__btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.insight__n { font-weight: 700; color: var(--accent); min-width: 2.2ch; text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { font: inherit; font-size: .85rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.is-active .count { background: rgba(255, 255, 255, .25); color: #fff; }
.stat--link { display: flex; flex-direction: column; justify-content: flex-start; }

/* Suivi du traitement */
.progress-card__top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.progress-card__title { font-size: 1.05rem; }
.bar { height: 10px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--border); }
.bar span { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.progress-card__links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.progress-card__links .chip { display: inline-flex; gap: 6px; align-items: center; }
.treat { min-width: 230px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; cursor: pointer; margin-bottom: 4px; }
.treat__comment { padding: 5px 8px !important; font-size: .85rem; }
.treat__state { display: block; font-size: .75rem; min-height: 1em; }
tr.is-treated td { color: var(--muted); }
tr.is-treated td.treat { color: var(--text); }
tr.is-treated .mono { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.treat__who { display: block; font-size: .75rem; min-height: 1em; }
.auth { display: grid; place-items: center; padding: 48px 0; }
.auth__card { width: min(100%, 420px); display: grid; gap: 14px; }
.auth__card form { display: grid; gap: 14px; }
.logout { display: inline-flex; margin: 0; }
.logout .link { padding: 8px 12px; }
