/* ============================================================
   HACCPilot — Modal system (hm- prefix)
   ============================================================ */

/* ── Overlay ── */
.hm-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(0, 0, 0, 0.48);
  display: none;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.22s ease;
}
.hm-overlay.is-open {
  opacity: 1;
}

/* ── Sheet ── */
.hm-sheet {
  position: relative;
  width: 100%;
  max-width: 480px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.hm-overlay.is-open .hm-sheet {
  transform: translateY(0);
}

/* ── Drag handle ── */
.hm-drag {
  width: 36px;
  height: 4px;
  background: #E5E7EB;
  border-radius: 2px;
  margin: 10px auto 0;
}

/* ── Header ── */
.hm-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 12px;
}
.hm-head__icon {
  position: relative;
  flex-shrink: 0;
}
.hm-icon-wrap {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hm-icon-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 18px;
  line-height: 1;
}
.hm-icon-badge--red {
  width: 20px;
  height: 20px;
  background: #DC2626;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  font-weight: 700;
  line-height: 1;
}
.hm-head__body {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}
.hm-head__title {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  line-height: 1.25;
  margin-bottom: 6px;
}
.hm-close {
  width: 32px;
  height: 32px;
  border: none;
  background: #F3F4F6;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  color: #6B7280;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  -webkit-tap-highlight-color: transparent;
}
.hm-close:active { background: #E5E7EB; }

/* ── Badge ── */
.hm-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}
.hm-badge--warn { background: #FEF3C7; color: #92400E; }
.hm-badge--err  { background: #FEE2E2; color: #991B1B; }

/* ── Body ── */
.hm-body {
  padding: 0 16px 8px;
}
.hm-item-name {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
  padding: 8px 12px;
  background: #F9FAFB;
  border-radius: 8px;
}
.hm-intro {
  font-size: 14px;
  color: #4B5563;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* ── Why block ── */
.hm-why {
  border: 1px solid;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.hm-why__title {
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.hm-why__text {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  margin: 0;
}

/* ── Section title ── */
.hm-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Steps ── */
.hm-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}
.hm-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.hm-step__icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.hm-step__text {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  padding-top: 8px;
  flex: 1;
}

/* ── Buttons ── */
.hm-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 16px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  border: none;
  margin-bottom: 10px;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s, transform 0.12s;
}
.hm-btn:active { transform: scale(0.97); }
.hm-btn--primary {
  color: #fff;
}
.hm-btn--ghost {
  background: transparent;
  border: 1.5px solid;
}
.hm-btn--danger {
  background: #DC2626;
  color: #fff;
}
.hm-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Alert (non conforme) ── */
.hm-alert {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.hm-alert__line {
  font-size: 13px;
  color: #374151;
  margin-bottom: 4px;
}
.hm-alert__warn {
  font-size: 13px;
  color: #DC2626;
  font-weight: 700;
}

/* ── NC steps list ── */
.hm-nc-steps {
  padding-left: 18px;
  margin: 0 0 18px;
}
.hm-nc-steps li {
  font-size: 13px;
  color: #374151;
  line-height: 1.5;
  margin-bottom: 5px;
}

/* ── Form ── */
.hm-form { margin-bottom: 12px; }
.hm-form__label {
  font-size: 13px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 8px;
}
.hm-req { color: #DC2626; }
.hm-radios {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hm-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  cursor: pointer;
}
.hm-radio input[type="radio"] { accent-color: #DC2626; width: 16px; height: 16px; flex-shrink: 0; }
.hm-radio__label { font-size: 14px; color: #374151; }
.hm-other-input {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1.5px solid #D1D5DB;
  border-radius: 8px;
  font-size: 13px;
  color: #111827;
  font-family: inherit;
  outline: none;
}
.hm-other-input:focus { border-color: #DC2626; }
.hm-select {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #D1D5DB;
  border-radius: 10px;
  font-size: 14px;
  color: #111827;
  background: #fff;
  font-family: inherit;
  outline: none;
  margin-bottom: 16px;
}
.hm-select:focus { border-color: #DC2626; }

/* ── Existing corrective action (read mode) ── */
.hm-ca-existing {
  background: #F0FDF4;
  border: 1px solid #BBF7D0;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.hm-ca-existing__badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #15803D;
  margin-bottom: 10px;
}
.hm-ca-row {
  display: flex;
  gap: 8px;
  margin-bottom: 5px;
  font-size: 13px;
}
.hm-ca-key { color: #6B7280; min-width: 90px; flex-shrink: 0; }
.hm-ca-val { color: #111827; font-weight: 500; }

/* ── Indicator badge on list item (has corrective action) ── */
.hm-ca-indicator {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  font-weight: 700;
  color: #15803D;
  background: #DCFCE7;
  border-radius: 100px;
  padding: 2px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Footer ── */
.hm-footer {
  padding: 12px 16px 8px;
  border-top: 1px solid #F3F4F6;
  display: flex;
  justify-content: center;
}
.hm-faq-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: #9CA3AF;
  text-decoration: none;
}
.hm-faq-link:active { color: #6B7280; }
