:root {
  --bg: #0d131a; --panel: #151d27; --panel-2: #1b2531; --line: #2a3849;
  --text: #e8edf3; --muted: #9aa8b9; --brass: #c8a45d; --brass-ink: #1c1608;
  --ok: #5dba8e; --warn: #e0a84d; --danger: #e5675f; --info: #6fa8dc;
  --radius: 6px;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.25; margin: 0; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
a { color: var(--brass); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
.muted { color: var(--muted); }

/* barre du haut */
#topbar { background: var(--panel); border-bottom: 2px solid var(--brass); }
.bar { max-width: 1080px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 1.15rem; display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none; margin-right: auto; }
.brand svg { color: var(--brass); }
.bar nav { display: flex; gap: 6px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: .9rem; }

/* boutons et champs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel-2); color: var(--text); font: inherit; font-size: .95rem; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: var(--brass); }
.btn.primary { background: var(--brass); border-color: var(--brass); color: var(--brass-ink); font-weight: 600; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #1c0907; }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: .88rem; }
.btn.active { border-color: var(--brass); color: var(--brass); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg, .ic { width: 16px; height: 16px; flex: none; }
label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; padding: 9px 11px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--brass); outline: none; }
textarea { min-height: 90px; resize: vertical; }
.req::after { content: " *"; color: var(--brass); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.grid .full { grid-column: 1 / -1; }
.form-error { color: var(--danger); background: rgba(229,103,95,.1); border: 1px solid var(--danger); border-radius: var(--radius); padding: 8px 12px; margin-bottom: 12px; }
.hint { font-size: .82rem; color: var(--muted); margin-top: 3px; }

/* panneaux */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 20px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }

/* connexion */
.login { max-width: 400px; margin: 8vh auto 0; }
.login h1 { margin-bottom: 4px; }
.login form > div { margin-bottom: 14px; }
.login .btn { width: 100%; justify-content: center; }

/* recherche */
.search-hero { padding: 36px 0 20px; }
.search-hero h1 { font-size: 2rem; margin-bottom: 6px; }
.search-box { display: flex; gap: 8px; margin-top: 18px; }
.search-box input { font-size: 1.1rem; padding: 13px 14px; }
.search-box .btn { padding: 0 22px; }

/* tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .88rem; white-space: nowrap; }
tbody tr:hover { background: var(--panel-2); }
td.num { font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }

/* étiquettes */
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .8rem; border: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: var(--warn); border-color: var(--warn); }
.badge.danger { color: var(--danger); border-color: var(--danger); }
.badge.info { color: var(--info); border-color: var(--info); }

/* fiche */
.file-head { border-left: 4px solid var(--brass); padding-left: 16px; margin-bottom: 22px; }
.file-head .case { color: var(--brass); font-variant-numeric: tabular-nums; font-size: .95rem; }
.file-head h1 { font-size: 2rem; }
dl.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 20px; margin: 0; }
dl.facts dt { color: var(--muted); font-size: .85rem; }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
.meter { display: flex; gap: 3px; margin: 6px 0; }
.meter i { width: 18px; height: 10px; border-radius: 2px; background: var(--line); }
.meter i.on { background: var(--brass); }
.meter.low i.on { background: var(--danger); }
.record { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; background: var(--panel-2); }
.record.arrest { border-left-color: var(--warn); }
.record.conviction { border-left-color: var(--danger); }
.record-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: baseline; margin-bottom: 8px; }
.record p { margin: 6px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.record .meta { color: var(--muted); font-size: .88rem; display: flex; gap: 6px 18px; flex-wrap: wrap; }
.record .row-actions { margin-top: 10px; display: flex; gap: 6px; }

/* états */
.state { text-align: center; padding: 40px 16px; color: var(--muted); }
.state h3 { color: var(--text); margin-bottom: 6px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brass); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }

/* notifications et fenêtres */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: calc(100vw - 32px); }
.toast { padding: 11px 16px; border-radius: var(--radius); background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--info); box-shadow: 0 4px 16px rgba(0,0,0,.4); }
.toast.ok { border-left-color: var(--ok); } .toast.error { border-left-color: var(--danger); }
.overlay { position: fixed; inset: 0; background: rgba(5,8,12,.75); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 12px; overflow-y: auto; z-index: 40; }
.dialog { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--brass); border-radius: var(--radius); width: 100%; max-width: 640px; padding: 20px; }
.dialog h2 { margin-bottom: 14px; }
.dialog .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.noscript { padding: 20px; text-align: center; }

@media (max-width: 700px) {
  .grid { grid-template-columns: 1fr; }
  .search-box { flex-direction: column; } .search-box .btn { min-height: 46px; justify-content: center; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 1px solid var(--line); padding: 8px 0; }
  table.stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 10px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  table.stack td.actions { justify-content: flex-end; }
  table.stack td.actions::before { content: none; }
}
