.ems {
  position: relative;
  width: 100%;
}

.ems-native-select {
  display: none !important;
}

.ems-control {
  min-height: 36px;
  border: 1px solid #ced4da;
  border-radius: 4px;
  background: #fff;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  cursor: text;
}

.ems-control:focus,
.ems-control.is-focused {
  border-color: #16a085;
  box-shadow: 0 0 0 0.2rem rgba(22, 160, 133, 0.2);
  outline: none;
}

.ems-control.is-open {
  border-color: #16a085;
}

.ems-control.is-disabled {
  background: #f8f9fa;
  cursor: not-allowed;
  opacity: 0.75;
}

.ems-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1 1 auto;
  min-width: 0;
}

.ems-chip {
  border: 1px solid #16a085;
  color: #0f6b59;
  background: #e8f6f3;
  border-radius: 999px;
  padding: 0 8px;
  max-width: 180px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.ems-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ems-chip-remove {
  border: 0;
  background: transparent;
  color: #0f6b59;
  padding: 0;
  line-height: 1;
  cursor: pointer;
  font-size: 14px;
}

.ems-chip-remove:focus {
  outline: 2px solid #0f6b59;
  outline-offset: 1px;
}

.ems-chip-overflow {
  border: 1px dashed #8fbcb3;
  color: #356a61;
  background: #f3fbfa;
  border-radius: 999px;
  padding: 0 8px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  font-size: 12px;
}

.ems-input {
  border: 0;
  outline: 0;
  width: 100%;
  min-width: 80px;
  font-size: 13px;
  background: transparent;
}

.ems-input::placeholder {
  color: #6c757d;
}

.ems-indicator {
  color: #6c757d;
  font-size: 12px;
  user-select: none;
}

.ems-panel {
  position: absolute;
  left: 0;
  right: 0;
  margin-top: 4px;
  border: 1px solid #ced4da;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.12);
  z-index: 2100;
}

.ems-options-viewport {
  max-height: 280px;
  overflow: auto;
}

.ems-options-spacer {
  position: relative;
  width: 100%;
}

.ems-options-render {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
}

.ems-option {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 10px;
  border-bottom: 1px solid #f2f4f5;
  cursor: pointer;
  background: #fff;
}

.ems-option:last-child {
  border-bottom: 0;
}

.ems-option:hover,
.ems-option.is-active {
  background: #eef8f6;
}

.ems-option.is-disabled {
  color: #9aa1a9;
  cursor: not-allowed;
  background: #fafbfc;
}

.ems-option-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.ems-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.ems-option-desc {
  color: #6c757d;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}

.ems-highlight {
  background: #fff3cd;
  border-radius: 2px;
}

.ems-option-check {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  pointer-events: none;
}

.ems-option-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #16a085;
}

.ems-empty {
  padding: 12px;
  color: #6c757d;
  font-size: 12px;
}

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

.ems-sheet {
  position: fixed;
  inset: 0;
  z-index: 4000;
  background: rgba(15, 23, 42, 0.45);
  display: none;
}

.ems-sheet.is-open {
  display: block;
}

.ems-sheet-dialog {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.ems-sheet-header {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #fff;
  border-bottom: 1px solid #e9ecef;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ems-sheet-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  flex: 1 1 auto;
}

.ems-sheet-search {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  border: 1px solid #ced4da;
  border-radius: 4px;
  padding: 8px;
  width: 100%;
}

.ems-sheet-body {
  flex: 1 1 auto;
  min-height: 0;
}

.ems-sheet .ems-option {
  height: 48px;
}

.ems-sheet-footer {
  border-top: 1px solid #e9ecef;
  padding: 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: #fff;
}

body.ems-sheet-open {
  overflow: hidden;
}

@media (max-width: 767px) {
  .ems-panel {
    display: none !important;
  }

  .ems-control {
    min-height: 42px;
  }

  .ems-chip {
    max-width: 140px;
  }
}
