:root {
  --paper: #f6f4ef; --card: #ffffff; --ink: #18212f; --muted: #6a7282; --line: #e3dfd6;
  --accent: #1f5f6b; --accent-2: #2c8190; --red: #b8412c; --amber: #b7791f; --green: #2f7d4f; --blue: #2d5fa8;
  --shadow: 0 1px 2px rgba(24, 33, 47, .06), 0 8px 24px rgba(24, 33, 47, .06);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.45 Onest, system-ui, sans-serif; }
code { font: 12.5px "JetBrains Mono", monospace; background: #eeeae1; padding: 1px 5px; border-radius: 4px; }
button, .btn { font: inherit; font-weight: 500; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 8px; cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button:disabled, .btn.disabled { opacity: .45; pointer-events: none; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-2); }
.hidden { display: none !important; }
.note { color: var(--muted); font-size: 13px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 32px;
  background: var(--ink); color: #fff; flex-wrap: wrap; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand img { width: 36px; height: 36px; }
.brand b { font-size: 20px; display: block; letter-spacing: .2px; }
.brand span { color: #b9c1cf; font-size: 13px; }
.meta { color: #b9c1cf; font-size: 13px; }
.meta code { background: #263244; color: #e6ebf2; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 32px 64px; display: grid; gap: 20px; }
section { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; box-shadow: var(--shadow); }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 6px; color: var(--muted); font-weight: 500; }

.intake { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: stretch; }
.drop { border: 2px dashed #cfc8b8; border-radius: 12px; display: grid; place-items: center; padding: 28px; text-align: center; transition: .15s; }
.drop.over { border-color: var(--accent); background: #eef5f6; }
.drop-body b { font-size: 18px; display: block; }
.drop-body span { color: var(--muted); display: block; margin: 4px 0 16px; }
.drop-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; align-content: center; }
.stages li { display: grid; grid-template-columns: 28px 90px 1fr; align-items: center; gap: 10px; }
.stages b { width: 28px; height: 28px; border-radius: 50%; background: #e7efef; color: var(--accent); display: grid; place-items: center; font-size: 13px; }
.stages span { font-weight: 600; }
.stages small { color: var(--muted); }

.progress { height: 6px; background: #eeeae1; border-radius: 3px; overflow: hidden; }
.bar { height: 100%; background: var(--accent); width: 0; transition: width .4s; }
.now { margin: 10px 0 16px; color: var(--muted); }
.cards { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.stat { background: var(--paper); border-radius: 10px; padding: 12px 14px; }
.stat span { font-size: 13px; color: var(--muted); display: block; }
.stat b { font-size: 28px; display: block; line-height: 1.2; }
.stat small { color: var(--muted); font-size: 12px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 16px; }

.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { padding: 6px 12px; font-size: 13px; }
.tabs .on { background: var(--ink); color: #fff; border-color: var(--ink); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12.5px; border-bottom: 1px solid var(--line); padding: 8px 10px; }
td { border-bottom: 1px solid #f0ede6; padding: 9px 10px; vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #faf8f3; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 10px; background: #eeeae1; margin: 0 4px 2px 0; white-space: nowrap; }
.tag.red { background: #f7e1dc; color: var(--red); }
.tag.amber { background: #f8ecd4; color: var(--amber); }
.tag.green { background: #dfefe5; color: var(--green); }
.tag.blue { background: #e0e8f5; color: var(--blue); }

.qs { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.q b { font-size: 34px; display: block; color: var(--accent); }
.q > span { color: var(--muted); font-size: 13px; display: block; margin-bottom: 10px; }
.weak { display: grid; gap: 4px; }
.weak i { font-style: normal; font-size: 12.5px; display: grid; grid-template-columns: 150px 1fr; align-items: center; position: relative; }
.weak i::after { content: ""; grid-column: 2; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--accent) calc(var(--v) * 100%), #eeeae1 0); }
.weak em { font-style: normal; color: var(--muted); }

.card { position: fixed; inset: 0 0 0 auto; width: min(1100px, 100vw); background: var(--card); box-shadow: -12px 0 40px rgba(0,0,0,.18);
  display: flex; flex-direction: column; z-index: 10; }
.card-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.card-head b { display: block; font-size: 17px; }
.card-head span { color: var(--muted); font-size: 13px; }
.card-head button { font-size: 22px; line-height: 1; padding: 4px 12px; }
.card-body { display: grid; grid-template-columns: 1fr 420px; overflow: hidden; flex: 1; }
.pages { overflow-y: auto; background: #e9e6df; padding: 16px; display: grid; gap: 12px; align-content: start; }
.pages img { width: 100%; box-shadow: var(--shadow); background: #fff; }
.fields { overflow-y: auto; padding: 16px 20px; }
dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
dt { color: var(--muted); }
dd { margin: 0; word-break: break-word; }
dd.empty { color: #aab0ba; }
dd.miss { color: var(--amber); background: #fbf1dc; border-radius: 4px; padding: 0 4px; }
.reasons { margin: 0 0 16px; padding: 0; list-style: none; display: grid; gap: 6px; }
.reasons li { padding: 8px 10px; border-radius: 8px; background: #f7e1dc; color: #7a2a1c; font-size: 13.5px; }
.reasons li.error { background: #f7e1dc; color: #7a2a1c; font-weight: 500; }
.reasons li.missing { background: #fbf1dc; color: #7a4f12; }
.reasons li.solidary, .reasons li.fssp_action { background: #e0e8f5; color: #1f3f70; }

.mail { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.mail-head { background: var(--paper); padding: 10px 14px; }
.mail-head b { display: block; }
.mail-head span { color: var(--muted); font-size: 13px; }
.mail-body { padding: 14px; overflow-x: auto; font-size: 14px; }

@media (max-width: 900px) {
  .top, main { padding-left: 16px; padding-right: 16px; }
  .intake, .qs { grid-template-columns: 1fr; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .card-body { grid-template-columns: 1fr; overflow-y: auto; }
  .pages { max-height: 50vh; }
}
