.modal-body input.input-empty,
.modal-body textarea.input-empty {
  background: #f8fafc;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 2000;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(92vw, 910px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  border: none;
}

/* 설비연결 모달은 더 작은 크기 */
#linkEquipmentModal .modal-card {
  width: min(90vw, 420px);
}

.modal-header {
  padding: 16px 40px 16px 20px;
  border-bottom: 1px solid #f3f4f6;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  background: #fff;
}

.modal-body {
  padding: 20px 40px 20px 20px;
  display: grid;
  gap: 20px;
  background: #fff;
}

/* Compact two-column modal layout: photo on left, form on right */
.modal-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  column-gap: 20px;
  align-items: stretch;
}

/* Photo column - left side of modal layout */
.photo-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

@media (max-width: 900px) {
  .modal-layout {
    grid-template-columns: 1fr;
  }
}

/* Form column - right side of modal layout */
.form-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  background: #fff;
  box-sizing: border-box;
  overflow: hidden;
}

/* form-col 내부의 모든 요소에 box-sizing 적용하여 너비 계산 오류 방지 */
.form-col * {
  box-sizing: border-box;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
  width: 100% !important;
  box-sizing: border-box;
}

.form-grid>* {
  min-width: 0;
  box-sizing: border-box;
}

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  min-width: 0;
}

.form-grid input,
.form-grid textarea {
  width: 100%;
  max-width: 100%;
  /* 부모 영역을 넘지 않도록 제한 */
  min-width: 0;
  /* 최소 너비를 0으로 설정하여 overflow 방지 */
  box-sizing: border-box;
  /* 패딩과 테두리를 너비에 포함 */
}

.form-grid .full {
  grid-column: 1 / -1;
}

.modal-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.modal-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.modal-row-3>* {
  min-width: 0;
}

@media (max-width: 640px) {

  .modal-row,
  .modal-row-3 {
    grid-template-columns: 1fr;
  }
}

.modal-body label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.form-col label {
  font-size: 11px !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: #475569 !important;
  font-weight: 500;
}

.modal-body input,
.modal-body textarea {
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 13px;
  background-color: #f3f4f6;
  transition: all 0.2s ease;
  color: #1f2937;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

/* Status toggle on modal header */
.status-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 9999px;
  width: auto;
  flex: 1;
}

.status-toggle .status-btn {
  padding: 8px 10px;
  border: none;
  border-radius: 9999px;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  color: #6b7280;
  transition: all 0.2s ease;
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
}

.status-toggle .status-btn:hover {
  color: #1f2937;
}

.status-toggle .status-btn.active {
  background: #374151;
  /* fallback */
  color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Status specific colors when active */
.status-toggle .status-btn.active[data-status="normal"] {
  background: #27811e;
  color: #fff;
}

.status-toggle .status-btn.active[data-status="damage"] {
  background: #7f1d1d;
  color: #fff;
}

.status-toggle .status-btn.active[data-status="fault"] {
  background: #dc2626;
  color: #fff;
}

.status-toggle .status-btn.active[data-status="outbound"] {
  background: #0d6efd;
  color: #fff;
}

.status-toggle .status-btn.active[data-status="sold"] {
  background: #000000;
  color: #fff;
}


/* Ensure photo modal stays above edit modal */
#assetPhotoModal {
  z-index: 8000;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 12px 40px 12px 16px;
  border-top: 1px solid #e5e7eb;
}

/* Modal adjustments - Mobile only */
@media (max-width: 1000px) {
  .modal-card {
    width: 100%;
    height: 100%;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-header {
    padding: 12px 16px;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
  }

  .modal-layout {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .photo-col {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
  }

  .form-col {
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
  }

  .form-col .form-grid {
    width: 100% !important;
    max-width: 100% !important;
  }

  .form-col .form-grid>* {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  .form-col input,
  .form-col textarea,
  .form-col select {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
  }

  .modal-actions {
    padding: 12px 16px;
  }
}


.modal-body input:focus,
.modal-body textarea:focus {
  background-color: #fff;
  border-color: #0d6efd;
  box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1);
  outline: none;
}

.modal-body textarea {
  resize: none;
}

/* Ensure confirm/alert modals stack above edit modal */
#confirmModal,
#alertModal {
  z-index: 7000;
}

/* Note wrapper to fill vertical space */
.note-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 10px;
  min-height: 120px;
}

.note-wrapper label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
}

.note-wrapper textarea {
  flex: 1;
  resize: none;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
}