/* RapportPro par MOSCOW — couleurs relevées dans le logo MOSCOW.
   Les noms de variables « navy / gold » sont conservés : navy = encre MOSCOW, gold = accent lavande. */
:root {
  --navy: #12194F;           /* encre MOSCOW */
  --navy-2: #2F40CE;         /* bleu profond */
  --blue: #2844EE;           /* bleu électrique */
  --navy-soft: #EEF0FF;      /* brume */
  --gold: #7064F8;           /* lavande : liserés, focus, sceau */
  --gold-text: #3B35C8;      /* lavande foncée, lisible sur fond clair */
  --gold-soft: #EEF0FF;
  --paper: #F6F7FC;
  --card: #FFFFFF;
  --ink: #161B3D;
  --muted: #5D6280;
  --line: #D9DCEF;
  --danger: #B3261E;
  --serif: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;  /* titres : sans géométrique, comme le logo */
  --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);
  border-image: linear-gradient(90deg, var(--blue), var(--gold)) 1;
}
.brandline { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: #C9CCF2; margin-bottom: 4px; }
.brandline img { width: 26px; height: 26px; border-radius: 7px; background: #fff; padding: 2px; }
body:not(.on-list) .brandline { display: none; }
.brand { flex: 1; min-width: 0; }
.company { display: block; font-size: .8rem; color: #C9CCF2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company:empty { display: none; }
.topbar h1 {
  margin: 0; font: 700 1.1rem/1.25 var(--serif); letter-spacing: -.2px;
  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 #E3E5F3;
}
.block h2 {
  margin: 0 0 14px; font: 700 1.12rem/1.3 var(--serif); color: var(--navy); letter-spacing: -.2px;
}
.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(112,100,248,.40);
}
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(112,100,248,.40); }
.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 #E3E5F3; border-left: 4px solid #C6CAE0;
  border-radius: 10px; padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
}
.report.done { border-left-color: var(--blue); }
.report:active { background: #F0F1FB; }
.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 #C6CAE0; 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(246,247,252,0), var(--paper) 30%);
}
.bottom-bar .btn { max-width: 652px; margin: 0 auto; display: flex; font-size: 1.05rem; }
.bottom-bar .btn.primary {
  background: linear-gradient(100deg, var(--navy-2), var(--blue) 55%, var(--gold));
  box-shadow: 0 6px 18px rgba(40,68,238,.30);
}

/* ---------- 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(18,25,79,.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 #B9BEFB; 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(246,247,252,.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 #E3E5F3; border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.detail-head { padding: 18px 16px 16px; border-bottom: 1px solid #E3E5F3; }
.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; }

/* ---------- Compte, équipe, synchronisation ---------- */
.info { background: var(--navy-soft); color: var(--navy); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.account-links { display: flex; justify-content: space-between; margin: 6px 0 4px; }
.who { margin: 0 0 8px; font-weight: 700; color: var(--navy); }
.muted-text { font-weight: 400; color: var(--muted); }
.acc-status { margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--navy-soft); color: var(--navy); }
.acc-status.ok { background: var(--gold-soft); color: var(--gold-text); border: 1.5px solid var(--gold); }
.acc-status.wait { background: #FFF6E5; color: #7A4B00; }
.acc-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

.team { list-style: none; margin: 0 0 12px; padding: 0; }
.member { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; align-items: center; padding: 12px 0; border-top: 1px solid #E3E5F3; }
.member:first-child { border-top: 0; }
.member .m-name { font-weight: 700; color: var(--navy); overflow-wrap: anywhere; }
.member .m-mail { grid-column: 1; color: var(--muted); font-size: .86rem; overflow-wrap: anywhere; }
.member .m-act { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.member select {
  font: inherit; font-size: .9rem; padding: 8px 10px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink);
}

.tabs { display: flex; gap: 4px; padding: 4px; margin: 0 0 14px; background: var(--navy-soft); border-radius: 12px; }
.tabs button {
  flex: 1; min-height: 44px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 600; color: var(--navy-2); cursor: pointer;
}
.tabs button[aria-selected="true"] { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(18,25,79,.15), inset 0 -2px 0 var(--gold); }

.sync-banner {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; font-size: .92rem;
  background: #FFF6E5; color: #7A4B00; border: 1px solid #F1D9A6;
}
.sync-line { display: block; margin-top: 8px; font-size: .88rem; font-weight: 600; }
.sync-line.sent { color: var(--gold-text); }
.sync-line.pending { color: #7A4B00; }
.report .meta .cloud { color: var(--gold-text); }

/* ---------- Fiches clients, photos du bureau, sauvegarde ---------- */
.field-note { margin: -6px 0 14px; font-size: .88rem; color: var(--gold-text); font-weight: 600; }
.field-note:empty { display: none; }
#backup-info { color: var(--muted); font-weight: 400; margin-top: 4px; }
#settings-form { margin-bottom: 14px; }
.nowrap { white-space: nowrap; }
.backup-actions { display: flex; gap: 10px; margin-bottom: 12px; }
.backup-actions > * { flex: 1; margin: 0; }
.photo a { display: block; width: 100%; height: 100%; }
.photo.loading { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- Console MOSCOW ---------- */
.console { border: 1.5px solid var(--gold); background: linear-gradient(180deg, var(--gold-soft), #fff 160px); }
.console h3 { margin: 6px 0 12px; font: 700 1rem/1.3 var(--serif); color: var(--navy); }
.orgs { list-style: none; margin: 0 0 16px; padding: 0; }
.org { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.org.off { opacity: .65; }
.org-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.org-name { font-weight: 700; color: var(--navy); overflow-wrap: anywhere; }
.org-code {
  font-weight: 700; letter-spacing: .5px; color: var(--gold-text); background: var(--gold-soft);
  border: 1.5px dashed var(--gold); border-radius: 8px; padding: 2px 8px; white-space: nowrap; cursor: pointer;
}
.org-stats { color: var(--muted); font-size: .88rem; margin: 6px 0 10px; }
.org-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.org-actions input { width: 90px; min-height: 44px; margin: 0; }
.org-actions select { flex: 1 1 100%; margin: 0; min-height: 44px; padding: 8px 12px; }
.org-actions .btn { min-height: 44px; }

/* ---------- Secteurs, PV, montant ---------- */
select {
  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;
}
select:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(112,100,248,.40); }
select:disabled { opacity: .7; }
.doc-tabs { margin-bottom: 14px; }
.sublabel { margin: 0 0 8px; font-size: .9rem; font-weight: 600; color: var(--navy-2); }
.deliverable { display: grid; grid-template-columns: 1fr 46px; gap: 8px; margin-bottom: 10px; }
.deliverable input { margin: 0; }
#btn-add-deliverable { margin-bottom: 12px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--ink); min-height: 44px; }
.check input { width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--blue); flex: none; }
.choices { display: grid; gap: 8px; margin-bottom: 14px; }
.choice {
  display: flex; align-items: center; gap: 10px; margin: 0; padding: 12px 14px; min-height: var(--tap);
  border: 1.5px solid var(--line); border-radius: 10px; color: var(--ink); font-weight: 600; cursor: pointer;
}
.choice input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--blue); }
.choice:has(input:checked) { border-color: var(--blue); background: var(--navy-soft); }
.material.priced { grid-template-columns: 1fr 64px 92px 46px; }
.billing { margin: 4px 0 14px; }
.billing .b-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #E3E5F3; font-size: .95rem; }
.billing .b-row span:last-child { white-space: nowrap; font-variant-numeric: tabular-nums; }
.billing .b-total { border: 0; margin-top: 6px; padding: 12px 14px; border-radius: 10px; background: var(--navy); color: #fff; font-weight: 700; font-size: 1.05rem; }
.billing .b-note { color: var(--muted); font-size: .85rem; margin-top: 8px; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--navy-soft); color: var(--navy-2); margin-left: 6px; vertical-align: 1px; }

/* ---------- 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(18,25,79,.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; }
}
