:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1f2933;
  --muted: #5f6c7b;
  --border: #dde3ea;
  --primary: #16a085;
  --primary-dark: #128a72;
  --accent: #2980b9;
  --danger: #c0392b;
  --warn: #d68910;
  --info: #2874a6;
  --ok: #1e8449;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 16px rgba(16, 24, 40, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { line-height: 1.45; font-size: 15px; }
a { color: var(--accent); }
h2 { margin: 0 0 .5rem; font-size: 1.35rem; }
h3 { margin: 1.2rem 0 .5rem; font-size: 1.1rem; }
code { background: #eef2f6; padding: .1em .35em; border-radius: 4px; font-size: .92em; }
pre { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.link { color: var(--accent); text-decoration: underline; cursor: pointer; }

/* Barre supérieure */
.topbar { display: flex; align-items: center; gap: 1.5rem; padding: .7rem 1.5rem; background: #142430; color: #fff; }
.brand { font-weight: 700; font-size: 1.15rem; display: flex; align-items: center; gap: .6rem; }
.brand small { font-weight: 400; color: #a9b8c4; font-size: .8rem; }
.logo { background: var(--primary); color: #fff; border-radius: 7px; padding: .15rem .45rem; font-size: .85rem; letter-spacing: .5px; }
.topbar nav { display: flex; gap: 1rem; margin-left: auto; }
.topbar nav a { color: #cfd8e0; text-decoration: none; padding: .3rem .6rem; border-radius: 6px; }
.topbar nav a.active, .topbar nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.chip { font-size: .78rem; padding: .25rem .6rem; border-radius: 999px; background: #2c3e50; color: #fff; white-space: nowrap; }
.chip-ok { background: var(--ok); }
.chip-warn { background: var(--warn); }
.chip-muted { background: #4a5a68; }

.container { max-width: 1180px; margin: 1.5rem auto 3rem; padding: 0 1rem; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem 1.6rem; margin-bottom: 1.2rem; }
.panel { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1.1rem; }
.panel h4 { margin: 0 0 .5rem; font-size: .95rem; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem 1.2rem; }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .topbar { flex-wrap: wrap; } .topbar nav { margin-left: 0; } }

/* Stepper */
.stepper { list-style: none; display: flex; gap: .5rem; padding: 0; margin: 0 0 1.2rem; flex-wrap: wrap; }
.stepper li { display: flex; align-items: center; gap: .5rem; padding: .4rem .8rem; border-radius: 999px; background: #e6ebf0; color: var(--muted); font-size: .9rem; }
.stepper li span { display: inline-flex; width: 22px; height: 22px; border-radius: 50%; background: #c8d1da; color: #fff; align-items: center; justify-content: center; font-size: .8rem; font-weight: 700; }
.stepper li.current { background: var(--primary); color: #fff; }
.stepper li.current span { background: rgba(255,255,255,.35); }
.stepper li.done { background: #d5f0e8; color: var(--primary-dark); }
.stepper li.done span { background: var(--primary); }

/* Zone de dépôt */
.dropzone { border: 2px dashed #b8c4d0; border-radius: var(--radius); padding: 2.2rem 1rem; text-align: center; color: var(--muted); cursor: pointer; transition: .15s; margin: 1rem 0; }
.dropzone:hover, .dropzone.over, .dropzone:focus { border-color: var(--primary); background: #f0faf7; outline: none; }
.dz-icon { font-size: 2rem; margin-bottom: .3rem; }
.options-row { display: flex; gap: 1.2rem; flex-wrap: wrap; align-items: flex-end; margin: .5rem 0 1rem; }
.options-row label { display: flex; flex-direction: column; gap: .25rem; font-size: .88rem; color: var(--muted); }
.options-row label.check, .toolbar label.check { flex-direction: row; align-items: center; gap: .4rem; }
select, input[type=text], input[type=number], input[type=search], input[type=password], textarea { font: inherit; padding: .45rem .6rem; border: 1px solid var(--border); border-radius: 7px; background: #fff; color: var(--text); min-width: 180px; }
textarea { width: 100%; }
.file-info { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem 1rem; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: .8rem 1rem; margin: .5rem 0 1rem; font-size: .9rem; }
.file-info b { display: block; color: var(--muted); font-weight: 500; font-size: .78rem; text-transform: uppercase; letter-spacing: .3px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .86em; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.2rem; }
.btn { font: inherit; padding: .55rem 1.1rem; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; transition: .12s; }
.btn:hover { background: #f0f3f6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.small { padding: .3rem .6rem; font-size: .82rem; }
.btn.danger { color: var(--danger); border-color: #efc7c2; }

/* Progression */
.progress { margin: 1rem 0; }
.bar { height: 10px; background: #e6ebf0; border-radius: 999px; overflow: hidden; }
.bar > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); transition: width .2s; }

/* Tables */
.badge { display: inline-block; background: #e6ebf0; color: var(--muted); font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; vertical-align: middle; }
.toolbar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: .6rem; font-size: .9rem; }
.toolbar label { display: flex; gap: .4rem; align-items: center; color: var(--muted); }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); max-height: 520px; }
table.maps { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.maps th, table.maps td { padding: .45rem .6rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
table.maps thead th { position: sticky; top: 0; background: #f2f5f8; z-index: 1; font-weight: 600; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .3px; }
table.maps tr.excluded td { color: #98a2ad; }
table.maps tr.active td { background: #f0faf7; }
.type-pill { display: inline-block; padding: .15rem .5rem; border-radius: 999px; color: #fff; font-size: .78rem; font-weight: 600; }
.conf { display: inline-flex; align-items: center; gap: .4rem; min-width: 110px; }
.conf .track { width: 70px; height: 8px; background: #e6ebf0; border-radius: 999px; overflow: hidden; }
.conf .track div { height: 100%; }
.conf-high .track div { background: var(--ok); }
.conf-medium .track div { background: var(--warn); }
.conf-low .track div, .conf-none .track div { background: var(--danger); }
.action-select { min-width: 150px; font-size: .85rem; padding: .3rem .4rem; }
.ai-cell { font-size: .8rem; color: var(--muted); max-width: 240px; white-space: normal !important; }

/* Profils */
.profiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: .8rem; margin: .8rem 0 1.2rem; }
.profile { border: 2px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; cursor: pointer; transition: .12s; }
.profile:hover { border-color: #b8c4d0; }
.profile.selected { border-color: var(--primary); background: #f0faf7; }
.profile h4 { margin: 0 0 .3rem; font-size: 1rem; }
.profile p { margin: 0; font-size: .85rem; color: var(--muted); }
.params label { display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; color: var(--muted); }
.params input { min-width: 0; }
.expert { margin: 1rem 0; }
.expert summary { cursor: pointer; color: var(--accent); }
.plan-preview { margin-top: 1rem; font-size: .9rem; }
.plan-preview ul { margin: .3rem 0; padding-left: 1.2rem; }

/* Notices */
.notice { border-radius: var(--radius); padding: .8rem 1rem; margin: .8rem 0; border: 1px solid var(--border); background: #f8fafc; }
.notice.good { border-color: #bfe3d2; background: #ecf9f2; }
.notice.medium { border-color: #f4dcb0; background: #fdf6e8; }
.notice.low { border-color: #f1c2bc; background: #fdeeec; }
.warnings { display: flex; flex-direction: column; gap: .4rem; margin: .6rem 0 1rem; }
.warning { padding: .55rem .8rem; border-radius: 8px; font-size: .9rem; border-left: 4px solid; background: #f8fafc; }
.warning.danger { border-color: var(--danger); background: #fdeeec; }
.warning.warn { border-color: var(--warn); background: #fdf6e8; }
.warning.info { border-color: var(--info); background: #eaf3fb; }

/* Scores séparés (compatibilité définition, certitude fonctionnelle, intégrité checksum, marge injecteur) */
.score-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .8rem; margin: 1rem 0; }
.score-card { border: 1px solid var(--border); border-left: 6px solid #cbd5e1; border-radius: var(--radius); padding: .7rem .9rem; background: #fff; display: flex; flex-direction: column; gap: .25rem; }
.score-card .label { font-size: .85rem; color: var(--muted); }
.score-card .value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.score-card .value small { font-size: .85rem; color: var(--muted); font-weight: 400; margin-left: .25rem; }
.score-card .status { font-size: .85rem; font-weight: 600; }
.score-card .detail { font-size: .78rem; color: var(--muted); }
.score-card .score-parts { margin-top: .4rem; gap: .3rem; }
.score-card .score-part { font-size: .8rem; }
.score-card.status-ok { border-left-color: var(--ok); } .score-card.status-ok .status { color: var(--ok); }
.score-card.status-warn { border-left-color: var(--warn); background: #fffbf3; } .score-card.status-warn .status { color: var(--warn); }
.score-card.status-danger, .score-card.status-critical { border-left-color: var(--danger); background: #fdf1ef; } .score-card.status-danger .status, .score-card.status-critical .status { color: var(--danger); }
.score-card.status-critical .value { color: var(--danger); }
.score-card.status-na { border-left-color: #cbd5e1; } .score-card.status-na .status { color: var(--muted); }
.score-card.status-external { border-left-color: #2563eb; background: #eaf3fb; } .score-card.status-external .status { color: #1e40af; }
.score-mini.status-external { border-left-color: #2563eb; }
/* Politique de checksum (badges informatifs : externe = bleu, jamais rouge) */
.badge.policy-external { background: #dbeafe; color: #1e40af; }
.badge.policy-internal { background: #d5f0e8; color: var(--ok); }
.badge.policy-unknown { background: #fdeeec; color: var(--danger); }
.checksum-pref { display: flex; align-items: flex-start; gap: .5rem; margin: .6rem 0 .2rem; font-size: .88rem; }
.checksum-pref input { margin-top: .2rem; }
.checksum-lines { font-size: .85rem; margin: .3rem 0; padding-left: 1.1rem; }
.score-strip { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0 .8rem; }
.score-mini { border: 1px solid var(--border); border-left: 4px solid #cbd5e1; border-radius: 8px; padding: .3rem .6rem; font-size: .82rem; background: #fff; }
.score-mini .value { font-weight: 700; font-size: 1rem; margin-left: .2rem; }
.score-mini small { color: var(--muted); }
.score-mini.status-ok { border-left-color: var(--ok); }
.score-mini.status-warn { border-left-color: var(--warn); }
.score-mini.status-danger, .score-mini.status-critical { border-left-color: var(--danger); }
.score-mini.status-critical .value { color: var(--danger); }
/* Marge injecteur */
.duty-block { border: 1px solid var(--border); border-left: 5px solid #cbd5e1; border-radius: var(--radius); padding: .7rem .9rem; margin: .8rem 0 .4rem; background: #fff; font-size: .9rem; }
.duty-block h4 { margin: 0 0 .4rem; }
.duty-block p { margin: .3rem 0; }
.duty-block.status-ok { border-left-color: var(--ok); }
.duty-block.status-warn { border-left-color: var(--warn); background: #fffbf3; }
.duty-block.status-danger, .duty-block.status-critical { border-left-color: var(--danger); background: #fdf1ef; }
.duty-table { font-size: .8rem; border-collapse: collapse; margin: .4rem 0; }
.duty-table th, .duty-table td { padding: .15rem .5rem; text-align: right; border-bottom: 1px solid #eef2f6; white-space: nowrap; }
.duty-table th { color: var(--muted); font-weight: 600; }
.band-ok { color: var(--ok); font-weight: 600; }
.band-warn { color: var(--warn); font-weight: 600; }
.band-danger { color: var(--danger); font-weight: 600; }
.band-critical { color: var(--danger); font-weight: 700; text-decoration: underline; }
.badge.band-ok { background: #d5f0e8; color: var(--ok); }
.badge.band-warn { background: #fdf6e8; color: var(--warn); }
.badge.band-danger, .badge.band-critical { background: #fdeeec; color: var(--danger); }
.duty-legend { font-size: .78rem; color: var(--muted); margin: .2rem 0 .6rem; display: flex; flex-wrap: wrap; gap: .8rem; }
.score-parts { display: flex; flex-direction: column; gap: .5rem; }
.score-part { display: grid; grid-template-columns: 1fr auto; gap: .3rem .8rem; font-size: .9rem; }
.score-part .track { grid-column: 1 / -1; height: 7px; background: #e6ebf0; border-radius: 999px; overflow: hidden; }
.score-part .track div { height: 100%; background: var(--accent); }
.score-part small { grid-column: 1 / -1; color: var(--muted); }
.report { font-size: .8rem; background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: 420px; overflow: auto; }

/* IA */
.ai-result { margin-top: 1rem; }
.ai-result .panel { margin-bottom: .8rem; }
.ai-result ul { margin: .3rem 0; padding-left: 1.2rem; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .8rem; font-size: .9rem; }
.kv b { color: var(--muted); font-weight: 500; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(20, 36, 48, .55); display: flex; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal-box { background: #fff; border-radius: var(--radius); width: min(1100px, 100%); max-height: 95vh; overflow: auto; padding: 1.2rem 1.4rem; position: relative; }
.modal-close { position: absolute; right: .8rem; top: .6rem; border: 0; background: transparent; font-size: 1.6rem; cursor: pointer; color: var(--muted); }
.modal-body { display: grid; grid-template-columns: 1fr 340px; gap: 1rem; }
@media (max-width: 900px) { .modal-body { grid-template-columns: 1fr; } }
.viewer { position: relative; }
.viewer canvas { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.tooltip { position: absolute; background: #142430; color: #fff; padding: .3rem .5rem; border-radius: 6px; font-size: .78rem; pointer-events: none; white-space: nowrap; }
.details h4 { margin: .6rem 0 .3rem; }
.details ul { margin: .2rem 0; padding-left: 1.1rem; font-size: .88rem; }
.details .kv { margin-bottom: .6rem; }
.override { display: flex; flex-direction: column; gap: .5rem; margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--border); font-size: .88rem; }
.override label { display: flex; align-items: center; gap: .5rem; }
.override select, .override input { min-width: 0; flex: 1; }

.footer { max-width: 1180px; margin: 0 auto 2rem; padding: 0 1rem; color: var(--muted); font-size: .82rem; }

/* Explications (définition, compatibilité) */
details.why { margin-top: .25rem; }
details.why summary { cursor: pointer; color: var(--accent); font-size: .8rem; }
details.why ul, ul.why-list { font-size: .8rem; margin: .2rem 0; padding-left: 1.1rem; color: var(--muted); white-space: normal; }
ul.why-list > li { margin: .25rem 0; color: var(--text); }

/* Origine des paramètres de définition */
.badge.origin-detected { background: #d5f0e8; color: var(--primary-dark); }
.badge.origin-sha { background: #dbeafe; color: #1e40af; }
.badge.origin-rebuilt { background: #ede9fe; color: #5b21b6; }
.badge.origin-unverified { background: #fdf6e8; color: #92400e; }
.badge.e85 { background: #fdebd0; color: #9a3412; }
.plan-preview li.group-check { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: .5rem .7rem; margin: .4rem 0; list-style: none; line-height: 1.5; }
