:root {
  --bg: #f3f1ec;
  --bg-glow: #ffffff;
  --bg-top: #ebe7df;
  --bg-bottom: #e7e2d8;
  --ink: #121212;
  --muted: #5c5c5c;
  --line: #d6d2c8;
  --accent: #1a1a1a;
  --accent-ink: #ffffff;
  --danger: #9b1c1c;
  --card: #fffdf8;
  --input-bg: #ffffff;
  --drop-bg: rgba(255, 255, 255, 0.55);
  --drop-border: #9a958a;
  --bubble-assistant: #f0ebe3;
  --bubble-user: #121212;
  --bubble-user-ink: #ffffff;
  --shadow: rgba(0, 0, 0, 0.04);
  --credit-ring: rgba(255, 253, 248, 0.9);
  --radius: 16px;
  --font: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #141414;
  --bg-glow: #1f1f1f;
  --bg-top: #101010;
  --bg-bottom: #0c0c0c;
  --ink: #f2f0ea;
  --muted: #a39e94;
  --line: #2e2e2e;
  --accent: #f2f0ea;
  --accent-ink: #121212;
  --danger: #e07070;
  --card: #1c1c1c;
  --input-bg: #121212;
  --drop-bg: rgba(255, 255, 255, 0.04);
  --drop-border: #5a564e;
  --bubble-assistant: #262626;
  --bubble-user: #f2f0ea;
  --bubble-user-ink: #121212;
  --shadow: rgba(0, 0, 0, 0.35);
  --credit-ring: rgba(20, 20, 20, 0.9);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-glow) 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 40%, var(--bg-bottom) 100%);
  color: var(--ink);
  font-family: var(--font);
}

#app {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 16px 20px;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow: hidden;
}
@media (min-width: 840px) {
  #app {
    padding: 24px 24px 24px;
    gap: 20px;
  }
}
@media (min-width: 1200px) {
  #app {
    padding: 28px 32px 28px;
  }
}

.top {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding-top: 8px;
  min-height: 48px;
}
.logo-btn {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  line-height: 0;
}
.logo-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 4px;
  border-radius: 8px;
}
.logo { width: min(280px, 70vw); height: auto; display: block; }
@media (min-width: 840px) {
  .logo { width: min(320px, 40vw); }
}

.job-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: 0 6px 18px var(--shadow);
}
.job-bar.hidden { display: none !important; }
.job-bar-msg {
  margin: 0;
  flex: 1;
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
}
.job-bar .job-bar-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
  flex-shrink: 0;
}
.job-bar .job-bar-spinner.hidden { display: none !important; }
.job-bar-action {
  flex-shrink: 0;
  padding: 8px 12px;
  min-height: 0;
}
.job-bar-action.hidden { display: none !important; }

.top-tools {
  position: absolute;
  right: 0;
  top: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}
.theme-toggle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 4px 14px var(--shadow);
  flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--ink); }
.theme-toggle svg {
  width: 20px;
  height: 20px;
  display: none;
}
.theme-toggle.install-app svg { display: block; }
.theme-toggle.install-app.hidden { display: none !important; }
[data-theme="light"] .theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

.nav-home {
  position: absolute;
  left: 0;
  top: 8px;
  z-index: 2;
}
.nav-home svg { display: block; }
.nav-home.hidden { display: none !important; }

.credit-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--credit-ring);
}
.credit-dot.hidden { display: none !important; }
.credit-dot.ok { background: #2f7d4a; }
.credit-dot.exhausted { background: var(--danger); }

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: 0 10px 30px var(--shadow);
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
@media (min-width: 840px) {
  .panel { padding: 28px 24px; }
}
.panel.hidden, .hidden { display: none !important; }

/* ---- Accueil master-detail (tablette paysage / expanded) ---- */
.panel-home {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.home-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: hidden;
}
.home-create {
  min-width: 0;
  order: -1; /* mobile : upload d’abord */
  flex: 0 0 auto;
}
.home-list-pane {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.home-list-pane .home-list-head {
  flex: 0 0 auto;
}
.home-list-pane .dossier-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.home-list-pane .dossier-list-msg {
  flex: 0 0 auto;
}
@media (min-width: 840px) {
  .home-layout {
    display: grid;
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
  }
  .home-create {
    order: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: unset;
    min-height: 0;
    overflow: hidden;
  }
  .home-list-pane {
    border-right: 1px solid var(--line);
    padding-right: 24px;
  }
  .home-list-pane .home-list-head {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
  }
  .home-list-pane .dossier-list {
    padding-right: 4px;
  }
  .home-list-pane .dossier-search {
    max-width: none;
    flex: 1 1 auto;
  }
  #view-home .dropzone {
    min-height: 0;
    padding: 48px 28px;
    height: 100%;
  }
  #view-home .progress {
    min-height: 0;
    height: 100%;
  }
}
@media (min-width: 1200px) {
  .home-layout {
    grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
    gap: 28px;
  }
  .home-list-pane { padding-right: 28px; }
}

h1 { font-size: 1.35rem; margin: 0 0 8px; letter-spacing: .02em; }
.muted { color: var(--muted); margin: 0 0 16px; line-height: 1.4; }
.error { color: var(--danger); margin-top: 12px; }

input[type="password"], input[type="text"], input[type="email"], input[type="tel"],
textarea, select {
  width: 100%;
  font-size: 1.05rem;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  margin-bottom: 12px;
  font-family: inherit;
}
textarea { min-height: 72px; resize: vertical; }
select { appearance: auto; }
input::placeholder, textarea::placeholder { color: var(--muted); }

.missing-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--card));
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.4;
}
.missing-banner strong { color: var(--danger); }
.missing-banner ul {
  margin: 8px 0 0;
  padding-left: 1.1em;
  color: var(--muted);
  font-size: 0.9rem;
}
.missing-banner-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.missing-banner-actions .btn {
  width: auto;
  min-height: 40px;
}

.data-form {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.data-section {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.data-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.data-section h2 {
  margin: 0 0 10px;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.field {
  margin-bottom: 4px;
}
.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
  color: var(--ink);
}
.field.missing label::after {
  content: " · manquant";
  color: var(--danger);
  font-weight: 500;
  font-size: 0.8rem;
}
.field.missing input,
.field.missing textarea,
.field.missing select {
  border-color: color-mix(in srgb, var(--danger) 55%, var(--line));
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  min-height: 44px;
}
.check-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ink);
}
.list-block {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 12px;
  background: var(--drop-bg);
}
.list-block .list-item {
  display: grid;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.list-block .list-item:first-child { border-top: none; padding-top: 0; }
.list-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.list-actions .btn {
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.9rem;
  border-radius: 10px;
}
.data-form-actions { margin-top: 4px; }
.data-form-msg { margin: 8px 0 0; }
.data-form-msg.ok { color: #2f7d4a; }
.data-form-msg.err { color: var(--danger); }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 18px;
  border-radius: 999px;
  cursor: pointer;
  min-height: 48px;
}
.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  width: 100%;
}
.btn.ghost { background: transparent; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn-icon svg {
  width: 1.15em;
  height: 1.15em;
  flex: 0 0 auto;
}
.btn-icon .btn-label { line-height: 1.2; }

.dropzone {
  border: 2px dashed var(--drop-border);
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  background: var(--drop-bg);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  transition: border-color .15s, background .15s;
}
.dropzone.dragover {
  border-color: var(--ink);
  background: var(--input-bg);
}
.dz-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
#view-home .dropzone .muted { margin: 0; }

.progress {
  margin: 8px 0 4px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 140px;
  justify-content: center;
}
.progress #progress-msg { margin: 0; font-weight: 600; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 28dvh;
  overflow-y: auto;
  margin-bottom: 14px;
  padding-right: 4px;
}
.bubble {
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  max-width: 95%;
}
.bubble.assistant { background: var(--bubble-assistant); align-self: flex-start; }
.bubble.user {
  background: var(--bubble-user);
  color: var(--bubble-user-ink);
  align-self: flex-end;
}

.chat-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}
.chat-form {
  display: flex;
  gap: 8px;
}
.chat-form input { margin: 0; flex: 1; }
.chat-form .btn { flex: 0 0 auto; border-radius: 12px; padding-inline: 16px; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

@media (min-width: 700px) {
  .chat-actions { flex-direction: row; }
  .chat-actions .btn.primary { width: auto; flex: 1; }
}

/* ---- Accueil : drop + liste ---- */
.home-list-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
  margin: 28px 0 12px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.home-list-titles {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.home-list-titles h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0.02em;
}
.home-count { margin: 0; font-size: 0.9rem; }
.dossier-search {
  flex: 1 1 200px;
  max-width: 320px;
}
.dossier-search input {
  margin: 0;
  min-height: 44px;
  font-size: 1rem;
}

.dossier-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dossier-row {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px;
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--input-bg);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dossier-row:hover, .dossier-row:focus-visible {
  border-color: var(--ink);
  background: var(--drop-bg);
}
.dossier-row:disabled { opacity: .5; }
.dr-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.dr-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.dr-name {
  font-weight: 700;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.dr-plate {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  white-space: nowrap;
}
.dr-meta { color: var(--muted); font-size: 0.88rem; }
.dr-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}
.dr-status {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
}
.dr-status.signed {
  color: #2f7d4a;
  border-color: color-mix(in srgb, #2f7d4a 40%, var(--line));
  background: color-mix(in srgb, #2f7d4a 10%, var(--card));
}
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid transparent;
}
.badge.warn-30d {
  color: #8a5a00;
  background: color-mix(in srgb, #d99a00 16%, var(--card));
  border-color: color-mix(in srgb, #d99a00 45%, var(--line));
}
.badge.warn-7d {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, var(--card));
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}
[data-theme="dark"] .badge.warn-30d { color: #e6b84d; }
.dossier-list-msg { margin: 10px 0 0; text-align: center; }
.dossier-list-msg.err { color: var(--danger); }

/* ---- Fiche dossier ---- */
.dossier-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}
.back-btn { min-height: 44px; padding: 8px 16px; font-size: 0.95rem; }
.dossier-title { min-width: 0; width: 100%; }
.dossier-title h1 { margin-bottom: 4px; overflow-wrap: anywhere; }
.dossier-title .muted { margin: 0; }

.dossier-edit-head {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
}
.dossier-edit-head .dossier-title {
  flex: 1 1 12rem;
  width: auto;
}
.dossier-edit-head .source-toggle {
  margin-left: auto;
  align-self: flex-start;
}
.dossier-edit-layout {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.dossier-form-slot { min-width: 0; }
.source-pane {
  order: 2;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.source-pane.hidden { display: none !important; }
.source-toggle {
  width: auto;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.9rem;
}
.source-toggle.hidden { display: none !important; }
.source-viewer {
  min-height: 240px;
  max-height: 46vh;
  background: color-mix(in srgb, var(--ink) 4%, var(--card));
}
.source-viewer iframe,
.source-viewer embed,
.source-viewer img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 240px;
  max-height: 46vh;
  border: 0;
  object-fit: contain;
  background: #1a1a1a;
}
.source-viewer .source-empty {
  margin: 0;
  padding: 24px 16px;
  color: var(--muted);
  text-align: center;
}
@media (min-width: 960px) {
  .dossier-edit-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: 18px;
  }
  .dossier-form-slot {
    order: 1;
    flex: 1 1 0;
    min-width: 0;
  }
  .source-pane {
    order: 2;
    flex: 0 0 min(44%, 30rem);
    position: sticky;
    top: 12px;
    align-self: flex-start;
    max-height: calc(100vh - 24px);
  }
  .source-viewer {
    max-height: none;
    height: calc(100vh - 96px);
    min-height: 420px;
  }
  .source-viewer iframe,
  .source-viewer embed,
  .source-viewer img {
    max-height: none;
    height: 100%;
    min-height: 420px;
  }
}

.dossier-hero {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  min-width: 0;
}
.dossier-hero-main {
  min-width: 0;
  flex: 1 1 16rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}
.dossier-hero-id {
  min-width: 0;
  flex: 1 1 12rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
}
.dossier-plate {
  margin: 0;
  flex: 0 0 auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.2;
  color: var(--ink);
}
.dossier-plate:not([hidden]) {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--input-bg);
}
.dossier-hero-id h1 {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  overflow-wrap: anywhere;
  letter-spacing: 0.01em;
  line-height: 1.25;
}
.dossier-vehicle {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--muted);
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.dossier-hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  margin-top: 6px;
}
.dossier-status-pill {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  white-space: nowrap;
}
.dossier-status-pill.signed {
  color: #2f7d4a;
  border-color: color-mix(in srgb, #2f7d4a 40%, var(--line));
  background: color-mix(in srgb, #2f7d4a 10%, var(--card));
}
.dossier-sub { margin: 0; font-size: 0.92rem; }
.retention-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.4;
  border: 1px solid color-mix(in srgb, #d99a00 45%, var(--line));
  background: color-mix(in srgb, #d99a00 12%, var(--card));
}
.retention-banner.warn-7d {
  border-color: color-mix(in srgb, var(--danger) 40%, var(--line));
  background: color-mix(in srgb, var(--danger) 10%, var(--card));
}
.retention-banner.warn-7d strong { color: var(--danger); }
.dossier-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin: 0;
  flex: 0 1 auto;
}
.dossier-actions .btn {
  width: auto;
  min-height: 40px;
  padding: 8px 14px;
  font-size: 0.92rem;
  gap: 8px;
}
.dossier-actions .btn.primary {
  width: auto;
  flex: 0 1 auto;
}
@media (max-width: 560px) {
  .dossier-actions {
    width: 100%;
    justify-content: stretch;
  }
  .dossier-actions .btn.primary { flex: 1 1 100%; }
  .dossier-actions .btn:not(.primary) { flex: 1 1 calc(33.33% - 8px); }
}
#btn-dossier-sign.has-sig {
  border-color: color-mix(in srgb, #2f7d4a 45%, var(--line));
  color: #2f7d4a;
}
[data-theme="dark"] #btn-dossier-sign.has-sig { color: #7dcea0; }
#dossier-msg { margin: 0 0 14px; }

/* ---- Résumé consultation ---- */
.dossier-summary {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 0 18px;
}
@media (min-width: 840px) {
  .dossier-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 20px;
    align-items: start;
  }
  .dossier-summary .summary-section[data-wide="true"] {
    grid-column: 1 / -1;
  }
}
.summary-section h2 {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.summary-dl {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card);
}
.summary-row {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr;
  gap: 8px 12px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  align-items: start;
}
.summary-row:first-child { border-top: none; }
.summary-row dt {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.summary-row dd {
  margin: 0;
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* ---- Signature client ---- */
.sig-block {
  margin: 0 0 20px;
  padding: 0 0 4px;
}
.sig-status { margin: 0; font-size: 0.9rem; }
.sig-pad-wrap {
  position: relative;
  border: 1px dashed var(--drop-border);
  border-radius: 14px;
  background:
    linear-gradient(180deg, transparent 70%, color-mix(in srgb, var(--line) 55%, transparent) 70.5%, transparent 71%),
    var(--input-bg);
  overflow: hidden;
  touch-action: none;
  min-height: 220px;
}
@media (min-width: 840px) {
  .sig-pad-wrap { min-height: 360px; }
  .sig-block {
    max-width: 920px;
    margin-left: auto;
    margin-right: auto;
  }
}
.sig-canvas {
  display: block;
  /* width/height fixés en JS (alignés buffer ÷ DPR) pour éviter le décalage doigt */
  width: 100%;
  height: auto;
  min-height: 220px;
  max-width: 100%;
  vertical-align: top;
  cursor: crosshair;
  touch-action: none;
}
@media (min-width: 840px) {
  .sig-canvas { min-height: 360px; }
}
.sig-preview {
  display: block;
  width: 100%;
  min-height: 220px;
  max-height: 420px;
  object-fit: contain;
  background: var(--input-bg);
  padding: 8px;
}
@media (min-width: 840px) {
  .sig-preview { min-height: 360px; }
}
.sig-preview.hidden { display: none !important; }
.sig-pad-wrap.has-saved .sig-canvas { display: none; }
.sig-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.sig-actions .btn { flex: 1; min-width: 120px; }
.sig-actions .btn.primary { width: auto; }
#sig-msg { margin: 8px 0 0; }

/* ---- Photos atelier ---- */
.photos-block {
  margin: 0 0 20px;
  padding: 16px 0 4px;
  border-top: 1px solid var(--line);
}
.photos-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 12px;
  margin-bottom: 12px;
}
.photos-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.photos-titles h2 {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.photos-count { margin: 0; font-size: 0.9rem; }
.photos-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  cursor: pointer;
  min-height: 44px;
  padding: 8px 16px;
}
.photo-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px;
}
.photo-grid:empty { display: none; }
.photo-tile {
  position: relative;
  margin: 0;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--input-bg);
  cursor: zoom-in;
}
.photo-tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.photo-tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.photo-tile .photo-del {
  position: absolute;
  top: 6px;
  right: 6px;
  appearance: none;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  color: var(--danger);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 8px var(--shadow);
}
.photo-tile .photo-del:hover { background: var(--card); }
#photos-msg { margin: 10px 0 0; }

/* ---- Lightbox photos ---- */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  background: color-mix(in srgb, #0a0a0a 88%, transparent);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
}
.photo-lightbox.hidden { display: none !important; }
.photo-lb-stage {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
  max-width: min(960px, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.photo-lb-stage img {
  display: block;
  max-width: 100%;
  max-height: calc(100dvh - 72px);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  user-select: none;
  -webkit-user-drag: none;
}
.photo-lb-counter {
  margin: 0;
  color: #f2f0ea;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.photo-lb-close,
.photo-lb-nav {
  appearance: none;
  border: 1px solid rgba(242, 240, 234, 0.28);
  background: rgba(28, 28, 28, 0.72);
  color: #f2f0ea;
  cursor: pointer;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.photo-lb-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 2;
  width: 44px;
  height: 44px;
  font-size: 1.5rem;
  line-height: 1;
  font-weight: 600;
}
.photo-lb-nav {
  flex: 0 0 auto;
  width: 48px;
  height: 64px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 400;
}
.photo-lb-close:hover,
.photo-lb-nav:hover {
  background: rgba(40, 40, 40, 0.9);
}
.photo-lb-nav:disabled {
  opacity: 0.28;
  cursor: default;
}
@media (max-width: 560px) {
  .photo-lightbox {
    flex-direction: column;
    gap: 10px;
  }
  .photo-lb-stage {
    order: 1;
    max-width: 100%;
    height: auto;
    flex: 1 1 auto;
  }
  .photo-lb-stage img {
    max-height: calc(100dvh - 140px);
  }
  .photo-lb-prev { order: 2; }
  .photo-lb-next { order: 3; }
  .photo-lb-nav {
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    width: 52px;
    height: 52px;
    font-size: 1.75rem;
  }
  .photo-lb-prev { left: max(16px, env(safe-area-inset-left)); }
  .photo-lb-next { right: max(16px, env(safe-area-inset-right)); }
  .photo-lb-counter {
    position: absolute;
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 12px));
    left: 50%;
    transform: translateX(-50%);
  }
}
#dossier-form-slot .data-form { margin-bottom: 8px; }
#dossier-form-slot .data-form-actions .btn { width: 100%; }
.dossier-footer {
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

/* iframe d'impression hors-écran (PDF → print()) */
.print-frame {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  border: 0;
  opacity: 0;
  pointer-events: none;
}
