/* Tableau de bord douanier : thème clair institutionnel. Aucun style en ligne n'est nécessaire ; rayons <= 4 px. */
:root {
  --bg: #f6f7f9; --card: #fff; --ink: #18212f; --ink2: #3d4a5e; --muted: #667388; --line: #e2e6ec; --line2: #cdd4de;
  --accent: #12365f; --accent-h: #0c2a4a; --accent-soft: #eaf0f7; --blue: #12365f;
  --green: #1d6b44; --green-bg: #e7f2ec; --red: #a8281f; --red-bg: #fbeceb; --amber: #85560a; --amber-bg: #fbf1dc; --gold: #b58a1b;
  --blue-bg: #eaf0f7;
  --r: 3px; --top: 56px; --side: 248px; --pad: 28px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top) + 12px); }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
body.lock { overflow: hidden; }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.005em; }
h2 { font-size: 15px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.r { text-align: right; }
.skip { position: absolute; left: 8px; top: -48px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: var(--r); z-index: 100; text-decoration: none; }
.skip:focus { top: 8px; }
.ic { flex: none; }
.ic.big { width: 36px; height: 36px; stroke-width: 1.4; }
.ic.lg { width: 22px; height: 22px; }

/* ---------- structure : barre latérale + contenu ---------- */
#side { position: fixed; inset: 0 auto 0 0; width: var(--side); background: #fff; border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 60; }
.side-brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px 18px; border-bottom: 1px solid var(--line); }
.side-logo { width: 46px; height: auto; flex: none; }
.side-name { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.side-name strong { font-size: 14px; letter-spacing: .01em; }
.side-name small { color: var(--muted); font-size: 12px; margin-top: 2px; }
#menu { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
#menu a { display: flex; align-items: center; gap: 11px; padding: 0 12px; min-height: 40px; border-radius: var(--r); color: var(--ink2); text-decoration: none; font-size: 14.5px; transition: background-color .15s, color .15s; }
#menu a .ic { color: var(--muted); transition: color .15s; }
#menu a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
#menu a.on .ic { color: var(--accent); }
.side-user { border-top: 1px solid var(--line); padding: 14px 14px calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 12px; }
.who-wrap { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 650; font-size: 13px; display: grid; place-items: center; }
.who { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.who b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#top { position: fixed; top: 0; left: var(--side); right: 0; z-index: 40; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: env(safe-area-inset-top) 24px 0 24px; height: calc(var(--top) + env(safe-area-inset-top)); }
.top-logo, .top-title, #menuBtn { display: none; }
@media (max-width: 900px) { #menuBtn { display: grid; } }
.top-logo { height: 32px; width: auto; }
.top-poste { color: var(--muted); font-size: 14px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 20px; }
.top-date { color: var(--muted); font-size: 13px; text-transform: capitalize; }
.top-user { display: flex; align-items: center; gap: 10px; line-height: 1.25; }
.top-user .who { display: flex; flex-direction: column; }
.top-user .who small { color: var(--muted); font-size: 12px; }
.top-title { font-size: 15px; }
.icon-btn { width: 42px; height: 42px; display: grid; place-items: center; background: transparent; border: 0; border-radius: var(--r); color: var(--ink); }
#scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); z-index: 50; animation: fade .2s ease-out both; }
main { margin-left: var(--side); padding: calc(var(--top) + var(--pad)) var(--pad) calc(48px + env(safe-area-inset-bottom)); max-width: calc(1240px + var(--side)); outline: none; }
main.enter { animation: rise .2s ease-out both; }
body.auth main { margin: 0 auto; max-width: none; padding: 16px; }

@media (max-width: 900px) {
  :root { --pad: 16px; }
  #top { left: 0; padding: env(safe-area-inset-top) 8px 0 8px; }
  .top-poste, .top-date, .top-user .who { display: none; }
  .top-logo, .top-title { display: block; }
  .top-right { margin-left: auto; padding-right: 4px; }
  main { margin-left: 0; }
  #side { width: min(300px, 86vw); transform: translateX(-100%); transition: transform .22s ease-out, visibility 0s linear .22s; visibility: hidden; padding-top: env(safe-area-inset-top); }
  #side.open { transform: none; visibility: visible; transition: transform .22s ease-out, visibility 0s; box-shadow: 0 8px 28px rgba(16, 24, 40, .2); }
  body.drawer { overflow: hidden; }
}

/* ---------- boutons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 0 16px; font-weight: 600; font-size: 14.5px; line-height: 1; text-decoration: none; white-space: nowrap;
  background: #fff; color: var(--ink); border: 1px solid var(--line2); border-radius: var(--r); transition: background-color .15s, border-color .15s, color .15s; position: relative; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-o { color: var(--red); border-color: #e2b8b4; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--ink2); }
.btn.quiet-danger { border-color: transparent; background: transparent; color: var(--red); }
.btn.lg { min-height: 44px; font-size: 15px; }
.btn.block-btn, .block-btn { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.loading { color: transparent !important; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 16px; height: 16px; border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn:not(.primary):not(.danger).loading::after { border-color: rgba(24, 33, 47, .2); border-top-color: var(--ink); }
.btn.quiet.block-btn { justify-content: flex-start; padding: 0 10px; }
.page-actions .btn, .form-actions .btn { }
.linkbtn { background: none; border: 0; color: var(--accent); }

/* ---------- formulaires ---------- */
.field { margin: 0 0 16px; min-width: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink2); margin: 0 0 5px; }
.req { color: var(--red); margin-left: 3px; font-weight: 700; }
.opt { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line2); border-radius: var(--r); padding: 0 11px; min-height: 40px; transition: border-color .15s, box-shadow .15s; }
textarea { padding: 9px 11px; resize: vertical; line-height: 1.45; }
select { padding-right: 8px; }
input::placeholder, textarea::placeholder { color: #98a2b3; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(18, 54, 95, .14); }
input[aria-invalid=true], select[aria-invalid=true], textarea[aria-invalid=true] { border-color: var(--red); background: #fffafa; }
input[aria-invalid=true]:focus, select[aria-invalid=true]:focus, textarea[aria-invalid=true]:focus { box-shadow: 0 0 0 3px rgba(168, 40, 31, .14); }
input[readonly] { background: var(--bg); color: var(--ink2); font-weight: 600; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; min-height: 0; padding: 0; accent-color: var(--accent); }
.field-err { color: var(--red); font-size: 13px; margin-top: 5px; animation: fade .15s ease-out both; }
.field-err:empty { display: none; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 5px; }
.form-alert { display: flex; gap: 8px; align-items: flex-start; background: var(--red-bg); color: var(--red); border: 1px solid #efc7c3; border-radius: var(--r); padding: 10px 12px; font-size: 14px; margin: 4px 0 14px; animation: fade .15s ease-out both; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.form-actions.stack { flex-direction: column; margin-top: 16px; }
.qty { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.search { position: relative; flex: 1 1 280px; max-width: 460px; }
.search .ic { position: absolute; left: 11px; top: 11px; color: var(--muted); pointer-events: none; }
.search input { padding-left: 36px; }
.fs { border: 1px solid var(--line); border-radius: var(--r); background: #fff; padding: 6px 20px 8px; margin: 0 0 16px; min-width: 0; }
.fs legend { font-size: 13px; font-weight: 650; color: var(--ink); padding: 0 8px; margin-left: -8px; text-transform: uppercase; letter-spacing: .04em; }
.fgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; padding-top: 10px; }
.fgrid .wide { grid-column: 1 / -1; }
.dform { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.dform-side { position: sticky; top: calc(var(--top) + 16px); }

/* ---------- en-tête de page, panneaux ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 0 0 20px; }
.page-head h1 { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-sub { margin: 4px 0 0; color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.crumb a { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; color: var(--ink2); }
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r); margin: 0 0 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px 18px; }
.panel .empty-state { border: 0; }
.grid-main { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: stretch; }
.grid-main .panel { margin: 0 0 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }
.total-v { font-size: 28px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.01em; margin: 2px 0 6px; }
.total-split { margin: 0 0 12px; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.total-split div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.total-split dt { color: var(--muted); }
.total-split dd { margin: 0; font-weight: 600; }
.total-lbl { margin: 0; font-size: 12.5px; }
.grid-kpi { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin: 0 0 16px; }
.grid-kpi.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kpi-l { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.kpi-v { font-size: 26px; font-weight: 650; line-height: 1.1; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi.a .kpi-v { color: var(--amber); } .kpi.g .kpi-v { color: var(--green); } .kpi.r .kpi-v { color: var(--red); }
.grid-detail { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; min-width: 0; }
.kvs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; padding: 4px 18px 8px; gap: 0 24px; }
.grid-detail > .col:last-child .kvs { grid-template-columns: 1fr; }
.kv { padding: 10px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.kv dt { font-size: 12.5px; color: var(--muted); margin: 0 0 2px; }
.kv dd { margin: 0; font-weight: 550; overflow-wrap: anywhere; }
.kv dd small { display: block; color: var(--muted); font-weight: 400; font-size: 12.5px; }
.kv.total { grid-column: 1 / -1; border-bottom: 0; }
.kv.total dd { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 16px 22px; display: flex; flex-direction: column; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 0; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); z-index: 1; }
.timeline li::after { content: ""; position: absolute; left: 4px; top: 16px; bottom: -6px; width: 1px; background: var(--line2); }
.timeline li:last-child { padding-bottom: 0; } .timeline li:last-child::after { display: none; }
.timeline span { color: var(--ink2); } .timeline small { color: var(--muted); font-size: 12.5px; }
.foot-note { color: var(--muted); font-size: 13px; margin: 12px 0 0; max-width: 80ch; }
.dlg-text { margin: 8px 0 0; color: var(--ink2); }

/* ---------- notes ---------- */
.note { display: flex; gap: 10px; align-items: flex-start; padding: 10px 13px; border: 1px solid var(--line2); background: #fff; border-radius: var(--r); font-size: 14px; margin: 0 0 14px; color: var(--ink2); }
.note .ic { margin-top: 2px; }
.note.info { background: var(--accent-soft); border-color: #cddbea; color: var(--accent); }
.note.warn { background: var(--amber-bg); border-color: #ecd9a8; color: var(--amber); }
.note.err { background: var(--red-bg); border-color: #efc7c3; color: var(--red); }
.note.ok, .note.rej { background: var(--green-bg); border-color: #c4dfd0; color: var(--green); }
.note.rej { background: var(--red-bg); border-color: #efc7c3; color: var(--red); }
.panel-body .note { margin: 12px 0 0; }

/* ---------- badges, pastilles ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; line-height: 1; padding: 4px 8px; border-radius: 3px; white-space: nowrap; background: #eef1f5; color: var(--ink2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.soumis { background: var(--amber-bg); color: var(--amber); }
.badge.valide { background: var(--green-bg); color: var(--green); }
.badge.rejete, .badge.PROHIBEE { background: var(--red-bg); color: var(--red); }
.badge.NON_PROHIBEE { background: var(--accent-soft); color: var(--accent); }
.dotc { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--muted); }
.dotc.g { background: #2f7d55; } .dotc.y { background: #c79a1d; } .dotc.r { background: #b4372c; }
.you { font-size: 11px; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: 1px 6px; border-radius: 2px; margin-left: 6px; vertical-align: 1px; }

/* ---------- tableaux ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: #fafbfc; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color .15s; }
.tbl.rows tbody tr { cursor: pointer; }
.tbl th.r, .tbl td.r { text-align: right; }
.tbl td.main b { display: block; font-weight: 600; }
.tbl small { display: block; color: var(--muted); font-size: 12.5px; }
.tbl tr.me td { background: #f3f7fb; }
.tbl a.item { font-weight: 600; text-decoration: none; }
.tbl.compact td { padding: 7px 0; }
.tbl.compact td:last-child { text-align: right; }
.tbl.compact tr.tot td { font-weight: 700; border-top: 1px solid var(--ink); border-bottom: 0; padding-top: 10px; }
.w-rank { width: 64px; }
.rank-n { display: inline-grid; place-items: center; width: 26px; height: 26px; border: 1px solid var(--line2); border-radius: 3px; font-weight: 650; font-size: 13px; color: var(--ink2); font-variant-numeric: tabular-nums; }
.rank-n.r1 { background: var(--accent); border-color: var(--accent); color: #fff; }
.rank-n.r2, .rank-n.r3 { border-color: var(--accent); color: var(--accent); }
.pts-col { min-width: 170px; }
.pts-cell { display: grid; gap: 5px; } .pts-cell b { font-variant-numeric: tabular-nums; font-weight: 600; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 0 0 14px; }
.panel > .toolbar { margin: 0; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: var(--r); background: #fff; overflow: hidden; max-width: 100%; overflow-x: auto; }
.seg button { background: #fff; color: var(--ink2); border: 0; border-right: 1px solid var(--line); border-radius: 0; padding: 0 14px; min-height: 36px; font-size: 14px; white-space: nowrap; transition: background-color .15s, color .15s; }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: #fff; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 18px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; padding: 10px 14px; font-size: 14.5px; color: var(--muted); white-space: nowrap; transition: color .15s, border-color .15s; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---------- graphiques ---------- */
.chart-host { width: 100%; height: 280px; position: relative; }
.chart { touch-action: pan-y; }
.chart .cross { stroke: #9aa6b8; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { transition: r .12s ease-out; cursor: pointer; }
.chart .dot.on { r: 7; fill: var(--accent); }
.chart .val { transition: opacity .12s; } .chart .val.dim { opacity: 0; }
.chart-tip { position: absolute; pointer-events: none; background: #1a2433; color: #fff; padding: 8px 10px; border-radius: 3px; font-size: 12.5px; line-height: 1.35; display: grid; gap: 1px; white-space: nowrap; box-shadow: 0 2px 8px rgba(16, 24, 40, .18); animation: tip-in .12s ease-out both; }
.chart-tip b { font-size: 12px; font-weight: 600; opacity: .75; text-transform: capitalize; }
.chart-tip span { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; }
.chart-tip small { font-size: 11.5px; } .chart-tip .up { color: #7fdca0; } .chart-tip .down { color: #ff9b9b; }
@keyframes tip-in { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .chart-tip { animation: none; } .chart .dot, .chart .val { transition: none; } }
.chart { display: block; }
.chart .grid { stroke: #edf0f4; stroke-width: 1; }
.chart .axis { stroke: #c4ccd8; stroke-width: 1; }
.chart .area { fill: var(--accent); opacity: .07; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: #fff; stroke: var(--accent); stroke-width: 2; }
.chart .val { font-size: 11px; font-weight: 600; fill: var(--ink2); paint-order: stroke; stroke: #fff; stroke-width: 4px; stroke-linejoin: round; }
.chart .dot.last { fill: var(--accent); }
.total-stats { margin: 18px 0 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--line); }
.total-stats div { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.total-stats dt { color: var(--muted); }
.total-stats dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.total-stats .up { color: #1b6b3a; } .total-stats .down { color: #a12a2a; }
.chart .lab { font-size: 11px; fill: var(--muted); }
.c1 { --c: #12365f; } .c2 { --c: #4a79a8; } .c3 { --c: #8fabc8; } .c4 { --c: #66727f; } .c5 { --c: #c2c9d3; }
.cg { --c: #2f7d55; } .cy { --c: #c79a1d; } .cr { --c: #b4372c; }
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { position: relative; width: 124px; height: 124px; flex: none; }
.donut svg { width: 100%; height: 100%; display: block; }
.donut .seg { stroke: var(--c); }
.donut .seg-bg { stroke: #eef1f5; }
.donut span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 650; font-size: 22px; font-variant-numeric: tabular-nums; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 150px; font-size: 14px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.legend li:last-child { border: 0; }
.legend .lg-l { flex: 1; } .legend small { color: var(--muted); min-width: 36px; text-align: right; }
.sw { width: 10px; height: 10px; border-radius: 2px; background: var(--c, #ccc); flex: none; }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: minmax(80px, 38%) 1fr auto; gap: 12px; align-items: center; font-size: 14px; }
.bl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink2); }
.bar b { font-variant-numeric: tabular-nums; min-width: 24px; text-align: right; font-weight: 600; }
progress.prog { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 6px; border: 0; border-radius: 2px; background: #e9edf2; overflow: hidden; }
progress.prog::-webkit-progress-bar { background: #e9edf2; border-radius: 2px; }
progress.prog::-webkit-progress-value { background: var(--accent); border-radius: 2px; transition: width .25s ease-out; }
progress.prog::-moz-progress-bar { background: var(--accent); border-radius: 2px; }
progress.prog.ok::-webkit-progress-value { background: var(--green); } progress.prog.ok::-moz-progress-bar { background: var(--green); }

/* ---------- état vide, squelettes ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 44px 20px; color: var(--muted); }
.empty-state .ic { color: #9aa5b5; margin-bottom: 6px; }
.empty-state b { color: var(--ink); font-size: 15px; }
.empty-state p { margin: 0 0 8px; max-width: 46ch; font-size: 14px; }
.empty { text-align: center; color: var(--muted); padding: 28px 0; }
.sk { background: #e8ecf1; border-radius: var(--r); animation: pulse 1.1s ease-in-out infinite alternate; }
.sk.kpi { height: 84px; border: 0; } .sk.box { height: 230px; margin-bottom: 16px; } .sk.row { height: 46px; margin-bottom: 8px; }
.sk-head { height: 28px; margin-bottom: 22px; } .sk-head.w40 { width: 40%; max-width: 320px; }

/* ---------- notifications ---------- */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: 10px; background: #fff; border: 1px solid var(--line2); border-radius: var(--r); padding: 11px 8px 11px 13px; box-shadow: 0 4px 16px rgba(16, 24, 40, .12); font-size: 14px; animation: slide .2s ease-out both; }
.toast.out { animation: slideout .2s ease-in both; }
.toast .ic { margin-top: 1px; } .toast.ok .ic { color: var(--green); } .toast.err .ic { color: var(--red); } .toast.info .ic { color: var(--accent); }
.toast-msg { flex: 1; padding-top: 1px; }
.toast-x { background: none; border: 0; color: var(--muted); width: 26px; height: 26px; display: grid; place-items: center; border-radius: var(--r); padding: 0; }
.toast-x .ic { width: 14px; height: 14px; }
@media (max-width: 900px) {
  #toasts { top: auto; bottom: calc(14px + env(safe-area-inset-bottom)); left: 16px; right: 16px; width: auto; }
}

/* ---------- fenêtres modales ---------- */
.overlay { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 120; animation: fade .15s ease-out both; }
.overlay.out { animation: fadeout .16s ease-in both; }
.dialog { background: #fff; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; border-radius: 4px; padding: 22px 24px 20px; box-shadow: 0 12px 32px rgba(16, 24, 40, .22); animation: rise .18s ease-out both; outline: none; }
.dialog.sm { max-width: 440px; }
.dialog h2 { font-size: 17px; margin-bottom: 4px; }
.dialog .field { margin-top: 14px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.codebox { background: var(--bg); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; text-align: center; margin: 14px 0; }
.codebox small { display: block; color: var(--muted); margin-top: 8px; font-size: 12.5px; } .codebox small:first-child { margin-top: 0; }
.codebox b { display: block; font-size: 17px; }
.codebox b.big { font-size: 34px; letter-spacing: 6px; color: var(--accent); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
  .overlay { align-items: flex-end; padding: 0; }
  .dialog, .dialog.sm { max-width: none; border-radius: 4px 4px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .dlg-actions .btn { flex: 1; }
}

/* ---------- animations ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeout { to { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slide { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes slideout { to { opacity: 0; transform: translateX(12px); } }
@keyframes pulse { from { opacity: 1; } to { opacity: .55; } }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* ---------- adaptation mobile ---------- */
@media (max-width: 1100px) {
  .grid-kpi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-main, .grid-detail, .dform { grid-template-columns: 1fr; }
  .dform-side { position: static; }
}
@media (max-width: 720px) {
  h1 { font-size: 20px; }
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .grid-kpi.two { grid-template-columns: 1fr; }
  .kpi-v { font-size: 22px; }
  .grid-2 { grid-template-columns: 1fr; }
  .fgrid, .kvs { grid-template-columns: 1fr; }
  .fs { padding: 4px 14px 6px; }
  .page-head { align-items: stretch; }
  .page-actions { width: 100%; } .page-actions .btn { flex: 1 1 auto; }
  input, select, textarea { font-size: 16px; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar .seg { width: 100%; } .toolbar .seg button { flex: 1; padding: 0 8px; }
  .panel-head, .panel-body { padding-left: 14px; padding-right: 14px; }
  .bar { grid-template-columns: minmax(70px, 34%) 1fr auto; gap: 8px; }
  /* tableaux empilés : une fiche par ligne */
  .tbl:not(.compact) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tbl:not(.compact), .tbl:not(.compact) tbody, .tbl:not(.compact) tr, .tbl:not(.compact) td { display: block; width: 100%; }
  .tbl:not(.compact) tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl:not(.compact) tbody tr:last-child { border-bottom: 0; }
  .tbl:not(.compact) td { border: 0; padding: 4px 14px; display: flex; justify-content: space-between; align-items: center; gap: 14px; text-align: right; }
  .tbl:not(.compact) td::before { content: attr(data-l); color: var(--muted); font-size: 12.5px; text-align: left; flex: none; }
  .tbl:not(.compact) td.main { display: block; text-align: left; padding-bottom: 6px; } .tbl:not(.compact) td.main::before { content: none; }
  .tbl:not(.compact) td.pts-col { min-width: 0; } .tbl:not(.compact) .pts-cell { width: 55%; text-align: right; }
  .tbl:not(.compact) td.r { text-align: right; }
}

/* ---------- impression ---------- */
.print-head, .print-only { display: none; }
@media print {
  #side, #top, #toasts, #scrim, .noprint, .skip, .crumb { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  main { margin: 0 !important; padding: 0 !important; max-width: none; }
  .print-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid #000; padding-bottom: 10px; margin-bottom: 14px; }
  .print-head img { height: 80px; }
  .print-only.sign { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 48px; text-align: center; }
  .panel { border: 1px solid #999; break-inside: avoid; }
  .grid-detail { grid-template-columns: 1fr; }
  .badge { border: 1px solid #999; background: #fff !important; color: #000 !important; }
}

.tbl.compact td:last-child { white-space: nowrap; }
.dform-side .field { margin-top: 14px; }
.kpi { text-align: left; }
.total-stats dd small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

/* ---------- mouvement (désactivé si l'utilisateur préfère moins d'animations) ---------- */
@media (prefers-reduced-motion: no-preference) {
  main.enter .page-head, main.enter .note, main.enter .kpi, main.enter .panel, main.enter .pg-panel, main.enter .pg-tablewrap, main.enter .pg-bar { animation: rise .45s cubic-bezier(.2, .7, .2, 1) both; }
  main.enter .note { animation-delay: .04s; }
  main.enter .grid-kpi > :nth-child(1) { animation-delay: .06s; } main.enter .grid-kpi > :nth-child(2) { animation-delay: .1s; }
  main.enter .grid-kpi > :nth-child(3) { animation-delay: .14s; } main.enter .grid-kpi > :nth-child(4) { animation-delay: .18s; }
  main.enter .grid-kpi > :nth-child(5) { animation-delay: .22s; } main.enter .grid-kpi > :nth-child(6) { animation-delay: .26s; }
  main.enter .grid-main > :nth-child(1) { animation-delay: .24s; } main.enter .grid-main > :nth-child(2) { animation-delay: .3s; }
  main.enter .grid-2 > :nth-child(1) { animation-delay: .34s; } main.enter .grid-2 > :nth-child(2) { animation-delay: .4s; } main.enter .grid-2 > :nth-child(3) { animation-delay: .46s; }
  main.enter > .panel:last-child { animation-delay: .5s; }

  .kpi, .grid-2 .panel, .grid-main .panel { transition: border-color .18s, box-shadow .18s, transform .18s; }

  /* courbe : tracé progressif, aire qui apparaît, points qui s'allument un à un */
  .chart .line { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.1s .35s cubic-bezier(.4, 0, .2, 1) forwards; }
  .chart .area { animation: area-in .8s .9s backwards; }
  .chart .dot, .chart .val { animation: pop .35s backwards; transform-box: fill-box; transform-origin: center; }
  .chart .dot:nth-of-type(1), .chart .val:nth-of-type(1) { animation-delay: .5s; }
  .chart .dot:nth-of-type(2) { animation-delay: .65s; } .chart .dot:nth-of-type(3) { animation-delay: .8s; }
  .chart .dot:nth-of-type(4) { animation-delay: .95s; } .chart .dot:nth-of-type(5) { animation-delay: 1.1s; } .chart .dot:nth-of-type(6) { animation-delay: 1.25s; }
  .chart .val { animation-name: fade; animation-delay: 1.2s; animation-fill-mode: backwards; }
  .donut svg { animation: donut-in .9s .3s cubic-bezier(.2, .7, .2, 1) both; }
  .donut span { animation: fade .6s .8s both; }
  progress.prog::-webkit-progress-value, progress.pg-meter::-webkit-progress-value { transition: width .9s cubic-bezier(.2, .7, .2, 1); }
  progress.prog::-moz-progress-bar { transition: width .9s cubic-bezier(.2, .7, .2, 1); }

  /* tableaux : lignes en cascade (les 12 premières) */
  .tbl tbody tr, .pg-table tbody tr { animation: rise .35s ease-out both; }
  .tbl tbody tr:nth-child(2), .pg-table tbody tr:nth-child(2) { animation-delay: .04s; } .tbl tbody tr:nth-child(3), .pg-table tbody tr:nth-child(3) { animation-delay: .08s; }
  .tbl tbody tr:nth-child(4), .pg-table tbody tr:nth-child(4) { animation-delay: .12s; } .tbl tbody tr:nth-child(5), .pg-table tbody tr:nth-child(5) { animation-delay: .16s; }
  .tbl tbody tr:nth-child(6), .pg-table tbody tr:nth-child(6) { animation-delay: .2s; } .tbl tbody tr:nth-child(7), .pg-table tbody tr:nth-child(7) { animation-delay: .24s; }
  .tbl tbody tr:nth-child(n+8), .pg-table tbody tr:nth-child(n+8) { animation-delay: .28s; }

  /* navigation, boutons, avatars */
  #menu a { transition: background-color .15s, color .15s, transform .15s; }
  .btn { transition: background-color .15s, border-color .15s, transform .12s, box-shadow .15s; }
  .btn:not(:disabled):active { transform: translateY(1px); }
  .av { transition: transform .2s; }
  .pg-pod { transition: transform .2s, border-color .2s; }
  .badge { transition: transform .15s; }
}
@keyframes area-in { from { opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.2); } to { opacity: 1; transform: none; } }
@keyframes donut-in { from { opacity: 0; transform: rotate(-120deg) scale(.85); } to { opacity: 1; transform: none; } }

/* bouton de déconnexion : noir */
#logoutBtn { background: #111; border-color: #111; color: #fff; justify-content: center; }
#logoutBtn .ic { color: #fff; }

/* profil */
a.top-user { color: inherit; text-decoration: none; padding: 5px 8px; margin-right: -8px; border-radius: var(--r); transition: background-color .15s; }
.profile-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.profile-card { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 28px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; position: sticky; top: calc(var(--top) + 16px); }
.profile-card h2 { font-size: 19px; margin-top: 14px; overflow-wrap: anywhere; }
.profile-card .pc-grade { margin: 0 0 6px; color: var(--muted); font-size: 13.5px; }
.profile-card .pc-mat { margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); width: 100%; color: var(--muted); font-size: 13.5px; }
.profile-card .pc-mat b { color: var(--ink); font-variant-numeric: tabular-nums; }
.profile-card .av-xl { width: 132px; height: 132px; font-size: 42px; }
.profile-card .photo-ctl { flex-direction: column; gap: 14px; }
.profile-card .photo-actions { justify-content: center; }
.profile-main .pg-panel { padding: 22px 24px; }
.profile-main .pg-panel h2 { font-size: 16px; margin-bottom: 4px; }
.profile-main .pg-panel > .muted { margin: 4px 0 0; font-size: 13.5px; }
.profile-kv { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; margin: 12px 0 8px; }
.profile-kv div { padding: 12px 0; border-bottom: 1px solid var(--line); }
.profile-kv dt { font-size: 12.5px; color: var(--muted); }
.profile-kv dd { margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.profile-pw { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 20px; margin-top: 14px; align-items: start; }
@media (max-width: 1100px) { .profile-kv, .profile-pw { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .profile-layout { grid-template-columns: 1fr; } .profile-card { position: static; } }
@media (max-width: 560px) { .profile-kv, .profile-pw { grid-template-columns: 1fr; } }


/* ---------- survol réservé aux pointeurs précis (souris) : pas de :hover collant au toucher ---------- */
@media (hover: hover) {
  #menu a:hover { background: #f1f4f8; color: var(--ink); }
  .icon-btn:hover { background: #f1f4f8; }
  .btn:hover { background: #f4f6f9; border-color: #b9c2cf; }
  .btn.primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
  .btn.danger:hover { background: #8d2019; border-color: #8d2019; }
  .btn.danger-o:hover { background: var(--red-bg); border-color: var(--red); }
  .btn.quiet:hover { background: #f1f4f8; }
  .btn.quiet-danger:hover { background: var(--red-bg); }
  input:hover:not(:disabled):not([readonly]), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #aab4c3; }
  .crumb a:hover { color: var(--accent); }
  .tbl tbody tr:hover { background: #f8f9fb; }
  .tbl a.item:hover { text-decoration: underline; }
  .tbl.compact tbody tr:hover { background: transparent; }
  .seg button:hover { background: #f4f6f9; }
  .tabs button:hover { color: var(--ink); }
  .toast-x:hover { background: #f1f4f8; color: var(--ink); }
  #logoutBtn:hover { background: #2b2b2b; border-color: #2b2b2b; color: #fff; }
  a.top-user:hover { background: #f1f4f8; }
}
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .tbl tbody tr[data-href] td:first-child { transition: transform .15s; }
  .kpi:hover, .grid-2 .panel:hover, .grid-main .panel:hover { border-color: #b9c4d3; box-shadow: 0 3px 10px rgba(16, 24, 40, .07); transform: translateY(-2px); }
  .tbl tbody tr[data-href]:hover td:first-child { transform: translateX(2px); }
  #menu a:hover { transform: translateX(3px); }
  #menu a:hover .ic { color: var(--accent); }
  .btn:not(:disabled):hover { transform: translateY(-1px); }
  .btn.primary:not(:disabled):hover { box-shadow: 0 3px 10px rgba(19, 49, 92, .25); }
  .who-cell:hover .av { transform: scale(1.12); }
  .pg-pod:hover { transform: translateY(-3px); }
  .badge:hover { transform: scale(1.06); }
}

/* =====================================================================================
   Tactile : mobile, tablette. Cibles >= 44 px, champs >= 16 px (pas de zoom automatique iOS),
   zones sûres (encoche), pas de comportements de souris au toucher.
   ===================================================================================== */
html { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
a, button, label, select, summary, [role=tab], tr[data-href], input[type=checkbox], input[type=radio] { touch-action: manipulation; }
#menu, .dialog, .overlay, .seg, .tabs, .pg-seg, .pg-tabs, .pg-tablewrap { overscroll-behavior: contain; }
@media (display-mode: standalone) { body { overscroll-behavior-y: none; } }
#scrim { touch-action: none; }
.seg, .tabs, .pg-seg, .pg-tabs { scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.seg::-webkit-scrollbar, .tabs::-webkit-scrollbar, .pg-seg::-webkit-scrollbar, .pg-tabs::-webkit-scrollbar { display: none; }
.chart { max-width: 100%; }
.search .ic { top: 50%; transform: translateY(-50%); }

/* zones sûres (encoche, barre d'accueil) en portrait comme en paysage */
#side { padding-left: env(safe-area-inset-left); }
#top { padding-left: max(24px, env(safe-area-inset-left)); padding-right: max(24px, env(safe-area-inset-right)); }
main { padding-left: max(var(--pad), env(safe-area-inset-left, 0px)); padding-right: max(var(--pad), env(safe-area-inset-right, 0px)); }
.overlay { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }

/* retour visuel à l'appui (le survol n'existe pas au toucher) */
.btn:not(:disabled):active { background: #eef1f5; }
.btn.primary:not(:disabled):active { background: var(--accent-h); }
.btn.danger:not(:disabled):active { background: #8d2019; }
#menu a:active, .seg button:active, .tabs button:active, .pg-seg button:active, .pg-tabs button:active, .pg-ib:active, .icon-btn:active { background: #e8edf3; }
.tbl tbody tr[data-href]:active { background: #eef2f7; }

/* tablette en paysage : barre latérale plus étroite pour laisser la place au contenu */
@media (min-width: 901px) and (max-width: 1100px) {
  :root { --side: 216px; --pad: 22px; }
  #top { padding-left: max(20px, env(safe-area-inset-left)); padding-right: max(20px, env(safe-area-inset-right)); }
  .top-date { display: none; }
}

/* tablette : on exploite la largeur au lieu d'étirer la disposition téléphone */
@media (min-width: 721px) and (max-width: 1100px) {
  :root { --pad: 24px; }
  .grid-main { grid-template-columns: 250px minmax(0, 1fr); }
  .grid-main .total-v { font-size: 22px; }
  .total-stats div { flex-wrap: wrap; }
  .grid-detail { grid-template-columns: minmax(0, 1fr) 280px; }
  .grid-detail .kvs { grid-template-columns: 1fr; }
  .grid-detail > .col:first-child .kvs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fgrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dform { grid-template-columns: minmax(0, 1fr) 280px; }
  .dform-side { position: sticky; }
  .tbl th, .tbl td { padding-left: 10px; padding-right: 10px; }
  .panel > #list { overflow-x: auto; }
}
@media (min-width: 721px) and (max-width: 900px) {
  .dform { grid-template-columns: 1fr; }
  .dform-side { position: static; }
  .dform-side .panel-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 24px; align-items: start; }
  .dform-side .panel-body > p, .dform-side .panel-body > .foot-note { grid-column: 1 / -1; }
}

/* cibles tactiles et champs lisibles : écrans étroits ou pointeur grossier (doigt) */
@media (pointer: coarse), (max-width: 1100px) {
  input, select, textarea { font-size: 16px; }
}
@media (pointer: coarse), (max-width: 900px) {
  .btn { min-height: 44px; }
  .btn.lg { min-height: 48px; }
  input, select, textarea { min-height: 44px; }
  textarea { min-height: 96px; }
  .icon-btn { width: 44px; height: 44px; }
  a.top-user { min-height: 44px; min-width: 44px; justify-content: center; margin-right: -4px; }
  #menu a { min-height: 48px; }
  .seg button, .tabs button { min-height: 44px; }
  .crumb a { min-height: 44px; padding-right: 10px; }
  .toast-x { width: 40px; height: 40px; }
  .tbl a.item { display: inline-flex; align-items: center; min-height: 44px; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .tap { display: grid; place-items: center; min-width: 44px; min-height: 44px; margin: 0 auto; cursor: pointer; }
  .skip:focus { top: calc(8px + env(safe-area-inset-top)); }
}

/* téléphone */
@media (max-width: 720px) {
  :root { --pad: 14px; }
  .chart-host { height: 240px; }
  .total-v { font-size: 24px; }
  .page-head h1 { font-size: 20px; }
  .tbl:not(.compact) tr { padding: 6px 0; }
  .tbl:not(.compact) td { min-height: 36px; }
  .grid-2 { grid-template-columns: 1fr; }
  .donut-wrap { gap: 16px; }
  .profile-card { padding: 22px 16px; }
  .profile-main .pg-panel { padding: 18px 16px; }
  .toolbar .seg, .pg-bar .pg-seg { width: 100%; }
}
@media (max-width: 360px) {
  .top-title { font-size: 14px; }
  .kpi { padding: 12px; }
  .kpi-v { font-size: 20px; }
}

/* fenêtres : feuille ancrée en bas sur téléphone, bouton d'action toujours visible au-dessus du clavier */
@media (max-width: 600px) {
  .dialog, .dialog.sm { max-height: 92vh; max-height: 92dvh; }
  .dialog .dlg-actions { position: sticky; bottom: calc(-20px - env(safe-area-inset-bottom)); background: #fff; margin: 18px -24px calc(-20px - env(safe-area-inset-bottom)); padding: 12px 24px calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); z-index: 1; }
}
/* téléphone en paysage : hauteur réduite */
@media (max-height: 500px) and (orientation: landscape) {
  :root { --top: 48px; }
  .overlay { align-items: flex-start; padding-top: 8px; padding-bottom: 8px; }
  .dialog { max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 16px 20px; }
  .dialog .dlg-actions { position: sticky; bottom: -16px; background: #fff; margin: 14px -20px -16px; padding: 10px 20px 16px; border-top: 1px solid var(--line); z-index: 1; }
  .auth-wrap { align-items: flex-start; }
  #toasts { bottom: 8px; }
}

/* animations allégées sur petits écrans (fluidité) */
@media (prefers-reduced-motion: no-preference) and (max-width: 900px) {
  main.enter .page-head, main.enter .note, main.enter .kpi, main.enter .panel, main.enter .pg-panel, main.enter .pg-tablewrap, main.enter .pg-bar { animation-duration: .28s; }
  main.enter .grid-kpi > *, main.enter .grid-main > *, main.enter .grid-2 > *, main.enter > .panel:last-child, main.enter .note { animation-delay: 0s; }
  .chart .line { animation-duration: .7s; animation-delay: .15s; }
  .chart .area { animation-delay: .5s; }
  .chart .dot, .chart .val { animation-delay: .3s !important; }
  .tbl tbody tr, .pg-table tbody tr { animation-duration: .22s; animation-delay: 0s !important; }
}

/* boutons d'accès rapide dans les bandeaux */
.note { align-items: center; }
.note .note-act { margin-left: auto; flex: none; min-height: 32px; padding: 0 12px; font-size: 13px; background: #fff; }
@media (max-width: 560px) { .note { flex-wrap: wrap; } .note .note-act { margin-left: 0; width: 100%; min-height: 44px; } }
.linkbtn.inline { display: inline; padding: 0; margin-left: 4px; font: inherit; font-weight: 600; text-decoration: underline; cursor: pointer; }

/* ---------- marchandises multiples (formulaire et fiche) ---------- */
.fs-lignes { padding-bottom: 16px; }
.lhint { margin: 8px 0 14px; }
#lignes { display: grid; gap: 14px; }
.lcard { border: 1px solid var(--line2); border-radius: var(--r); background: #fff; min-width: 0; }
.lcard-head { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 6px 4px 14px; background: #fafbfc; border-bottom: 1px solid var(--line); border-radius: var(--r) var(--r) 0 0; }
.lcard-head h3 { margin: 0; font-size: 14px; font-weight: 650; color: var(--ink); white-space: nowrap; }
.lcard-est { flex: 1; min-width: 0; text-align: right; color: var(--accent); font-size: 13px; font-weight: 600; }
.lrm { flex: none; padding: 0 12px; gap: 6px; }
.lrm svg { width: 16px; height: 16px; }
.fgrid.lgrid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); padding: 14px 14px 0; gap: 4px 16px; }
.fgrid.lgrid .wide { grid-column: 1 / -1; }
.lactions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.estim-l { margin-bottom: 12px; }
.estim-l caption { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 0 0 4px; }
.estim-l td:first-child { padding-right: 10px; overflow-wrap: anywhere; }
.tscroll { overflow-x: auto; }
.lines-t td.ln { width: 48px; color: var(--muted); font-weight: 600; }
.lines-t tfoot td { font-weight: 700; border-top: 1px solid var(--ink); background: #fafbfc; }
.lines-t tr { break-inside: avoid; }
@media (max-width: 720px) {
  .lactions .btn { width: 100%; }
  .lcard-head { padding-left: 12px; flex-wrap: wrap; }
  .lcard-est { order: 3; flex: 1 0 100%; text-align: left; padding: 0 0 8px; }
  .lcard-est:empty { display: none; }
  .lrm { margin-left: auto; }
  .fgrid.lgrid { padding: 12px 12px 0; }
  .tbl.lines-t td.ln-tot { text-align: left; }
  .tbl.lines-t td.ln-tot::before { content: none; }
  .tbl.lines-t tfoot tr { background: #fafbfc; border-top: 1px solid var(--ink); }
}
@media (prefers-reduced-motion: no-preference) {
  .lcard.fresh { animation: rise .3s cubic-bezier(.2, .7, .2, 1) both; }
}

/* Saisie des identifiants à format imposé */
.suggest { margin-top: 8px; }
.suggest[hidden] { display: none; }
.cnt { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.cnt.ok { color: #2f7d55; }
.cnt.bad { color: #b4372c; }

/* Total des marchandises (somme des valeurs CAF) */
.ltotal { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-top: 14px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 10px; }
.ltotal > span { font-weight: 600; }
.ltotal b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.ltotal small { color: var(--muted); flex-basis: 100%; }
.recap .kv.total dd { font-size: 1.15rem; }

.remaining { margin: 12px 0 8px; font-size: .9rem; font-weight: 600; }
.remaining.todo { color: #b4372c; }
.remaining.done { color: #2f7d55; }

/* Déclarants : mini-histogramme de tendance */
.spark { display: block; }
.spark rect { fill: var(--line); }
.spark rect.on { fill: var(--accent); }
td small, .tbl small { display: block; }

/* Intervenants d'un dossier et répartition */
.chips { list-style: none; margin: 8px 0 12px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface, transparent); }
.chip b { font-weight: 600; }
.chip small { color: var(--muted); }
.chip.fixed { border-style: dashed; }
.chip-x { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.chip-x:hover, .chip-x:focus-visible { background: rgba(180, 55, 44, 0.12); color: #b4372c; }
.interv-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.interv-add select { flex: 1 1 240px; min-width: 0; }
input.pct { width: 5.5rem; text-align: right; }
.interv-t .ok, .interv-t td.ok { color: #2f7d55; font-weight: 700; }
.interv-t .bad, .interv-t td.bad { color: #b4372c; font-weight: 700; }
small.warn-t { color: #a8641a; font-weight: 600; }
.pg-bar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

.linkbtn.urgent { font-weight: 700; text-decoration: underline; }
.install-box { margin-top: 12px; }
.install-box[hidden] { display: none; }
.install-help { font-size: .9rem; color: var(--muted, #5b6b7b); }
.install-help summary { cursor: pointer; font-weight: 600; }
.auth-help { font-size: .88rem; margin: 10px 0 0; }
.email-now { margin: 10px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.check-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; cursor: pointer; }
.check-row input { width: 20px; height: 20px; }

/* Période de travail libre (date et heure de début / fin) */
.range-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, transparent); }
.range-bar label { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--muted); }
.range-bar input[type="datetime-local"] { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; }
.range-note { display: flex; align-items: center; gap: 6px; margin: 0 0 12px; font-size: 13px; }
.ca-block .total-split { margin-top: 0; }
.panel-prohibees h3 { font-size: 14px; margin: 0 0 8px; }

/* Prévision de recettes de l'unité */
.panel-prevision .pv-main { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin: 6px 0 8px; }
.panel-prevision .pv-pct { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.panel-prevision progress.pg-meter { width: 100%; height: 12px; }
.panel-prevision .pv-time { display: grid; gap: 4px; margin: 12px 0 14px; font-size: 13.5px; }
.panel-prevision .pv-time .up { color: var(--ok, #1a7f4b); font-weight: 600; }
.panel-prevision .pv-time .down { color: var(--bad, #b42318); font-weight: 600; }
.panel-prevision h3 { font-size: 14px; margin: 16px 0 6px; }
.pv-histo { margin-top: 14px; }
.pv-histo summary { cursor: pointer; font-weight: 600; }

/* Rapport mensuel */
.report-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 14px; margin: 4px 0 12px; }
.report-head h2 { margin: 0; }
.report .up { color: var(--ok, #1a7f4b); } .report .down { color: var(--bad, #b42318); }
@media print {
  .report .panel, .report .grid-kpi { break-inside: avoid; }
  .report table { font-size: 10pt; }
  .report .tscroll { overflow: visible; }
  .report .kpi { border: 1px solid #999; }
  @page { margin: 14mm; }
}

/* Page Graphiques */
.g1 { --c: #12365f; } .g2 { --c: #2f7d55; } .g3 { --c: #c79a1d; } .g4 { --c: #b4372c; } .g5 { --c: #4a79a8; } .g6 { --c: #7a4fa3; }
.gsection { margin: 26px 0 8px; }
.gsec-head { margin: 0 0 12px; padding-left: 12px; border-left: 4px solid var(--accent); }
.gsec-head h2 { font-size: 18px; letter-spacing: -.005em; }
.gsec-head p { margin: 2px 0 0; font-size: 13.5px; }
.ggrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.ggrid .gcard { grid-column: span 2; min-width: 0; }
.ggrid .gcard.half { grid-column: span 3; }
.ggrid .gcard.wide { grid-column: 1 / -1; }
@media (max-width: 980px) { .ggrid .gcard, .ggrid .gcard.half { grid-column: 1 / -1; } }
.gcard .panel-head { align-items: baseline; }
.colchart { width: 100%; }
.colsvg { width: 100%; height: auto; display: block; }
.colsvg .lab { font-size: 11px; fill: var(--muted); }
.colsvg .grid { stroke: #edf0f4; } .colsvg .axis { stroke: #c4ccd8; }
.colsvg .col { fill: var(--c); transition: opacity .12s; }
.colsvg .hit { fill: transparent; }
.colsvg .colg:hover .col { opacity: .78; }
.colsvg .colg:hover .hit { fill: rgba(18, 54, 95, .05); }
.legend.inline { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 8px 0 0; padding: 0; font-size: 13px; }
.legend.inline li { display: inline-flex; align-items: center; gap: 6px; }
.legend.inline .sw { width: 11px; height: 11px; border-radius: 3px; background: var(--c); display: inline-block; }
.gauge { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.gauge-v { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.gauge-sub { margin-top: 12px; display: grid; gap: 4px; font-size: 13px; }
@media print { .ggrid { grid-template-columns: 1fr 1fr; } .gcard { break-inside: avoid; } }

/* Total encaissé : 2 lignes x 2 colonnes (droits | amendes, puis total général | évolution) */
.total-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.total-grid .tile { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; background: var(--card); min-width: 0; }
.total-grid .tile-l { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.total-grid .tile-v { display: block; font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
.total-grid .tile-main { background: var(--accent-soft); border-color: transparent; }
.total-grid .tile-main .total-v { display: block; margin: 2px 0 0; }
.total-grid .tile-stats .total-stats { margin: 0; border-top: 0; }
.total-grid .tile-stats .total-stats div:last-child { border-bottom: 0; }
@media (max-width: 640px) { .total-grid { grid-template-columns: 1fr; } }

/* Total encaissé : pleine largeur, caractères plus imposants */
.grid-main > .panel.total { grid-column: 1 / -1; }
.panel.total .panel-head h2 { font-size: 18px; }
.total-grid { gap: 18px; }
.total-grid .tile { padding: 22px 26px; border-radius: 10px; }
.total-grid .tile-l { font-size: 15px; margin-bottom: 8px; }
.total-grid .tile-v { font-size: 34px; line-height: 1.15; }
.total-grid .tile-main .total-v { font-size: 46px; line-height: 1.1; }
.total-grid .tile-stats .total-stats div { padding: 13px 0; font-size: 16px; }
.total-grid .tile-stats .total-stats dd { font-size: 18px; }
@media (max-width: 900px) { .total-grid .tile-v { font-size: 26px; } .total-grid .tile-main .total-v { font-size: 34px; } }
.total-grid .tile-main { display: flex; flex-direction: column; justify-content: center; }

/* Barre de défilement horizontale (gauche ↔ droite) : tableaux plus larges que l'écran.
   La barre est collée en bas de l'écran (public/js/xscroll.js) ; celle du tableau est masquée quand elle existe. */
.tscroll, .pg-tablewrap, .panel > #list { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: auto; scrollbar-color: #8aa0ba #eef1f5; }
.has-xbar { scrollbar-width: none; }
.has-xbar::-webkit-scrollbar { display: none; }
.xbar { position: sticky; bottom: 0; z-index: 6; overflow-x: scroll; overflow-y: hidden; height: 16px; margin: 0 0 12px; background: #eef1f5; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 -4px 10px rgba(16, 24, 40, .06); scrollbar-width: auto; scrollbar-color: #5f7a99 #eef1f5; }
.xbar[hidden] { display: none; }
.xbar > div { height: 1px; }
.xbar::-webkit-scrollbar { height: 14px; }
.xbar::-webkit-scrollbar-track { background: #eef1f5; border-radius: 8px; }
.xbar::-webkit-scrollbar-thumb { background: #5f7a99; border-radius: 8px; border: 2px solid #eef1f5; }
.xbar::-webkit-scrollbar-thumb:hover { background: #12365f; }
@media (min-width: 721px) { .tbl:not(.lines-t), .pg-table { min-width: 760px; } }
@media print { .tbl, .pg-table { min-width: 0 !important; } .tscroll, .pg-tablewrap, .panel > #list { overflow: visible; } .xbar { display: none !important; } }
