/* Portail SecurAI — signalétique de quai : plaques émaillées cerclées de noir sur fond ballast,
   un seul jaune (« à vérifier par vous »), l'état porté par la forme et le mot. */
:root {
  --ground: #e6e7e2;
  --ground-deep: #d9dbd5;
  --plate: #f9f9f6;
  --ink: #16191c;
  --ink-2: #474d53;
  --ink-3: #5d646a;
  --rim: #16191c;
  --rule: #c9ccc5;
  --signal: #f2c200;
  --signal-ink: #16191c;
  --ok: #2f6f4e;
  --ko: #a1301c;
  --radius: 14px;
  --rim-w: 3px;
  --gap: clamp(16px, 2.2vw, 28px);
  --font: "Overpass", "Segoe UI", system-ui, sans-serif;
  --mono: "Overpass Mono", ui-monospace, "Cascadia Mono", monospace;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 17px/1.5 var(--font);
  font-feature-settings: "tnum" 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
::selection { background: var(--signal); color: var(--signal-ink); }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; border-radius: 6px; }
a { color: inherit; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.1; text-wrap: balance; }
p { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }

html { scrollbar-color: var(--ink-3) var(--ground-deep); }

/* ---------- Plaque émaillée ---------- */
.plate {
  background: var(--plate);
  border: var(--rim-w) solid var(--rim);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 rgba(22, 25, 28, .06), 0 10px 24px -14px rgba(22, 25, 28, .35);
}

.picto {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px; height: 44px;
  background: var(--ink);
  color: var(--plate);
  border-radius: 8px;
}
.picto svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bandeau ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  background: var(--ink); color: var(--plate);
}
.brand { display: flex; align-items: baseline; gap: 14px; text-decoration: none; }
.brand-mark { font-weight: 800; font-size: 24px; letter-spacing: -.01em; }
.brand-sub { font-size: 15px; color: #c9ccc5; border-left: 2px solid #5d646a; padding-left: 14px; }
.who { display: flex; align-items: center; gap: 14px; font-size: 15px; color: #c9ccc5; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 32ch; }
.btn-quiet {
  background: none; border: 2px solid #5d646a; color: var(--plate);
  border-radius: 999px; padding: 6px 14px; font-size: 14px; font-weight: 600;
  transition: border-color .2s var(--ease-out);
}
.btn-quiet:hover { border-color: var(--plate); }
.btn-quiet:focus-visible { outline-color: var(--plate); }

main { flex: 1; width: 100%; max-width: 1360px; margin: 0 auto; padding: var(--gap) clamp(16px, 4vw, 48px) 48px; }

/* ---------- Connexion ---------- */
.gate { min-height: 62vh; display: grid; place-items: center; }
.gate-plate { max-width: 520px; padding: clamp(28px, 5vw, 48px); display: grid; gap: 18px; }
.gate-plate h1 { font-size: clamp(32px, 5vw, 44px); font-weight: 800; }
.gate-plate p { color: var(--ink-2); }
.gate-error { color: var(--ko); font-weight: 600; }
.btn-primary {
  justify-self: start;
  background: var(--ink); color: var(--plate); border: 0;
  border-radius: 999px; padding: 14px 28px; font-weight: 800; font-size: 17px;
  transition: transform .25s var(--ease-out), background-color .2s;
}
.btn-primary:hover { background: #2a2f34; }
.btn-primary:active { transform: translateY(1px); }

/* ---------- Panneau d'état du site ---------- */
.site {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--gap);
  align-items: end; padding: 32px; padding: clamp(22px, 3.4vw, 40px);
}
.site[data-state="offline"] { border-style: dashed; }
.site[data-state="maintenance"] .site-state { font-size: clamp(40px, 6vw, 72px); }
.health dd.dd-text { font: 600 17px/1.4 var(--font); max-width: 60ch; }
.site-state {
  font-size: clamp(48px, 8.4vw, 96px); font-weight: 800; letter-spacing: -.035em; line-height: .98;
  margin: 0 0 14px;
}
.site-since { font-size: clamp(18px, 2vw, 22px); font-weight: 600; }
.health { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 22px 0 0; padding-top: 18px; border-top: 2px solid var(--rule); }
.health div { min-width: 0; }
.health dt { font-size: 14px; color: var(--ink-3); }
.health dd { margin: 2px 0 0; font: 500 17px/1.3 var(--mono); }
.site-action { display: grid; gap: 10px; justify-items: end; }

.to-check {
  display: grid; gap: 4px; text-align: left; min-width: 260px;
  background: var(--signal); color: var(--signal-ink);
  border: var(--rim-w) solid var(--rim); border-radius: 12px;
  padding: 16px 20px; font-weight: 800;
  transition: transform .3s var(--ease-out), box-shadow .3s var(--ease-out);
}
.to-check:hover { transform: translateY(-2px); box-shadow: 0 12px 22px -14px rgba(22, 25, 28, .6); }
.to-check .n { font-size: 44px; line-height: 1; letter-spacing: -.03em; }
.to-check .l { font-size: 16px; }
.all-clear { font-weight: 600; color: var(--ink-2); max-width: 26ch; text-align: right; }

/* ---------- Plaques caméra ---------- */
.cameras { margin-top: var(--gap); }
.camera-row { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.cam { padding: 16px 18px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; }
.cam h3 { font-size: 18px; font-weight: 800; }
.cam .cam-state { grid-column: 1 / -1; font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.cam .cam-note { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); line-height: 1.4; }
.cam[data-state="unknown"] { border-color: var(--ink-3); border-width: 2px; box-shadow: none; }
.cam[data-state="unknown"] .cam-state { color: var(--ink-2); }
.cam[data-state="disabled"] { background: var(--ground-deep); border-color: var(--ink-3); box-shadow: none; }
.cam[data-state="disabled"] .cam-state { color: var(--ink-2); }
.cam[data-state="alert"] .cam-state { background: var(--signal); justify-self: start; padding: 0 8px; border-radius: 6px; }

/* ---------- Journal + synthèse ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; margin-top: calc(var(--gap) * 1.6); }
.views { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: var(--rim-w) solid var(--rim); }
.view-tab {
  border: 0; background: none; padding: 10px 16px 12px; min-height: 44px; font-weight: 800; font-size: 18px; color: var(--ink-3);
  border-radius: 10px 10px 0 0; transition: background-color .25s var(--ease-out), color .25s var(--ease-out);
}
.view-tab:hover { color: var(--ink); }
.view-tab[aria-pressed="true"] { background: var(--ink); color: var(--plate); }
.work { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: var(--gap); margin-top: 18px; align-items: start; }
.view { margin-top: 18px; }
.view-title { font-size: clamp(28px, 3.4vw, 38px); font-weight: 800; letter-spacing: -.02em; }
.view-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px; }
.view-intro, .view-note { margin: 10px 0 18px; color: var(--ink-2); max-width: 75ch; }
.view-note { margin-top: 14px; font-size: 15px; }
.btn-line {
  border: var(--rim-w) solid var(--rim); background: var(--plate); color: var(--ink); border-radius: 999px;
  padding: 8px 18px; min-height: 44px; font-weight: 800; font-size: 15px; transition: background-color .2s var(--ease-out);
}
.btn-line:hover { background: #ecece6; }
.btn-line:disabled { opacity: .45; cursor: not-allowed; }
.report-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.select {
  font: 700 15px var(--font); color: var(--ink); background: var(--plate); border: var(--rim-w) solid var(--rim);
  border-radius: 999px; padding: 8px 14px; min-height: 44px;
}

/* Tableaux (enlèvements, bilan) */
.table-wrap { overflow-x: auto; border: var(--rim-w) solid var(--rim); border-radius: var(--radius); background: var(--plate); }
.data-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.data-table th, .data-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.data-table thead th { font-size: 14px; color: var(--ink-3); font-weight: 700; background: #f1f2ee; white-space: nowrap; }
.data-table tbody tr:last-child > * { border-bottom: 0; }
.data-table td.muted { color: var(--ink-3); }
.data-table td.num { font: 600 17px var(--mono); white-space: nowrap; }
.data-table tr.row-false td { color: var(--ink-3); }
.data-table a { font-weight: 700; }

/* Bilan imprimable */
.report { margin-top: 16px; padding: clamp(20px, 3vw, 36px); }
.report-head { display: grid; gap: 4px; margin-bottom: 20px; }
.report-brand { font-size: 14px; font-weight: 700; color: var(--ink-3); }
.report-head h3 { font-size: clamp(26px, 3vw, 34px); font-weight: 800; }
.report-sub { color: var(--ink-2); }
.report-table tbody th { font-weight: 700; width: 34%; }
.report-foot { margin-top: 18px; font-size: 14px; color: var(--ink-3); max-width: 80ch; }
.switch { display: inline-flex; border: var(--rim-w) solid var(--rim); border-radius: 999px; background: var(--plate); padding: 3px; }
.switch button {
  border: 0; background: none; border-radius: 999px; padding: 8px 18px; min-height: 44px; font-weight: 700; font-size: 15px; color: var(--ink-2);
  transition: background-color .25s var(--ease-out), color .25s var(--ease-out);
}
.switch button[aria-pressed="true"] { background: var(--ink); color: var(--plate); }
.source-note { margin: 12px 0 0; color: var(--ink-2); max-width: 70ch; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 14px; }
.chip {
  border: 2px solid var(--ink-3); background: transparent; border-radius: 999px;
  padding: 5px 16px; min-height: 44px; font-size: 15px; font-weight: 600; color: var(--ink-2);
}
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--plate); }

.alerts { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.alert { background: var(--plate); border: var(--rim-w) solid var(--rim); border-radius: var(--radius); overflow: hidden;
  transition: border-color .35s var(--ease-out), background-color .35s var(--ease-out); }
.alerts.has-open > li:not(.open) { border-color: var(--ink-3); background: #f1f2ee; }
.alerts.has-open > li:not(.open) .picto { opacity: .55; transition: opacity .35s var(--ease-out); }
.alert[data-state="pending"] { box-shadow: 0 10px 24px -16px rgba(22, 25, 28, .45); }
.alert-head {
  width: 100%; display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 14px; align-items: center;
  padding: 14px 16px; background: none; border: 0; text-align: left;
}
.alert-head:hover .alert-title { text-decoration: underline; text-decoration-thickness: 2px; }
.alert-title { display: block; font-size: 19px; font-weight: 800; line-height: 1.2; }
.alert-meta { display: block; font: 500 14px/1.4 var(--mono); color: var(--ink-3); margin-top: 4px; }
.chev { width: 22px; height: 22px; fill: none; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; transition: transform .35s var(--ease-out); }
.open .chev { transform: rotate(180deg); }

.tag { font-size: 14px; font-weight: 800; border-radius: 8px; padding: 5px 10px; white-space: nowrap; }
.tag-pending { background: var(--signal); color: var(--signal-ink); border: 2px solid var(--rim); }
.tag-info { color: var(--ink-2); border: 2px dashed var(--ink-3); }
.tag-ok { color: var(--ok); border: 2px solid var(--ok); }
.tag-ko { color: var(--ko); border: 2px dashed var(--ko); }

.alert-body {
  display: grid; grid-template-rows: 0fr; transition: grid-template-rows .45s var(--ease-out);
}
.open .alert-body { grid-template-rows: 1fr; }
.alert-body > div { overflow: hidden; }
.alert-inner { padding: 0 16px 18px; display: grid; gap: 14px; }
.alert-msg { max-width: 70ch; color: var(--ink-2); }
.alert-muted { max-width: 70ch; font-size: 15px; color: var(--ink-2); border: 2px dashed var(--ink-3); border-radius: 10px; padding: 10px 14px; }
.proof { position: relative; margin: 0; border: 2px solid var(--rim); border-radius: 10px; overflow: hidden; background: var(--ink); }
.proof img { display: block; width: 100%; height: auto; max-height: 70vh; object-fit: contain; }
.proof a { display: block; }
.proof-missing { padding: 28px 18px; color: #c9ccc5; font-weight: 600; }
.proof figcaption { padding: 8px 12px; font-size: 14px; color: #c9ccc5; background: #23282c; }

.stamp {
  position: absolute; right: 18px; bottom: 58px; pointer-events: none;
  border: 4px double currentColor; border-radius: 10px; padding: 6px 14px;
  font-weight: 800; font-size: clamp(18px, 2.4vw, 26px); letter-spacing: .04em; text-transform: uppercase;
  background: rgba(249, 249, 246, .92); transform: rotate(-6deg);
  display: grid; gap: 0; line-height: 1.15; text-align: center;
}
.stamp small { font: 500 12px/1.3 var(--mono); letter-spacing: 0; text-transform: none; }
.stamp-ok { color: var(--ok); }
.stamp-ko { color: var(--ko); }
.stamp.landed { animation: stamp-in .5s var(--ease-out) both; }
@keyframes stamp-in {
  0% { opacity: 0; transform: rotate(-14deg) scale(1.6); filter: blur(2px); }
  60% { opacity: 1; transform: rotate(-5deg) scale(.96); filter: blur(0); }
  100% { opacity: 1; transform: rotate(-6deg) scale(1); }
}

.verdict-form { display: grid; gap: 10px; }
.verdict-form label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.verdict-form input {
  font: inherit; padding: 10px 12px; border: 2px solid var(--ink-3); border-radius: 10px; background: #fff; width: 100%; max-width: 520px;
}
.verdict-form input:focus-visible { border-color: var(--ink); outline-offset: 1px; }
.verdict-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-ok, .btn-ko {
  border-radius: 999px; padding: 11px 22px; font-weight: 800; font-size: 16px; border: 3px solid var(--rim);
  transition: transform .2s var(--ease-out), background-color .2s;
}
.btn-ok { background: var(--ok); color: var(--plate); border-color: var(--ok); }
.btn-ok:hover { background: #255a3f; }
.btn-ko { background: var(--plate); color: var(--ko); border-color: var(--ko); }
.btn-ko:hover { background: #f4e7e3; }
.btn-ok:active, .btn-ko:active { transform: translateY(1px); }
.btn-ok:disabled, .btn-ko:disabled { opacity: .5; cursor: progress; }
.verdict-done { font-size: 15px; color: var(--ink-2); }
.verdict-err { color: var(--ko); font-weight: 600; }

.empty {
  border: var(--rim-w) dashed var(--ink-3); border-radius: var(--radius); padding: 26px 22px; color: var(--ink-2);
  display: grid; gap: 8px; max-width: 70ch;
}
.empty strong { color: var(--ink); font-size: 19px; }

/* ---------- Synthèse ---------- */
.summary { padding: 22px; display: grid; gap: 12px; position: sticky; top: 16px; }
.summary h2 { font-size: 26px; font-weight: 800; }
.summary h3 { font-size: 17px; font-weight: 800; margin-top: 8px; }
.summary-period { font-size: 15px; color: var(--ink-2); }
.summary-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.summary-table td { padding: 7px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
.summary-table td:last-child { text-align: right; font: 500 16px var(--mono); padding-left: 12px; }
.summary-note { font-size: 14px; color: var(--ink-2); }

/* ---------- Pied ---------- */
.foot { padding: 22px clamp(16px, 4vw, 48px) 30px; color: var(--ink-3); font-size: 14px; display: grid; gap: 4px; border-top: 2px solid var(--ground-deep); }

.loading { color: var(--ink-2); padding: 20px 0; }

/* ---------- Écrans étroits ---------- */
@media (max-width: 1080px) {
  .work { grid-template-columns: 1fr; }
  .summary { position: static; }
  .camera-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  body { font-size: 16px; }
  .brand-sub { display: none; }
  .who span { display: none; }
  .site { grid-template-columns: 1fr; align-items: start; }
  .site-action { justify-items: stretch; }
  .to-check { min-width: 0; }
  .all-clear { text-align: left; }
  .camera-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .cam { padding: 12px; gap: 6px 10px; }
  .cam .picto { width: 34px; height: 34px; }
  .cam .picto svg { width: 20px; height: 20px; }
  .cam h3 { font-size: 16px; }
  .cam .cam-state { font-size: 17px; }
  .cam .cam-note { display: none; }
  .cam[data-state="disabled"] { grid-column: 1 / -1; }
  .cam[data-state="disabled"] .cam-note { display: block; }
  .alert-head { grid-template-columns: auto minmax(0, 1fr) auto; }
  .alert-head .tag { grid-column: 2 / 4; justify-self: start; }
  .alert-head .chev { grid-row: 1; grid-column: 3; }
  .stamp { right: 10px; bottom: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media (max-width: 640px) {
  .view-tab { font-size: 16px; padding: 10px 12px; }
  .data-table thead { display: none; }
  .data-table tr { display: block; border-bottom: 2px solid var(--rule); padding: 8px 0; }
  .data-table td, .data-table tbody th { display: block; border: 0; padding: 4px 14px; width: auto; }
  #pickups .data-table td::before { content: attr(data-label) " : "; font-weight: 700; color: var(--ink-3); }
}

/* Impression : seul le bilan sort, sur fond blanc. */
@media print {
  body { background: #fff; }
  .topbar, .foot, .site, .cameras, .toolbar, .source-note, #view-alerts, #view-pickups, .view-head { display: none !important; }
  main { padding: 0; max-width: none; }
  .report { border: 0; box-shadow: none; padding: 0; margin: 0; background: #fff; }
  .data-table { font-size: 12pt; }
  .data-table thead th { background: #eee; }
}
