:root {
  --navy: #011936;
  --teal: #028090;
  --mint: #02c39a;
  --grey: #64748b;
  --bg: #f4f9f8;
}

* { box-sizing: border-box; }

body {
  font-family: -apple-system, "Segoe UI", Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: #1f2937;
}

header {
  background: var(--navy);
  color: white;
  padding: 24px 20px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

header h1 { margin: 0; font-size: 22px; }
.subtitle { margin: 4px 0 0; color: #9fb8c8; font-size: 14px; }

.agent-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #cadcfc;
  white-space: nowrap;
}
.agent-bar button {
  width: auto;
  background: transparent;
  border: 1px solid #9fb8c8;
  color: #cadcfc;
  padding: 4px 10px;
  font-size: 11px;
}
.agent-bar a {
  color: #cadcfc;
  font-size: 11px;
  text-decoration: underline;
}

.sync-badge {
  margin: 10px 0 0;
  font-size: 12px;
  color: #011936;
  background: #f4b400;
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
}

main {
  max-width: 480px;
  margin: 0 auto;
  padding: 20px;
}

section {
  background: white;
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

section h2 {
  font-size: 15px;
  color: var(--teal);
  margin: 0 0 12px;
}

select, input[type="text"], input[type="file"], textarea {
  width: 100%;
  padding: 10px;
  margin-bottom: 10px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}

.capture-row {
  display: flex;
  gap: 10px;
}
.capture-row label { flex: 1; font-size: 12px; color: var(--grey); }

#assign-row { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
#assign-row select { margin-bottom: 0; flex: 1; }
#assign-row button { width: auto; padding: 8px 14px; }

button {
  background: var(--teal);
  color: white;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}
button:hover { background: var(--mint); }

#upload-status, #report-status {
  font-size: 13px;
  color: var(--grey);
  margin-top: 8px;
}

.summary {
  font-size: 13px;
  color: var(--navy);
  background: var(--bg);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 12px;
}

.hint {
  font-size: 12px;
  color: var(--grey);
  margin-top: 0;
}

.pairing-columns {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}
.pairing-columns > div { flex: 1; min-width: 0; }

.col-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--teal);
  margin: 0 0 6px;
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
}

.thumb-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
  border: 3px solid transparent;
  cursor: pointer;
}
.thumb-grid img.selected {
  border-color: var(--mint);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.gallery-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
}
.gallery-item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.gallery-item .badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(1, 25, 54, 0.75);
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: capitalize;
}
.gallery-item button {
  width: 100%;
  border-radius: 0;
  font-size: 11px;
  padding: 4px;
  background: #b91c1c;
}

#discarded-details {
  margin-top: 4px;
  margin-bottom: 12px;
}
#discarded-details summary {
  font-size: 12px;
  color: var(--grey);
  cursor: pointer;
  margin-bottom: 8px;
}

.gallery-grid.discarded .gallery-item img {
  opacity: 0.55;
}
.gallery-grid.discarded .gallery-item .reason {
  font-size: 10px;
  color: var(--grey);
  background: var(--bg);
  padding: 3px 4px;
  min-height: 14px;
}
.gallery-grid.discarded .gallery-item button {
  background: var(--teal);
}

.pair-card {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
}
.pair-card img { width: 70px; height: 52px; object-fit: cover; border-radius: 4px; }
.pair-card .pair-info { flex: 1; font-size: 12px; color: var(--navy); }
.pair-card button {
  width: auto;
  background: none;
  color: #b91c1c;
  padding: 4px 8px;
  font-size: 12px;
}
.locked-tag {
  font-size: 11px;
  color: var(--grey);
  white-space: nowrap;
}

/* Assistance IA — boutons et boîtes de suggestion */
.notes-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.notes-actions button { width: auto; }

.ai-btn {
  background: transparent;
  border: 1px solid var(--teal);
  color: var(--teal);
  font-size: 13px;
  padding: 8px 12px;
}
.ai-btn:disabled {
  opacity: 0.5;
}

.ai-suggestion {
  border: 1px solid var(--teal);
  border-left: 3px solid var(--teal);
  background: #f0fafa;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.ai-suggestion .ai-label {
  font-size: 11px;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.ai-suggestion .ai-text {
  font-size: 14px;
  color: var(--navy);
  white-space: pre-wrap;
  margin-bottom: 10px;
}
.ai-suggestion .ai-actions {
  display: flex;
  gap: 8px;
}
.ai-suggestion .ai-actions button {
  width: auto;
  font-size: 12px;
  padding: 6px 12px;
}
.ai-suggestion .accept-btn { background: var(--mint); }
.ai-suggestion .reject-btn {
  background: transparent;
  color: var(--grey);
  border: 1px solid #ccc;
}

/* Saisie vocale */
.voice-btn {
  width: auto;
  background: transparent;
  border: 1px solid var(--navy);
  color: var(--navy);
  font-size: 13px;
  padding: 8px 12px;
  margin-bottom: 8px;
}
.voice-btn.listening {
  background: #b91c1c;
  color: white;
  border-color: #b91c1c;
}

/* Tableau de mesures (aperçu avant enregistrement) */
#mesures-preview {
  border: 1px solid var(--teal);
  border-left: 3px solid var(--teal);
  background: #f0fafa;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.mesures-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.mesures-table th {
  background: var(--navy);
  color: white;
  padding: 6px 8px;
  text-align: left;
  font-weight: 600;
}
.mesures-table td {
  border: 1px solid #ddd;
  padding: 6px 8px;
  color: var(--navy);
}

/* Page publique de vérification */
.verdict {
  padding: 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 16px;
  margin-bottom: 16px;
  text-align: center;
}
.verdict.ok { background: #e6f9f2; color: #027a54; border: 1px solid #02C39A; }
.verdict.ko { background: #fdecea; color: #b91c1c; border: 1px solid #b91c1c; }
.verdict.warn { background: #fef6e6; color: #92600a; border: 1px solid #e0a94a; }

.verify-meta {
  background: #f6f8fa;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}
.verify-meta p { margin: 4px 0; }

.verify-capture {
  border: 1px solid #e0e0e0;
  border-left: 4px solid #ccc;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.verify-capture.ok { border-left-color: #02C39A; }
.verify-capture.ko { border-left-color: #b91c1c; }
.verify-capture.warn { border-left-color: #e0a94a; }
.vc-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--navy);
}
.vc-statut { font-weight: 600; }
.vc-statut.ok { color: #027a54; }
.vc-statut.ko { color: #b91c1c; }
.vc-statut.warn { color: #92600a; }
.vc-meta { font-size: 12px; color: var(--grey); margin: 6px 0; }
.vc-hash {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  color: #999;
  word-break: break-all;
}
.tag-ecartee {
  display: inline-block;
  background: #fef6e6;
  color: #92600a;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 6px;
}

/* Historique des rapports */
.history-item {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.hi-main { font-size: 14px; color: var(--navy); }
.hi-meta { font-size: 12px; color: var(--grey); margin: 4px 0 8px; }
.hi-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.hi-actions a { font-size: 13px; color: var(--teal); text-decoration: underline; }

.vc-geo { font-size: 12px; color: var(--teal); margin: 4px 0; }
.vc-geo a { color: var(--teal); text-decoration: underline; }

/* Choix du mode de mot de passe (création d'agent) */
.pw-choice { margin: 10px 0; }
.radio-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: normal;
  margin-bottom: 6px;
  cursor: pointer;
}
.radio-line input { width: auto; margin: 0; }
