:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1d2433; --muted: #6b7385; --line: #e3e6ec;
  --accent: #1f4e8c; --accent-soft: #e8eef8; --acte: #c2187a; --courrier: #1f78c8; --recu: #1e9e4a;
  --warn: #a15c00; --warn-soft: #fff4e0;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.top { display: flex; align-items: center; gap: 24px; padding: 0 20px; height: 52px;
  background: #16213a; color: #fff; position: sticky; top: 0; z-index: 10; }
.top .brand { font-weight: 700; letter-spacing: .3px; color: #fff; }
.top nav a { color: #c8d2e8; margin-right: 16px; padding: 15px 0; }
.top nav a.on { color: #fff; border-bottom: 2px solid #fff; }
.top .user { margin-left: auto; color: #c8d2e8; font-size: 13px; display: flex; gap: 12px; align-items: center; }
.top .user button { background: none; border: 1px solid #44506b; color: #c8d2e8; border-radius: 6px;
  padding: 3px 10px; cursor: pointer; font: inherit; }
main { padding: 20px; max-width: 1400px; margin: 0 auto; }
h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 22px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.sub { color: var(--muted); margin-bottom: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
form.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
input[type=search], input[type=text], input[type=password], select {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
input[type=search] { min-width: 320px; }
button.primary { font: inherit; background: var(--accent); color: #fff; border: 0; border-radius: 7px;
  padding: 7px 14px; cursor: pointer; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .3px;
  background: #fafbfc; }
tr.click:hover td { background: var(--accent-soft); cursor: pointer; }
.tablewrap { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; overflow-x: auto; }
.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 10px; background: #eef0f4;
  color: var(--muted); white-space: nowrap; }
.tag.arch { background: var(--warn-soft); color: var(--warn); }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 12px; color: var(--muted); }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px 20px; margin: 14px 0 6px; }
.facts div span { display: block; font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; flex-wrap: wrap; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a .n { font-size: 11px; background: #eef0f4; border-radius: 9px; padding: 0 6px; margin-left: 4px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card ul { list-style: none; padding: 0; margin: 0; }
.card li { padding: 6px 0; border-top: 1px solid var(--line); }
.card li:first-child { border-top: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.acte { background: var(--acte); } .dot.courrier { background: var(--courrier); } .dot.recu { background: var(--recu); }
.files a { margin-right: 10px; white-space: nowrap; }
.note { background: var(--warn-soft); color: var(--warn); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
dl.kv { display: grid; grid-template-columns: 200px 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; white-space: pre-wrap; }
pre.texte { white-space: pre-wrap; font: 15px/1.6 Georgia, "Times New Roman", serif; max-width: 820px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 28px 36px; }
.login { max-width: 360px; margin: 12vh auto; }
.login label { display: block; margin: 12px 0 4px; color: var(--muted); }
.login input { width: 100%; }
.err { color: #b3261e; margin-top: 10px; }
.show-sm { display: none; }
@media (max-width: 700px) {
  .show-sm { display: inline; } .top { gap: 14px; padding: 0 12px; }
  main { padding: 12px; } input[type=search] { min-width: 0; width: 100%; }
  .grid2 { grid-template-columns: 1fr; } dl.kv { grid-template-columns: 1fr; }
  .top nav a { margin-right: 10px; } .hide-sm { display: none; }
}

/* --- buttons, global search, viewer, search hits --- */
a.button { display: inline-block; background: var(--accent); color: #fff; border-radius: 7px; padding: 7px 14px;
  white-space: nowrap; }
a.button:hover { text-decoration: none; opacity: .92; }
a.button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--line); }
.globalsearch { flex: 1; max-width: 420px; }
.globalsearch input { width: 100%; min-width: 0; background: #24304d; border-color: #33405f; color: #fff; }
.globalsearch input::placeholder { color: #9aa6c2; }
th.sortable a { color: inherit; }
.files a.dl { margin-left: -6px; color: var(--muted); }
iframe.viewer { width: 100%; height: calc(100vh - 190px); min-height: 480px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff; }
img.viewer-img { max-width: 100%; height: auto; }
article.apercu { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 32px 40px;
  max-width: 860px; font: 15px/1.6 Georgia, "Times New Roman", serif; overflow-x: auto; }
article.apercu table { border-collapse: collapse; width: auto; }
article.apercu td, article.apercu th { border: 1px solid var(--line); padding: 4px 8px; font: 13px/1.4 -apple-system, sans-serif; }
mark { background: #ffe58a; padding: 0 1px; border-radius: 2px; }
.hit { padding: 10px 0; border-bottom: 1px solid var(--line); }
.hit .snippet { color: #3b4356; margin-top: 4px; font-size: 13.5px; }
.viewer-head { margin-bottom: 12px; }
@media (max-width: 700px) {
  .globalsearch { display: none; }
  article.apercu { padding: 18px; }
  iframe.viewer { height: 70vh; }
}

/* --- logo, flash messages, forms, agenda, dashboard --- */
.top .brand { display: flex; align-items: center; gap: 10px; }
.top .brand img.mono { width: 34px; height: 34px; background: #fff; border-radius: 50%; padding: 3px; }
.login { max-width: 480px; }
.login img.bandeau { width: 100%; height: auto; border-radius: 10px; margin-bottom: 14px; display: block; }
.flash { margin-bottom: 14px; }
.msg { padding: 10px 14px; border-radius: 8px; margin-bottom: 6px; background: var(--accent-soft); color: var(--accent); }
.msg.success { background: #e6f5ec; color: #17693a; }
.msg.error { background: #fdecea; color: #b3261e; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
a.small, button.small { font-size: 12.5px; padding: 3px 9px; }
button.secondary, button.danger { font: inherit; border-radius: 7px; padding: 7px 14px; cursor: pointer;
  background: #fff; border: 1px solid var(--line); color: var(--accent); }
button.danger { color: #b3261e; border-color: #f0c9c5; }
button.link { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; }
form.saisie { max-width: 860px; }
form.saisie fieldset { border: 1px solid var(--line); border-radius: 10px; background: var(--panel); padding: 12px 16px 6px;
  margin: 0 0 14px; }
form.saisie legend { font-weight: 600; padding: 0 6px; color: var(--muted); }
.champs { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 18px; }
.champ { margin-bottom: 10px; }
.champ.large { grid-column: 1 / -1; }
.champ label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.champ input[type=text], .champ input[type=email], .champ input[type=number], .champ input[type=date],
.champ input[type=time], .champ input[type=url], .champ select, .champ textarea, .champ input[type=file] {
  width: 100%; font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; background: #fff; }
.champ ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.champ .aide { font-size: 12px; color: var(--muted); }
.champ .errorlist { color: #b3261e; list-style: none; padding: 0; margin: 2px 0; font-size: 12.5px; }
.champ.checkbox label { display: inline; color: var(--ink); font-size: 14px; }
.barre { display: flex; gap: 10px; align-items: center; margin-top: 6px; }
.barre .droite { margin-left: auto; }
.card .edit { float: right; font-size: 12.5px; }
.card li .edit { float: right; font-size: 12px; visibility: hidden; }
.card li:hover .edit { visibility: visible; }
.retard { color: #b3261e; }
.fait { text-decoration: line-through; color: var(--muted); }
.agenda { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.jour { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; min-height: 110px;
  font-size: 13px; }
.jour.weekend { background: #fafbfc; }
.jour.today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.jour .j { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.jour .j a { visibility: hidden; } .jour:hover .j a { visibility: visible; }
.jour .item { padding: 3px 5px; border-radius: 5px; margin-bottom: 3px; background: var(--accent-soft); }
.jour .item.imp { background: var(--warn-soft); }
.jour .item.imp.fait { background: #eef0f4; }
.jour .item .d { font-size: 11.5px; color: var(--muted); }
.kpis { display: flex; gap: 12px; flex-wrap: wrap; margin: 12px 0; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 150px; }
.kpi b { font-size: 22px; display: block; }
.kpi.alerte b { color: #b3261e; }
.liste-modeles { columns: 2 380px; column-gap: 28px; }
.liste-modeles a { display: block; padding: 4px 0; break-inside: avoid; }
@media (max-width: 900px) { .agenda { grid-template-columns: 1fr; } .jour { min-height: 0; } }
@media (max-width: 700px) {
  .top { height: auto; flex-wrap: wrap; padding: 8px 12px 0; gap: 8px 14px; }
  .top nav { order: 3; width: 100%; overflow-x: auto; white-space: nowrap; }
  .top nav a { display: inline-block; padding: 8px 0; }
}
