/* RapportPro — direction « Bleu nuit & or » */
:root {
  --navy: #0F2342;
  --navy-2: #1C3A66;
  --navy-soft: #E7ECF4;
  --gold: #C9A33A;
  --gold-text: #8A6A12;      /* or lisible sur fond clair */
  --gold-soft: #F7F0DC;
  --paper: #F5F6F9;
  --card: #FFFFFF;
  --ink: #18233A;
  --muted: #5E6778;
  --line: #D8DDE6;
  --danger: #B3261E;
  --serif: Georgia, "Times New Roman", "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --r: 12px;
  --tap: 52px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font: 16px/1.5 var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
svg { width: 22px; height: 22px; flex: none; }
button { font: inherit; }

/* ---------- Barre du haut ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px 14px;
  background: var(--navy); color: #fff;
  border-bottom: 3px solid var(--gold);
}
.brand { flex: 1; min-width: 0; }
.company { display: block; font-size: .8rem; color: #B9C4D8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company:empty { display: none; }
.topbar h1 {
  margin: 0; font: 600 1.1rem/1.25 var(--serif);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.on-list .topbar { padding-top: calc(22px + env(safe-area-inset-top)); padding-bottom: 18px; align-items: flex-end; }
body.on-list .topbar h1 { font-size: 1.6rem; white-space: normal; letter-spacing: .1px; }
body:not(.on-list) .topbar { padding-left: 4px; }

.icon-btn {
  display: grid; place-items: center;
  width: 46px; height: 46px; border: 0; border-radius: 50%;
  background: transparent; color: #fff; cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,.12); }
.net {
  font-size: .75rem; font-weight: 600; padding: 4px 10px; border-radius: 99px;
  background: var(--gold); color: var(--navy); align-self: center;
}

/* ---------- Mise en page ---------- */
.view { max-width: 680px; margin: 0 auto; padding: 16px 14px 120px; }

.block {
  background: var(--card); border-radius: var(--r);
  padding: 18px 16px 6px; margin-bottom: 14px;
  border: 1px solid #E4E8EF;
}
.block h2 {
  margin: 0 0 14px; font: 600 1.15rem/1.3 var(--serif); color: var(--navy);
}
.hint { margin: -8px 0 14px; color: var(--muted); font-size: .9rem; }

/* ---------- Champs ---------- */
label { display: block; margin-bottom: 14px; font-size: .9rem; font-weight: 600; color: var(--navy-2); }
.opt { font-weight: 400; color: var(--muted); }
input, textarea {
  display: block; width: 100%; margin-top: 6px;
  min-height: var(--tap); padding: 12px 14px;
  font: 400 1rem/1.4 var(--sans); color: var(--ink);
  background: #FBFCFD; border: 1.5px solid var(--line); border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 0; }
input:focus, textarea:focus {
  outline: none; border-color: var(--navy-2); background: #fff;
  box-shadow: 0 0 0 3px rgba(201,163,58,.45);
}
input::placeholder, textarea::placeholder { color: #98A0AE; }
.row { display: flex; gap: 12px; }
.row > label { flex: 1; }

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px; border-radius: 12px;
  font-weight: 600; font-size: 1rem; cursor: pointer;
  border: 1.5px solid transparent; text-decoration: none;
  transition: transform .08s, background-color .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--navy); color: #fff; box-shadow: inset 0 -3px 0 var(--gold); }
.btn.primary:active { background: var(--navy-2); }
.btn.secondary { background: var(--navy-soft); color: var(--navy); }
.btn.ghost { background: #fff; color: var(--navy-2); border-color: var(--line); }
.btn.small { min-height: 44px; font-size: .92rem; padding: 0 14px; }
.btn.wide { width: 100%; }
.file-btn { margin: 0 0 12px; font-size: 1rem; }
.link-btn {
  background: none; border: 0; padding: 10px 4px; min-height: 44px;
  color: var(--navy-2); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.link-btn.danger { color: var(--danger); }
.btn:focus-visible, .link-btn:focus-visible, .icon-btn:focus-visible, .report:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}

/* ---------- Recherche + liste ---------- */
.search {
  display: flex; align-items: center; gap: 8px; margin: 0 0 16px;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 0 12px; color: var(--muted);
}
.search:focus-within { border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(201,163,58,.45); }
.search input { border: 0; margin: 0; padding: 12px 0; background: transparent; box-shadow: none; }
.search input:focus { box-shadow: none; }

.reports { list-style: none; margin: 0; padding: 0; }
.report {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 12px;
  background: var(--card); border: 1px solid #E4E8EF; border-left: 4px solid #C3CAD6;
  border-radius: 10px; padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
}
.report.done { border-left-color: var(--gold); }
.report:active { background: #F0F3F8; }
.report .client { font-weight: 700; color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.report .meta { grid-column: 1; color: var(--muted); font-size: .86rem; }
.report .status { grid-column: 2; grid-row: 1 / span 2; }
.month { margin: 18px 2px 8px; font: 600 .95rem var(--serif); color: var(--muted); }
.month:first-child { margin-top: 0; }

.status {
  font-size: .78rem; font-weight: 700; padding: 3px 10px; border-radius: 99px;
  border: 1.5px solid #C3CAD6; color: var(--muted); background: #fff; white-space: nowrap;
}
.status.done { border-color: var(--gold); color: var(--gold-text); background: var(--gold-soft); }

.empty { text-align: center; color: var(--muted); padding: 48px 18px; }
.empty-title { font: 600 1.2rem var(--serif); color: var(--navy); margin: 0 0 6px; }
.empty p { margin: 0 auto; max-width: 34ch; }
.no-result { text-align: center; color: var(--muted); padding: 30px 10px; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(245,246,249,0), var(--paper) 30%);
}
.bottom-bar .btn { max-width: 652px; margin: 0 auto; display: flex; font-size: 1.05rem; }

/* ---------- Matériel ---------- */
.material { display: grid; grid-template-columns: 1fr 84px 46px; gap: 8px; margin-bottom: 10px; }
.material input { margin: 0; }
.material .del {
  display: grid; place-items: center; border: 1.5px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--muted); cursor: pointer;
}
.material .del svg { width: 18px; height: 18px; }
#btn-add-material { margin-bottom: 12px; }

/* ---------- Photos ---------- */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(98px, 1fr)); gap: 8px; margin-bottom: 12px; }
.photos:empty { display: none; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--navy-soft); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo button {
  position: absolute; top: 5px; right: 5px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; border: 0; background: rgba(15,35,66,.78); color: #fff; cursor: pointer;
}
.photo button svg { width: 16px; height: 16px; }

/* ---------- Signature ---------- */
.sig-wrap {
  position: relative; background: #fff; border-radius: 10px;
  border: 1.5px solid var(--gold); box-shadow: inset 0 0 0 4px var(--gold-soft);
}
#sig { display: block; width: 100%; height: 200px; touch-action: none; position: relative; z-index: 1; }
.sig-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #A7AFBC; pointer-events: none; }
.sig-line { position: absolute; left: 18px; right: 18px; bottom: 44px; border-bottom: 1px dashed #CBB27A; pointer-events: none; }
.sign-block .link-btn { margin: 2px 0 8px; }

.error {
  background: #FCEDEC; color: var(--danger); border-radius: 10px; padding: 12px 14px; font-weight: 600; margin: 0 0 14px;
}

.form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 10px;
  margin: 0 -14px; padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: rgba(245,246,249,.96); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.form-actions .btn { flex: 1; padding: 0 10px; }
.form-actions .btn.primary { flex: 1.4; }

/* ---------- Détail ---------- */
.detail { background: var(--card); border: 1px solid #E4E8EF; border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.detail-head { padding: 18px 16px 16px; border-bottom: 1px solid #E4E8EF; }
.detail-head .num { color: var(--muted); font-size: .9rem; }
.detail-head h2 { margin: 2px 0 6px; font: 600 1.4rem/1.25 var(--serif); color: var(--navy); }
.detail-head .when { color: var(--ink); }
.detail dl { margin: 0; padding: 6px 16px 10px; }
.detail dt { color: var(--muted); font-size: .82rem; font-weight: 600; margin-top: 12px; }
.detail dd { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.seal {
  margin: 4px 16px 18px; padding: 12px; border-radius: 10px; text-align: center;
  border: 1.5px solid var(--gold); background: linear-gradient(var(--gold-soft), #fff 70%);
}
.seal img { max-width: 100%; max-height: 120px; display: block; margin: 0 auto 6px; mix-blend-mode: multiply; }
.seal .by { color: var(--gold-text); font-weight: 700; font-size: .9rem; }
.quiet-actions { display: flex; justify-content: space-between; padding: 0 4px 12px; }
#view-detail { padding-bottom: 0; }
#view-form { padding-bottom: 0; }

/* ---------- Paramètres ---------- */
.logo-row { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.logo-box {
  width: 120px; height: 72px; flex: none; display: grid; place-items: center;
  border: 1.5px dashed var(--line); border-radius: 10px; background: #FBFCFD; color: var(--muted); font-size: .85rem;
}
.logo-box img { max-width: 108px; max-height: 60px; }
.logo-btns { display: flex; flex-direction: column; align-items: flex-start; }
.logo-btns .file-btn { margin: 0; }
.footnote { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 22px; }

/* ---------- Message temporaire ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 50; max-width: min(92vw, 520px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px;
  border-left: 4px solid var(--gold); box-shadow: 0 8px 24px rgba(15,35,66,.25); font-size: .95rem;
  animation: toast-in .2s ease-out;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

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