/* =============================================================================
   TerraTrack — Refonte modale Visite HANDOFF_3
   Scopé au #modal : ajout visuel uniquement, wiring index.html/rapports.js conservé.
   ============================================================================= */

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

#modal .modal-header-info {
  min-width: 0;
}

#modal .modal-close-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

#modal .modal-close-btn:hover {
  color: var(--fg);
  background: var(--surface-hover);
  border-color: var(--border-strong);
}

#modal .modal-close-btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

#modal .ms {
  grid-template-areas:
    "handle handle"
    "header header"
    "context context"
    "tabs tabs"
    "hint hint"
    "panel panel"
    "footer footer";
}

#modal .visit-tabs {
  border-radius: var(--r-lg);
  padding: 4px;
  gap: 4px;
  margin: 14px 0 10px;
}

#modal .visit-tab {
  border-radius: var(--r-md);
  padding: 8px 10px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  transition: background var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease);
}

#modal .visit-tab:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

#modal .visit-tab.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-xs);
}

#modal .visit-tab-step {
  width: 19px;
  height: 19px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
}

#modal .visit-tab.is-active .visit-tab-step {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

#modal .visit-tab-hint {
  grid-area: hint;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 24px 16px;
  padding: 10px 12px;
  border: 1px solid var(--tt-accent-border);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
  color: var(--fg-secondary);
  font-size: 12.5px;
  line-height: 1.45;
}

#modal .visit-tab-hint svg,
#modal .visit-tab-hint i {
  color: var(--accent);
  flex: 0 0 auto;
}

#modal #statut-commercial-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

#modal #statut-commercial-grid .so {
  min-height: 48px;
  flex-direction: row;
  justify-content: flex-start;
  padding: 10px 12px;
  text-align: left;
}

#modal #funnel-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-xs);
}

#modal .funnel-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

#modal #funnel-steps {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
}

#modal #refus-motif-wrap {
  background: var(--danger-soft);
  border: 1px solid var(--tt-danger-border);
  border-radius: var(--r-lg);
  padding: 14px;
}

#modal #m-refus-motif {
  margin-bottom: 6px;
}

#modal .visit-lock-banner {
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid var(--tt-danger-border);
  border-left: 3px solid var(--danger);
  border-radius: var(--r-lg);
  background: var(--danger-soft);
  color: var(--danger);
}

#modal #msheet.is-locked .so,
#modal #msheet.is-locked .star,
#modal #msheet.is-fiche-readonly .mf.is-readonly {
  opacity: 0.62;
}

#modal #msheet.is-fiche-readonly .mf.is-readonly input,
#modal #msheet.is-fiche-readonly .mf.is-readonly textarea,
#modal #msheet.is-fiche-readonly .mf.is-readonly select {
  background: var(--surface-2);
  color: var(--fg-muted);
}

#modal .sgrid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#modal .so {
  min-height: 58px;
  padding: 11px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface);
  color: var(--fg-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  transition: background var(--dur-1) var(--ease),
              color var(--dur-1) var(--ease),
              border-color var(--dur-1) var(--ease),
              transform var(--dur-1) var(--ease),
              box-shadow var(--dur-1) var(--ease);
}

#modal .so:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--fg);
  transform: translateY(-1px);
  box-shadow: var(--shadow-xs);
}

#modal .so:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

#modal .so.sv { border-color: var(--tt-success-border); color: var(--success); background: var(--success-soft); }
#modal .so.sr { border-color: var(--tt-warn-border); color: var(--warn); background: var(--warn-soft); }
#modal .so.sa { border-color: var(--tt-danger-border); color: var(--danger); background: var(--danger-soft); }
#modal .so.sn { border-color: var(--border-strong); color: var(--fg-muted); background: var(--surface-2); }
#modal .so.sra { border-color: var(--tt-accent-border); color: var(--accent); background: var(--accent-soft); }
#modal .so.sec2 { border-color: var(--tt-info); color: var(--info); background: var(--info-soft); }

#modal .visit-quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 14px;
}

#modal .visit-quick-actions .btn {
  min-height: 44px;
  padding: 11px 12px;
  font-size: 12.5px;
}

#modal .visit-priority-label {
  margin-bottom: 6px;
}

#modal .star {
  font-size: 24px;
  color: var(--border-strong);
  line-height: 1;
}

#modal .star.lit {
  color: var(--warn);
}

#modal .fiche-section {
  border-radius: 14px !important;
  margin-bottom: 12px !important;
  box-shadow: var(--shadow-xs);
  scroll-margin-top: 12px;
}

#modal .fiche-section h4 {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
}

#modal .fiche-jump {
  position: sticky;
  top: 52px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 12px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--bg-elev);
  box-shadow: var(--shadow-xs);
}

#modal .fiche-jump button {
  min-height: 34px;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--fg-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

#modal .fiche-jump button:hover {
  color: var(--fg);
  background: var(--surface-hover);
}

#modal .fiche-jump button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

#modal .fiche-jump button.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

#modal .m-section-action {
  align-items: center;
  justify-content: space-between;
}

#modal .m-section-action::after {
  display: none;
}

#modal .btn-fiche-edit-mode {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--fg-secondary);
  padding: 8px 10px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

#modal .btn-fiche-edit-mode:hover {
  border-color: var(--border-strong);
  background: var(--surface-hover);
  color: var(--fg);
}

#modal .btn-fiche-edit-mode:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
}

#modal .qualification-potential-card {
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding: 12px 14px;
  border: 1px solid var(--tt-accent-border);
  border-radius: var(--r-lg);
  background: var(--accent-soft);
}

#modal .qualification-potential-card .pot-amount {
  color: var(--accent);
}

#modal .mbtns {
  position: sticky;
  bottom: 0;
  z-index: 4;
  background: linear-gradient(to top, var(--bg-elev) 84%, transparent);
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

#modal .mbtns .btn {
  min-height: 44px;
  height: auto;
}

#modal #btn-ms {
  flex: 2;
  min-height: 48px;
}

#modal .visit-delete-btn {
  border-color: var(--tt-danger-border);
  color: var(--danger);
  background: var(--danger-soft);
}

@media (prefers-reduced-motion: reduce) {
  #modal .so,
  #modal .visit-tab {
    transition: none;
  }

  #modal .so:hover {
    transform: none;
  }
}
